From 49469f01f17043b2c1dfde8b2dd9ad2a8a1d9bd9 Mon Sep 17 00:00:00 2001 From: annzhang Date: Mon, 22 Feb 2021 14:30:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(permission):=20fix=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8C=89=E9=92=AE=E6=97=A0=E6=95=88bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/CommonSetting.tsx | 53 ++----------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/libs/permission-utils/src/components/CommonSetting.tsx b/libs/permission-utils/src/components/CommonSetting.tsx index 372433ae8..2cc909a24 100644 --- a/libs/permission-utils/src/components/CommonSetting.tsx +++ b/libs/permission-utils/src/components/CommonSetting.tsx @@ -3,13 +3,11 @@ import update from "immutability-helper"; import { DeleteOutlined, PlusOutlined } from "@ant-design/icons"; import { Table, Button, Modal, Switch, Tag } from "antd"; import * as _ from "lodash"; - -import { Permission, User } from "../interfaces"; +import { Permission } from "../interfaces"; import { BatchHandleUser } from "./BatchHandleUser"; import { PermissionCollection } from "../processors"; import { SelectUserOrGroup } from "./SelectUserOrGroup"; import styles from "./index.module.css"; -import { CmdbModels } from "@next-sdk/cmdb-sdk"; export interface CommonSettingPropsDefine { instanceData: any; permissionList: Permission[]; @@ -208,7 +206,7 @@ export class CommonSetting extends React.Component< } renderWhiteListEnabled = (text: boolean, record: any) => ( this.handleToggleWhiteListEnabled(checked, record) } @@ -254,50 +252,7 @@ export class CommonSetting extends React.Component< this.setState({ batchType: "add", }); - if (this.props.onSingleAddUserModelOpen) { - const objectIdObjectMap: Record< - string, - Partial - > = { - USER: { - objectId: "USER", - name: "用户", - }, - USER_GROUP: { - objectId: "USER_GROUP", - name: "用户组", - }, - }; - const reverseObjectIdMap: Record = { - USER: "USER_GROUP", - USER_GROUP: "USER", - }; - const onSingleAddUserModelOpen = (objectId: string) => { - const object = objectIdObjectMap[objectId]; - const reversedObject = objectIdObjectMap[reverseObjectIdMap[objectId]]; - this.props.onSingleAddUserModelOpen({ - objectId, - modalTitle: ( - <> - 选择{object.name} - - - ), - }); - }; - onSingleAddUserModelOpen("USER_GROUP"); - } else { - this.setState({ showAddUser: true }); - } + this.setState({ showAddUser: true }); }; // 保存为单个权限添加用户 handleStoreSingleAddUser = () => { @@ -369,6 +324,8 @@ export class CommonSetting extends React.Component< permissionList[modifiedIndex]._whiteListEnabled = checked; if (checked && _.isEmpty(permissionList[modifiedIndex].authorizers)) { permissionList[modifiedIndex].authorizers.push("easyops"); + } else if (!checked) { + permissionList[modifiedIndex].authorizers = []; } this.setState((prevState) => ({ collections: { ...prevState.collections, permissionList },