) => {
- onChangeDescription(value.target.value);
+ if (!readOnly) onUpdateDashboard({ description: value.target.value, id: dashboardId });
}
);
@@ -31,7 +27,7 @@ export const DashboardEditTitles: React.FC<{
- {(description || allowEdit) && (
+ {(description || !readOnly) && (
= ({ dashboardId }) => {
+export const DashboardViewDashboardController: React.FC = ({
+ dashboardId,
+ readOnly = false
+}) => {
const isAnonymousUser = useUserConfigContextSelector((state) => state.isAnonymousUser);
const { data: dashboardResponse } = useGetDashboard(dashboardId);
const { mutateAsync: onUpdateDashboard } = useUpdateDashboard();
const { mutateAsync: onUpdateDashboardConfig } = useUpdateDashboardConfig();
const [openAddContentModal, setOpenAddContentModal] = useState(false);
- const allowEdit = dashboardResponse?.permission !== ShareRole.VIEWER && !isAnonymousUser;
+ const allowEdit =
+ !readOnly && dashboardResponse?.permission !== ShareRole.VIEWER && !isAnonymousUser;
const metrics = dashboardResponse?.metrics;
const dashboard = dashboardResponse?.dashboard;
@@ -33,7 +37,7 @@ export const DashboardViewDashboardController: React.FC = ({
@@ -43,6 +47,7 @@ export const DashboardViewDashboardController: React.FC = ({
dashboard={dashboard}
onUpdateDashboardConfig={onUpdateDashboardConfig}
onOpenAddContentModal={onOpenAddContentModal}
+ readOnly={readOnly}
/>
);
diff --git a/web/src/controllers/DashboardController/config.ts b/web/src/controllers/DashboardController/config.ts
index 4d7e8570a..43c321689 100644
--- a/web/src/controllers/DashboardController/config.ts
+++ b/web/src/controllers/DashboardController/config.ts
@@ -5,6 +5,7 @@ import React from 'react';
export interface DashboardViewProps {
dashboardId: string;
+ readOnly?: boolean;
}
export const DashboardViewComponents: Record> = {