-
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
Migrate SO management section to NP #61700
Migrate SO management section to NP #61700
Conversation
…gement-final-countdown
Pinging @elastic/kibana-platform (Team:Platform) |
…gement-final-countdown
…gement-final-countdown
savedSearches: { | ||
/** | ||
* Create a {@link SavedObjectLoader | loader} to handle the saved searches type. | ||
* @param services | ||
*/ | ||
createLoader(services: SavedObjectKibanaServices): SavedObjectLoader; | ||
}; |
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.
While trying to reduce the initial bundle size, I saw that the async import
of the management section mount I added was only reducing the SOM bundle size from 4mb to 3.7mb. After a few checks, the cause appeared to be the createSavedSearchesLoader
static import I'm using in the SOM plugin, that caused the full discover
plugin + deps to be bundled into the SOM plugin.
After exposing this method from the contract instead, the SOM plugin is no longer using non-type imports from any plugin, and the initial bundle size went from 3.8mb to 51kb.
cc @elastic/kibana-app (btw it seems the discover
NP plugin is not present in CODEOWNERS
)
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.
Thanks for pinging about the codeowners, I will set up a PR for 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.
Changes in discover plugin LGTM, code review only.
@pgayvallet There is already a plugin |
@flash1293 This was an option, but after some discussion, we decided (at least for now) to create a distinct plugin. Main reasons would be better isolation/ per plugin responsibilities, and the fact that atm, the SOM plugin is depending on plugins exposing their SO loaders, and that we didn't want to propagate these dependencies to the SO plugin, as that would cause cyclic dependencies (namely in the We have a follow-up issue (#62048) to get rid of the Happy to discuss it further if you have an opinion on the subject. |
…gement-final-countdown
@flash1293 just merged master, the new |
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.
Still LGTM :) Not even code review
ack: reviewing... |
@@ -22,10 +22,15 @@ import { SavedObjectsManagementPlugin } from './plugin'; | |||
|
|||
export { SavedObjectsManagementPluginSetup, SavedObjectsManagementPluginStart } from './plugin'; | |||
export { | |||
ISavedObjectsManagementActionRegistry, | |||
SavedObjectsManagementActionService, |
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 see any usages outside of the plugin
// depends on `getStartServices`, should not be awaited | ||
registerServices(this.serviceRegistry, core.getStartServices); |
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.
Is it a result of the poor implementation ? as per https://github.com/elastic/kibana/pull/61700/files#r401190691
return { | ||
actionRegistry: this.actionRegistry, | ||
actions: actionSetup, | ||
serviceRegistry: this.serviceRegistry, |
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.
+1 to remove unused API
@@ -65,12 +86,27 @@ export class SavedObjectsManagementPlugin | |||
category: FeatureCatalogueCategory.ADMIN, | |||
}); | |||
|
|||
const actionSetup = this.actionService.setup(); | |||
|
|||
registerManagementSection({ |
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.
optional: why not to keep this logic in the plugin? it would make it possible to assess dependencies from the first glance.
}: MountParams) => { | ||
const [coreStart, { data }, pluginStart] = await core.getStartServices(); | ||
const { element, basePath, setBreadcrumbs } = mountParams; | ||
const allowedTypes = await getAllowedTypes(coreStart.http); |
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.
Is it okay to fetch types on every mount?
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.
Low impact, but obviously unnecessary, as these will never change during the app lifecycle. Will fix to only perform the http call on initial mount.
} | ||
|
||
export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedObjectsTableState> { | ||
private _isMounted = false; |
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.
😕
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.
🙈 on that one. This is there because debouncedFetch
is performing debounced http calls followed by setState
calls (which will raise an error when called after unmount). Removing that would require to be able to interrupt the http requests on unmount, which is indeed better and technically possible with NP apis but way more complicated than this ugly manual mount stats property (which is indeed an anti-pattern)...
@@ -124,21 +158,20 @@ export class ObjectsTable extends Component { | |||
} | |||
|
|||
fetchCounts = async () => { | |||
const { allowedTypes } = this.props; | |||
const { queryText, visibleTypes } = parseQuery(this.state.activeQuery); |
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 be typed now when we have usage examples? or you'd prefer to do it in a follow-up?
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.
Added proper typing to parseQuery
param & return type
return http.post<any>('/api/saved_objects/_resolve_import_errors', { | ||
headers: { | ||
// Important to be undefined, it forces proper headers to be set for FormData | ||
'Content-Type': 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.
I'd say it shouldn't be necessary, but I can see
kibana/src/core/public/http/fetch.ts
Line 131 in 3ec71c3
'Content-Type': 'application/json', |
@@ -27,13 +27,11 @@ interface RetryObject { | |||
replaceReferences?: any[]; | |||
} | |||
|
|||
async function callResolveImportErrorsApi(file: File, retries: any) { | |||
async function callResolveImportErrorsApi(http: HttpStart, file: File, retries: any) { |
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 wish we split the logic in this file...
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.
Yea. Honestly the whole src/plugins/saved_objects_management/public/lib
utilities are a mess, with honourable mentions for this file and resolve_saved_objects
. I want to avoid as must as possible to modify them until I got a clearer vision on what needs to be done to get rid of the SavedObjectLoader
usages (in #62048), as this will impact a lot of the lib
files.
import { findTestSubject } from '@elastic/eui/lib/test'; | ||
// @ts-ignore |
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 API is not meant to be used as public ?
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.
Though I did try to import from @elastic/eui
, but apparently not, as keyCodes
is actually exported from the root package.
changed to import { keyCodes } from '@elastic/eui';
findTestSubject
however is declared as also available from '@elastic/eui';
in the definition file, but is actually not exported... If I try to import { findTestSubject } from '@elastic/eui';
, TS compiler does not complain, however at runtime I get:
TypeError: (0 , _eui.findTestSubject) is not a function
So I still need the ts-ignore on import { findTestSubject } from '@elastic/eui/lib/test';
Ping @elastic/kibana-design ^
…gement-final-countdown
…gement-final-countdown
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* move libs to new plugin * adapt libs to use NP apis * add required plugins * add get_allowed_types route * move object_view components * add service registry * migrate table header component * migrate table component * migrate saved_objects_table component * remove migrated legacy files * fix re-export from legacy management + section label * migrate services registration * adapt management section mock * fix imports * migrate flyout component * migrate relationships component * migrate saved_objects_table tests * migrate breadcrumb * add redirect if unauthorized check * migrate translations to new savedObjectsManagement prefix * remove obsolete translations * convert action registry to service pattern * wire extra actions * remove importAndExportableTypes from injected vars * handle newIndexPatternUrl * remove duplicate dashboard dependency * remove old TODO * remove old TODO * properly mock lodash in tests * add async management section loading * expose createSavedSearchesLoader from discover plugin contract * address most review comments * fix merge conflicts
* Migrate SO management section to NP (#61700) * move libs to new plugin * adapt libs to use NP apis * add required plugins * add get_allowed_types route * move object_view components * add service registry * migrate table header component * migrate table component * migrate saved_objects_table component * remove migrated legacy files * fix re-export from legacy management + section label * migrate services registration * adapt management section mock * fix imports * migrate flyout component * migrate relationships component * migrate saved_objects_table tests * migrate breadcrumb * add redirect if unauthorized check * migrate translations to new savedObjectsManagement prefix * remove obsolete translations * convert action registry to service pattern * wire extra actions * remove importAndExportableTypes from injected vars * handle newIndexPatternUrl * remove duplicate dashboard dependency * remove old TODO * remove old TODO * properly mock lodash in tests * add async management section loading * expose createSavedSearchesLoader from discover plugin contract * address most review comments * fix merge conflicts * fix types for 7.x
Summary
Fix #50308
Last part of the #50308 'epic'. This moves the SO management section from the legacy kibana plugin in
src/legacy/core_plugins/kibana/public/management/sections
to a newsavedObjectsManagement
platform plugin.I tried to reduce this PR's size with the preliminary PRs I did last weeks, however this one is still quite big. I can't really split that any more, so this last part will have to be reviewed in a single shot unfortunately.
Most UI components were migrated in the simplest way, by converting them to TS and using NP APIs instead of legacy imports. Code cleanup, refactoring and type fixing should be considered as outside of the scope of this PR (as much as possible), as they should be addressed in the #62048 follow-up instead.
Plugin bundle size:
async
require for the management section and removing static import fromdiscover
plugin: 50kb.Notes for reviewers
security
I think only owned files impacting changes are on
copy_saved_objects_to_space_service.ts
, and are trivial.app-arch
All
src/legacy/core_plugins/kibana/public/management/sections/objects
files got moved to the new SOM plugin. This changes their ownership from your team to ours, however a 'full' review is still very welcome.platform
See self-review
Checklist