mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LibraryPanels: Add search input back to add panel widget (#32719)
This commit is contained in:
parent
0f7d8ae6d2
commit
71e8a03c46
@ -10,6 +10,7 @@ import { GrafanaTheme } from '@grafana/data';
|
|||||||
|
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
|
import { FilterInput } from 'app/core/components/FilterInput/FilterInput';
|
||||||
import { addPanel } from 'app/features/dashboard/state/reducers';
|
import { addPanel } from 'app/features/dashboard/state/reducers';
|
||||||
import { DashboardModel, PanelModel } from '../../state';
|
import { DashboardModel, PanelModel } from '../../state';
|
||||||
import { LibraryPanelsView } from '../../../library-panels/components/LibraryPanelsView/LibraryPanelsView';
|
import { LibraryPanelsView } from '../../../library-panels/components/LibraryPanelsView/LibraryPanelsView';
|
||||||
@ -55,6 +56,7 @@ const getCopiedPanelPlugins = () => {
|
|||||||
|
|
||||||
export const AddPanelWidgetUnconnected: React.FC<Props> = ({ panel, dashboard }) => {
|
export const AddPanelWidgetUnconnected: React.FC<Props> = ({ panel, dashboard }) => {
|
||||||
const [addPanelView, setAddPanelView] = useState(false);
|
const [addPanelView, setAddPanelView] = useState(false);
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
|
|
||||||
const onCancelAddPanel = (evt: React.MouseEvent<HTMLButtonElement>) => {
|
const onCancelAddPanel = (evt: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
@ -138,12 +140,17 @@ export const AddPanelWidgetUnconnected: React.FC<Props> = ({ panel, dashboard })
|
|||||||
{addPanelView ? 'Add panel from panel library' : 'Add panel'}
|
{addPanelView ? 'Add panel from panel library' : 'Add panel'}
|
||||||
</AddPanelWidgetHandle>
|
</AddPanelWidgetHandle>
|
||||||
{addPanelView ? (
|
{addPanelView ? (
|
||||||
<LibraryPanelsView
|
<>
|
||||||
className={styles.libraryPanelsWrapper}
|
<div className={styles.panelSearchInput}>
|
||||||
onClickCard={(panel) => onAddLibraryPanel(panel)}
|
<FilterInput width={0} value={searchQuery} onChange={setSearchQuery} placeholder={'Search global panels'} />
|
||||||
showSecondaryActions={false}
|
</div>
|
||||||
searchString={''}
|
<LibraryPanelsView
|
||||||
/>
|
className={styles.libraryPanelsWrapper}
|
||||||
|
onClickCard={(panel) => onAddLibraryPanel(panel)}
|
||||||
|
showSecondaryActions={false}
|
||||||
|
searchString={searchQuery}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.actionsWrapper}>
|
<div className={styles.actionsWrapper}>
|
||||||
<div className={styles.actionsRow}>
|
<div className={styles.actionsRow}>
|
||||||
@ -219,6 +226,10 @@ const getStyles = (theme: GrafanaTheme) => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
panelSearchInput: css`
|
||||||
|
padding-left: ${theme.spacing.sm};
|
||||||
|
padding-right: ${theme.spacing.sm};
|
||||||
|
`,
|
||||||
wrapper: css`
|
wrapper: css`
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
outline: 2px dotted transparent;
|
outline: 2px dotted transparent;
|
||||||
|
@ -14,6 +14,7 @@ exports[`Render should render component 1`] = `
|
|||||||
"headerRow": "css-1ka09x",
|
"headerRow": "css-1ka09x",
|
||||||
"libraryPanelsWrapper": "css-18m13of",
|
"libraryPanelsWrapper": "css-18m13of",
|
||||||
"noMargin": "css-u023fv",
|
"noMargin": "css-u023fv",
|
||||||
|
"panelSearchInput": "css-2ug8g3",
|
||||||
"wrapper": "css-1sl7nld",
|
"wrapper": "css-1sl7nld",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user