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

Management API - redirect on disabled app path #55136

Merged
merged 5 commits into from
Jan 17, 2020

Conversation

mattkime
Copy link
Contributor

@mattkime mattkime commented Jan 16, 2020

Summary

Previously a disabled app didn't show in the side nav but its path was still available to the user. This PR fixes that, but it will still be up to management apps to handle the case where a user is already viewing an app when its disabled.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

@mattkime mattkime changed the title redirect on disabled management app path Management API - redirect on disabled app path Jan 16, 2020
@mattkime mattkime added v8.0.0 v7.6.0 release_note:skip Skip the PR/issue when compiling release notes Team:AppArch labels Jan 16, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@mattkime mattkime marked this pull request as ready for review January 16, 2020 23:26
@mattkime mattkime requested a review from a team as a code owner January 16, 2020 23:26
Copy link
Contributor

@streamich streamich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One comment below that needs addressing.

/>,
params.element
);
}
return async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems appUnmount() and ReactDOM.unmountComponentAtNode(params.element) will be called even if React was not mounted. Maybe you could do an early return

if (!this.enabledStatus) {
  window.location.hash = '/management';
  // Early return
  return () => {};
}

and leave the rest of the function as before.

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected for Security plugin, thanks! Just two optional nits and +1 to comment about appUnmount that may be undefined now.

@@ -34,7 +34,7 @@ export class ManagementApp {
readonly basePath: string;
readonly order: number;
readonly mount: ManagementSectionMount;
protected enabledStatus: boolean = true;
private enabledStatus: boolean = true;
Copy link
Member

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.

if (!this.enabledStatus) {
window.location.hash = '/management';
} else {
async function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) {
Copy link
Member

Choose a reason for hiding this comment

The 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 setBreadcrumbs function one level up to create it only once per app (or even make it a private class method assuming getStartServices can become a private readonly as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mattkime mattkime merged commit c1ccb30 into elastic:master Jan 17, 2020
mattkime added a commit to mattkime/kibana that referenced this pull request Jan 17, 2020
* redirect on disabled management app path
mattkime added a commit to mattkime/kibana that referenced this pull request Jan 17, 2020
* redirect on disabled management app path
mattkime added a commit that referenced this pull request Jan 18, 2020
* redirect on disabled management app path
mattkime added a commit that referenced this pull request Jan 18, 2020
* redirect on disabled management app path
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 20, 2020
* upstream/master: (24 commits)
  Show error page when accessing unavailable app (elastic#54656)
  [ML] Improving job wizards with datafeed aggregations (elastic#55180)
  remove flaly assetion. a license presence tested anyway (elastic#55289)
  fix commonly used ranges uptime (elastic#54930)
  [SIEM] Use proper icons on Detections view (elastic#55215)
  Fix: invalid translation referenced (elastic#54901)
  [State Management] Remove AppState from edit_index_pattern page (elastic#54104)
  Implements `getStartServices` on server-side (elastic#55156)
  Move vis_vega_type/data_model tests to jest (elastic#55186)
  [SIEM] [Detection Engine] Update status on rule details page (elastic#55201)
  Fix KQL value suggestions for nested fields (elastic#54820)
  Enforce camelCase format for a plugin id (elastic#53759)
  [SIEM] Detection engine cleanup for rule details/creation/edit page (elastic#55069)
  Remove nested root from index pattern (elastic#54978)
  [Reporting/Migration] ReportingSetup, LegacySetup (elastic#54198)
  [SIEM] [Detection Engine] Fixes duplicate rule action (elastic#55252)
  [SIEM] Detections add alert & signal tab (elastic#55127)
  Management API - redirect on disabled app path (elastic#55136)
  [SIEM][Detection Engine] Fixes critical regression on the backend with immutable and tags
  update local (elastic#55177)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 20, 2020
* master: (108 commits)
  [ML] Single Metric Viewer: Fix job check. (elastic#55191)
  Show error page when accessing unavailable app (elastic#54656)
  [ML] Improving job wizards with datafeed aggregations (elastic#55180)
  remove flaly assetion. a license presence tested anyway (elastic#55289)
  fix commonly used ranges uptime (elastic#54930)
  [SIEM] Use proper icons on Detections view (elastic#55215)
  Fix: invalid translation referenced (elastic#54901)
  [State Management] Remove AppState from edit_index_pattern page (elastic#54104)
  Implements `getStartServices` on server-side (elastic#55156)
  Move vis_vega_type/data_model tests to jest (elastic#55186)
  [SIEM] [Detection Engine] Update status on rule details page (elastic#55201)
  Fix KQL value suggestions for nested fields (elastic#54820)
  Enforce camelCase format for a plugin id (elastic#53759)
  [SIEM] Detection engine cleanup for rule details/creation/edit page (elastic#55069)
  Remove nested root from index pattern (elastic#54978)
  [Reporting/Migration] ReportingSetup, LegacySetup (elastic#54198)
  [SIEM] [Detection Engine] Fixes duplicate rule action (elastic#55252)
  [SIEM] Detections add alert & signal tab (elastic#55127)
  Management API - redirect on disabled app path (elastic#55136)
  [SIEM][Detection Engine] Fixes critical regression on the backend with immutable and tags
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants