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

[Canvas] Remove Angular and unnecessary reporting config from Canvas #54050

Merged
merged 13 commits into from
Jan 27, 2020

Conversation

poffdeluxe
Copy link
Contributor

@poffdeluxe poffdeluxe commented Jan 6, 2020

Summary

  • Removed Angular from the Canvas application
    • Removed the controller as well as state setup
  • Added a Canvas "app"
  • Removed workpad export disabled panel since reporting no longer has the option to use phantom for generating PDFs
  • Modified the store setup the be more NP compliant by trying to usage of injected variables
    • Removed kbnVersion from frontend state since we don't appear to use it anywhere I could find

Checklist

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

For maintainers

@poffdeluxe poffdeluxe added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort v8.0.0 release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. v7.7.0 labels Jan 6, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas (Team:Canvas)

initClipboard(plugins.__LEGACY.storage);
initLoadingIndicator(core.http.addLoadingCountSource);

const CanvasRootController = CanvasRootControllerFactory(core, plugins);
plugins.__LEGACY.setRootController('canvas', CanvasRootController);
core.chrome.setBadge(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was just moved from the controller. Definitely need to test read only

@@ -32,7 +32,6 @@ export interface AppState {
}

interface StoreAppState {
kbnVersion: string;
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 couldn't find any usage of the kbnVersion in our frontend code so I'm removing it

element
);
return () => ReactDOM.unmountComponentAtNode(element);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was created based on the new conventions laid out here: https://github.com/elastic/kibana/blob/0dac43516e0690486d13071063cb089bce96ee11/src/core/CONVENTIONS.md#applications

The thing is, it's kinda weird to have applications at the same level as our apps directory (which houses home, workpad, and export)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could this just live in the root of public as just application.tsx or something like that?

@poffdeluxe poffdeluxe added v7.6.0 and removed v7.7.0 labels Jan 7, 2020
const CanvasRootController = CanvasRootControllerFactory(core, plugins);
plugins.__LEGACY.setRootController('canvas', CanvasRootController);
core.chrome.setBadge(
core.application.capabilities.canvas && core.application.capabilities.canvas.save
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally this was checking for the existence just of core.application.capabilities.canvas.save but I was running into a test error where .canvas wasn't defined on capabilities. I fixed it by adding this check. If we want to fix this by doing a mock somewhere for the test instead, I can do that

@poffdeluxe poffdeluxe marked this pull request as ready for review January 7, 2020 22:13
@poffdeluxe poffdeluxe requested a review from a team as a code owner January 7, 2020 22:13
Copy link
Contributor

@rudolf rudolf left a comment

Choose a reason for hiding this comment

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

The way Core API's are consumed lgtm 👍

canvasStore: Store
) => {
ReactDOM.render(
<KibanaContextProvider services={{ ...coreStart, ...plugins }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The KibanaContextProvider uses react context to provide enable deeply nested react components to directly consume these services. I didn't look closely at the Canvas code, but since you seem to be using Redux, you probably won't need this context and would instead consume Core API's from reducers.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rudolf We are using useSetting and other hooks from kibana-react and I thought those required setting a context like this, or is there a way to do that without requiring a context like this?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're using the hooks from kibana-react then this is correct.

@rudolf
Copy link
Contributor

rudolf commented Jan 9, 2020

Caveat: reportingBrowserType is a config var coming from the reporting side of things. As far as I can tell, NP doesn't have a great way to retrieve cross-plugin config at the moment so I kept it using injected variables for now until we can replace it with something better

NP doesn't / won't allow cross-plugin config reading, so the reporting plugin will have to expose any of it's config values that are meant to be consumed by other plugins from it's setup or start API's.

@poffdeluxe poffdeluxe added v7.7.0 and removed v7.6.0 labels Jan 15, 2020
Copy link
Contributor

@crob611 crob611 left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of nits.

If we could remove the bulk of the stuff on the server side that is injecting the vars, that would be great too.

element
);
return () => ReactDOM.unmountComponentAtNode(element);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this just live in the root of public as just application.tsx or something like that?

canvasStore: Store
) => {
ReactDOM.render(
<KibanaContextProvider services={{ ...coreStart, ...plugins }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

@rudolf We are using useSetting and other hooks from kibana-react and I thought those required setting a context like this, or is there a way to do that without requiring a context like this?

const initialState = getInitialState();

const basePath = core.http.basePath.get();
const reportingBrowserType = core.injectedMetadata.getInjectedVar('reportingBrowserType');
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we decide that injectedVars are going away? If so, let's shim out the reporting plugin in our dependency and pass that in here instead.

@@ -43,9 +43,6 @@ export interface CanvasStartDeps {
setRootController: Chrome['setRootController'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can setRootController also be removed? Think we're just using the application.register now?

reporting:
npSetup.core && npSetup.core.injectedMetadata.getInjectedVar('reportingBrowserType')
? {}
: undefined,
Copy link
Member

Choose a reason for hiding this comment

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

The reason that Canvas had to check the Reporting browser type was because, if it was configured to phantom, the, the PDF would fail. Originally it was important to show that the configuration had to change and make the browser type become chromium

In Kibana 7.x we dropped support for phantom, and now chromium is the only valid option for the type setting! The setting will probably go away completely in 8.0.

Letting you know this, because you can remove lots of code in Canvas, since the browser type check isn't needed! 🍾


core.injectUiAppVars('canvas', async () => {
const config = core.getServerConfig();
const basePath = config.get('server.basePath');
const reportingBrowserType = (() => {
Copy link
Member

Choose a reason for hiding this comment

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

No need to worry about this, per https://github.com/elastic/kibana/pull/54050/files#r370402125

Leaving this as-is would complicate the Reporting team from upgrading to the NP config service anyway 😄

@tsullivan
Copy link
Member

You could probably get rid of I think you can get rid of x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/disabled_panel.tsx if you wanted.

@poffdeluxe poffdeluxe changed the title [Canvas] Remove Angular from Canvas [Canvas] Remove Angular and unnecessary reporting config from Canvas Jan 24, 2020
@poffdeluxe
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@poffdeluxe poffdeluxe merged commit be9d9c2 into elastic:master Jan 27, 2020
@poffdeluxe poffdeluxe deleted the canvas-remove-angular branch January 27, 2020 21:01
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 28, 2020
…ve-out-legacy

* 'master' of github.com:elastic/kibana: (187 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...

# Conflicts:
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/containers/panel.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/context.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/index.ts
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/split_panel.test.tsx
#	src/legacy/ui/public/vis/editors/default/default_editor.tsx
#	src/plugins/console/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/console/public/application/components/split_panel/components/resizer.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel_container.tsx
#	src/plugins/console/public/application/components/split_panel/context.tsx
#	src/plugins/console/public/application/components/split_panel/index.ts
#	src/plugins/console/public/application/components/split_panel/registry.ts
#	src/plugins/console/public/application/components/split_panel/split_panel.test.tsx
#	src/plugins/kibana_react/public/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/kibana_react/public/split_panel/containers/panel.tsx
#	src/plugins/kibana_react/public/split_panel/context.tsx
#	src/plugins/kibana_react/public/split_panel/index.ts
#	src/plugins/kibana_react/public/split_panel/split_panel.test.tsx
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 28, 2020
* master: (77 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...
poffdeluxe added a commit that referenced this pull request Jan 28, 2020
…54050) (#56067)

* Remove Angular from Canvas

* Remove reporting config behavior from Canvas since it's no longer needed

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants