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