Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/@types/nodekit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface SharedAppConfig {
editor: string;
viewer: string;
limitedViewer?: string;
entryBindingCreator?: string;
limitedEntryBindingCreator?: string;
};
};
workbook: {
Expand All @@ -74,6 +76,16 @@ export interface SharedAppConfig {
limitedViewer?: string;
};
};
sharedEntry: {
roles: {
admin: string;
editor: string;
viewer: string;
limitedViewer?: string;
entryBindingCreator?: string;
limitedEntryBindingCreator?: string;
};
};
};

// sorted roles from the role with the most rights to the role with the least
Expand Down
12 changes: 12 additions & 0 deletions src/server/configs/opensource/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export default {
editor: 'datalens.collections.editor',
viewer: 'datalens.collections.viewer',
limitedViewer: 'datalens.collections.limitedViewer',
entryBindingCreator: 'datalens.collections.entryBindingCreator',
limitedEntryBindingCreator: 'datalens.collections.limitedEntryBindingCreator',
},
},
workbook: {
Expand All @@ -149,6 +151,16 @@ export default {
limitedViewer: 'datalens.workbooks.limitedViewer',
},
},
sharedEntry: {
roles: {
admin: 'datalens.sharedEntries.admin',
editor: 'datalens.sharedEntries.editor',
viewer: 'datalens.sharedEntries.viewer',
limitedViewer: 'datalens.sharedEntries.limitedViewer',
entryBindingCreator: 'datalens.sharedEntries.entryBindingCreator',
limitedEntryBindingCreator: 'datalens.sharedEntries.limitedEntryBindingCreator',
},
},
},

orderedAuthRoles: [UserRole.Admin, UserRole.Editor, UserRole.Viewer],
Expand Down
13 changes: 13 additions & 0 deletions src/shared/schema/extensions/actions/iam-access-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import type {
GetClaimsResponse,
ListCollectionAccessBindingsArgs,
ListCollectionAccessBindingsResponse,
ListSharedEntryAccessBindingsArgs,
ListSharedEntryAccessBindingsResponse,
ListWorkbookAccessBindingsArgs,
ListWorkbookAccessBindingsResponse,
UpdateCollectionAccessBindingsArgs,
UpdateSharedEntryAccessBindingsArgs,
UpdateWorkbookAccessBindingsArgs,
} from '../types';

