PublicDashboards: Email sharing users page (#67124)

This commit is contained in:
Juan Cabanas
2023-04-27 14:20:03 -03:00
committed by GitHub
parent 35407142d0
commit fc3737bf4f
15 changed files with 553 additions and 30 deletions

View File

@@ -120,7 +120,7 @@ const ConfigPublicDashboard = () => {
{hasEmailSharingEnabled && <EmailSharingConfiguration />}
<Field label="Dashboard URL" className={styles.publicUrl}>
<Input
value={generatePublicDashboardUrl(publicDashboard!)}
value={generatePublicDashboardUrl(publicDashboard!.accessToken!)}
readOnly
disabled={!publicDashboard?.isEnabled}
data-testid={selectors.CopyUrlInput}
@@ -129,7 +129,7 @@ const ConfigPublicDashboard = () => {
data-testid={selectors.CopyUrlButton}
variant="primary"
disabled={!publicDashboard?.isEnabled}
getText={() => generatePublicDashboardUrl(publicDashboard!)}
getText={() => generatePublicDashboardUrl(publicDashboard!.accessToken!)}
>
Copy
</ClipboardButton>

View File

@@ -31,7 +31,7 @@ describe('generatePublicDashboardUrl', () => {
updateConfig({ appUrl });
let pubdash = { accessToken } as PublicDashboard;
expect(generatePublicDashboardUrl(pubdash)).toEqual(`${appUrl}public-dashboards/${accessToken}`);
expect(generatePublicDashboardUrl(pubdash.accessToken!)).toEqual(`${appUrl}public-dashboards/${accessToken}`);
});
});

View File

@@ -25,6 +25,18 @@ export interface PublicDashboard extends PublicDashboardSettings {
recipients?: Array<{ uid: string; recipient: string }>;
}
export interface SessionDashboard {
dashboardTitle: string;
dashboardUid: string;
publicDashboardAccessToken: string;
}
export interface SessionUser {
email: string;
firstSeenAtAge: string;
totalDashboards: number;
}
// Instance methods
export const dashboardHasTemplateVariables = (variables: VariableModel[]): boolean => {
return variables.length > 0;
@@ -58,10 +70,10 @@ export const getUnsupportedDashboardDatasources = (panels: PanelModel[]): string
*
* All app urls from the Grafana boot config end with a slash.
*
* @param publicDashboard
* @param accessToken
*/
export const generatePublicDashboardUrl = (publicDashboard: PublicDashboard): string => {
return `${getConfig().appUrl}public-dashboards/${publicDashboard.accessToken}`;
export const generatePublicDashboardUrl = (accessToken: string): string => {
return `${getConfig().appUrl}public-dashboards/${accessToken}`;
};
export const validEmailRegex = /^[A-Z\d._%+-]+@[A-Z\d.-]+\.[A-Z]{2,}$/i;