Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix observibility dashboard delete (opensearch-project#4508)
Browse files Browse the repository at this point in the history
abbyhu2000 committed Jul 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5b46f79 commit a9a2879
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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);

@@ -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(() => {

0 comments on commit a9a2879

Please sign in to comment.