Expand All @@ -34,6 +37,16 @@ export const iamAccessDialogActions = {
>(async () => {
return {} as GetDatalensOperationResponse;
}),
listSharedEntryAccessBindings: createAction<
ListSharedEntryAccessBindingsResponse,
ListSharedEntryAccessBindingsArgs
>(async () => []),
updateSharedEntryAccessBindings: createAction<
GetDatalensOperationResponse,
UpdateSharedEntryAccessBindingsArgs
>(async () => {
return {} as GetDatalensOperationResponse;
}),
getClaims: createAction<GetClaimsResponse, GetClaimsArgs>(async () => {
return {subjectDetails: []};
}),
Expand Down
14 changes: 14 additions & 0 deletions src/shared/schema/extensions/types/iam-access-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ export type UpdateWorkbookAccessBindingsArgs = {
deltas: AccessBindingDelta[];
};

export type ListSharedEntryAccessBindingsArgs = {
entryId: string;
withInherits?: boolean;
pageTokenData?: PageTokenData;
pageSize?: number;
};

export type ListSharedEntryAccessBindingsResponse = ListAccessBindingsResultItem[];

export type UpdateSharedEntryAccessBindingsArgs = {
entryId: string;
deltas: AccessBindingDelta[];
};

export type PageTokenData = {
type: `${AccessServiceResourceType}`;
id: string;
Expand Down
12 changes: 12 additions & 0 deletions src/shared/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ export type DLGlobalData = {
editor: string;
viewer: string;
limitedViewer?: string;
entryBindingCreator?: string;
limitedEntryBindingCreator?: string;
};
};
workbook: {
Expand All @@ -210,6 +212,16 @@ export type DLGlobalData = {
limitedViewer?: string;
};
};
sharedEntry: {
roles: {
admin: string;
editor: string;
viewer: string;
limitedViewer?: string;
entryBindingCreator?: string;
limitedEntryBindingCreator?: string;
};
};
};
// sorted roles from the role with the most rights to the role with the least
orderedAuthRoles?: `${UserRole}`[];
Expand Down
6 changes: 5 additions & 1 deletion src/ui/components/IamAccessDialog/AccessList/AccessList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {useSelector} from 'react-redux';
import {Waypoint} from 'react-waypoint';
import type {SharedScope} from 'shared';
import {Utils} from 'ui';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {
ListAccessBindingsResultItem,
PageTokenData,
} from '../../../../shared/schema/extensions/types';
import type {ResourceType} from '../../../store/actions/iamAccessDialog';
import {
selectGetCollectionBreadcrumbsData,
selectGetCollectionBreadcrumbsError,
Expand Down Expand Up @@ -39,6 +40,7 @@ export type Props = {
resourceId: string;
resourceType: ResourceType;
resourceTitle: string;
resourceScope?: SharedScope;
canUpdate: boolean;
refetch: () => void;
loadMoreInheritedAccessBindings: (pageTokenData?: PageTokenData) => void;
Expand All @@ -60,6 +62,7 @@ export const AccessList = React.memo<Props>(
onClose,
isLoadingDirect,
isLoadingInherited,
resourceScope,
}) => {
const accessBindingsError = useSelector(selectListAccessBindingsError);
const accessBindings: ListAccessBindingsResultItem[] | null =
Expand Down Expand Up @@ -210,6 +213,7 @@ export const AccessList = React.memo<Props>(
<ActionPanel
type={resourceType}
title={resourceTitle}
resourceScope={resourceScope}
canUpdate={canUpdate}
onAddUserClick={onAddUserClick}
isLoadingDirect={isLoadingDirect}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {Plus} from '@gravity-ui/icons';
import {Button, Icon} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import type {SharedScope} from 'shared';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {ResourceType} from '../../../../store/actions/iamAccessDialog';
import {ResourceInfo} from '../../ResourceInfo/ResourceInfo';

import './ActionPanel.scss';
Expand All @@ -17,16 +18,24 @@ const i18n = I18n.keyset('component.iam-access-dialog');
export type Props = {
type: ResourceType;
title: string;
resourceScope?: SharedScope;
canUpdate: boolean;
onAddUserClick: () => void;
isLoadingDirect: boolean;
};

export const ActionPanel = ({type, title, canUpdate, onAddUserClick, isLoadingDirect}: Props) => {
export const ActionPanel = ({
type,
title,
canUpdate,
onAddUserClick,
isLoadingDirect,
resourceScope,
}: Props) => {
return (
<div className={b()}>
<div className={b('info')}>
<ResourceInfo type={type} title={title} />
<ResourceInfo scope={resourceScope} type={type} title={title} />
</div>
<div className={b('add-button')}>
<Button onClick={onAddUserClick} disabled={!canUpdate || isLoadingDirect}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React from 'react';
import {Button, Icon, Select} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {useDispatch} from 'react-redux';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {SubjectClaims} from '../../../../../../shared/schema/extensions/types';
import {AccessBindingAction} from '../../../../../../shared/schema/extensions/types';
import type {
IamAccessDialogDispatch,
ResourceType,
} from '../../../../../store/actions/iamAccessDialog';
import type {IamAccessDialogDispatch} from '../../../../../store/actions/iamAccessDialog';
import {
updateAccessBindings,
updateListAccessBindingsInline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import {Dialog, Table} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {useDispatch} from 'react-redux';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {SubjectDetails} from '../../../../../shared/schema/extensions/types';
import {
AccessBindingAction,
ClaimsSubjectType,
} from '../../../../../shared/schema/extensions/types';
import {registry} from '../../../../registry';
import type {
IamAccessDialogDispatch,
ResourceType,
} from '../../../../store/actions/iamAccessDialog';
import type {IamAccessDialogDispatch} from '../../../../store/actions/iamAccessDialog';
import {updateAccessBindings} from '../../../../store/actions/iamAccessDialog';
import {CLOSE_DELETE_TIMEOUT} from '../../constants';
import {filterByUser, getAccessSubjectType, getResourceRoles} from '../../utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Label, Table} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {Link} from 'react-router-dom';
import {getSharedEntryMockText} from 'ui/units/collections/components/helpers';

import type {SubjectDetails} from '../../../../../shared/schema/extensions/types';
import {ClaimsSubjectType} from '../../../../../shared/schema/extensions/types';
Expand Down Expand Up @@ -76,7 +77,7 @@ export const InheritedAccessesTable = ({data}: Props) => {
return role;
}

const {collection, workbook} = iamResources;
const {collection, workbook, sharedEntry} = iamResources;

switch (role) {
case collection.roles.admin:
Expand All @@ -91,6 +92,22 @@ export const InheritedAccessesTable = ({data}: Props) => {
case collection.roles.limitedViewer:
case workbook.roles.limitedViewer:
return <Label theme="normal">{i18n('role_limited-viewer')}</Label>;
case collection.roles.entryBindingCreator:
case sharedEntry.roles.entryBindingCreator:
return (
<Label theme="normal">
{getSharedEntryMockText('iam-dialog-role-entryBindingCreator')}
</Label>
);
case collection.roles.limitedEntryBindingCreator:
case sharedEntry.roles.limitedEntryBindingCreator:
return (
<Label theme="normal">
{getSharedEntryMockText(
'iam-dialog-role-limitedEntryBindingCreator',
)}
</Label>
);
default:
return role;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';

import {Select} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import type {SharedScope} from 'shared';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {ResourceType} from '../../../../store/actions/iamAccessDialog';
import {ResourceInfo} from '../../ResourceInfo/ResourceInfo';
import {getResourceRoles} from '../../utils';

Expand All @@ -14,6 +15,7 @@ const b = block('dl-iam-access-dialog-add-user-action-panel');
export type Props = {
type: ResourceType;
title: string;
resourceScope?: SharedScope;
options: {
title: string;
value: string;
Expand All @@ -22,13 +24,13 @@ export type Props = {
onChangeRole: (role: string) => void;
};

export const ActionPanel = ({type, title, role, onChangeRole}: Props) => {
export const ActionPanel = ({type, title, role, resourceScope, onChangeRole}: Props) => {
const options = getResourceRoles(type);

return (
<div className={b()}>
<div className={b('info')}>
<ResourceInfo type={type} title={title} />
<ResourceInfo scope={resourceScope} type={type} title={title} />
</div>
<div className={b('change-role')}>
<Select
Expand Down
8 changes: 6 additions & 2 deletions src/ui/components/IamAccessDialog/AddSubjects/AddSubjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {Button, Dialog, Icon} from '@gravity-ui/uikit';
import block from 'bem-cn-lite';
import {I18n} from 'i18n';
import {useDispatch} from 'react-redux';
import type {SharedScope} from 'shared';
import type {ResourceType} from 'ui/registry/units/common/types/components/IamAccessDialog';

import type {AccessBindingDelta, SubjectClaims} from '../../../../shared/schema/extensions/types';
import {AccessBindingAction} from '../../../../shared/schema/extensions/types';
import type {IamAccessDialogDispatch, ResourceType} from '../../../store/actions/iamAccessDialog';
import type {IamAccessDialogDispatch} from '../../../store/actions/iamAccessDialog';
import {updateAccessBindings} from '../../../store/actions/iamAccessDialog';
import {getAccessSubjectType, getResourceRoles} from '../utils';

Expand All @@ -24,13 +26,14 @@ const i18n = I18n.keyset('component.iam-access-dialog');
export type Props = {
resourceId: string;
resourceType: ResourceType;
resourceScope?: SharedScope;
resourceTitle: string;
refetch: () => void;
onBack: () => void;
};

export const AddSubjects = React.memo<Props>(
({resourceId, resourceType, resourceTitle, refetch, onBack}) => {
({resourceId, resourceType, resourceTitle, refetch, resourceScope, onBack}) => {
const dispatch = useDispatch<IamAccessDialogDispatch>();

const options = getResourceRoles(resourceType);
Expand Down Expand Up @@ -89,6 +92,7 @@ export const AddSubjects = React.memo<Props>(
<ActionPanel
type={resourceType}
title={resourceTitle}
resourceScope={resourceScope}
options={options}
role={role}
onChangeRole={setRole}
Expand Down
13 changes: 12 additions & 1 deletion src/ui/components/IamAccessDialog/IamAccessDialogComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ enum Mode {
reducerRegistry.register({iamAccessDialog: iamAccessDialogReducer});

export const IamAccessDialogComponent = React.memo<IamAccessDialogProps>(
({open, resourceId, resourceType, resourceTitle, parentId, canUpdate, onClose}) => {
({
open,
resourceId,
resourceType,
resourceTitle,
resourceScope,
parentId,
canUpdate,
onClose,
}) => {
const dispatch = useDispatch<IamAccessDialogDispatch>();

const [mode, setMode] = React.useState(Mode.AccessListMode);
Expand Down Expand Up @@ -286,6 +295,7 @@ export const IamAccessDialogComponent = React.memo<IamAccessDialogProps>(
resourceId={resourceId}
resourceType={resourceType}
resourceTitle={resourceTitle}
resourceScope={resourceScope}
canUpdate={canUpdate}
refetch={fetchData}
loadMoreInheritedAccessBindings={loadMoreInheritedAccessBindings}
Expand All @@ -298,6 +308,7 @@ export const IamAccessDialogComponent = React.memo<IamAccessDialogProps>(
/>
) : (
<AddSubjects
resourceScope={resourceScope}
resourceId={resourceId}
resourceType={resourceType}
resourceTitle={resourceTitle}
Expand Down
Loading
Loading