mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Library Panels: Use UIDs to list Dashboards using a panel (#53477)
This commit is contained in:
parent
e3c50f0cd6
commit
742686bab1
@ -2,7 +2,7 @@ import { createAction } from '@reduxjs/toolkit';
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
import { LoadingState } from '@grafana/data';
|
||||
import { DashboardSearchHit } from 'app/features/search/types';
|
||||
import { DashboardSearchItem } from 'app/features/search/types';
|
||||
|
||||
export interface DeleteLibraryPanelModalState {
|
||||
loadingState: LoadingState;
|
||||
@ -14,7 +14,7 @@ export const initialDeleteLibraryPanelModalState: DeleteLibraryPanelModalState =
|
||||
dashboardTitles: [],
|
||||
};
|
||||
|
||||
export const searchCompleted = createAction<{ dashboards: DashboardSearchHit[] }>(
|
||||
export const searchCompleted = createAction<{ dashboards: DashboardSearchItem[] }>(
|
||||
'libraryPanels/delete/searchCompleted'
|
||||
);
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { GrafanaTheme2, SelectableValue, urlUtil } from '@grafana/data';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { AsyncSelect, Button, Modal, useStyles2 } from '@grafana/ui';
|
||||
|
||||
import { DashboardSearchHit } from '../../../search/types';
|
||||
import { DashboardSearchItem } from '../../../search/types';
|
||||
import { getConnectedDashboards, getLibraryPanelConnectedDashboards } from '../../state/api';
|
||||
import { LibraryElementDTO } from '../../types';
|
||||
|
||||
@ -19,7 +19,7 @@ export function OpenLibraryPanelModal({ libraryPanel, onDismiss }: OpenLibraryPa
|
||||
const styles = useStyles2(getStyles);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [connected, setConnected] = useState(0);
|
||||
const [option, setOption] = useState<SelectableValue<DashboardSearchHit> | undefined>(undefined);
|
||||
const [option, setOption] = useState<SelectableValue<DashboardSearchItem> | undefined>(undefined);
|
||||
useEffect(() => {
|
||||
const getConnected = async () => {
|
||||
const connectedDashboards = await getLibraryPanelConnectedDashboards(libraryPanel.uid);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { getBackendSrv } from '../../../core/services/backend_srv';
|
||||
import { DashboardSearchHit } from '../../search/types';
|
||||
import { DashboardSearchItem } from '../../search/types';
|
||||
import {
|
||||
LibraryElementConnectionDTO,
|
||||
LibraryElementDTO,
|
||||
@ -101,12 +101,13 @@ export async function getLibraryPanelConnectedDashboards(
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getConnectedDashboards(uid: string): Promise<DashboardSearchHit[]> {
|
||||
export async function getConnectedDashboards(uid: string): Promise<DashboardSearchItem[]> {
|
||||
const connections = await getLibraryPanelConnectedDashboards(uid);
|
||||
if (connections.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const searchHits = await getBackendSrv().search({ dashboardIds: connections.map((c) => c.connectionId) });
|
||||
const searchHits = await getBackendSrv().search({ dashboardUIDs: connections.map((c) => c.connectionUid) });
|
||||
|
||||
return searchHits;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ export interface LibraryElementConnectionDTO {
|
||||
kind: LibraryElementConnectionKind;
|
||||
elementId: number;
|
||||
connectionId: number;
|
||||
connectionUid: string;
|
||||
created: string;
|
||||
createdBy: LibraryElementDTOMetaUser;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user