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;
|
onClickCard?: (panel: LibraryPanelDTO) => void;
|
||||||
formatDate?: (dateString: DateTimeInput, format?: string) => string;
|
formatDate?: (dateString: DateTimeInput, format?: string) => string;
|
||||||
showSecondaryActions?: boolean;
|
showSecondaryActions?: boolean;
|
||||||
|
currentPanelId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
||||||
@@ -22,6 +23,7 @@ export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
|||||||
onClickCard,
|
onClickCard,
|
||||||
formatDate,
|
formatDate,
|
||||||
showSecondaryActions,
|
showSecondaryActions,
|
||||||
|
currentPanelId: currentPanel,
|
||||||
}) => {
|
}) => {
|
||||||
const styles = useStyles(getPanelViewStyles);
|
const styles = useStyles(getPanelViewStyles);
|
||||||
const [searchString, setSearchString] = useState('');
|
const [searchString, setSearchString] = useState('');
|
||||||
@@ -38,10 +40,14 @@ export const LibraryPanelsView: React.FC<LibraryPanelViewProps> = ({
|
|||||||
const [filteredItems, setFilteredItems] = useState(libraryPanels);
|
const [filteredItems, setFilteredItems] = useState(libraryPanels);
|
||||||
useDebounce(
|
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,
|
300,
|
||||||
[searchString, libraryPanels]
|
[searchString, libraryPanels, currentPanel]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onDeletePanel = async (uid: string) => {
|
const onDeletePanel = async (uid: string) => {
|
||||||
|
@@ -59,6 +59,7 @@ export const PanelLibraryOptionsGroup: React.FC<Props> = ({ panel, dashboard })
|
|||||||
>
|
>
|
||||||
<LibraryPanelsView
|
<LibraryPanelsView
|
||||||
formatDate={(dateString: string) => dashboard.formatDate(dateString, 'L')}
|
formatDate={(dateString: string) => dashboard.formatDate(dateString, 'L')}
|
||||||
|
currentPanelId={panel.libraryPanel?.uid}
|
||||||
showSecondaryActions
|
showSecondaryActions
|
||||||
>
|
>
|
||||||
{(panel) => (
|
{(panel) => (
|
||||||
|
Reference in New Issue
Block a user