Skip to content

Commit

Permalink
[FIX] Dashboard list integrated delete (#3796) (#3876)
Browse files Browse the repository at this point in the history
* [FIx] Dashboard-List Integrated Delete



* Add toast notification on deletion error



* add toast notification dependency



---------





(cherry picked from commit 9d27023)

Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com>
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Peter Fitzgibbons <pjfitz@amazon.com>
Co-authored-by: Josh Romero <rmerqg@amazon.com>
  • Loading branch information
4 people committed Apr 18, 2023
1 parent 0ae76d2 commit d476d23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import 'angular-sanitize';
import { i18nDirective, i18nFilter, I18nProvider } from '@osd/i18n/angular';
import {
ChromeStart,
ToastsStart,
IUiSettingsClient,
CoreStart,
SavedObjectsClientContract,
Expand Down Expand Up @@ -93,6 +94,7 @@ export interface RenderDeps {
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
savedObjects: SavedObjectsStart;
restorePreviousUrl: () => void;
toastNotifications: ToastsStart;
}

let angularModuleInstance: IModule | null = null;
Expand Down
14 changes: 12 additions & 2 deletions src/plugins/dashboard/public/application/legacy_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export function initDashboardApp(app, deps) {
deps.core.chrome.docTitle.change(
i18n.translate('dashboard.dashboardPageTitle', { defaultMessage: 'Dashboards' })
);
const service = deps.savedDashboards;
const dashboardConfig = deps.dashboardConfig;

// syncs `_g` portion of url with query services
Expand Down Expand Up @@ -171,7 +170,18 @@ export function initDashboardApp(app, deps) {
history.push(deps.addBasePath(viewUrl));
};
$scope.delete = (dashboards) => {
return service.delete(dashboards.map((d) => d.id));
const ids = dashboards.map((d) => ({ id: d.id, appId: d.appId }));
return Promise.all(
ids.map(({ id, appId }) => {
return deps.savedObjectsClient.delete(appId, id);
})
).catch((error) => {
deps.toastNotifications.addError(error, {
title: i18n.translate('dashboard.dashboardListingDeleteErrorTitle', {
defaultMessage: 'Error deleting dashboard',
}),
});
});
};
$scope.hideWriteControls = dashboardConfig.getHideWriteControls();
$scope.initialFilter = parse(history.location.search).filter || EMPTY_FILTER;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class DashboardPlugin
registerDashboardProvider({
savedObjectsType: 'dashboard',
savedObjectsName: 'Dashboard',
appId: 'dashboards',
appId: 'dashboard',
viewUrlPathFn: (obj) => `#/view/${obj.id}`,
editUrlPathFn: (obj) => `/view/${obj.id}?_a=(viewMode:edit)`,
createUrl: core.http.basePath.prepend('/app/dashboards#/create'),
Expand Down

0 comments on commit d476d23

Please sign in to comment.