mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 02:26:19 +08:00
Task: Improve public dashboard config url formatting (#79424)
* Update publicdashboard config url * add slug to sessiondashboard * swagger doc update
This commit is contained in:
@ -55,7 +55,7 @@ func (d *PublicDashboardStoreImpl) FindAllWithPagination(ctx context.Context, qu
|
|||||||
}
|
}
|
||||||
|
|
||||||
pubdashBuilder := db.NewSqlBuilder(d.cfg, d.features, d.sqlStore.GetDialect(), recursiveQueriesAreSupported)
|
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(" FROM dashboard_public")
|
||||||
pubdashBuilder.Write(" JOIN dashboard ON dashboard.uid = dashboard_public.dashboard_uid AND dashboard.org_id = dashboard_public.org_id")
|
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)
|
pubdashBuilder.Write(` WHERE dashboard_public.org_id = ?`, query.OrgID)
|
||||||
|
@ -117,6 +117,7 @@ type PublicDashboardListResponse struct {
|
|||||||
Title string `json:"title" xorm:"title"`
|
Title string `json:"title" xorm:"title"`
|
||||||
DashboardUid string `json:"dashboardUid" xorm:"dashboard_uid"`
|
DashboardUid string `json:"dashboardUid" xorm:"dashboard_uid"`
|
||||||
IsEnabled bool `json:"isEnabled" xorm:"is_enabled"`
|
IsEnabled bool `json:"isEnabled" xorm:"is_enabled"`
|
||||||
|
Slug string `json:"slug" xorm:"slug"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeSettings struct {
|
type TimeSettings struct {
|
||||||
|
@ -17364,6 +17364,9 @@
|
|||||||
"isEnabled": {
|
"isEnabled": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -40,7 +40,7 @@ export const DashboardsListModal = ({ email, onDismiss }: { email: string; onDis
|
|||||||
<span className={styles.urlsDivider}>•</span>
|
<span className={styles.urlsDivider}>•</span>
|
||||||
<a
|
<a
|
||||||
className={cx('external-link', styles.url)}
|
className={cx('external-link', styles.url)}
|
||||||
href={generatePublicDashboardConfigUrl(dash.dashboardUid)}
|
href={generatePublicDashboardConfigUrl(dash.dashboardUid, dash.slug)}
|
||||||
onClick={onDismiss}
|
onClick={onDismiss}
|
||||||
>
|
>
|
||||||
Public dashboard settings
|
Public dashboard settings
|
||||||
|
@ -32,6 +32,7 @@ export interface SessionDashboard {
|
|||||||
dashboardTitle: string;
|
dashboardTitle: string;
|
||||||
dashboardUid: string;
|
dashboardUid: string;
|
||||||
publicDashboardAccessToken: string;
|
publicDashboardAccessToken: string;
|
||||||
|
slug: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SessionUser {
|
export interface SessionUser {
|
||||||
@ -87,8 +88,8 @@ export const generatePublicDashboardUrl = (accessToken: string): string => {
|
|||||||
return `${getConfig().appUrl}public-dashboards/${accessToken}`;
|
return `${getConfig().appUrl}public-dashboards/${accessToken}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generatePublicDashboardConfigUrl = (dashboardUid: string): string => {
|
export const generatePublicDashboardConfigUrl = (dashboardUid: string, dashboardName: string): string => {
|
||||||
return `/d/${dashboardUid}?shareView=${shareDashboardType.publicDashboard}`;
|
return `/d/${dashboardUid}/${dashboardName}?shareView=${shareDashboardType.publicDashboard}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const validEmailRegex = /^[A-Z\d._%+-]+@[A-Z\d.-]+\.[A-Z]{2,}$/i;
|
export const validEmailRegex = /^[A-Z\d._%+-]+@[A-Z\d.-]+\.[A-Z]{2,}$/i;
|
||||||
|
@ -22,6 +22,7 @@ const publicDashboardListResponse: PublicDashboardListResponse[] = [
|
|||||||
title: 'New dashboardasdf',
|
title: 'New dashboardasdf',
|
||||||
dashboardUid: 'iF36Qb6nz',
|
dashboardUid: 'iF36Qb6nz',
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
|
slug: 'new-dashboardasdf',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: 'EuiEbd3nz',
|
uid: 'EuiEbd3nz',
|
||||||
@ -29,6 +30,7 @@ const publicDashboardListResponse: PublicDashboardListResponse[] = [
|
|||||||
title: 'New dashboard',
|
title: 'New dashboard',
|
||||||
dashboardUid: 'kFlxbd37k',
|
dashboardUid: 'kFlxbd37k',
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
|
slug: 'new-dashboard',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -39,6 +41,7 @@ const orphanedDashboardListResponse: PublicDashboardListResponse[] = [
|
|||||||
title: '',
|
title: '',
|
||||||
dashboardUid: '',
|
dashboardUid: '',
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
|
slug: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: 'EuiEbd3nz2',
|
uid: 'EuiEbd3nz2',
|
||||||
@ -46,6 +49,7 @@ const orphanedDashboardListResponse: PublicDashboardListResponse[] = [
|
|||||||
title: '',
|
title: '',
|
||||||
dashboardUid: '',
|
dashboardUid: '',
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
|
slug: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ const PublicDashboardCard = ({ pd }: { pd: PublicDashboardListResponse }) => {
|
|||||||
icon="cog"
|
icon="cog"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
color={theme.colors.warning.text}
|
color={theme.colors.warning.text}
|
||||||
href={generatePublicDashboardConfigUrl(pd.dashboardUid)}
|
href={generatePublicDashboardConfigUrl(pd.dashboardUid, pd.slug)}
|
||||||
key="public-dashboard-config-url"
|
key="public-dashboard-config-url"
|
||||||
tooltip="Configure public dashboard"
|
tooltip="Configure public dashboard"
|
||||||
data-testid={selectors.ListItem.configButton}
|
data-testid={selectors.ListItem.configButton}
|
||||||
|
@ -20,6 +20,7 @@ export interface PublicDashboardListResponse {
|
|||||||
accessToken: string;
|
accessToken: string;
|
||||||
dashboardUid: string;
|
dashboardUid: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
slug: string;
|
||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8255,6 +8255,9 @@
|
|||||||
"isEnabled": {
|
"isEnabled": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"slug": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user