From de4890ce3f77f5f1ef3144ac382a161efaedfdc5 Mon Sep 17 00:00:00 2001 From: Konstantin Shishov Date: Fri, 20 Oct 2023 17:45:39 +0300 Subject: [PATCH] fix: allow column groups create form only for map_nodes [YTFRONT-3901] --- .../ui/components/ACL/ACL-connect-helpers.js | 5 ++++ packages/ui/src/ui/components/ACL/ACL.js | 5 +++- .../ACL/ColumnGroups/ColumnGroups.tsx | 26 ++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/ui/src/ui/components/ACL/ACL-connect-helpers.js b/packages/ui/src/ui/components/ACL/ACL-connect-helpers.js index 54c640490..3c0686657 100644 --- a/packages/ui/src/ui/components/ACL/ACL-connect-helpers.js +++ b/packages/ui/src/ui/components/ACL/ACL-connect-helpers.js @@ -17,6 +17,8 @@ import { permissionDeletionError, } from '../../store/selectors/acl'; +import {getType} from '../../store/selectors/navigation'; + import {getColumnsColumns} from '../../store/selectors/acl-filters'; import { @@ -83,6 +85,8 @@ const makeAclMapStateToProps = (inputIdmKind) => { const readApprovers = getNotInheritedReadApprovers(state, idmKind); const responsible = getNotInheritedResponsibles(state, idmKind); + const nodeType = getType(state); + return { cluster: getCluster(state), @@ -92,6 +96,7 @@ const makeAclMapStateToProps = (inputIdmKind) => { errorData, path, + nodeType, version: getIdmPathVersion(state, idmKind), idmKind, disableAclInheritance, diff --git a/packages/ui/src/ui/components/ACL/ACL.js b/packages/ui/src/ui/components/ACL/ACL.js index 458cf6c70..fe3382b10 100644 --- a/packages/ui/src/ui/components/ACL/ACL.js +++ b/packages/ui/src/ui/components/ACL/ACL.js @@ -78,6 +78,7 @@ class ACL extends Component { path: PropTypes.string.isRequired, idmKind: PropTypes.string.isRequired, + nodeType: PropTypes.string.isRequired, version: PropTypes.string, disableAclInheritance: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]), bossApproval: PropTypes.bool, @@ -429,13 +430,15 @@ class ACL extends Component { } renderColumnGroups() { - const {columnGroups, idmKind, path, loadAclData, cluster, aclRequestOptions} = this.props; + const {columnGroups, idmKind, path, loadAclData, cluster, aclRequestOptions, nodeType} = + this.props; const {useEffective} = aclRequestOptions; const props = { path, loadAclDataFn: () => loadAclData({path, idmKind}), columnGroups, cluster, + allowEdit: nodeType === 'map_node', }; return isIdmAclAvailable() && idmKind === IdmObjectType.PATH && !useEffective ? ( diff --git a/packages/ui/src/ui/components/ACL/ColumnGroups/ColumnGroups.tsx b/packages/ui/src/ui/components/ACL/ColumnGroups/ColumnGroups.tsx index 674433464..36e1b6a71 100644 --- a/packages/ui/src/ui/components/ACL/ColumnGroups/ColumnGroups.tsx +++ b/packages/ui/src/ui/components/ACL/ColumnGroups/ColumnGroups.tsx @@ -25,9 +25,16 @@ interface Props { path: string; loadAclDataFn: () => void; cluster: string; + allowEdit?: boolean; } -export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster}: Props) { +export default function ColumnGroups({ + columnGroups, + path, + loadAclDataFn, + cluster, + allowEdit = false, +}: Props) { const [modalProps, setModalProps] = useState({ title: '', confirmText: '', @@ -137,7 +144,7 @@ export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster name: '', className: block('actions'), render({row}) { - return ( + return allowEdit ? ( <> - ); + ) : null; }, align: 'right', }, @@ -164,10 +171,15 @@ export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster
Column Groups - + {allowEdit && ( + + )}
{columnGroups.length === 0 ? undefined : (