import {CircleXmark, Pencil} from '@gravity-ui/icons'; import {ActionTooltip, Button, Flex, Icon} from '@gravity-ui/uikit'; import {useEditAccessAvailable} from '../../../../../../store/reducers/capabilities/hooks'; import {useClusterWithProxy} from '../../../../../../store/reducers/cluster/cluster'; import {selectSubjectExplicitRights} from '../../../../../../store/reducers/schemaAcl/schemaAcl'; import {useAclSyntax, useTypedSelector} from '../../../../../../utils/hooks'; import {useCurrentSchema} from '../../../../TenantContext'; import {useTenantQueryParams} from '../../../../useTenantQueryParams'; import i18n from '../../i18n'; import {block} from '../../shared'; import {getRevokeAllRightsDialog} from './RevokeAllRightsDialog'; export function Actions() { return null; } interface ActionProps { subject: string; className?: string; } export function SubjectActions({subject, className}: ActionProps) { const editable = useEditAccessAvailable(); if (!editable) { return null; } return ( ); } function GrantRightsToSubject({subject}: ActionProps) { const {handleShowGrantAccessChange, handleAclSubjectChange} = useTenantQueryParams(); const handleClick = () => { handleShowGrantAccessChange(true); handleAclSubjectChange(subject); }; return ( ); } function RevokeAllRights({subject}: ActionProps) { const {path, database, databaseFullPath} = useCurrentSchema(); const useMetaProxy = useClusterWithProxy(); const dialect = useAclSyntax(); const subjectExplicitRights = useTypedSelector((state) => selectSubjectExplicitRights( state, subject, path, database, databaseFullPath, dialect, useMetaProxy, ), ); const noRightsToRevoke = subjectExplicitRights.length === 0; const handleClick = async () => { await getRevokeAllRightsDialog({path, database, databaseFullPath, subject}); }; return ( {/* this wrapper is needed to show tooltip if button is disabled */}
); }