Skip to content

Commit

Permalink
fix observibility dashboard delete (#4508)
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyhu2000 authored Jul 6, 2023
1 parent a94b339 commit 2cba0e1
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ export const DashboardListing = () => {
history,
uiSettings,
notifications,
savedDashboards,
dashboardProviders,
data: { query },
osdUrlStateStorage,
},
} = useOpenSearchDashboards<DashboardServices>();

const location = useLocation();
const queryParameters = new URLSearchParams(location.search);
const queryParameters = useMemo(() => new URLSearchParams(location.search), [location]);
const initialFiltersFromURL = queryParameters.get('filter');
const [initialFilter, setInitialFilter] = useState<string | null>(initialFiltersFromURL);

Expand Down Expand Up @@ -168,10 +167,18 @@ export const DashboardListing = () => {
// );

const deleteItems = useCallback(
(dashboards: object[]) => {
return savedDashboards.delete(dashboards.map((d: any) => d.id));
async (dashboards: object[]) => {
await Promise.all(
dashboards.map((dashboard: any) => savedObjectsClient.delete(dashboard.appId, dashboard.id))
).catch((error) => {
notifications.toasts.addError(error, {
title: i18n.translate('dashboard.dashboardListingDeleteErrorTitle', {
defaultMessage: 'Error deleting dashboard',
}),
});
});
},
[savedDashboards]
[savedObjectsClient, notifications]
);

useMount(() => {
Expand Down

0 comments on commit 2cba0e1

Please sign in to comment.