forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] IngestManager Plugin interface for registering UI extensions (e…
…lastic#82783) (elastic#83307) * Expose `registerExtension()` interface on `Plugin#start` * Refactor use of `CustomConfigurePackagePolicy` to the new registerExtension approach * Refactor to always show registered ui extension (even if Integration has configuration options)
- Loading branch information
1 parent
64d0fd8
commit 8f7b38d
Showing
20 changed files
with
478 additions
and
125 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/fleet/public/applications/fleet/components/extension_wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo, ReactNode, Suspense } from 'react'; | ||
import { EuiErrorBoundary } from '@elastic/eui'; | ||
import { Loading } from './loading'; | ||
|
||
export const ExtensionWrapper = memo<{ children: ReactNode }>(({ children }) => { | ||
return ( | ||
<EuiErrorBoundary> | ||
<Suspense fallback={<Loading />}>{children}</Suspense> | ||
</EuiErrorBoundary> | ||
); | ||
}); |
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/fleet/public/applications/fleet/hooks/use_ui_extension.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useContext } from 'react'; | ||
import { UIExtensionPoint, UIExtensionsStorage } from '../types'; | ||
|
||
export const UIExtensionsContext = React.createContext<UIExtensionsStorage>({}); | ||
|
||
type NarrowExtensionPoint<V extends UIExtensionPoint['view'], A = UIExtensionPoint> = A extends { | ||
view: V; | ||
} | ||
? A | ||
: never; | ||
|
||
export const useUIExtension = <V extends UIExtensionPoint['view'] = UIExtensionPoint['view']>( | ||
packageName: UIExtensionPoint['package'], | ||
view: V | ||
): NarrowExtensionPoint<V>['component'] | undefined => { | ||
const registeredExtensions = useContext(UIExtensionsContext); | ||
|
||
if (!registeredExtensions) { | ||
throw new Error('useUIExtension called outside of UIExtensionsContext'); | ||
} | ||
|
||
const extension = registeredExtensions?.[packageName]?.[view]; | ||
|
||
if (extension) { | ||
// FIXME:PT Revisit ignore below and see if TS error can be addressed | ||
// @ts-ignore | ||
return extension.component; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
...eet/sections/agent_policy/create_package_policy_page/components/custom_package_policy.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.