Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [FIX] Dashboard list integrated delete #3876

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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