Skip to content

Commit 89804af

Browse files
authored
feat(Acl): support InterruptInheritance, fix styles (#1154)
1 parent 512786c commit 89804af

File tree

5 files changed

+59
-23
lines changed

5 files changed

+59
-23
lines changed

src/containers/Tenant/Acl/Acl.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
&__result {
66
padding-bottom: var(--g-spacing-4);
77
padding-left: var(--g-spacing-2);
8+
9+
&_no-title {
10+
margin-top: var(--g-spacing-3);
11+
}
812
}
913
&__definition-content {
1014
display: flex;
1115
flex-direction: column;
16+
align-items: flex-end;
1217
}
1318
&__list-title {
1419
margin: var(--g-spacing-3) 0 var(--g-spacing-5);

src/containers/Tenant/Acl/Acl.tsx

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22

33
import {DefinitionList} from '@gravity-ui/components';
44
import type {DefinitionListItem} from '@gravity-ui/components';
5+
import {SquareCheck} from '@gravity-ui/icons';
6+
import {Icon} from '@gravity-ui/uikit';
57

68
import {ResponseError} from '../../../components/Errors/ResponseError';
79
import {Loader} from '../../../components/Loader';
@@ -94,6 +96,7 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] {
9496
return {
9597
name: Subject,
9698
content: <DefinitionValue value={definedDataEntries[0][1]} />,
99+
multilineName: true,
97100
};
98101
}
99102
return {
@@ -105,6 +108,7 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] {
105108
return {
106109
name: aclParamToName[key],
107110
content: <DefinitionValue value={value} />,
111+
multilineName: true,
108112
};
109113
}
110114
return undefined;
@@ -121,8 +125,22 @@ function getOwnerItem(owner?: string): DefinitionListItem[] {
121125
}
122126
return [
123127
{
124-
name: <span className={b('owner')}>{preparedOwner}</span>,
125-
content: <span className={b('owner')}>{i18n('title_owner')}</span>,
128+
name: preparedOwner,
129+
content: i18n('title_owner'),
130+
multilineName: true,
131+
},
132+
];
133+
}
134+
135+
function getInterruptInheritanceItem(flag?: boolean): DefinitionListItem[] {
136+
if (!flag) {
137+
return [];
138+
}
139+
return [
140+
{
141+
name: i18n('title_interupt-inheritance'),
142+
content: <Icon data={SquareCheck} size={20} />,
143+
multilineName: true,
126144
},
127145
];
128146
}
@@ -132,13 +150,15 @@ export const Acl = ({path, database}: {path: string; database: string}) => {
132150

133151
const loading = isFetching && !currentData;
134152

135-
const {acl, effectiveAcl, owner} = currentData || {};
153+
const {acl, effectiveAcl, owner, interruptInheritance} = currentData || {};
136154

137155
const aclListItems = getAclListItems(acl);
138156
const effectiveAclListItems = getAclListItems(effectiveAcl);
139157

140158
const ownerItem = getOwnerItem(owner);
141159

160+
const interruptInheritanceItem = getInterruptInheritanceItem(interruptInheritance);
161+
142162
if (loading) {
143163
return <Loader />;
144164
}
@@ -155,26 +175,34 @@ export const Acl = ({path, database}: {path: string; database: string}) => {
155175

156176
return (
157177
<div className={b()}>
158-
{accessRightsItems.length ? (
159-
<React.Fragment>
160-
<div className={b('list-title')}>{i18n('title_rights')}</div>
161-
<DefinitionList
162-
items={accessRightsItems}
163-
nameMaxWidth={200}
164-
className={b('result')}
165-
/>
166-
</React.Fragment>
167-
) : null}
168-
{effectiveAclListItems.length ? (
169-
<React.Fragment>
170-
<div className={b('list-title')}>{i18n('title_effective-rights')}</div>
171-
<DefinitionList
172-
items={effectiveAclListItems}
173-
nameMaxWidth={200}
174-
className={b('result')}
175-
/>
176-
</React.Fragment>
177-
) : null}
178+
<AclDefinitionList items={interruptInheritanceItem} />
179+
<AclDefinitionList items={accessRightsItems} title={i18n('title_rights')} />
180+
<AclDefinitionList
181+
items={effectiveAclListItems}
182+
title={i18n('title_effective-rights')}
183+
/>
178184
</div>
179185
);
180186
};
187+
188+
interface AclDefinitionListProps {
189+
items: DefinitionListItem[];
190+
title?: string;
191+
}
192+
193+
function AclDefinitionList({items, title}: AclDefinitionListProps) {
194+
if (!items.length) {
195+
return null;
196+
}
197+
return (
198+
<React.Fragment>
199+
{title && <div className={b('list-title')}>{title}</div>}
200+
<DefinitionList
201+
items={items}
202+
nameMaxWidth={200}
203+
className={b('result', {'no-title': !title})}
204+
responsive
205+
/>
206+
</React.Fragment>
207+
);
208+
}

src/containers/Tenant/Acl/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"title_rights": "Access Rights",
33
"title_effective-rights": "Effective Access Rights",
44
"title_owner": "Owner",
5+
"title_interupt-inheritance": "Interrupt inheritance",
56
"description_empty": "No Acl data"
67
}

src/store/reducers/schemaAcl/schemaAcl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const schemaAclApi = api.injectEndpoints({
1111
acl: data.Common.ACL,
1212
effectiveAcl: data.Common.EffectiveACL,
1313
owner: data.Common.Owner,
14+
interruptInheritance: data.Common.InterruptInheritance,
1415
},
1516
};
1617
} catch (error) {

src/types/api/acl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface TMetaCommonInfo {
1515
Owner?: string;
1616
ACL?: TACE[];
1717
EffectiveACL?: TACE[];
18+
InterruptInheritance?: boolean;
1819
}
1920

2021
export interface TACE {

0 commit comments

Comments
 (0)