mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Library Panels: Don't list current panel in available panels list (#31472)
This commit is contained in:
@@ -13,6 +13,7 @@ interface LibraryPanelViewProps {
|
||||
onClickCard?: (panel: LibraryPanelDTO) => void;
|
||||
formatDate?: (dateString: DateTimeInput, format?: string) => string;
|
||||
showSecondaryActions?: boolean;
|
||||
currentPanelId?: string;
|
||||
}
|
||||
|
||||
export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
||||
@@ -22,6 +23,7 @@ export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
||||
onClickCard,
|
||||
formatDate,
|
||||
showSecondaryActions,
|
||||
currentPanelId: currentPanel,
|
||||
}) => {
|
||||
const styles = useStyles(getPanelViewStyles);
|
||||
const [searchString, setSearchString] = useState('');
|
||||
@@ -38,10 +40,14 @@ export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
||||
const [filteredItems, setFilteredItems] = useState(libraryPanels);
|
||||
useDebounce(
|
||||
() => {
|
||||
setFilteredItems(libraryPanels?.filter((v) => v.name.toLowerCase().includes(searchString.toLowerCase())));
|
||||
setFilteredItems(
|
||||
libraryPanels?.filter(
|
||||
(v) => v.name.toLowerCase().includes(searchString.toLowerCase()) && v.uid !== currentPanel
|
||||
)
|
||||
);
|
||||
},
|
||||
300,
|
||||
[searchString, libraryPanels]
|
||||
[searchString, libraryPanels, currentPanel]
|
||||
);
|
||||
|
||||
const onDeletePanel = async (uid: string) => {
|
||||
|
@@ -59,6 +59,7 @@ export const PanelLibraryOptionsGroup: React.FC<Props> = ({ panel, dashboard })
|
||||
>
|
||||
<LibraryPanelsView
|
||||
formatDate={(dateString: string) => dashboard.formatDate(dateString, 'L')}
|
||||
currentPanelId={panel.libraryPanel?.uid}
|
||||
showSecondaryActions
|
||||
>
|
||||
{(panel) => (
|
||||
|
Reference in New Issue
Block a user