mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 18:13:09 +08:00
Dashboards: Add toggle for folder names in dashboard list panel (#87288)
* refactor: add switch * refactor: add functionality * refactor: fix test
This commit is contained in:
@ -20,6 +20,7 @@ export interface Options {
|
|||||||
keepTime: boolean;
|
keepTime: boolean;
|
||||||
maxItems: number;
|
maxItems: number;
|
||||||
query: string;
|
query: string;
|
||||||
|
showFolderNames: boolean;
|
||||||
showHeadings: boolean;
|
showHeadings: boolean;
|
||||||
showRecentlyViewed: boolean;
|
showRecentlyViewed: boolean;
|
||||||
showSearch: boolean;
|
showSearch: boolean;
|
||||||
@ -32,6 +33,7 @@ export const defaultOptions: Partial<Options> = {
|
|||||||
keepTime: false,
|
keepTime: false,
|
||||||
maxItems: 10,
|
maxItems: 10,
|
||||||
query: '',
|
query: '',
|
||||||
|
showFolderNames: true,
|
||||||
showHeadings: true,
|
showHeadings: true,
|
||||||
showRecentlyViewed: false,
|
showRecentlyViewed: false,
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
|
@ -150,7 +150,7 @@ export function DashList(props: PanelProps<Options>) {
|
|||||||
];
|
];
|
||||||
}, [dashboards]);
|
}, [dashboards]);
|
||||||
|
|
||||||
const { showStarred, showRecentlyViewed, showHeadings, showSearch } = props.options;
|
const { showStarred, showRecentlyViewed, showHeadings, showFolderNames, showSearch } = props.options;
|
||||||
|
|
||||||
const dashboardGroups: DashboardGroup[] = [
|
const dashboardGroups: DashboardGroup[] = [
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ export function DashList(props: PanelProps<Options>) {
|
|||||||
<a className={css.dashlistTitle} href={url}>
|
<a className={css.dashlistTitle} href={url}>
|
||||||
{dash.title}
|
{dash.title}
|
||||||
</a>
|
</a>
|
||||||
{dash.folderTitle && <div className={css.dashlistFolder}>{dash.folderTitle}</div>}
|
{showFolderNames && dash.folderTitle && <div className={css.dashlistFolder}>{dash.folderTitle}</div>}
|
||||||
</div>
|
</div>
|
||||||
<IconButton
|
<IconButton
|
||||||
tooltip={dash.isStarred ? `Unmark "${dash.title}" as favorite` : `Mark "${dash.title}" as favorite`}
|
tooltip={dash.isStarred ? `Unmark "${dash.title}" as favorite` : `Mark "${dash.title}" as favorite`}
|
||||||
|
@ -56,6 +56,7 @@ describe('dashlist migrations', () => {
|
|||||||
showRecentlyViewed: true,
|
showRecentlyViewed: true,
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
showHeadings: true,
|
showHeadings: true,
|
||||||
|
showFolderNames: true,
|
||||||
maxItems: 7,
|
maxItems: 7,
|
||||||
query: 'hello, query',
|
query: 'hello, query',
|
||||||
includeVars: false,
|
includeVars: false,
|
||||||
@ -103,6 +104,7 @@ describe('dashlist migrations', () => {
|
|||||||
showRecentlyViewed: true,
|
showRecentlyViewed: true,
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
showHeadings: true,
|
showHeadings: true,
|
||||||
|
showFolderNames: true,
|
||||||
maxItems: 7,
|
maxItems: 7,
|
||||||
query: 'hello, query',
|
query: 'hello, query',
|
||||||
includeVars: false,
|
includeVars: false,
|
||||||
|
@ -42,6 +42,11 @@ export const plugin = new PanelPlugin<Options>(DashList)
|
|||||||
name: 'Show headings',
|
name: 'Show headings',
|
||||||
defaultValue: defaultOptions.showHeadings,
|
defaultValue: defaultOptions.showHeadings,
|
||||||
})
|
})
|
||||||
|
.addBooleanSwitch({
|
||||||
|
path: 'showFolderNames',
|
||||||
|
name: 'Show folder names',
|
||||||
|
defaultValue: defaultOptions.showFolderNames,
|
||||||
|
})
|
||||||
.addNumberInput({
|
.addNumberInput({
|
||||||
path: 'maxItems',
|
path: 'maxItems',
|
||||||
name: 'Max items',
|
name: 'Max items',
|
||||||
|
@ -28,6 +28,7 @@ composableKinds: PanelCfg: {
|
|||||||
showRecentlyViewed: bool | *false
|
showRecentlyViewed: bool | *false
|
||||||
showSearch: bool | *false
|
showSearch: bool | *false
|
||||||
showHeadings: bool | *true
|
showHeadings: bool | *true
|
||||||
|
showFolderNames: bool | *true
|
||||||
maxItems: int | *10
|
maxItems: int | *10
|
||||||
query: string | *""
|
query: string | *""
|
||||||
tags: [...string] | *[]
|
tags: [...string] | *[]
|
||||||
|
@ -18,6 +18,7 @@ export interface Options {
|
|||||||
keepTime: boolean;
|
keepTime: boolean;
|
||||||
maxItems: number;
|
maxItems: number;
|
||||||
query: string;
|
query: string;
|
||||||
|
showFolderNames: boolean;
|
||||||
showHeadings: boolean;
|
showHeadings: boolean;
|
||||||
showRecentlyViewed: boolean;
|
showRecentlyViewed: boolean;
|
||||||
showSearch: boolean;
|
showSearch: boolean;
|
||||||
@ -30,6 +31,7 @@ export const defaultOptions: Partial<Options> = {
|
|||||||
keepTime: false,
|
keepTime: false,
|
||||||
maxItems: 10,
|
maxItems: 10,
|
||||||
query: '',
|
query: '',
|
||||||
|
showFolderNames: true,
|
||||||
showHeadings: true,
|
showHeadings: true,
|
||||||
showRecentlyViewed: false,
|
showRecentlyViewed: false,
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
|
Reference in New Issue
Block a user