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

[APM] Some miscellaneous client new platform updates #51482

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

smith
Copy link
Contributor

@smith smith commented Nov 22, 2019

  • Move setHelpExtension to plugin start method instead of plugin root
  • Move setHelpExtension to a separate file
  • Remove 'ui/modules' import
  • Use new platform capabilities in useUpdateBadgeEffect
  • Move useUpdateBadgeEffect to a utility function called in start
  • Add plugins and plugins context to new platform start
  • Use new platform plugins for KueryBar autocomplete provider
  • Add types for plugin and rename to ApmPublicPlugin
  • Add empty setup method to plugin
  • Move all context providers from App to render method
  • Remove some unnecessary mocks

References #32894.

@smith smith requested a review from a team as a code owner November 22, 2019 18:14
@smith smith added release_note:skip Skip the PR/issue when compiling release notes v7.6.0 labels Nov 22, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

</LocationProvider>
</Router>
</i18nCore.Context>
</PluginsContext.Provider>
</KibanaCoreContextProvider>,
document.getElementById(REACT_APP_ROOT_ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

document.getElementById(REACT_APP_ROOT_ID) should be passed in a param domElement to align a bit better with the NP plugin pattern. This element reference is already in checkForRoot, so it can be passed as a result of that promise.

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'm going to skip doing this for now, until we implement the mount method when we register the NP application.

@@ -57,5 +31,5 @@ const checkForRoot = () => {
});
};
checkForRoot().then(() => {
plugin().start(core);
plugin().start(core, plugins);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to use async/await here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can only await inside of an async function, so if we wanted to do that here we would need to wrap everything inside an immediately executing async function, which would probably be just as complex as what we're doing already.

Copy link
Contributor

@ogupte ogupte left a comment

Choose a reason for hiding this comment

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

some feedback, but overall it looks good!

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Nice cleanup, thanks!

@@ -6,16 +6,16 @@

import { i18n } from '@kbn/i18n';
import { useEffect } from 'react';
import { capabilities } from 'ui/capabilities';
import { useKibanaCore } from '../../../../../observability/public';

export const useUpdateBadgeEffect = () => {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this in a hook I think it would make more sense to update the badge from the plugin's start method outside React like you did for core.chrome.setHelpExtension (although still in separate file):

export class Plugin {
  start(core: LegacyCoreStart){
    setBadge(core);
    ReactDOM.render(...);
  }
}

@@ -74,6 +74,8 @@ export function KueryBar() {
});
const { urlParams } = useUrlParams();
const location = useLocation();
const { data } = usePlugins();
const autocompleteProvider = data.autocomplete.getProvider('kuery');
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for moving the unnecessary abstraction 👍

})
}
]
});
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps move this to a separate file similar to chrome.setBadge

* Move `setHelpExtension` to plugin start method instead of plugin root
* Move `setHelpExtension` to a separate file
* Remove 'ui/modules' import
* Use new platform capabilities in useUpdateBadgeEffect
* Move useUpdateBadgeEffect to a utility function called in start
* Add plugins and plugins context to new platform start
* Use new platform plugins for KueryBar autocomplete provider
* Add types for plugin and rename to ApmPublicPlugin
* Add empty setup method to plugin
* Move all context providers from App to render method
* Remove some unnecessary mocks

References elastic#32894.
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@smith smith merged commit 3dcb94d into elastic:master Nov 25, 2019
@smith smith deleted the nls/np-easy branch November 25, 2019 19:39
smith added a commit to smith/kibana that referenced this pull request Nov 26, 2019
* Move `setHelpExtension` to plugin start method instead of plugin root
* Move `setHelpExtension` to a separate file
* Remove 'ui/modules' import
* Use new platform capabilities in useUpdateBadgeEffect
* Move useUpdateBadgeEffect to a utility function called in start
* Add plugins and plugins context to new platform start
* Use new platform plugins for KueryBar autocomplete provider
* Add types for plugin and rename to ApmPublicPlugin
* Add empty setup method to plugin
* Move all context providers from App to render method
* Remove some unnecessary mocks

References elastic#32894.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants