mirror of
https://github.com/grafana/grafana.git
synced 2025-01-26 16:27:02 -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(', ')} />
|
||||
)}
|
||||
|
||||
{hasEmailSharingEnabled && <EmailSharingConfiguration />}
|
||||
{hasEmailSharingEnabled && <EmailSharingConfiguration dashboard={dashboard} />}
|
||||
|
||||
<Field
|
||||
label={t('public-dashboard.config.dashboard-url-field-label', 'Dashboard URL')}
|
||||
|
@ -15,8 +15,10 @@ import {
|
||||
useReshareAccessToRecipientMutation,
|
||||
useUpdatePublicDashboardMutation,
|
||||
} 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 { AccessControlAction, useSelector } from 'app/types';
|
||||
import { AccessControlAction } from 'app/types';
|
||||
|
||||
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 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 [addEmail, { isLoading: isAddEmailLoading }] = useAddRecipientMutation();
|
||||
|
||||
@ -135,7 +136,7 @@ export const EmailSharingConfiguration = () => {
|
||||
|
||||
const onSubmit = async (data: EmailSharingConfigurationForm) => {
|
||||
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 });
|
||||
};
|
||||
|
||||
@ -215,7 +216,7 @@ export const EmailSharingConfiguration = () => {
|
||||
{!!publicDashboard?.recipients?.length && (
|
||||
<EmailList
|
||||
recipients={publicDashboard.recipients}
|
||||
dashboardUid={dashboard.uid}
|
||||
dashboardUid={dashboardUid}
|
||||
publicDashboardUid={publicDashboard.uid}
|
||||
/>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user