Skip to content

Commit

Permalink
fix(ACL): UI should display an error when user has no permission to s…
Browse files Browse the repository at this point in the history
…et ACL [#938]
  • Loading branch information
vitshev committed Jan 28, 2025
1 parent 71d0534 commit b3fdc7b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/ui/src/ui/utils/acl/acl-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import isEqual_ from 'lodash/isEqual';
import map_ from 'lodash/map';
import reduce_ from 'lodash/reduce';
import some_ from 'lodash/some';

import {Toaster} from '@gravity-ui/uikit';
// @ts-ignore
import yt from '@ytsaurus/javascript-wrapper/lib/yt';

Expand All @@ -21,7 +21,7 @@ import {
UpdateResponse,
} from './acl-types';
import {YTApiId, ytApiV3, ytApiV3Id} from '../../rum/rum-wrap-api';
import {getBatchError, splitBatchResults} from '../../utils/utils';
import {getBatchError, showErrorPopup, splitBatchResults} from '../../utils/utils';
import {convertFromUIPermission, convertToUIPermissions} from '.';
import {
BatchResultsItem,
Expand All @@ -37,6 +37,8 @@ import {
import {RequestPermissionParams} from './external-acl-api';
import {IdmObjectType, REGISTER_QUEUE_CONSUMER_VITAL} from '../../constants/acl';

const toaster = new Toaster();

function getInheritAcl(path: string): Promise<ACLResponsible> {
return yt.v3.get({path: path + '/@inherit_acl'}).then((inherit_acl: boolean) => {
return {
Expand Down Expand Up @@ -246,7 +248,17 @@ export function requestPermissions(params: RequestPermissionParams): Promise<Upd
};
return yt.v3.executeBatch(batchParams).then((results: BatchResultsItem<unknown>[]) => {
const error = getBatchError(results, 'Failed to request permissions');

if (error) {
toaster.add({
name: 'get operation',
autoHiding: false,
theme: 'danger',
title: 'Failed to request permissions',
content: error.message,
actions: [{label: ' view', onClick: () => showErrorPopup(error)}],
});

throw error;
}
return results;
Expand Down

0 comments on commit b3fdc7b

Please sign in to comment.