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:
Laura Benz
2024-05-03 17:52:10 +02:00
committed by GitHub
parent 5b424ed6bb
commit ecd7357049
6 changed files with 14 additions and 2 deletions

View File

@ -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,

View File

@ -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`}

View File

@ -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,

View File

@ -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',

View File

@ -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] | *[]

View File

@ -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,