Skip to content

Commit 9d27023

Browse files
pjfitzgibbonsPeter Fitzgibbonsjoshuarrrr
authored
[FIX] Dashboard list integrated delete (#3796)
* [FIx] Dashboard-List Integrated Delete Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com> * Add toast notification on deletion error Signed-off-by: Josh Romero <rmerqg@amazon.com> * add toast notification dependency Signed-off-by: Josh Romero <rmerqg@amazon.com> --------- Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com> Signed-off-by: Josh Romero <rmerqg@amazon.com> Co-authored-by: Peter Fitzgibbons <pjfitz@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
1 parent ee32d20 commit 9d27023

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/plugins/dashboard/public/application/application.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import 'angular-sanitize';
3737
import { i18nDirective, i18nFilter, I18nProvider } from '@osd/i18n/angular';
3838
import {
3939
ChromeStart,
40+
ToastsStart,
4041
IUiSettingsClient,
4142
CoreStart,
4243
SavedObjectsClientContract,
@@ -93,6 +94,7 @@ export interface RenderDeps {
9394
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
9495
savedObjects: SavedObjectsStart;
9596
restorePreviousUrl: () => void;
97+
toastNotifications: ToastsStart;
9698
}
9799

98100
let angularModuleInstance: IModule | null = null;

src/plugins/dashboard/public/application/legacy_app.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export function initDashboardApp(app, deps) {
114114
deps.core.chrome.docTitle.change(
115115
i18n.translate('dashboard.dashboardPageTitle', { defaultMessage: 'Dashboards' })
116116
);
117-
const service = deps.savedDashboards;
118117
const dashboardConfig = deps.dashboardConfig;
119118

120119
// syncs `_g` portion of url with query services
@@ -171,7 +170,18 @@ export function initDashboardApp(app, deps) {
171170
history.push(deps.addBasePath(viewUrl));
172171
};
173172
$scope.delete = (dashboards) => {
174-
return service.delete(dashboards.map((d) => d.id));
173+
const ids = dashboards.map((d) => ({ id: d.id, appId: d.appId }));
174+
return Promise.all(
175+
ids.map(({ id, appId }) => {
176+
return deps.savedObjectsClient.delete(appId, id);
177+
})
178+
).catch((error) => {
179+
deps.toastNotifications.addError(error, {
180+
title: i18n.translate('dashboard.dashboardListingDeleteErrorTitle', {
181+
defaultMessage: 'Error deleting dashboard',
182+
}),
183+
});
184+
});
175185
};
176186
$scope.hideWriteControls = dashboardConfig.getHideWriteControls();
177187
$scope.initialFilter = parse(history.location.search).filter || EMPTY_FILTER;

src/plugins/dashboard/public/plugin.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export class DashboardPlugin
344344
registerDashboardProvider({
345345
savedObjectsType: 'dashboard',
346346
savedObjectsName: 'Dashboard',
347-
appId: 'dashboards',
347+
appId: 'dashboard',
348348
viewUrlPathFn: (obj) => `#/view/${obj.id}`,
349349
editUrlPathFn: (obj) => `/view/${obj.id}?_a=(viewMode:edit)`,
350350
createUrl: core.http.basePath.prepend('/app/dashboards#/create'),

0 commit comments

Comments
 (0)