Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow column groups create form only for map_nodes [YTFRONT-3901] - hotfix #176

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/ui/src/ui/components/ACL/ACL-connect-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
permissionDeletionError,
} from '../../store/selectors/acl';

import {getType} from '../../store/selectors/navigation';

import {getColumnsColumns} from '../../store/selectors/acl-filters';

import {
Expand Down Expand Up @@ -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),

Expand All @@ -92,6 +96,7 @@ const makeAclMapStateToProps = (inputIdmKind) => {
errorData,

path,
nodeType,
version: getIdmPathVersion(state, idmKind),
idmKind,
disableAclInheritance,
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/ui/components/ACL/ACL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ? (
<ColumnGroups {...props} />
Expand Down
26 changes: 19 additions & 7 deletions packages/ui/src/ui/components/ACL/ColumnGroups/ColumnGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -137,7 +144,7 @@ export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster
name: '',
className: block('actions'),
render({row}) {
return (
return allowEdit ? (
<>
<span
className={block('icon', {delete: true})}
Expand All @@ -152,7 +159,7 @@ export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster
<Icon awesome="pencil" />
</span>
</>
);
) : null;
},
align: 'right',
},
Expand All @@ -164,10 +171,15 @@ export default function ColumnGroups({columnGroups, path, loadAclDataFn, cluster
<div className={block()}>
<div className="elements-heading elements-heading_size_xs">
Column Groups
<Button className={block('button', {add: true})} onClick={handleAddClick}>
<Icon awesome={'plus'} />
Add
</Button>
{allowEdit && (
<Button
className={block('button', {add: true})}
onClick={handleAddClick}
>
<Icon awesome={'plus'} />
Add
</Button>
)}
</div>
{columnGroups.length === 0 ? undefined : (
<DataTableYT<ColumnGroup>
Expand Down