From 29e4e34f3f6ed1c15fd4fe592c1da15dd2c73a96 Mon Sep 17 00:00:00 2001 From: Elena Makarova Date: Wed, 14 Aug 2024 09:55:48 +0300 Subject: [PATCH] feat(Acl): support InterruptInheritance, fix styles --- src/containers/Tenant/Acl/Acl.scss | 5 ++ src/containers/Tenant/Acl/Acl.tsx | 74 ++++++++++++++++------- src/containers/Tenant/Acl/i18n/en.json | 1 + src/store/reducers/schemaAcl/schemaAcl.ts | 1 + src/types/api/acl.ts | 1 + 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/containers/Tenant/Acl/Acl.scss b/src/containers/Tenant/Acl/Acl.scss index 4694799e4..710cce076 100644 --- a/src/containers/Tenant/Acl/Acl.scss +++ b/src/containers/Tenant/Acl/Acl.scss @@ -5,10 +5,15 @@ &__result { padding-bottom: var(--g-spacing-4); padding-left: var(--g-spacing-2); + + &_no-title { + margin-top: var(--g-spacing-3); + } } &__definition-content { display: flex; flex-direction: column; + align-items: flex-end; } &__list-title { margin: var(--g-spacing-3) 0 var(--g-spacing-5); diff --git a/src/containers/Tenant/Acl/Acl.tsx b/src/containers/Tenant/Acl/Acl.tsx index 349072ef2..9d85d9a32 100644 --- a/src/containers/Tenant/Acl/Acl.tsx +++ b/src/containers/Tenant/Acl/Acl.tsx @@ -2,6 +2,8 @@ import React from 'react'; import {DefinitionList} from '@gravity-ui/components'; import type {DefinitionListItem} from '@gravity-ui/components'; +import {SquareCheck} from '@gravity-ui/icons'; +import {Icon} from '@gravity-ui/uikit'; import {ResponseError} from '../../../components/Errors/ResponseError'; import {Loader} from '../../../components/Loader'; @@ -94,6 +96,7 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] { return { name: Subject, content: , + multilineName: true, }; } return { @@ -105,6 +108,7 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] { return { name: aclParamToName[key], content: , + multilineName: true, }; } return undefined; @@ -121,8 +125,22 @@ function getOwnerItem(owner?: string): DefinitionListItem[] { } return [ { - name: {preparedOwner}, - content: {i18n('title_owner')}, + name: preparedOwner, + content: i18n('title_owner'), + multilineName: true, + }, + ]; +} + +function getInterruptInheritanceItem(flag?: boolean): DefinitionListItem[] { + if (!flag) { + return []; + } + return [ + { + name: i18n('title_interupt-inheritance'), + content: , + multilineName: true, }, ]; } @@ -132,13 +150,15 @@ export const Acl = ({path, database}: {path: string; database: string}) => { const loading = isFetching && !currentData; - const {acl, effectiveAcl, owner} = currentData || {}; + const {acl, effectiveAcl, owner, interruptInheritance} = currentData || {}; const aclListItems = getAclListItems(acl); const effectiveAclListItems = getAclListItems(effectiveAcl); const ownerItem = getOwnerItem(owner); + const interruptInheritanceItem = getInterruptInheritanceItem(interruptInheritance); + if (loading) { return ; } @@ -155,26 +175,34 @@ export const Acl = ({path, database}: {path: string; database: string}) => { return (
- {accessRightsItems.length ? ( - -
{i18n('title_rights')}
- -
- ) : null} - {effectiveAclListItems.length ? ( - -
{i18n('title_effective-rights')}
- -
- ) : null} + + +
); }; + +interface AclDefinitionListProps { + items: DefinitionListItem[]; + title?: string; +} + +function AclDefinitionList({items, title}: AclDefinitionListProps) { + if (!items.length) { + return null; + } + return ( + + {title &&
{title}
} + +
+ ); +} diff --git a/src/containers/Tenant/Acl/i18n/en.json b/src/containers/Tenant/Acl/i18n/en.json index 0bf6aa879..f9c3ff902 100644 --- a/src/containers/Tenant/Acl/i18n/en.json +++ b/src/containers/Tenant/Acl/i18n/en.json @@ -2,5 +2,6 @@ "title_rights": "Access Rights", "title_effective-rights": "Effective Access Rights", "title_owner": "Owner", + "title_interupt-inheritance": "Interrupt inheritance", "description_empty": "No Acl data" } diff --git a/src/store/reducers/schemaAcl/schemaAcl.ts b/src/store/reducers/schemaAcl/schemaAcl.ts index fbdfc4f10..949f0f802 100644 --- a/src/store/reducers/schemaAcl/schemaAcl.ts +++ b/src/store/reducers/schemaAcl/schemaAcl.ts @@ -11,6 +11,7 @@ export const schemaAclApi = api.injectEndpoints({ acl: data.Common.ACL, effectiveAcl: data.Common.EffectiveACL, owner: data.Common.Owner, + interruptInheritance: data.Common.InterruptInheritance, }, }; } catch (error) { diff --git a/src/types/api/acl.ts b/src/types/api/acl.ts index 3febe43c0..b9ce22079 100644 --- a/src/types/api/acl.ts +++ b/src/types/api/acl.ts @@ -15,6 +15,7 @@ export interface TMetaCommonInfo { Owner?: string; ACL?: TACE[]; EffectiveACL?: TACE[]; + InterruptInheritance?: boolean; } export interface TACE {