Task: Improve public dashboard config url formatting (#79424)

* Update publicdashboard config url

* add slug to sessiondashboard

* swagger doc update
This commit is contained in:
Lucy Chen
2023-12-14 14:35:17 -05:00
committed by GitHub
parent 8a650e535b
commit a29e1ee6a6
9 changed files with 18 additions and 5 deletions

View File

@ -55,7 +55,7 @@ func (d *PublicDashboardStoreImpl) FindAllWithPagination(ctx context.Context, qu
}
pubdashBuilder := db.NewSqlBuilder(d.cfg, d.features, d.sqlStore.GetDialect(), recursiveQueriesAreSupported)
pubdashBuilder.Write("SELECT dashboard_public.uid, dashboard_public.access_token, dashboard.uid as dashboard_uid, dashboard_public.is_enabled, dashboard.title")
pubdashBuilder.Write("SELECT dashboard_public.uid, dashboard_public.access_token, dashboard.uid as dashboard_uid, dashboard_public.is_enabled, dashboard.title, dashboard.slug")
pubdashBuilder.Write(" FROM dashboard_public")
pubdashBuilder.Write(" JOIN dashboard ON dashboard.uid = dashboard_public.dashboard_uid AND dashboard.org_id = dashboard_public.org_id")
pubdashBuilder.Write(` WHERE dashboard_public.org_id = ?`, query.OrgID)

View File

@ -117,6 +117,7 @@ type PublicDashboardListResponse struct {
Title string `json:"title" xorm:"title"`
DashboardUid string `json:"dashboardUid" xorm:"dashboard_uid"`
IsEnabled bool `json:"isEnabled" xorm:"is_enabled"`
Slug string `json:"slug" xorm:"slug"`
}
type TimeSettings struct {

View File

@ -17364,6 +17364,9 @@
"isEnabled": {
"type": "boolean"
},
"slug": {
"type": "string"
},
"title": {
"type": "string"
},

View File

@ -40,7 +40,7 @@ export const DashboardsListModal = ({ email, onDismiss }: { email: string; onDis
<span className={styles.urlsDivider}></span>
<a
className={cx('external-link', styles.url)}
href={generatePublicDashboardConfigUrl(dash.dashboardUid)}
href={generatePublicDashboardConfigUrl(dash.dashboardUid, dash.slug)}
onClick={onDismiss}
>
Public dashboard settings

View File

@ -32,6 +32,7 @@ export interface SessionDashboard {
dashboardTitle: string;
dashboardUid: string;
publicDashboardAccessToken: string;
slug: string;
}
export interface SessionUser {
@ -87,8 +88,8 @@ export const generatePublicDashboardUrl = (accessToken: string): string => {
return `${getConfig().appUrl}public-dashboards/${accessToken}`;
};
export const generatePublicDashboardConfigUrl = (dashboardUid: string): string => {
return `/d/${dashboardUid}?shareView=${shareDashboardType.publicDashboard}`;
export const generatePublicDashboardConfigUrl = (dashboardUid: string, dashboardName: string): string => {
return `/d/${dashboardUid}/${dashboardName}?shareView=${shareDashboardType.publicDashboard}`;
};
export const validEmailRegex = /^[A-Z\d._%+-]+@[A-Z\d.-]+\.[A-Z]{2,}$/i;

View File

@ -22,6 +22,7 @@ const publicDashboardListResponse: PublicDashboardListResponse[] = [
title: 'New dashboardasdf',
dashboardUid: 'iF36Qb6nz',
isEnabled: false,
slug: 'new-dashboardasdf',
},
{
uid: 'EuiEbd3nz',
@ -29,6 +30,7 @@ const publicDashboardListResponse: PublicDashboardListResponse[] = [
title: 'New dashboard',
dashboardUid: 'kFlxbd37k',
isEnabled: true,
slug: 'new-dashboard',
},
];
@ -39,6 +41,7 @@ const orphanedDashboardListResponse: PublicDashboardListResponse[] = [
title: '',
dashboardUid: '',
isEnabled: false,
slug: '',
},
{
uid: 'EuiEbd3nz2',
@ -46,6 +49,7 @@ const orphanedDashboardListResponse: PublicDashboardListResponse[] = [
title: '',
dashboardUid: '',
isEnabled: true,
slug: '',
},
];

View File

@ -106,7 +106,7 @@ const PublicDashboardCard = ({ pd }: { pd: PublicDashboardListResponse }) => {
icon="cog"
variant="secondary"
color={theme.colors.warning.text}
href={generatePublicDashboardConfigUrl(pd.dashboardUid)}
href={generatePublicDashboardConfigUrl(pd.dashboardUid, pd.slug)}
key="public-dashboard-config-url"
tooltip="Configure public dashboard"
data-testid={selectors.ListItem.configButton}

View File

@ -20,6 +20,7 @@ export interface PublicDashboardListResponse {
accessToken: string;
dashboardUid: string;
title: string;
slug: string;
isEnabled: boolean;
}

View File

@ -8255,6 +8255,9 @@
"isEnabled": {
"type": "boolean"
},
"slug": {
"type": "string"
},
"title": {
"type": "string"
},