Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add support for Kibana 7.10.0 #144

Merged
merged 45 commits into from
Dec 5, 2020
Merged

Add support for Kibana 7.10.0 #144

merged 45 commits into from
Dec 5, 2020

Conversation

annie3431
Copy link
Contributor

@annie3431 annie3431 commented Dec 2, 2020

Issue #, if available: N/A

Description of changes:

  • Bump plugin version to 1.12.0.0

  • Bump Kibana version to 7.10.0

  • Bump node version to 10.22.1

  • Changed year of license for multiple files

  • Remove index.js and public/app.js and have

  • Removed dependencies in package.json to avoid duplicate imports

Browser side changes:

  • Add public/index.ts, public/index_management_app.tsx, and public/plugin.ts to define entry point

  • Add CoreStart prop for components

  • Changes to toast notification to be added by core.notifications

  • Breadcrumbs of pages are now set by core.setBreadcrumbs

  • For APIs that require query string, a query object will be used as parameter instead of forming a query string. This is due to the http client function not decoding the query correctly with a query string.

  • Update the browser side services to replace legacy angularIHttpServiceand IHttpResponse with new HttpSetup and HttpResponse

Server side changes:

  • Add server/index.ts, server/plugin.ts as server side entry point and configuration

  • Update route definitions to support new platform

  • Update route handlers to support new platform

  • Some rollup data model fix in interface file

Other:

  • Add external link to documentation on create rollup page

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@annie3431
Copy link
Contributor Author

Output for running yarn run test:jest

Test Suites: 32 passed, 32 total
Tests:       167 passed, 167 total
Snapshots:   28 passed, 28 total
Time:        148.345 s, estimated 327 s
Ran all test suites.
✨  Done in 149.68s.

annie3431 added a commit that referenced this pull request Dec 3, 2020
package.json Outdated Show resolved Hide resolved
Comment on lines +52 to +58
return response.custom({
statusCode: 200,
body: {
ok: true,
response: results,
},
});
Copy link

Choose a reason for hiding this comment

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

Rather than response.custom, you can use the given response.ok which will return a statusCode of 200 by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was using response.ok but resulted in a lot of type error. So changed back to response.custom. Thanks for the reminder.

@@ -27,6 +27,7 @@ interface ChangeManagedIndicesProps {
onChangeManagedIndices: (selectedManagedIndices: { label: string; value?: ManagedIndexItem }[]) => void;
onChangeStateFilters: (stateFilter: { label: string }[]) => void;
managedIndicesError: string;
core: CoreStart;
Copy link

Choose a reason for hiding this comment

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

Since I see you are wrapping all of the UI components in a core services consumer, you should be able to access the services via context (like how AD does it here), rather than passing a core object via props. This would simplify your components from having to add a core prop for all components and/or subcomponents that need to access the core services for toasts, breadcrumbs, etc. More info here

Choose a reason for hiding this comment

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

In my mind, accessing object via Context or props depends on the usage frequency of the object.
If an object are utilized in most of the components from the parent to the child, passing that through props maybe looks better. While, if the object is only used in few components, especially the deepest component, accessing the object via Context like AD plugin does (and AD features in Alerting Kibana plugin as well) definitely much simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified code to get core from context instead of passing props.

package.json Show resolved Hide resolved
onStateSelectChange={() => {}}
selectedPoliciesError=""
/>
<CoreServicesContext.Provider value={coreServicesMock}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you need to wrap all of these in the provider since you're already passing it below as props? Should only need the provider if you're consuming the context internally in NewPolicy. And maybe look into Tylers comment, this seems like a lot of nested passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to let components access core by context. So the passing core as props arguments are removed.

@@ -34,6 +34,7 @@ interface NewPolicyProps {
onChangePolicy: (selectedPolicies: PolicyOption[]) => void;
onChangeStateRadio: (optionId: string) => void;
onStateSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
core: CoreStart;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should try to limit what you're passing down. We don't need this giant core object, we just need the notifications service. You can use that in the props and pass it as core.notifications in whoever renders this.

Choose a reason for hiding this comment

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

This is what I did in Alerting Kibana plugin inspired by Yan's previous comment: https://github.com/opendistro-for-elasticsearch/alerting-kibana-plugin/blob/master/public/pages/Main/Main.js#L61. Drew please feel free to leave comment, and I will also keep an eye on how core will be passed here in Index Management plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored code to get core from context. Removed arguments to pass core as props.

public/pages/Policies/containers/Policies/Policies.tsx Outdated Show resolved Hide resolved
public/services/RollupService.ts Outdated Show resolved Hide resolved
public/utils/helpers.ts Outdated Show resolved Hide resolved
server/routes/rollups.ts Outdated Show resolved Hide resolved
type Server = Legacy.Server;

export default function(server: Server, services: NodeServices) {
export default function (services: NodeServices, router: IRouter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the validations a requirement of the new framework? If we are going from no validations -> validations can you just confirm each API works as expected on Kibana.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested. Everything should work fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I don't think validation is required for new platform.

*/

import { AppMountParameters, CoreSetup, CoreStart, Plugin, PluginInitializerContext } from "../../../src/core/public";
import { IndexManagementPluginSetup } from ".";
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I've ever seen from "." 🤔

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 think this is because the interfaces IndexManagementPluginSetup and IndexManagementPluginStart are defined in ./index.ts

server/services/RollupService.ts Outdated Show resolved Hide resolved
dbbaughe
dbbaughe previously approved these changes Dec 4, 2020
@annie3431 annie3431 merged commit cb7fb8a into master Dec 5, 2020
@annie3431 annie3431 deleted the kibana-migration branch December 5, 2020 01:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants