-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Management API - redirect on disabled app path #55136
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<kbn-management-app> | ||
<div id="management-landing"></div> | ||
<div id="management-landing" data-test-subj="management-landing"></div> | ||
</kbn-management-app> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ export class ManagementApp { | |
readonly basePath: string; | ||
readonly order: number; | ||
readonly mount: ManagementSectionMount; | ||
protected enabledStatus: boolean = true; | ||
private enabledStatus: boolean = true; | ||
|
||
constructor( | ||
{ id, title, basePath, order = 100, mount }: CreateManagementApp, | ||
|
@@ -54,35 +54,38 @@ export class ManagementApp { | |
title, | ||
mount: async ({}, params) => { | ||
let appUnmount: Unmount; | ||
async function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) { | ||
const [coreStart] = await getStartServices(); | ||
coreStart.chrome.setBreadcrumbs([ | ||
{ | ||
text: i18n.translate('management.breadcrumb', { | ||
defaultMessage: 'Management', | ||
}), | ||
href: '#/management', | ||
}, | ||
...crumbs, | ||
]); | ||
} | ||
|
||
ReactDOM.render( | ||
<ManagementChrome | ||
getSections={getSections} | ||
selectedId={id} | ||
legacySections={getLegacyManagementSections().items} | ||
onMounted={async element => { | ||
appUnmount = await mount({ | ||
basePath, | ||
element, | ||
setBreadcrumbs, | ||
}); | ||
}} | ||
/>, | ||
params.element | ||
); | ||
if (!this.enabledStatus) { | ||
window.location.hash = '/management'; | ||
} else { | ||
async function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional nit: it was here before, so feel free to ignore, but technically we can move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll likely address this in a future refactor. Gave it a try but it twas changing a bit more code than I'd like for this PR. |
||
const [coreStart] = await getStartServices(); | ||
coreStart.chrome.setBreadcrumbs([ | ||
{ | ||
text: i18n.translate('management.breadcrumb', { | ||
defaultMessage: 'Management', | ||
}), | ||
href: '#/management', | ||
}, | ||
...crumbs, | ||
]); | ||
} | ||
|
||
ReactDOM.render( | ||
<ManagementChrome | ||
getSections={getSections} | ||
selectedId={id} | ||
legacySections={getLegacyManagementSections().items} | ||
onMounted={async element => { | ||
appUnmount = await mount({ | ||
basePath, | ||
element, | ||
setBreadcrumbs, | ||
}); | ||
}} | ||
/>, | ||
params.element | ||
); | ||
} | ||
return async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems if (!this.enabledStatus) {
window.location.hash = '/management';
// Early return
return () => {};
} and leave the rest of the function as before. |
||
appUnmount(); | ||
ReactDOM.unmountComponentAtNode(params.element); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optioanal nit: I believe
:boolean
is not needed as the correct type is derived from the initial value.