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