mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 08:47:12 -06:00
Scenes: Fix public dashboard email sharing section (#84467)
This commit is contained in:
parent
311aa94fab
commit
98a6b5debf
@ -124,7 +124,7 @@ export function ConfigPublicDashboardBase({
|
|||||||
<UnsupportedDataSourcesAlert unsupportedDataSources={unsupportedDatasources.join(', ')} />
|
<UnsupportedDataSourcesAlert unsupportedDataSources={unsupportedDatasources.join(', ')} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{hasEmailSharingEnabled && <EmailSharingConfiguration />}
|
{hasEmailSharingEnabled && <EmailSharingConfiguration dashboard={dashboard} />}
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
label={t('public-dashboard.config.dashboard-url-field-label', 'Dashboard URL')}
|
label={t('public-dashboard.config.dashboard-url-field-label', 'Dashboard URL')}
|
||||||
|
@ -15,8 +15,10 @@ import {
|
|||||||
useReshareAccessToRecipientMutation,
|
useReshareAccessToRecipientMutation,
|
||||||
useUpdatePublicDashboardMutation,
|
useUpdatePublicDashboardMutation,
|
||||||
} from 'app/features/dashboard/api/publicDashboardApi';
|
} from 'app/features/dashboard/api/publicDashboardApi';
|
||||||
|
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||||
|
import { DashboardScene } from 'app/features/dashboard-scene/scene/DashboardScene';
|
||||||
import { DashboardInteractions } from 'app/features/dashboard-scene/utils/interactions';
|
import { DashboardInteractions } from 'app/features/dashboard-scene/utils/interactions';
|
||||||
import { AccessControlAction, useSelector } from 'app/types';
|
import { AccessControlAction } from 'app/types';
|
||||||
|
|
||||||
import { PublicDashboard, PublicDashboardShareType, validEmailRegex } from '../SharePublicDashboardUtils';
|
import { PublicDashboard, PublicDashboardShareType, validEmailRegex } from '../SharePublicDashboardUtils';
|
||||||
|
|
||||||
@ -93,13 +95,12 @@ const EmailList = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EmailSharingConfiguration = () => {
|
export const EmailSharingConfiguration = ({ dashboard }: { dashboard: DashboardModel | DashboardScene }) => {
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const dashboardState = useSelector((store) => store.dashboard);
|
|
||||||
const dashboard = dashboardState.getModel()!;
|
|
||||||
|
|
||||||
const { data: publicDashboard } = useGetPublicDashboardQuery(dashboard.uid);
|
const dashboardUid = dashboard instanceof DashboardScene ? dashboard.state.uid : dashboard.uid;
|
||||||
|
const { data: publicDashboard } = useGetPublicDashboardQuery(dashboardUid);
|
||||||
const [updateShareType] = useUpdatePublicDashboardMutation();
|
const [updateShareType] = useUpdatePublicDashboardMutation();
|
||||||
const [addEmail, { isLoading: isAddEmailLoading }] = useAddRecipientMutation();
|
const [addEmail, { isLoading: isAddEmailLoading }] = useAddRecipientMutation();
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ export const EmailSharingConfiguration = () => {
|
|||||||
|
|
||||||
const onSubmit = async (data: EmailSharingConfigurationForm) => {
|
const onSubmit = async (data: EmailSharingConfigurationForm) => {
|
||||||
DashboardInteractions.publicDashboardEmailInviteClicked();
|
DashboardInteractions.publicDashboardEmailInviteClicked();
|
||||||
await addEmail({ recipient: data.email, uid: publicDashboard!.uid, dashboardUid: dashboard.uid }).unwrap();
|
await addEmail({ recipient: data.email, uid: publicDashboard!.uid, dashboardUid }).unwrap();
|
||||||
reset({ email: '', shareType: PublicDashboardShareType.EMAIL });
|
reset({ email: '', shareType: PublicDashboardShareType.EMAIL });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -215,7 +216,7 @@ export const EmailSharingConfiguration = () => {
|
|||||||
{!!publicDashboard?.recipients?.length && (
|
{!!publicDashboard?.recipients?.length && (
|
||||||
<EmailList
|
<EmailList
|
||||||
recipients={publicDashboard.recipients}
|
recipients={publicDashboard.recipients}
|
||||||
dashboardUid={dashboard.uid}
|
dashboardUid={dashboardUid}
|
||||||
publicDashboardUid={publicDashboard.uid}
|
publicDashboardUid={publicDashboard.uid}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user