From ba2d8cd8382ac7025735aa4d2bbd61568b95af00 Mon Sep 17 00:00:00 2001 From: Ezequiel Victorero Date: Wed, 6 Jul 2022 18:21:00 -0300 Subject: [PATCH] Public Dashboards: disable saving button instead of hide before accepting checkboxes (#51744) --- .../ShareModal/SharePublicDashboard.tsx | 225 +++++++++--------- 1 file changed, 112 insertions(+), 113 deletions(-) diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx index e9c962b91f4..6c42a952944 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard.tsx @@ -2,18 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { AppEvents } from '@grafana/data'; import { reportInteraction } from '@grafana/runtime/src'; -import { - Alert, - Button, - Checkbox, - ClipboardButton, - Field, - FieldSet, - Icon, - Input, - LinkButton, - Switch, -} from '@grafana/ui'; +import { Alert, Button, Checkbox, ClipboardButton, Field, FieldSet, Input, LinkButton, Switch } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { createErrorNotification } from 'app/core/copy/appNotification'; import { appEvents } from 'app/core/core'; @@ -56,6 +45,16 @@ export const SharePublicDashboard = (props: Props) => { getPublicDashboardConfig(props.dashboard.uid, setPublicDashboardConfig).catch(); }, [props.dashboard.uid]); + useEffect(() => { + if (publicDashboardPersisted(publicDashboard)) { + setAcknowledgements({ + public: true, + datasources: true, + usage: true, + }); + } + }, [publicDashboard]); + const onSavePublicConfig = () => { reportInteraction('grafana_dashboards_public_create_clicked'); @@ -108,119 +107,119 @@ export const SharePublicDashboard = (props: Props) => { github discussion
- {!publicDashboardPersisted(publicDashboard) && ( -
- Before you click Save, please acknowledge the following information:
-
-
-
- onAcknowledge('public', e.currentTarget.checked)} - /> -
-
-
- onAcknowledge('datasources', e.currentTarget.checked)} - /> - -
-
+
+ Before you click Save, please acknowledge the following information:
+
+
+
onAcknowledge('usage', e.currentTarget.checked)} + label="Your entire dashboard will be public" + value={acknowledgements.public} + disabled={publicDashboardPersisted(publicDashboard)} + onChange={(e) => onAcknowledge('public', e.currentTarget.checked)} + /> +
+
+
+ onAcknowledge('datasources', e.currentTarget.checked)} /> -
-
-
-
- )} - {(publicDashboardPersisted(publicDashboard) || acknowledged()) && ( -
-

Public Dashboard Configuration

-
- Time Range -
-
- - From: - - } - /> - To: - } - /> -
-
- - { - reportInteraction('grafana_dashboards_public_enable_clicked', { - action: publicDashboard?.isEnabled ? 'disable' : 'enable', - }); +
+
+ onAcknowledge('usage', e.currentTarget.checked)} + /> + +
+
+
+
+
+

Public Dashboard Configuration

+
+ Time Range +
+
+ From: + } + /> + To: + } + /> +
+
+ + { + reportInteraction('grafana_dashboards_public_enable_clicked', { + action: publicDashboard?.isEnabled ? 'disable' : 'enable', + }); - setPublicDashboardConfig({ - ...publicDashboard, - isEnabled: !publicDashboard.isEnabled, - }); - }} + setPublicDashboardConfig({ + ...publicDashboard, + isEnabled: !publicDashboard.isEnabled, + }); + }} + /> + + {publicDashboardPersisted(publicDashboard) && publicDashboard.isEnabled && ( + + { + return generatePublicDashboardUrl(publicDashboard); + }} + onClipboardCopy={onShareUrlCopy} + > + Copy + + } /> - {publicDashboardPersisted(publicDashboard) && publicDashboard.isEnabled && ( - - { - return generatePublicDashboardUrl(publicDashboard); - }} - onClipboardCopy={onShareUrlCopy} - > - Copy - - } - /> - - )} -
- -
- )} + )} + + + )}