From d8cd4665026464720d8be47bf533a082b08e9bd8 Mon Sep 17 00:00:00 2001 From: tingfuyeh Date: Thu, 2 Jan 2025 11:31:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E9=80=80=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=9C=AA=E5=AE=9E=E7=8E=B0=E7=9A=84=E6=94=B9=E5=8A=A8=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../polaris/auth/common/UseableResource.tsx | 8 - web/src/polaris/auth/policy/Page.tsx | 108 +--- .../polaris/auth/policy/operation/Create.tsx | 472 +----------------- .../auth/policy/operation/CreateDuck.ts | 458 +---------------- .../fileGroup/detail/file/Page.tsx | 4 +- .../fileGroup/detail/version/PageDuck.tsx | 2 +- .../fileGroup/detail/version/model.ts | 1 + 7 files changed, 52 insertions(+), 1001 deletions(-) diff --git a/web/src/polaris/auth/common/UseableResource.tsx b/web/src/polaris/auth/common/UseableResource.tsx index 2755d04d..de740b55 100644 --- a/web/src/polaris/auth/common/UseableResource.tsx +++ b/web/src/polaris/auth/common/UseableResource.tsx @@ -16,14 +16,6 @@ interface Props { namespaces: StrategyResourceEntry[] services: StrategyResourceEntry[] config_groups: StrategyResourceEntry[] - router_rules: StrategyResourceEntry[] - // lane_rules: StrategyResourceEntry[] - circuitbreaker_rules: StrategyResourceEntry[] - faultdetect_rules: StrategyResourceEntry[] - ratelimit_rules: StrategyResourceEntry[] - users: StrategyResourceEntry[] - user_groups: StrategyResourceEntry[] - auth_policies: StrategyResourceEntry[] } } export default purify(function(props: Props) { diff --git a/web/src/polaris/auth/policy/Page.tsx b/web/src/polaris/auth/policy/Page.tsx index 0e7a311c..d2d2dc9b 100644 --- a/web/src/polaris/auth/policy/Page.tsx +++ b/web/src/polaris/auth/policy/Page.tsx @@ -34,25 +34,14 @@ import UseableResource from '../common/UseableResource' export enum AuthSubjectType { USER = 'user', USERGROUP = 'group', - ROLE = 'role', } export enum AuthResourceType { NAMESPACE = 'namespaces', SERVICE = 'services', CONFIGURATION = 'config_groups', - ROUTER_RULE = 'route_rules', - RATELIMIT_RULE = 'ratelimit_rules', - CIRCUIT_BREAKER_RULE = 'circuitbreaker_rules', - FAULTDETECT_RULE = 'faultdetect_rules', - LANE_RULE = 'lane_rules', - AUTH_USERS = 'users', - AUTH_USER_GROUP = 'user_groups', - AUTH_ROLE = 'roles', - AUTH_POLICY = 'auth_policies', } export const AUTH_SUBJECT_TYPE_MAP = { [AuthSubjectType.USER]: { text: '用户', urlKey: 'user' }, - // [AuthSubjectType.ROLE]: { text: '角色', urlKey: 'role' }, [AuthSubjectType.USERGROUP]: { text: '用户组', urlKey: 'usergroup' }, } export const AUTH_RESOURCE_TYPE_MAP = { @@ -68,34 +57,6 @@ export const AUTH_RESOURCE_TYPE_MAP = { text: '配置分组', columnsRender: x => x.name, }, - [AuthResourceType.ROUTER_RULE]: { - text: '路由规则', - columnsRender: x => x.name, - }, - [AuthResourceType.RATELIMIT_RULE]: { - text: '限流规则', - columnsRender: x => x.name, - }, - [AuthResourceType.CIRCUIT_BREAKER_RULE]: { - text: '熔断规则', - columnsRender: x => x.name, - }, - [AuthResourceType.FAULTDETECT_RULE]: { - text: '探测规则', - columnsRender: x => x.name, - }, - [AuthResourceType.AUTH_USERS]: { - text: '用户', - columnsRender: x => x.name, - }, - [AuthResourceType.AUTH_USER_GROUP]: { - text: '用户组', - columnsRender: x => x.name, - }, - [AuthResourceType.AUTH_POLICY]: { - text: '鉴权策略', - columnsRender: x => x.name, - }, } export const AuthSubjectTabs = Object.keys(AUTH_SUBJECT_TYPE_MAP).map(id => ({ id, @@ -178,8 +139,7 @@ export default function AuthPage(props: DuckCmpProps) { ...item, label: `${item.label}(${currentAuthItem?.principals?.[`${item.id}s`]?.length ?? 0})`, })) - const defaultList = authList.filter(item => item.default_strategy && item.name.indexOf('默认策略') > -1) - const globalList = authList.filter(item => item.default_strategy && item.name.indexOf('默认策略') === -1) + const defaultList = authList.filter(item => item.default_strategy) const customList = authList.filter(item => !item.default_strategy) const isCurrAuthItemOwnerDefaultPrinciple = currentAuthItem?.default_strategy && @@ -258,7 +218,7 @@ export default function AuthPage(props: DuckCmpProps) { -
+
) { 默认策略({defaultList.length}) {defaultList.filter(() => collapseDefault).map(renderListItem)} - { - setCollapseDefault(!collapseDefault) - }} - className={'auth-item'} - current={false} - > - - 全局策略({globalList.length}) - - {globalList.filter(() => collapseDefault).map(renderListItem)} { @@ -306,7 +254,7 @@ export default function AuthPage(props: DuckCmpProps) {
- + {currentAuthItem.id ? ( ) { {currentAuthItem.comment || '无备注'} - - {currentAuthItem.action} -
@@ -351,14 +296,6 @@ export default function AuthPage(props: DuckCmpProps) { namespaces: currentAuthItem?.resources?.['namespaces'], services: currentAuthItem?.resources?.['services'], config_groups: currentAuthItem?.resources?.config_groups, - router_rules: currentAuthItem?.resources?.route_rules, - ratelimit_rules: currentAuthItem?.resources?.ratelimit_rules, - circuitbreaker_rules: currentAuthItem?.resources?.circuitbreaker_rules, - faultdetect_rules: currentAuthItem?.resources?.faultdetect_rules, - users: currentAuthItem?.resources?.users, - user_groups: currentAuthItem?.resources?.user_groups, - auth_policies: currentAuthItem?.resources?.auth_policies, - // lane_rules: currentAuthItem?.resources?.lane_rules, }} /> @@ -402,35 +339,14 @@ export default function AuthPage(props: DuckCmpProps) {
- - {currentAuthItem.functions.length === 1 && currentAuthItem.functions[0] === '*' ? ( -
{`全部(含后续新增)`}
- ) : ( - x, - }, - ]} - addons={[scrollable({ maxHeight: '300px' }), autotip({})]} - style={{ marginTop: '20px' }} - /> - )} - - - - + setShowAuthResourceType(tab.id as AuthResourceType)} style={{ marginBottom: '20px' }} > - {currentAuthItem.resources[showAuthResourceType]?.length === 1 && + {currentAuthItem.resources[showAuthResourceType].length === 1 && currentAuthItem.resources[showAuthResourceType][0].id === '*' ? (
{`全部${AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].text}(含后续新增)`} @@ -445,6 +361,7 @@ export default function AuthPage(props: DuckCmpProps) { header: '名称', render: AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].columnsRender, }, + { key: 'auth', header: '权限', render: () => '读|写' }, ]} addons={[scrollable({ maxHeight: '300px' }), autotip({})]} style={{ marginTop: '20px' }} @@ -464,13 +381,24 @@ export default function AuthPage(props: DuckCmpProps) { ) + const [alertVisible, setAlertVisible] = React.useState(true) return isInDetailpage ? ( contentElement ) : ( }> - {authStatusMsg} + setAlertVisible(false)} + extra={ + + } + > + {authStatusMsg} + {contentElement} diff --git a/web/src/polaris/auth/policy/operation/Create.tsx b/web/src/polaris/auth/policy/operation/Create.tsx index 16338e39..07f370d0 100644 --- a/web/src/polaris/auth/policy/operation/Create.tsx +++ b/web/src/polaris/auth/policy/operation/Create.tsx @@ -13,12 +13,11 @@ import { Table, Button, FormText, - Segment, } from 'tea-component' import Duck from './CreateDuck' import { AuthResourceType, AuthSubjectType, AuthSubjectTabs, AuthResourceTabs, AUTH_RESOURCE_TYPE_MAP } from '../Page' -import { AuthStrategy, getServerFunctionDesc, ServerFunction, ServerFunctionZhDesc, User, UserGroup } from '../../model' +import { User, UserGroup } from '../../model' import { autotip } from 'tea-component/lib/table/addons' import FormField from '@src/polaris/common/duckComponents/form/Field' import SearchableTransfer from '@src/polaris/common/duckComponents/SearchableTransfer' @@ -26,83 +25,34 @@ import Input from '@src/polaris/common/duckComponents/form/Input' import DetailPage from '@src/polaris/common/duckComponents/DetailPage' import { Namespace, Service } from '@src/polaris/service/types' import router from '@src/polaris/common/util/router' -import { CircuitBreakerRule } from '@src/polaris/administration/breaker/types' -import { RateLimit } from '@src/polaris/administration/accessLimiting/model' -import { CustomRoute } from '@src/polaris/administration/dynamicRoute/customRoute/model' -import { FaultDetectRule } from '@src/polaris/administration/breaker/faultDetect/types' +import { ConfigFileGroup } from '@src/polaris/configuration/fileGroup/types' const steps = [ { id: '1', label: '选择用户' }, - { id: '2', label: '选择接口' }, - { id: '3', label: '选择资源' }, - { id: '4', label: '执行效果' }, - { id: '5', label: '预览' }, + { id: '2', label: '授权' }, + { id: '3', label: '预览' }, ] -export default purify(function (props: DuckCmpProps) { +export default purify(function(props: DuckCmpProps) { const { duck, store, dispatch } = props const { selectors, ducks, selector, creators } = duck const composedId = selectors.composedId(store) const { id } = composedId const [step, setStep] = React.useState('1') - const { name, - useAllNamespace, useAllService, useAllConfigGroup, - useAllRouterRule, useAllRatelimitRule, useAllCircuitBreakerRule, useAllFaultDetectRule, - useAllUsers, useAllUserGroups, useAllAuthPoliy, - useAllFunctions, comment, effect } = ducks.form - .getAPI(store, dispatch) - .getFields(['name', - 'useAllNamespace', 'useAllService', 'useAllConfigGroup', - 'useAllRouterRule', 'useAllRatelimitRule', 'useAllCircuitBreakerRule', 'useAllFaultDetectRule', - 'useAllUsers', 'useAllUserGroups', 'useAllAuthPoliy', - 'useAllFunctions', 'comment', 'effect']) + const { name, useAllNamespace, useAllService, useAllConfigGroup, comment } = ducks.form + .getAPI(store, dispatch) + .getFields(['name', 'useAllNamespace', 'useAllService', 'useAllConfigGroup', 'comment']) const isModify = !!id const [showAuthSubjectType, setShowAuthSubjectType] = React.useState(AuthSubjectType.USER) const [showAuthResourceType, setShowAuthResourceType] = React.useState(AuthResourceType.NAMESPACE) - const [showFunctionGroup, setFunctionGroup] = React.useState("Namespace") - - const serverFunctionGroups = { - namespaceView: "命名空间", - clientView: "客户端", - discoverView: "注册发现", - governanceView: "治理规则", - configView: "配置中心", - authView: "鉴权", - }; - - const serverFunctionOptions = [ - { groupKey: "namespaceView", text: "命名空间", value: "Namespace" }, - { groupKey: "clientView", text: "客户端", value: "Client" }, - { groupKey: "discoverView", text: "服务", value: "Service|ServiceContract" }, - { groupKey: "discoverView", text: "实例", value: "Instance" }, - { groupKey: "governanceView", text: "路由规则", value: "RouteRule" }, - { groupKey: "governanceView", text: "限流规则", value: "RateLimitRule" }, - { groupKey: "governanceView", text: "熔断规则", value: "CircuitBreakerRule" }, - { groupKey: "governanceView", text: "探测规则", value: "FaultDetectRule" }, - { groupKey: "configView", text: "配置分组", value: "ConfigGroup" }, - { groupKey: "configView", text: "配置文件", value: "ConfigFile|ConfigRelease" }, - { groupKey: "authView", text: "用户", value: "User" }, - { groupKey: "authView", text: "用户组", value: "UserGroup" }, - { groupKey: "authView", text: "鉴权策略", value: "AuthPolicy" }, - ]; const { user: { selection: userSelection }, userGroup: { selection: userGroupSelection }, - - opuser: { selection: opuserSelection }, - opuserGroup: { selection: opuserGroupSelection }, - authPolicy: { selection: authPolicySelection }, namespace: { selection: namespaceSelection }, service: { selection: serviceSelection }, configGroup: { selection: configGroupSelection }, - routerRules: { selection: routerRuleSelection }, - ratelimitRules: { selection: rateLimitRuleSelection }, - circuitbreakerRules: { selection: circuitbreakerRuleSelection }, - faultdetectRules: { selection: faultdetectRuleSelection }, - functions: { selection: functionSelection }, originPolicy, - functionGroup, } = selector(store) return ( ) { > {/* 内容区域一般使用 Card 组件显示内容 */} - }> + }> {step === '1' && (
@@ -161,47 +111,7 @@ export default purify(function (props: DuckCmpProps) { )} {step === '2' && ( - - { - useAllFunctions.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部(含后续新增)'} - {'指定接口'} - - {!useAllFunctions.getValue() && ( - <> - { - setFunctionGroup(val) - dispatch(creators.setFunctionGroup(val)) - }} - options={serverFunctionOptions} - groups={serverFunctionGroups} - style={{ marginTop: '10px' }} - /> - ( - {record.id}({record.desc}) - )} - /> - - )} - - - )} - {step === '3' && ( -
- + ) { duck={ducks.configGroup} store={store} dispatch={dispatch} - itemRenderer={(record: Service) => ( - - {record.name}({record.namespace}) - - )} - /> - )} - - - { - useAllRouterRule.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部路由规则(含后续新增)'} - {'指定路由规则'} - - {!useAllRouterRule.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllRatelimitRule.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部限流规则(含后续新增)'} - {'指定限流规则'} - - {!useAllRatelimitRule.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllCircuitBreakerRule.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部熔断规则(含后续新增)'} - {'指定熔断规则'} - - {!useAllCircuitBreakerRule.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllFaultDetectRule.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部探测规则(含后续新增)'} - {'指定探测规则'} - - {!useAllFaultDetectRule.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllUsers.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部用户(含后续新增)'} - {'指定用户'} - - {!useAllUsers.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllUserGroups.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部用户组(含后续新增)'} - {'指定用户组'} - - {!useAllUserGroups.getValue() && ( - ( - - {record.name}({record.id}) - - )} - /> - )} - - - { - useAllAuthPoliy.setValue(value === 'all') - }} - style={{ marginTop: '10px' }} - > - {'全部鉴权策略(含后续新增)'} - {'指定鉴权策略'} - - {!useAllAuthPoliy.getValue() && ( - ( - - {record.name}({record.id}) - - )} + itemRenderer={(record: ConfigFileGroup) => {record.name}} /> )} - - )} - {step === '4' && ( -
- - { - effect.setValue(value) - }} - style={{ marginTop: '10px' }} - > - {'允许'} - {'禁止'} - + + {'读操作|写操作'} )} - {step === '5' && ( + {step === '3' && (
{name.getValue()} @@ -497,29 +207,7 @@ export default purify(function (props: DuckCmpProps) { {userGroupSelection.map(item => `${item.name}(${item.id})`).join(',' || '无选中用户组')} - - - {effect.getValue() === 'ALLOW' ? '允许' : '禁止'} - - - - {useAllFunctions.getValue() ? ( - {'全部接口(含后续新增)'} - ) : ( -
x.id, - }, - ]} - addons={[autotip({})]} - /> - )} - - + ) { header: '名称', render: AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].columnsRender, }, + { key: 'auth', header: '权限', render: () => '读|写' }, ]} addons={[autotip({})]} /> @@ -554,14 +243,15 @@ export default purify(function (props: DuckCmpProps) { header: '名称', render: AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].columnsRender, }, + { key: 'auth', header: '权限', render: () => '读|写' }, ]} addons={[autotip({})]} /> )} - {useAllConfigGroup.getValue() ? ( - {'全部配置分组(含后续新增)'} + {useAllService.getValue() ? ( + {'全部服务(含后续新增)'} ) : (
) { header: '名称', render: AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].columnsRender, }, - ]} - addons={[autotip({})]} - /> - )} - - - {useAllRouterRule.getValue() ? ( - {'全部路由规则(含后续新增)'} - ) : ( -
- )} - - - {useAllRatelimitRule.getValue() ? ( - {'全部限流规则(含后续新增)'} - ) : ( -
- )} - - - {useAllCircuitBreakerRule.getValue() ? ( - {'全部熔断规则(含后续新增)'} - ) : ( -
- )} - - - {useAllFaultDetectRule.getValue() ? ( - {'全部探测规则(含后续新增)'} - ) : ( -
- )} - - - {useAllUsers.getValue() ? ( - {'全部用户(含后续新增)'} - ) : ( -
- )} - - - {useAllUserGroups.getValue() ? ( - {'全部用户组(含后续新增)'} - ) : ( -
- )} - - - {useAllAuthPoliy.getValue() ? ( - {'全部鉴权策略(含后续新增)'} - ) : ( -
'读|写' }, ]} addons={[autotip({})]} /> @@ -701,7 +273,7 @@ export default purify(function (props: DuckCmpProps) { )} - {step === '5' && ( + {step === '3' && ( )} - {Number(step) < 5 && ( + {Number(step) < 3 && ( - {isBetaingRelease(currentNode) ? ( + {/* {isBetaingRelease(currentNode) ? ( - )} + )} */} {editing ? ( <>