mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 07:52:21 +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.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)
|
||||
|
@ -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 {
|
||||
|
@ -17364,6 +17364,9 @@
|
||||
"isEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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: '',
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -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}
|
||||
|
@ -20,6 +20,7 @@ export interface PublicDashboardListResponse {
|
||||
accessToken: string;
|
||||
dashboardUid: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
|
@ -8255,6 +8255,9 @@
|
||||
"isEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"slug": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
|
Reference in New Issue
Block a user