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

[File upload][Maps] NP migration for server & client #51045

Merged
merged 20 commits into from
Nov 25, 2019

Conversation

kindsun
Copy link
Contributor

@kindsun kindsun commented Nov 19, 2019

This PR reshapes the File Upload plugin to a format compatible with the new platform, i.e.- all required steps up to the point of using shims but not yet moved to the new location. Wherever practical, new services were leveraged. Also includes small updates to the Maps app, which is currently the only app leveraging this plugin.

Server-side

  • De-couple from hapi.js server and request objects
  • Introduce new plugin definition shim
  • Switch to new platform services (Handle in separate PR pending router work and data and admin cluster handling work)
  • Migrate to the new plugin system (Handle in separate PR)

Browser-side

  • Create a plugin definition file
  • Export all static code and types from public/index.ts
  • Export your runtime contract
  • Move "owned" UI modules into your plugin and expose them from your public contract
  • Provide plugin extension points decoupled from angular.js (N/A)
  • Move all webpack alias imports into uiExport entry files (N/A)
  • Switch to new platform services
  • Migrate to the new plugin system (Handle in separate PR)

@kindsun kindsun added WIP Work in progress Feature:New Platform [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation Feature:File Upload labels Nov 19, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@kindsun kindsun added release_note:skip Skip the PR/issue when compiling release notes v7.6.0 v8.0.0 labels Nov 19, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@kindsun kindsun removed the WIP Work in progress label Nov 20, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@kindsun
Copy link
Contributor Author

kindsun commented Nov 20, 2019

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@kindsun
Copy link
Contributor Author

kindsun commented Nov 20, 2019

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@kindsun
Copy link
Contributor Author

kindsun commented Nov 21, 2019

retest

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM
code review, tested in chrome

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

🎉 one of first NP PRs for Maps

There's indirection between module dependencies and superfluous aliasing that I would simplify (although not sure if this is part of NP-guidelines or not).

x-pack/legacy/plugins/file_upload/index.js Outdated Show resolved Hide resolved
import { FileUploadPlugin as Plugin } from './plugin';

export function plugin() {
return new Plugin();
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to alias, just do new FileUploadPlugin

Even beyond that, what is this file adding beyond indirection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's about all it's adding here since we're not sharing any static code. I threw it in there to give it the same "shape" as other plugins. Other examples I saw were pretty minimal and didn't add much either. Agreed that aliasing is superfluous here.

*/

import { npStart } from 'ui/new_platform';
import { plugin } from '.';
Copy link
Contributor

Choose a reason for hiding this comment

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

that looks weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulled from the example on that one and found a few others who used the same syntax. No strong feelings either way personally so I just stuck with the example syntax

import { npStart } from 'ui/new_platform';
import { plugin } from '.';

const pluginInstance = plugin();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this module hopping? Is this something from the platform?

import { FileUploadPlugin } from './plugin';

const pluginInstance = new FileUploadPlugin();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again just sticking with the expected shape for consistency with other plugins at this stage. Ultimately this file will go away when moved though.

@@ -6,7 +6,7 @@


import React from 'react';
import { JsonUploadAndParse } from '../../../../../file_upload/public';
import { start as fileUpload } from '../../../../../file_upload/public/legacy';
Copy link
Contributor

@thomasneirynck thomasneirynck Nov 21, 2019

Choose a reason for hiding this comment

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

see above. if we're going to rename it here, just give it its usable name when exporting in legacy

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 definitely see your point, but I stuck with prevailing conventions on this one. If you do a local code search for "start as" you'll see some NP examples.


const pluginInstance = plugin();

export const start = pluginInstance.start(npStart.core);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the rename when it is being renamed yet again when it is imported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Related to the previous comment on naming it "start". Here's the relevant section in the migration guide.

const fileType = 'json';

export async function indexData(parsedFile, transformDetails, indexName, dataType, appName) {
if (!parsedFile) {
throw(i18n.translate('xpack.fileUpload.indexingService.noFileImported', {
defaultMessage: 'No file imported.'
}));
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

x-pack/legacy/plugins/file_upload/server/plugin.js Outdated Show resolved Hide resolved

public start(core: CoreStart) {
initServicesAndConstants(core);
return {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason this is wrapped in an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just another convention they used in the guide and I saw used around.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@kindsun
Copy link
Contributor Author

kindsun commented Nov 22, 2019

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@kindsun
Copy link
Contributor Author

kindsun commented Nov 25, 2019

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@kindsun kindsun merged commit b136bfd into elastic:master Nov 25, 2019
kindsun pushed a commit to kindsun/kibana that referenced this pull request Nov 25, 2019
* Use np savedObjectsClient in indexing service

* Export File Upload UI via start since it requires initialization

* Pass services through top level react component props

* Handle basePath ref and 'kbn-version' for requests

* Bulk of logic for removing hapi server dependencies for server app

* Use request obj subset of original request

* Move startup logic over to server plugin file and call from index.js

* Update server tests

* Clean up

* Remove old makeUsageCollector export statement

* initServicesAndConstants in the start method instead of in the react component

* Review feedback
kindsun pushed a commit that referenced this pull request Nov 25, 2019
* Use np savedObjectsClient in indexing service

* Export File Upload UI via start since it requires initialization

* Pass services through top level react component props

* Handle basePath ref and 'kbn-version' for requests

* Bulk of logic for removing hapi server dependencies for server app

* Use request obj subset of original request

* Move startup logic over to server plugin file and call from index.js

* Update server tests

* Clean up

* Remove old makeUsageCollector export statement

* initServicesAndConstants in the start method instead of in the react component

* Review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation Feature:File Upload Feature:New Platform 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.

4 participants