From dcf884018de55c314810bbe4e24d45158378adb1 Mon Sep 17 00:00:00 2001 From: tingfuyeh Date: Tue, 10 Dec 2024 14:27:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=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 | 45 +++++++++---------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/web/src/polaris/auth/common/UseableResource.tsx b/web/src/polaris/auth/common/UseableResource.tsx index 80a35927..2755d04d 100644 --- a/web/src/polaris/auth/common/UseableResource.tsx +++ b/web/src/polaris/auth/common/UseableResource.tsx @@ -15,7 +15,7 @@ interface Props { resources: { namespaces: StrategyResourceEntry[] services: StrategyResourceEntry[] - configGroups: StrategyResourceEntry[] + config_groups: StrategyResourceEntry[] router_rules: StrategyResourceEntry[] // lane_rules: StrategyResourceEntry[] circuitbreaker_rules: StrategyResourceEntry[] @@ -26,7 +26,7 @@ interface Props { auth_policies: StrategyResourceEntry[] } } -export default purify(function (props: Props) { +export default purify(function(props: Props) { const { resources } = props const [filterResourceType, setFilterResourceType] = React.useState('namespaces') const [keyword, setKeyword] = React.useState('') @@ -59,7 +59,7 @@ export default purify(function (props: Props) { if (filterResourceType === 'namespaces') { return '所有命名空间' } - if (filterResourceType === 'service') { + if (filterResourceType === 'services') { return '所有服务' } return '所有配置分组' @@ -67,7 +67,7 @@ export default purify(function (props: Props) { if (filterResourceType === 'namespaces') { return x.name } - if (filterResourceType === 'service') { + if (filterResourceType === 'services') { return {x.name} } return {x.name} diff --git a/web/src/polaris/auth/policy/Page.tsx b/web/src/polaris/auth/policy/Page.tsx index 51850918..0e7a311c 100644 --- a/web/src/polaris/auth/policy/Page.tsx +++ b/web/src/polaris/auth/policy/Page.tsx @@ -34,21 +34,21 @@ import UseableResource from '../common/UseableResource' export enum AuthSubjectType { USER = 'user', USERGROUP = 'group', - ROLE = "role", + 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", + 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' }, @@ -150,25 +150,25 @@ export default function AuthPage(props: DuckCmpProps) { const [authConsoleOpen, setAuthConsoleOpen] = React.useState(true) const fetchAuth = useCallback(async () => { const { clientOpen, consoleOpen } = await describeAuthStatus({}) - setAuthClientOpen(clientOpen === "true") - setAuthConsoleOpen(consoleOpen === "true") + setAuthClientOpen(clientOpen === 'true') + setAuthConsoleOpen(consoleOpen === 'true') }, []) React.useEffect(() => { fetchAuth() }, [fetchAuth]) - let tempAuthStatus = "" + let tempAuthStatus = '' if (authClientOpen && authConsoleOpen) { - tempAuthStatus = "鉴权策略针对控制台接口以及客户端接口均生效" + tempAuthStatus = '鉴权策略针对控制台接口以及客户端接口均生效' } if (authClientOpen && !authConsoleOpen) { - tempAuthStatus = "鉴权策略仅针对客户端接口生效" + tempAuthStatus = '鉴权策略仅针对客户端接口生效' } if (!authClientOpen && authConsoleOpen) { - tempAuthStatus = "鉴权策略仅针对控制台接口生效" + tempAuthStatus = '鉴权策略仅针对控制台接口生效' } if (!authClientOpen && !authConsoleOpen) { - tempAuthStatus = "鉴权策略不生效" + tempAuthStatus = '鉴权策略不生效' } const authStatusMsg = tempAuthStatus @@ -350,7 +350,7 @@ export default function AuthPage(props: DuckCmpProps) { resources={{ namespaces: currentAuthItem?.resources?.['namespaces'], services: currentAuthItem?.resources?.['services'], - configGroups: currentAuthItem?.resources?.config_groups, + config_groups: currentAuthItem?.resources?.config_groups, router_rules: currentAuthItem?.resources?.route_rules, ratelimit_rules: currentAuthItem?.resources?.ratelimit_rules, circuitbreaker_rules: currentAuthItem?.resources?.circuitbreaker_rules, @@ -403,11 +403,8 @@ export default function AuthPage(props: DuckCmpProps) { - {currentAuthItem.functions.length === 1 && - currentAuthItem.functions[0] === '*' ? ( -
- {`全部(含后续新增)`} -
+ {currentAuthItem.functions.length === 1 && currentAuthItem.functions[0] === '*' ? ( +
{`全部(含后续新增)`}
) : ( ) { style={{ marginBottom: '20px' }} > {currentAuthItem.resources[showAuthResourceType]?.length === 1 && - currentAuthItem.resources[showAuthResourceType][0].id === '*' ? ( + currentAuthItem.resources[showAuthResourceType][0].id === '*' ? (
{`全部${AUTH_RESOURCE_TYPE_MAP[showAuthResourceType].text}(含后续新增)`}