-
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
[Fleet] Create a new UIExtensionPoint
to replace the integration define step
#149653
Changes from 1 commit
2499179
48c18ac
4aad0dd
7af3d1d
e304afe
d63154a
5d0274e
5e0cec2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,16 @@ import type { ComponentType, LazyExoticComponent } from 'react'; | |
|
||
import type { FleetServerAgentComponentUnit } from '../../common/types/models/agent'; | ||
|
||
import type { Agent, NewPackagePolicy, PackageInfo, PackagePolicy } from '.'; | ||
import type { PackagePolicyValidationResults } from '../services'; | ||
|
||
import type { | ||
Agent, | ||
AgentPolicy, | ||
NewPackagePolicy, | ||
PackageInfo, | ||
PackagePolicy, | ||
RegistryPolicyTemplate, | ||
} from '.'; | ||
|
||
/** Register a Fleet UI extension */ | ||
export type UIExtensionRegistrationCallback = (extensionPoint: UIExtensionPoint) => void; | ||
|
@@ -20,6 +29,23 @@ export interface UIExtensionsStorage { | |
[key: string]: Partial<Record<UIExtensionPoint['view'], UIExtensionPoint>>; | ||
} | ||
|
||
/** | ||
* UI Component Extension is used to replace the Define Step on | ||
* the pages displaying the ability to edit/create an Integration Policy | ||
*/ | ||
export type PackagePolicyReplaceDefineStepExtensionComponent = | ||
ComponentType<PackagePolicyReplaceDefineStepExtensionComponentProps>; | ||
|
||
export type PackagePolicyReplaceDefineStepExtensionComponentProps = ( | ||
| (PackagePolicyEditExtensionComponentProps & { isEditPage: true }) | ||
| (PackagePolicyCreateExtensionComponentProps & { isEditPage: false }) | ||
) & { | ||
validationResults?: PackagePolicyValidationResults; | ||
agentPolicy?: AgentPolicy; | ||
packageInfo: PackageInfo; | ||
integrationInfo?: RegistryPolicyTemplate; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this extension replaces the first step entirely, and it slightly differs between the added props are from the actual props |
||
|
||
/** | ||
* UI Component Extension is used on the pages displaying the ability to edit an | ||
* Integration Policy | ||
|
@@ -73,6 +99,12 @@ export interface PackageGenericErrorsListProps { | |
packageErrors: FleetServerAgentComponentUnit[]; | ||
} | ||
|
||
export interface PackagePolicyReplaceDefineStepExtension { | ||
package: string; | ||
view: 'package-policy-replace-define-step'; | ||
Component: LazyExoticComponent<PackagePolicyReplaceDefineStepExtensionComponent>; | ||
} | ||
|
||
/** Extension point registration contract for Integration Policy Edit views */ | ||
export interface PackagePolicyEditExtension { | ||
package: string; | ||
|
@@ -184,6 +216,7 @@ export interface AgentEnrollmentFlyoutFinalStepExtension { | |
|
||
/** Fleet UI Extension Point */ | ||
export type UIExtensionPoint = | ||
| PackagePolicyReplaceDefineStepExtension | ||
| PackagePolicyEditExtension | ||
| PackagePolicyResponseExtension | ||
| PackagePolicyEditTabsExtension | ||
|
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 logging here is good enough, we could add
useUIExtensions
which would be typed to not allow this combinationThere 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.
Yeah I think
useUIExtensions
or adding an overload touseUIExtension
that takes an array of extensions would be the path forward here. Agree that logging is not enough to prevent this, as we should prevent it entirely at compile time.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.
@kpollich
thought about this again and i believe we shouldn't overload
useUIExtension
, because:registerExtension
take an array and type-check against invalid combinations, and run a full sweep on other plugins, which would somewhat mitigate possible future risk of misuselet me know what you think is best here/follow ups:
registerExtension
thanks!
also note i'd still want to merge #149137 as soon as we can because there are other PRs depending on it
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.
Following up on our chat offline:
Let's just
throw
an error when we encounter this case. This should result in the Fleet UI's error boundary being displayed and should catch the "incompatible UI extension" state during development. I don't want to silently ignore a UI extension with a browser console log/warning because it will be non-obvious to someone developing in this situation.Thanks for investigating here and following 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 this with some test updates that were needed