} onClick={onOpenAddContentModal} />
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx
index 3803f0e56..6aac2240a 100644
--- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx
+++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/FileContainerHeader.tsx
@@ -38,13 +38,16 @@ export const FileContainerHeader: React.FC = React.memo(() => {
[selectedFileType]
);
- const { data: hasAccess } = useAssetCheck(
+ const { data: hasAccessQuery } = useAssetCheck(
{ assetId: selectedFileId, fileType: selectedFileType },
(x) => x.has_access
);
+ const hasAccess = hasAccessQuery ?? true; // we assume access until it is revoked
if (isVersionHistoryMode) return ;
+ console.log(hasAccess, selectedFileView);
+
return (
<>
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricContainerHeaderButtons.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricContainerHeaderButtons.tsx
index 2489f9c88..821e6390e 100644
--- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricContainerHeaderButtons.tsx
+++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricContainerHeaderButtons.tsx
@@ -13,22 +13,30 @@ import { ShareMetricButton } from '../../../../../components/features/buttons/Sh
import { SquareChartPen, SquareCode } from '@/components/ui/icons';
import { useGetMetric } from '@/api/buster_rest/metrics';
import { ThreeDotMenuButton } from './MetricThreeDotMenu';
+import { canEdit, getIsEffectiveOwner } from '@/lib/share';
export const MetricContainerHeaderButtons: React.FC = React.memo(() => {
const selectedLayout = useChatLayoutContextSelector((x) => x.selectedLayout);
const selectedFileId = useChatIndividualContextSelector((x) => x.selectedFileId)!;
const metricId = selectedFileId;
- const { isFetched: isMetricFetched, error: metricError } = useGetMetric({ id: metricId });
+ const { error: metricError, data: permission } = useGetMetric(
+ { id: metricId },
+ (x) => x.permission
+ );
- if (!isMetricFetched || metricError) return null;
+ //we assume it is fetched until it is not
+ if (metricError) return null;
+
+ const isEditor = canEdit(permission);
+ const isEffectiveOwner = getIsEffectiveOwner(permission);
return (
-
-
+ {isEditor && }
+ {isEffectiveOwner && }
-
+ {isEffectiveOwner && }
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
index bf28ccfe3..2410831eb 100644
--- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
+++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
@@ -49,7 +49,6 @@ import { METRIC_CHART_TITLE_INPUT_ID } from '@/controllers/MetricController/Metr
import { ShareMenuContent } from '@/components/features/ShareMenu/ShareMenuContent';
import { canEdit, getIsEffectiveOwner, getIsOwner } from '@/lib/share';
import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers';
-import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
export const ThreeDotMenuButton = React.memo(({ metricId }: { metricId: string }) => {