-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Graph] Shim plugin #47469
[Graph] Shim plugin #47469
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No review so far, just a note, that I currently can't log in with this PR. In Chrome there's an endless redirect. In Safari if've got the following in my logs:
server log [15:41:02.010] [warning][server][Kibana][cookie-session-storage][http] Found 2 auth sessions when we were only expecting 1.
@kertal My bad, the Graph app was loaded twice due to an experiment I failed to clean up. |
@flash1293 works now 👍 |
Jenkins, test this. |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
@@ -67,7 +67,7 @@ export function* extractCodeMessages(buffer, reporter) { | |||
try { | |||
ast = parse(buffer.toString(), { | |||
sourceType: 'module', | |||
plugins: ['jsx', 'typescript', 'objectRestSpread', 'classProperties', 'asyncGenerators'], | |||
plugins: ['jsx', 'typescript', 'objectRestSpread', 'classProperties', 'asyncGenerators', 'dynamicImport'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to support dynamic imports via await import(...
@@ -24,7 +24,7 @@ import { TopNavMenu } from '../../../core_plugins/kibana_react/public'; | |||
|
|||
const module = uiModules.get('kibana'); | |||
|
|||
module.directive('kbnTopNav', () => { | |||
export function createTopNavDirective() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exporting the directive definition as a module export to be able to put it in a separate angular module with a different name. This is done to use existing code like this one but make sure it's not using any dependencies from the global angular instance
) => { | ||
const urlOverflow = new UrlOverflowService(); | ||
const check = () => { | ||
// disable long url checks when storing state in session storage | ||
if (config.get('state:storeInSessionStorage')) { | ||
if (newPlatform.uiSettings.get('state:storeInSessionStorage')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use config in here to avoid having to initialize it.
// one cache/swaps per Provider | ||
const cache = {}; | ||
const swaps = {}; | ||
export function PrivateProvider() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the top nav directive. Private isn't used in this PR but it will become necessary for shimming discover and others in the same style
Pinging @elastic/kibana-app (Team:KibanaApp) |
💚 Build Succeeded |
ack: will review tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes within respect to the operations team LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, tested locally in Chrome! I salute 🥁 your angular mastership!
core: CoreStart, | ||
{ data, npData, __LEGACY: { angularDependencies } }: GraphPluginStartDependencies | ||
) { | ||
// TODO is this really the right way? I though the app context would give us those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is the right way, but I'm sure @joshdover knows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the app mount context in the Legacy compatibility layer can't support plugins, only core services at this time. We could solve this by implementing the bindServices
proposal I've added in #46483 (comment) is still being debated, but we're making a decision on this by next week).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussion is still ongoing, I would like to go forward with this solution - it will definitely work and when we decide on another convention we can easily adjust it here.
return $injector; | ||
} | ||
|
||
function createLocalAngularModule(core: AppMountContext['core']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: since core is not used, it can be removed, also you could directly return the modules without graphAngularModule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking fantastic 👍
core: CoreStart, | ||
{ data, npData, __LEGACY: { angularDependencies } }: GraphPluginStartDependencies | ||
) { | ||
// TODO is this really the right way? I though the app context would give us those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the app mount context in the Legacy compatibility layer can't support plugins, only core services at this time. We could solve this by implementing the bindServices
proposal I've added in #46483 (comment) is still being debated, but we're making a decision on this by next week).
indexPatterns: DataStart['indexPatterns']['indexPatterns']; | ||
npData: ReturnType<DataPlugin['start']>; | ||
savedObjectsClient: SavedObjectsClientContract; | ||
xpackInfo: { get(path: string): unknown }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can be replaced by #44922 once it is complete (just an FYI)
this.dataStart = data; | ||
this.npDataStart = npData; | ||
this.angularDependencies = angularDependencies; | ||
this.savedObjectsClient = core.savedObjects.client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to get this from contextCore
in the mount function above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least not in the types - the AppMountContext['core']
seems to be a subset of CoreStart
: src/core/public/application/types.ts
line 100, and savedObjects
is not there.
|
||
export const renderApp = ({ appBasePath, element, ...deps }: GraphDependencies) => { | ||
const graphAngularModule = createLocalAngularModule(deps.coreStart); | ||
configureAppAngularModule(graphAngularModule); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really happy this turned out useful...spent a lot of time breaking this out only to wonder if we would use it.
That said, we need to spend some time removing some of the legacy dependencies that this module uses. Doesn't look like there's too much:
import { fatalError } from 'ui/notify';
import { capabilities } from 'ui/capabilities';
import { modifyUrl } from 'ui/url';
import { UrlOverflowService } from '../error_url_overflow';
import { toastNotifications } from '../notify';
import { isSystemApiRequest } from '../system_api';
We should also make this function take CoreStart as an argument rather than importing it via ui/new_platform
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to check but it might be sufficient to just pull in the necessary parts - it looks like Graph only really needs the badges handling and even that could probably be moved to the controller. It's probably not so simple for the Kibana app apps though, so still worth thinking about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worked on this in the dashboard shim PR - are you fine with leaving this as it is for now and we'll fix it there?
💔 Build Failed |
Jenkins, test this. Failure looks unrelated. |
💚 Build Succeeded |
This PR shims the Graph app plugin while still using angular under the hood by pulling in angular dependencies from the global angular and initializing some services itself again in the app-local angular.