ClusterTableActionsCell.tsx 946 B

1234567891011121314151617181920212223242526272829303132
  1. import React, { useMemo } from 'react';
  2. import { Cluster, ResourceType } from 'generated-sources';
  3. import { CellContext } from '@tanstack/react-table';
  4. import { clusterConfigPath } from 'lib/paths';
  5. import { useGetUserInfo } from 'lib/hooks/api/roles';
  6. import { ActionCanButton } from 'components/common/ActionComponent';
  7. type Props = CellContext<Cluster, unknown>;
  8. const ClusterTableActionsCell: React.FC<Props> = ({ row }) => {
  9. const { name } = row.original;
  10. const { data } = useGetUserInfo();
  11. const isApplicationConfig = useMemo(() => {
  12. return !!data?.userInfo?.permissions.some(
  13. (permission) => permission.resource === ResourceType.APPLICATIONCONFIG
  14. );
  15. }, [data]);
  16. return (
  17. <ActionCanButton
  18. buttonType="secondary"
  19. buttonSize="S"
  20. to={clusterConfigPath(name)}
  21. canDoAction={isApplicationConfig}
  22. >
  23. Configure
  24. </ActionCanButton>
  25. );
  26. };
  27. export default ClusterTableActionsCell;