-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard De-Angular] Add breadcrumb with view/edit mode and unsaved…
… flow (#4479) * set isDirty back to false when saving susccessfully Signed-off-by: abbyhu2000 <[email protected]> * Breadcrumb working Signed-off-by: abbyhu2000 <[email protected]> * change to dashboards in breadcrumb Signed-off-by: abbyhu2000 <[email protected]> --------- Signed-off-by: abbyhu2000 <[email protected]>
- Loading branch information
1 parent
7d005a1
commit 316a916
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/plugins/dashboard/public/application/utils/breadcrumbs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Any modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
import { DashboardConstants } from '../../dashboard_constants'; | ||
import { ViewMode } from '../../embeddable_plugin'; | ||
|
||
export function getLandingBreadcrumbs() { | ||
return [ | ||
{ | ||
text: i18n.translate('dashboard.dashboardAppBreadcrumbsTitle', { | ||
defaultMessage: 'Dashboards', | ||
}), | ||
href: `#${DashboardConstants.LANDING_PAGE_PATH}`, | ||
}, | ||
]; | ||
} | ||
|
||
export const setBreadcrumbsForNewDashboard = (viewMode: ViewMode, isDirty: boolean) => { | ||
if (viewMode === ViewMode.VIEW) { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardViewTitle', { | ||
defaultMessage: 'New Dashboard', | ||
}), | ||
}, | ||
]; | ||
} else { | ||
if (isDirty) { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardEditTitle', { | ||
defaultMessage: 'Editing New Dashboard (unsaved)', | ||
}), | ||
}, | ||
]; | ||
} else { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardEditTitle', { | ||
defaultMessage: 'Editing New Dashboard', | ||
}), | ||
}, | ||
]; | ||
} | ||
} | ||
}; | ||
|
||
export const setBreadcrumbsForExistingDashboard = ( | ||
title: string, | ||
viewMode: ViewMode, | ||
isDirty: boolean | ||
) => { | ||
if (viewMode === ViewMode.VIEW) { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardViewTitle', { | ||
defaultMessage: '{title}', | ||
values: { title }, | ||
}), | ||
}, | ||
]; | ||
} else { | ||
if (isDirty) { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardEditTitle', { | ||
defaultMessage: 'Editing {title} (unsaved)', | ||
values: { title }, | ||
}), | ||
}, | ||
]; | ||
} else { | ||
return [ | ||
...getLandingBreadcrumbs(), | ||
{ | ||
text: i18n.translate('dashboard.strings.dashboardEditTitle', { | ||
defaultMessage: 'Editing {title}', | ||
values: { title }, | ||
}), | ||
}, | ||
]; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters