Skip to content

Commit e490477

Browse files
committed
feat: Add setting to select syntax in ACL handlers
1 parent 0acabd6 commit e490477

File tree

16 files changed

+210
-88
lines changed

16 files changed

+210
-88
lines changed

src/containers/Tenant/Diagnostics/AccessRights/AccessRights.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {ResponseError} from '../../../../components/Errors/ResponseError';
77
import {LoaderWrapper} from '../../../../components/LoaderWrapper/LoaderWrapper';
88
import {useEditAccessAvailable} from '../../../../store/reducers/capabilities/hooks';
99
import {schemaAclApi} from '../../../../store/reducers/schemaAcl/schemaAcl';
10-
import {useAutoRefreshInterval} from '../../../../utils/hooks';
10+
import {useAclSyntax, useAutoRefreshInterval} from '../../../../utils/hooks';
1111
import {useCurrentSchema} from '../../TenantContext';
1212
import {useTenantQueryParams} from '../../useTenantQueryParams';
1313

@@ -22,8 +22,9 @@ export function AccessRights() {
2222
const {path, database} = useCurrentSchema();
2323
const editable = useEditAccessAvailable();
2424
const [autoRefreshInterval] = useAutoRefreshInterval();
25+
const dialect = useAclSyntax();
2526
const {isLoading, error} = schemaAclApi.useGetSchemaAclQuery(
26-
{path, database},
27+
{path, database, dialect},
2728
{
2829
pollingInterval: autoRefreshInterval,
2930
},

src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {Dialog, Text, TextInput} from '@gravity-ui/uikit';
55

66
import {schemaAclApi} from '../../../../../store/reducers/schemaAcl/schemaAcl';
77
import createToast from '../../../../../utils/createToast';
8+
import {useAclSyntax} from '../../../../../utils/hooks';
89
import {prepareErrorMessage} from '../../../../../utils/prepareErrorMessage';
910
import i18n from '../i18n';
1011
import {block} from '../shared';
@@ -61,13 +62,14 @@ function ChangeOwnerDialog({open, onClose, path, database}: ChangeOwnerDialogPro
6162
const [newOwner, setNewOwner] = React.useState('');
6263
const [requestErrorMessage, setRequestErrorMessage] = React.useState('');
6364
const [updateOwner, updateOwnerResponse] = schemaAclApi.useUpdateAccessMutation();
65+
const dialect = useAclSyntax();
6466

6567
const handleTyping = (value: string) => {
6668
setNewOwner(value);
6769
setRequestErrorMessage('');
6870
};
6971
const onApply = () => {
70-
updateOwner({path, database, rights: {ChangeOwnership: {Subject: newOwner}}})
72+
updateOwner({path, database, dialect, rights: {ChangeOwnership: {Subject: newOwner}}})
7173
.unwrap()
7274
.then(() => {
7375
onClose();

src/containers/Tenant/Diagnostics/AccessRights/components/Owner.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {ActionTooltip, Button, Card, Divider, Flex, Icon, Text} from '@gravity-u
44
import {SubjectWithAvatar} from '../../../../../components/SubjectWithAvatar/SubjectWithAvatar';
55
import {useEditAccessAvailable} from '../../../../../store/reducers/capabilities/hooks';
66
import {selectSchemaOwner} from '../../../../../store/reducers/schemaAcl/schemaAcl';
7-
import {useTypedSelector} from '../../../../../utils/hooks';
7+
import {useAclSyntax, useTypedSelector} from '../../../../../utils/hooks';
88
import {useCurrentSchema} from '../../../TenantContext';
99
import i18n from '../i18n';
1010
import {block} from '../shared';
@@ -14,7 +14,8 @@ import {getChangeOwnerDialog} from './ChangeOwnerDialog';
1414
export function Owner() {
1515
const editable = useEditAccessAvailable();
1616
const {path, database} = useCurrentSchema();
17-
const owner = useTypedSelector((state) => selectSchemaOwner(state, path, database));
17+
const dialect = useAclSyntax();
18+
const owner = useTypedSelector((state) => selectSchemaOwner(state, path, database, dialect));
1819

1920
if (!owner) {
2021
return null;

src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/Actions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ActionTooltip, Button, Flex, Icon} from '@gravity-ui/uikit';
33

44
import {useEditAccessAvailable} from '../../../../../../store/reducers/capabilities/hooks';
55
import {selectSubjectExplicitRights} from '../../../../../../store/reducers/schemaAcl/schemaAcl';
6-
import {useTypedSelector} from '../../../../../../utils/hooks';
6+
import {useAclSyntax, useTypedSelector} from '../../../../../../utils/hooks';
77
import {useCurrentSchema} from '../../../../TenantContext';
88
import {useTenantQueryParams} from '../../../../useTenantQueryParams';
99
import i18n from '../../i18n';
@@ -50,8 +50,9 @@ function GrantRightsToSubject({subject}: ActionProps) {
5050

5151
function RevokeAllRights({subject}: ActionProps) {
5252
const {path, database} = useCurrentSchema();
53+
const dialect = useAclSyntax();
5354
const subjectExplicitRights = useTypedSelector((state) =>
54-
selectSubjectExplicitRights(state, subject, path, database),
55+
selectSubjectExplicitRights(state, subject, path, database, dialect),
5556
);
5657
const noRightsToRevoke = subjectExplicitRights.length === 0;
5758

src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
selectSubjectExplicitRights,
1010
} from '../../../../../../store/reducers/schemaAcl/schemaAcl';
1111
import createToast from '../../../../../../utils/createToast';
12-
import {useTypedSelector} from '../../../../../../utils/hooks';
12+
import {useAclSyntax, useTypedSelector} from '../../../../../../utils/hooks';
1313
import {prepareErrorMessage} from '../../../../../../utils/prepareErrorMessage';
1414
import i18n from '../../i18n';
1515

@@ -72,8 +72,9 @@ function RevokeAllRightsDialog({
7272
database,
7373
subject,
7474
}: RevokeAllRightsDialogProps) {
75+
const dialect = useAclSyntax();
7576
const subjectExplicitRights = useTypedSelector((state) =>
76-
selectSubjectExplicitRights(state, subject, path, database),
77+
selectSubjectExplicitRights(state, subject, path, database, dialect),
7778
);
7879

7980
const [requestErrorMessage, setRequestErrorMessage] = React.useState('');
@@ -83,6 +84,7 @@ function RevokeAllRightsDialog({
8384
removeAccess({
8485
path,
8586
database,
87+
dialect,
8688
rights: {
8789
RemoveAccess: [
8890
{

src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RightsTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {Settings} from '@gravity-ui/react-data-table';
33
import {ResizeableDataTable} from '../../../../../../components/ResizeableDataTable/ResizeableDataTable';
44
import {selectPreparedRights} from '../../../../../../store/reducers/schemaAcl/schemaAcl';
55
import {DEFAULT_TABLE_SETTINGS} from '../../../../../../utils/constants';
6-
import {useTypedSelector} from '../../../../../../utils/hooks';
6+
import {useAclSyntax, useTypedSelector} from '../../../../../../utils/hooks';
77
import {useCurrentSchema} from '../../../../TenantContext';
88
import i18n from '../../i18n';
99
import {block} from '../../shared';
@@ -16,7 +16,8 @@ const AccessRightsTableSettings: Settings = {...DEFAULT_TABLE_SETTINGS, dynamicR
1616

1717
export function RightsTable() {
1818
const {path, database} = useCurrentSchema();
19-
const data = useTypedSelector((state) => selectPreparedRights(state, path, database));
19+
const dialect = useAclSyntax();
20+
const data = useTypedSelector((state) => selectPreparedRights(state, path, database, dialect));
2021
return (
2122
<ResizeableDataTable
2223
columnsWidthLSKey={RIGHT_TABLE_COLUMNS_WIDTH_LS_KEY}

src/containers/Tenant/GrantAccess/GrantAccess.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
selectSubjectInheritedRights,
1111
} from '../../../store/reducers/schemaAcl/schemaAcl';
1212
import createToast from '../../../utils/createToast';
13-
import {useTypedSelector} from '../../../utils/hooks';
13+
import {useAclSyntax, useTypedSelector} from '../../../utils/hooks';
1414
import {prepareErrorMessage} from '../../../utils/prepareErrorMessage';
1515
import {useCurrentSchema} from '../TenantContext';
1616
import {useTenantQueryParams} from '../useTenantQueryParams';
@@ -36,24 +36,27 @@ export function GrantAccess({handleCloseDrawer}: GrantAccessProps) {
3636
const [rightView, setRightsView] = React.useState<RightsView>('Groups');
3737

3838
const {path, database} = useCurrentSchema();
39+
const dialect = useAclSyntax();
3940
const {currentRightsMap, setExplicitRightsChanges, rightsToGrant, rightsToRevoke, hasChanges} =
4041
useRights({aclSubject: aclSubject ?? undefined, path, database});
4142
const {isFetching: aclIsFetching} = schemaAclApi.useGetSchemaAclQuery(
4243
{
4344
path,
4445
database,
46+
dialect,
4547
},
4648
{skip: !aclSubject},
4749
);
4850
const {isFetching: availableRightsAreFetching} = schemaAclApi.useGetAvailablePermissionsQuery({
4951
database,
52+
dialect,
5053
});
5154
const [updateRights, updateRightsResponse] = schemaAclApi.useUpdateAccessMutation();
5255

5356
const [updateRightsError, setUpdateRightsError] = React.useState('');
5457

5558
const inheritedRightsSet = useTypedSelector((state) =>
56-
selectSubjectInheritedRights(state, aclSubject ?? undefined, path, database),
59+
selectSubjectInheritedRights(state, aclSubject ?? undefined, path, database, dialect),
5760
);
5861

5962
const handleDiscardRightsChanges = React.useCallback(() => {
@@ -68,6 +71,7 @@ export function GrantAccess({handleCloseDrawer}: GrantAccessProps) {
6871
updateRights({
6972
path,
7073
database,
74+
dialect,
7175
rights: {
7276
AddAccess: subjects.map((subj) => ({
7377
AccessRights: rightsToGrant,
@@ -98,6 +102,7 @@ export function GrantAccess({handleCloseDrawer}: GrantAccessProps) {
98102
updateRights,
99103
path,
100104
database,
105+
dialect,
101106
rightsToGrant,
102107
aclSubject,
103108
rightsToRevoke,
@@ -106,7 +111,7 @@ export function GrantAccess({handleCloseDrawer}: GrantAccessProps) {
106111
]);
107112

108113
const availablePermissions = useTypedSelector((state) =>
109-
selectAvailablePermissions(state, database),
114+
selectAvailablePermissions(state, database, dialect),
110115
);
111116
const handleChangeRightGetter = React.useCallback(
112117
(right: string) => {

src/containers/Tenant/GrantAccess/utils.ts

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

33
import {selectSubjectExplicitRights} from '../../../store/reducers/schemaAcl/schemaAcl';
4-
import {useTypedSelector} from '../../../utils/hooks';
4+
import {useAclSyntax, useTypedSelector} from '../../../utils/hooks';
55

66
interface UseRightsProps {
77
aclSubject?: string;
@@ -10,8 +10,9 @@ interface UseRightsProps {
1010
}
1111

1212
export function useRights({aclSubject, path, database}: UseRightsProps) {
13+
const dialect = useAclSyntax();
1314
const subjectExplicitRights = useTypedSelector((state) =>
14-
selectSubjectExplicitRights(state, aclSubject ?? undefined, path, database),
15+
selectSubjectExplicitRights(state, aclSubject ?? undefined, path, database, dialect),
1516
);
1617
const [explicitRightsChanges, setExplicitRightsChanges] = React.useState(
1718
() => new Map<string, boolean>(),

src/containers/UserSettings/i18n/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,12 @@
4848
"settings.useClusterBalancerAsBackend.title": "Use cluster balancer as backend",
4949
"settings.useClusterBalancerAsBackend.description": "By default random cluster node is used as backend. It causes saved links to become invalid after some time, when node is restarted. Using balancer as backend fixes it",
5050

51+
"settings.aclSyntax.title": "ACL syntax format",
52+
"settings.aclSyntax.description": "Select the syntax format for displaying access control lists",
53+
"settings.aclSyntax.option-kikimr": "KiKiMr",
54+
"settings.aclSyntax.option-ydb-short": "YDB Short",
55+
"settings.aclSyntax.option-ydb": "YDB",
56+
"settings.aclSyntax.option-yql": "YQL",
57+
5158
"settings.about.interfaceVersionInfoField.title": "Interface version"
5259
}

src/containers/UserSettings/settings.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import type {IconProps} from '@gravity-ui/uikit';
33
import {createNextState} from '@reduxjs/toolkit';
44

55
import {
6+
ACL_SYNTAX_KEY,
67
AUTOCOMPLETE_ON_ENTER,
8+
AclSyntax,
79
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
810
ENABLE_AUTOCOMPLETE,
911
ENABLE_CODE_ASSISTANT,
@@ -146,6 +148,32 @@ export const autocompleteOnEnterSetting: SettingProps = {
146148
description: i18n('settings.editor.autocomplete-on-enter.description'),
147149
};
148150

151+
const aclSyntaxOptions = [
152+
{
153+
value: AclSyntax.Kikimr,
154+
content: i18n('settings.aclSyntax.option-kikimr'),
155+
},
156+
{
157+
value: AclSyntax.YdbShort,
158+
content: i18n('settings.aclSyntax.option-ydb-short'),
159+
},
160+
{
161+
value: AclSyntax.Ydb,
162+
content: i18n('settings.aclSyntax.option-ydb'),
163+
},
164+
{
165+
value: AclSyntax.Yql,
166+
content: i18n('settings.aclSyntax.option-yql'),
167+
},
168+
];
169+
170+
export const aclSyntaxSetting: SettingProps = {
171+
settingKey: ACL_SYNTAX_KEY,
172+
title: i18n('settings.aclSyntax.title'),
173+
type: 'radio',
174+
options: aclSyntaxOptions,
175+
};
176+
149177
export const interfaceVersionInfoField: SettingsInfoFieldProps = {
150178
title: i18n('settings.about.interfaceVersionInfoField.title'),
151179
type: 'info',
@@ -160,6 +188,7 @@ export const appearanceSection: SettingsSection = {
160188
invertedDisksSetting,
161189
binaryDataInPlainTextDisplay,
162190
showDomainDatabase,
191+
aclSyntaxSetting,
163192
],
164193
};
165194

0 commit comments

Comments
 (0)