diff --git a/src/containers/Tenant/Diagnostics/AccessRights/AccessRights.tsx b/src/containers/Tenant/Diagnostics/AccessRights/AccessRights.tsx index 37c5b9b64e..f785a248dd 100644 --- a/src/containers/Tenant/Diagnostics/AccessRights/AccessRights.tsx +++ b/src/containers/Tenant/Diagnostics/AccessRights/AccessRights.tsx @@ -22,7 +22,7 @@ export function AccessRights() { const {path, database} = useCurrentSchema(); const editable = useEditAccessAvailable(); const [autoRefreshInterval] = useAutoRefreshInterval(); - const {currentData, isFetching, error} = schemaAclApi.useGetSchemaAclQuery( + const {isLoading, error} = schemaAclApi.useGetSchemaAclQuery( {path, database}, { pollingInterval: autoRefreshInterval, @@ -31,8 +31,6 @@ export function AccessRights() { const {handleShowGrantAccessChange} = useTenantQueryParams(); - const loading = isFetching && !currentData; - const renderContent = () => { if (error) { return ; @@ -64,5 +62,5 @@ export function AccessRights() { ); }; - return {renderContent()}; + return {renderContent()}; } diff --git a/src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx b/src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx index b53ad38f6b..95f865bfe4 100644 --- a/src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx +++ b/src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx @@ -66,60 +66,56 @@ function ChangeOwnerDialog({open, onClose, path, database}: ChangeOwnerDialogPro setNewOwner(value); setRequestErrorMessage(''); }; + const onApply = () => { + updateOwner({path, database, rights: {ChangeOwnership: {Subject: newOwner}}}) + .unwrap() + .then(() => { + onClose(); + createToast({ + name: 'updateOwner', + content: i18n('title_owner-changed'), + autoHiding: 3000, + }); + }) + .catch((error) => { + setRequestErrorMessage(prepareErrorMessage(error)); + }); + }; return ( - + -
{ - e.preventDefault(); - updateOwner({path, database, rights: {ChangeOwnership: {Subject: newOwner}}}) - .unwrap() - .then(() => { - onClose(); - createToast({ - name: 'updateOwner', - content: i18n('title_owner-changed'), - autoHiding: 3000, - }); - }) - .catch((error) => { - setRequestErrorMessage(prepareErrorMessage(error)); - }); + +
+ + {requestErrorMessage && ( + + {requestErrorMessage} + + )} +
+
+ - -
- - {requestErrorMessage && ( - - {requestErrorMessage} - - )} -
-
- - + />
); } diff --git a/src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx b/src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx index bde65e5c50..78b9744193 100644 --- a/src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx +++ b/src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx @@ -79,62 +79,59 @@ function RevokeAllRightsDialog({ const [requestErrorMessage, setRequestErrorMessage] = React.useState(''); const [removeAccess, removeAccessResponse] = schemaAclApi.useUpdateAccessMutation(); + const onApply = () => { + removeAccess({ + path, + database, + rights: { + RemoveAccess: [ + { + Subject: subject, + AccessRights: Array.from(subjectExplicitRights), + AccessType: 'Allow', + }, + ], + }, + }) + .unwrap() + .then(() => { + onClose(); + createToast({ + name: 'revokeAllRights', + content: i18n('description_rights-revoked'), + autoHiding: 3000, + }); + }) + .catch((error) => { + setRequestErrorMessage(prepareErrorMessage(error)); + }); + }; + return ( -
{ - e.preventDefault(); - removeAccess({ - path, - database, - rights: { - RemoveAccess: [ - { - Subject: subject, - AccessRights: Array.from(subjectExplicitRights), - AccessType: 'Allow', - }, - ], - }, - }) - .unwrap() - .then(() => { - onClose(); - createToast({ - name: 'revokeAllRights', - content: i18n('description_rights-revoked'), - autoHiding: 3000, - }); - }) - .catch((error) => { - setRequestErrorMessage(prepareErrorMessage(error)); - }); + + + {i18n('description_revoke-all-rights')} + + + + - - - {i18n('description_revoke-all-rights')} - - - - - {requestErrorMessage && ( - - {requestErrorMessage} - - )} - - + {requestErrorMessage && ( + + {requestErrorMessage} + + )} +
); } diff --git a/src/containers/Tenant/GrantAccess/shared.ts b/src/containers/Tenant/GrantAccess/shared.ts index 3e17326a93..d11a9ec657 100644 --- a/src/containers/Tenant/GrantAccess/shared.ts +++ b/src/containers/Tenant/GrantAccess/shared.ts @@ -4,7 +4,7 @@ import i18n from './i18n'; export const block = cn('ydb-grant-access'); -export const HumanReadableRights: Record = { +export const RightsCodes: Record = { selectRow: 1, updateRow: 2, eraseRow: 4, @@ -31,36 +31,33 @@ export const HumanReadableRights: Record = { }; export const RightsDescription: Record = { - [HumanReadableRights.selectRow]: i18n('description_select-row'), - [HumanReadableRights.updateRow]: i18n('description_update-row'), - [HumanReadableRights.eraseRow]: i18n('description_erase-row'), - [HumanReadableRights.writeAttributes]: i18n('description_write-attributes'), - [HumanReadableRights.createDirectory]: i18n('description_create-directory'), - [HumanReadableRights.createTable]: i18n('description_create-table'), - [HumanReadableRights.createQueue]: i18n('description_create-queue'), - [HumanReadableRights.removeSchema]: i18n('description_remove-schema'), - [HumanReadableRights.alterSchema]: i18n('description_alter-schema'), - [HumanReadableRights.createDatabase]: i18n('description_create-database'), - [HumanReadableRights.dropDatabase]: i18n('description_drop-database'), - [HumanReadableRights.readAttributes]: i18n('description_read-attributes'), - [HumanReadableRights.describeSchema]: i18n('description_describe-schema'), - [HumanReadableRights.connectDatabase]: i18n('description_connect-database'), - [HumanReadableRights.grantAccessRights]: i18n('description_grant-access-rights'), - [HumanReadableRights.genericRead]: i18n('description_generic-read'), - [HumanReadableRights.genericWrite]: i18n('description_generic-write'), - [HumanReadableRights.genericManage]: i18n('description_generic-manage'), - [HumanReadableRights.genericList]: i18n('description_generic-list'), - [HumanReadableRights.genericUse]: i18n('description_generic-use'), - [HumanReadableRights.genericUseLegacy]: i18n('description_generic-use-legacy'), - [HumanReadableRights.genericFull]: i18n('description_generic-full'), - [HumanReadableRights.genericFullLegacy]: i18n('description_generic-full-legacy'), + [RightsCodes.selectRow]: i18n('description_select-row'), + [RightsCodes.updateRow]: i18n('description_update-row'), + [RightsCodes.eraseRow]: i18n('description_erase-row'), + [RightsCodes.writeAttributes]: i18n('description_write-attributes'), + [RightsCodes.createDirectory]: i18n('description_create-directory'), + [RightsCodes.createTable]: i18n('description_create-table'), + [RightsCodes.createQueue]: i18n('description_create-queue'), + [RightsCodes.removeSchema]: i18n('description_remove-schema'), + [RightsCodes.alterSchema]: i18n('description_alter-schema'), + [RightsCodes.createDatabase]: i18n('description_create-database'), + [RightsCodes.dropDatabase]: i18n('description_drop-database'), + [RightsCodes.readAttributes]: i18n('description_read-attributes'), + [RightsCodes.describeSchema]: i18n('description_describe-schema'), + [RightsCodes.connectDatabase]: i18n('description_connect-database'), + [RightsCodes.grantAccessRights]: i18n('description_grant-access-rights'), + [RightsCodes.genericRead]: i18n('description_generic-read'), + [RightsCodes.genericWrite]: i18n('description_generic-write'), + [RightsCodes.genericManage]: i18n('description_generic-manage'), + [RightsCodes.genericList]: i18n('description_generic-list'), + [RightsCodes.genericUse]: i18n('description_generic-use'), + [RightsCodes.genericUseLegacy]: i18n('description_generic-use-legacy'), + [RightsCodes.genericFull]: i18n('description_generic-full'), + [RightsCodes.genericFullLegacy]: i18n('description_generic-full-legacy'), }; export function isLegacyRight(right: number) { - return ( - right === HumanReadableRights.genericFullLegacy || - right === HumanReadableRights.genericUseLegacy - ); + return right === RightsCodes.genericFullLegacy || right === RightsCodes.genericUseLegacy; } export interface CommonRightsProps {