|
@@ -1,23 +1,25 @@
|
|
|
-import React, { useEffect } from 'react';
|
|
|
+import React, { useEffect, useMemo } from 'react';
|
|
|
import PageHeading from 'components/common/PageHeading/PageHeading';
|
|
|
import * as Metrics from 'components/common/Metrics';
|
|
|
import { Tag } from 'components/common/Tag/Tag.styled';
|
|
|
import Switch from 'components/common/Switch/Switch';
|
|
|
import { useClusters } from 'lib/hooks/api/clusters';
|
|
|
-import { Cluster, ServerStatus } from 'generated-sources';
|
|
|
+import { Cluster, ResourceType, ServerStatus } from 'generated-sources';
|
|
|
import { ColumnDef } from '@tanstack/react-table';
|
|
|
import Table, { SizeCell } from 'components/common/NewTable';
|
|
|
import useBoolean from 'lib/hooks/useBoolean';
|
|
|
-import { Button } from 'components/common/Button/Button';
|
|
|
import { clusterNewConfigPath } from 'lib/paths';
|
|
|
import { GlobalSettingsContext } from 'components/contexts/GlobalSettingsContext';
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
+import { ActionCanButton } from 'components/common/ActionComponent';
|
|
|
+import { useGetUserInfo } from 'lib/hooks/api/roles';
|
|
|
|
|
|
import * as S from './Dashboard.styled';
|
|
|
import ClusterName from './ClusterName';
|
|
|
import ClusterTableActionsCell from './ClusterTableActionsCell';
|
|
|
|
|
|
const Dashboard: React.FC = () => {
|
|
|
+ const { data } = useGetUserInfo();
|
|
|
const clusters = useClusters();
|
|
|
const { value: showOfflineOnly, toggle } = useBoolean(false);
|
|
|
const appInfo = React.useContext(GlobalSettingsContext);
|
|
@@ -62,6 +64,13 @@ const Dashboard: React.FC = () => {
|
|
|
}
|
|
|
}, [clusters, appInfo.hasDynamicConfig]);
|
|
|
|
|
|
+ const isApplicationConfig = useMemo(() => {
|
|
|
+ return (
|
|
|
+ data?.userInfo?.permissions.some(
|
|
|
+ (permission) => permission.resource === ResourceType.APPLICATIONCONFIG
|
|
|
+ ) || false
|
|
|
+ );
|
|
|
+ }, [data]);
|
|
|
return (
|
|
|
<>
|
|
|
<PageHeading text="Dashboard" />
|
|
@@ -87,9 +96,14 @@ const Dashboard: React.FC = () => {
|
|
|
<label>Only offline clusters</label>
|
|
|
</div>
|
|
|
{appInfo.hasDynamicConfig && (
|
|
|
- <Button buttonType="primary" buttonSize="M" to={clusterNewConfigPath}>
|
|
|
+ <ActionCanButton
|
|
|
+ buttonType="primary"
|
|
|
+ buttonSize="M"
|
|
|
+ to={clusterNewConfigPath}
|
|
|
+ canDoAction={isApplicationConfig}
|
|
|
+ >
|
|
|
Configure new cluster
|
|
|
- </Button>
|
|
|
+ </ActionCanButton>
|
|
|
)}
|
|
|
</S.Toolbar>
|
|
|
<Table
|