-
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
Management API - simpler interface, remove app context usage #71144
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
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.
Nice improvement, @mattkime! I found a few typos and things and I explained some of my concerns around the change to the Security section definition. I'd like to hear your perspective on that. None of my comments are terribly controversial though, so I'd like to see them addressed but I think I can still approve to unblock you.
src/plugins/management/public/components/management_sections.tsx
Outdated
Show resolved
Hide resolved
src/plugins/management/public/components/management_sections.tsx
Outdated
Show resolved
Hide resolved
src/plugins/management/public/components/management_sections.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security/public/management/management_service.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security/public/management/management_service.ts
Outdated
Show resolved
Hide resolved
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.
LGTM for platform changes
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.
LGTM for security/spaces changes
@elasticmachine merge upstream |
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.
ML changes LGTM
@elasticmachine merge upstream |
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.
Alerting changes LGTM
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
Looks good and works properly (already tested locally).
Added a few comments.
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ManagementStart {} | ||
|
||
export interface ManagementSectionsStartPrivate { |
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.
Haven't seen this pattern before (Private interface), why is it used?
Also, it seems to be the same as SectionsServiceStart
? Is it future proofing?
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.
One is for the service and one is for the plugin, you're right that its a little redundant but I think its okay.
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.
Not sure why we need this, but okay
return { | ||
sections: this.managementSections.start({ capabilities: core.application.capabilities }), | ||
}; | ||
this.managementSections.start({ capabilities: core.application.capabilities }); |
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.
Why aren't we returning sections on the start contract anymore?
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.
It was never used externally, only internally.
private getSection = (sectionId: ManagementSectionId | string) => | ||
this.sections.get(sectionId) as ManagementSection; | ||
constructor() { | ||
// Note on adding sections - sections can be defined in a plugin and exported as a contract |
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.
Can you provide a short example for what you mean?
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.
Here's a previous version of the code that was changed due to feedback - 291bf7a
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 mean an example in a comment
|
||
export class ManagementSectionsService { | ||
private sections: Map<ManagementSectionId | string, ManagementSection> = new Map(); | ||
definedSections: DefinedSections; |
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.
//Major nit
why not just sections
? (both for the variable and the class)
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.
its not necessarily the full set of sections, its just the set of sections that have been defined within this plugin. Sections could be defined and exposed via other plugins.
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 would then add a comment at least.
} from './types'; | ||
import { createGetterSetter } from '../../kibana_utils/public'; | ||
|
||
const [getSectionsServiceStartPrivate, setSectionsServiceStartPrivate] = createGetterSetter< |
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.
Would you mind explaining this bit?
Why is the getter setter called private
?
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.
Its only used internally.
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 think all getter-setters are used within the bundle they are defined in. Not sure 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'm not sure I understand, is there a change you'd recommend? This is used within the bundle.
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.
Just found the "Private" part a bit unclear. Not critical though.
this.licenseFeaturesSubscription = this.license.features$.subscribe(async (features) => { | ||
const securitySection = management.sections.getSection(ManagementSectionId.Security); | ||
const securitySection = this.securitySection as ManagementSection; |
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.
Why did you have to cast here?
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.
We know its been set in the setup
method but typescript isn't aware of this. It thinks it might be undefined.
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.
Won't this.securitySection!
work as well. I find it clearer.
…#71144) Management API - simpler interface, remove app context usage, consolidate rendeing # Conflicts: # src/core/MIGRATION.md # x-pack/plugins/upgrade_assistant/kibana.json
💔 Build Failed
Failed CI Steps
Test FailuresKibana Pipeline / kibana-oss-agent / Chrome UI Functional Tests.test/functional/apps/context/_date_nanos·js.context app context view for date_nanos displays predessors - anchor - successors in right orderStandard Out
Stack Trace
Kibana Pipeline / kibana-oss-agent / Chrome UI Functional Tests.test/functional/apps/context/_date_nanos·js.context app context view for date_nanos displays predessors - anchor - successors in right orderStandard Out
Stack Trace
Kibana Pipeline / kibana-oss-agent / Chrome UI Functional Tests.test/functional/apps/dashboard/dashboard_filter_bar·js.dashboard app using current data dashboard filter bar filter editor field list shows index pattern of vis when one is addedStandard Out
Stack Trace
and 6 more failures, only showing the first 3. Build metricsSaved Objects .kibana field count
History
To update your PR or re-run it, just comment with: |
Summary
Dev Docs
Management API changes - Public setup contract has been reduced to just
register
and a new interface,sections
which is a map of management sections provided by the plugin and replacesgetSection
. Public start interfaces have been removed as all registration should occur in the setup lifecycle.