Skip to content

Commit bce4e92

Browse files
authored
feat: add effective ACL (#1036)
1 parent f2dfacb commit bce4e92

File tree

8 files changed

+65
-27
lines changed

8 files changed

+65
-27
lines changed

src/containers/Tenant/Acl/Acl.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
.ydb-acl {
44
width: 100%;
5-
&__owner-container {
6-
padding-bottom: 25px;
7-
}
85
&__result {
9-
padding-bottom: 16px;
10-
}
11-
12-
&__owner {
13-
font-weight: 600;
6+
padding-bottom: var(--g-spacing-4);
7+
padding-left: var(--g-spacing-2);
148
}
159
&__definition-content {
1610
display: flex;
1711
flex-direction: column;
1812
}
13+
&__list-title {
14+
margin: var(--g-spacing-3) 0 var(--g-spacing-5);
15+
16+
font-weight: 600;
17+
@include subheader-2-typography();
18+
}
1919
&__group-label {
2020
@include subheader-2-typography();
2121
}

src/containers/Tenant/Acl/Acl.tsx

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import React from 'react';
22

3-
import type {DefinitionListItem} from '@gravity-ui/components';
43
import {DefinitionList} from '@gravity-ui/components';
4+
import type {DefinitionListItem} from '@gravity-ui/components';
55

66
import {ResponseError} from '../../../components/Errors/ResponseError';
77
import {Loader} from '../../../components/Loader';
88
import {schemaAclApi} from '../../../store/reducers/schemaAcl/schemaAcl';
99
import type {TACE} from '../../../types/api/acl';
1010
import {valueIsDefined} from '../../../utils';
1111
import {cn} from '../../../utils/cn';
12-
import i18n from '../i18n';
12+
13+
import i18n from './i18n';
1314

1415
import './Acl.scss';
1516

@@ -113,26 +114,28 @@ function getAclListItems(acl?: TACE[]): DefinitionListItem[] {
113114
});
114115
}
115116

116-
function getOwnerItem(owner?: string) {
117+
function getOwnerItem(owner?: string): DefinitionListItem[] {
117118
const preparedOwner = prepareLogin(owner);
118119
if (!preparedOwner) {
119120
return [];
120121
}
121122
return [
122123
{
123124
name: <span className={b('owner')}>{preparedOwner}</span>,
124-
content: <span className={b('owner')}>{i18n('acl.owner')}</span>,
125+
content: <span className={b('owner')}>{i18n('title_owner')}</span>,
125126
},
126-
] as DefinitionListItem[];
127+
];
127128
}
128129

129130
export const Acl = ({path}: {path: string}) => {
130131
const {currentData, isFetching, error} = schemaAclApi.useGetSchemaAclQuery({path});
131132

132133
const loading = isFetching && !currentData;
133-
const {acl, owner} = currentData || {};
134+
135+
const {acl, effectiveAcl, owner} = currentData || {};
134136

135137
const aclListItems = getAclListItems(acl);
138+
const effectiveAclListItems = getAclListItems(effectiveAcl);
136139

137140
const ownerItem = getOwnerItem(owner);
138141

@@ -144,21 +147,33 @@ export const Acl = ({path}: {path: string}) => {
144147
return <ResponseError error={error} />;
145148
}
146149

147-
if (!acl && !owner) {
148-
return <React.Fragment>{i18n('acl.empty')}</React.Fragment>;
150+
if (!acl && !owner && !effectiveAcl) {
151+
return <React.Fragment>{i18n('description_empty')}</React.Fragment>;
149152
}
150153

154+
const accessRightsItems = ownerItem.concat(aclListItems);
155+
151156
return (
152157
<div className={b()}>
153-
{ownerItem.length ? (
154-
<DefinitionList
155-
items={ownerItem}
156-
nameMaxWidth={200}
157-
className={b('owner-container')}
158-
/>
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>
159167
) : null}
160-
{aclListItems.length ? (
161-
<DefinitionList items={aclListItems} nameMaxWidth={200} className={b('result')} />
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>
162177
) : null}
163178
</div>
164179
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"title_rights": "Access Rights",
3+
"title_effective-rights": "Effective Access Rights",
4+
"title_owner": "Owner",
5+
"description_empty": "No Acl data"
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-acl';
6+
7+
export default registerKeysets(COMPONENT, {en});

src/containers/Tenant/i18n/en.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"page.title": "Database",
33
"pages.query": "Query",
44
"pages.diagnostics": "Diagnostics",
5-
"acl.owner": "Owner",
6-
"acl.empty": "No Acl data",
75
"summary.navigation": "Navigation",
86
"summary.showPreview": "Show preview",
97
"summary.source-type": "Source Type",

src/store/reducers/schemaAcl/schemaAcl.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ export const schemaAclApi = api.injectEndpoints({
66
queryFn: async ({path}: {path: string}, {signal}) => {
77
try {
88
const data = await window.api.getSchemaAcl({path}, {signal});
9-
return {data: {acl: data.Common.ACL, owner: data.Common.Owner}};
9+
return {
10+
data: {
11+
acl: data.Common.ACL,
12+
effectiveAcl: data.Common.EffectiveACL,
13+
owner: data.Common.Owner,
14+
},
15+
};
1016
} catch (error) {
1117
return {error};
1218
}

src/styles/mixins.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
line-height: var(--g-text-subheader-2-line-height);
4141
}
4242

43+
@mixin subheader-3-typography() {
44+
font-size: var(--g-text-subheader-3-font-size);
45+
line-height: var(--g-text-subheader-3-line-height);
46+
}
47+
4348
@mixin header-1-typography() {
4449
font-size: var(--g-text-header-1-font-size);
4550
line-height: var(--g-text-header-1-line-height);

src/types/api/acl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface TMetaCommonInfo {
1414
Path: string;
1515
Owner?: string;
1616
ACL?: TACE[];
17+
EffectiveACL?: TACE[];
1718
}
1819

1920
export interface TACE {

0 commit comments

Comments
 (0)