mirror of https://github.com/grafana/grafana
LibraryPanels: Separates name from panel title (#38707)
* LibraryPanels: Separates name from panel title * WIP * Chore: fixes update for duplicate lib panels * Chore: reverts implementation * Chore: show library options only for library panels * Chore: ui fixes after PR comments * Chore: fixes issue when creating library panelspull/38785/head
parent
6cfb640a0b
commit
55e20bbf04
@ -0,0 +1,48 @@ |
|||||||
|
import { Input } from '@grafana/ui'; |
||||||
|
import React from 'react'; |
||||||
|
import { OptionsPaneItemDescriptor } from './OptionsPaneItemDescriptor'; |
||||||
|
import { OptionsPaneCategoryDescriptor } from './OptionsPaneCategoryDescriptor'; |
||||||
|
import { OptionPaneRenderProps } from './types'; |
||||||
|
import { isPanelModelLibraryPanel } from '../../../library-panels/guard'; |
||||||
|
import { LibraryPanelInformation } from 'app/features/library-panels/components/LibraryPanelInfo/LibraryPanelInfo'; |
||||||
|
|
||||||
|
export function getLibraryPanelOptionsCategory(props: OptionPaneRenderProps): OptionsPaneCategoryDescriptor { |
||||||
|
const { panel, onPanelConfigChange, dashboard } = props; |
||||||
|
const descriptor = new OptionsPaneCategoryDescriptor({ |
||||||
|
title: 'Library panel options', |
||||||
|
id: 'Library panel options', |
||||||
|
isOpenDefault: true, |
||||||
|
}); |
||||||
|
|
||||||
|
if (isPanelModelLibraryPanel(panel)) { |
||||||
|
descriptor |
||||||
|
.addItem( |
||||||
|
new OptionsPaneItemDescriptor({ |
||||||
|
title: 'Name', |
||||||
|
value: panel.libraryPanel.name, |
||||||
|
popularRank: 1, |
||||||
|
render: function renderName() { |
||||||
|
return ( |
||||||
|
<Input |
||||||
|
id="LibraryPanelFrameName" |
||||||
|
defaultValue={panel.libraryPanel.name} |
||||||
|
onBlur={(e) => |
||||||
|
onPanelConfigChange('libraryPanel', { ...panel.libraryPanel, name: e.currentTarget.value }) |
||||||
|
} |
||||||
|
/> |
||||||
|
); |
||||||
|
}, |
||||||
|
}) |
||||||
|
) |
||||||
|
.addItem( |
||||||
|
new OptionsPaneItemDescriptor({ |
||||||
|
title: 'Information', |
||||||
|
render: function renderLibraryPanelInformation() { |
||||||
|
return <LibraryPanelInformation panel={panel} formatDate={dashboard.formatDate} />; |
||||||
|
}, |
||||||
|
}) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return descriptor; |
||||||
|
} |
Loading…
Reference in new issue