-
Notifications
You must be signed in to change notification settings - Fork 605
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
add dynamic sdk support for topology extensions #9055
add dynamic sdk support for topology extensions #9055
Conversation
/retest |
9ea76ea
to
29a39e2
Compare
const componentFactoryExtensions = useExtensions<TopologyComponentFactory>( | ||
isTopologyComponentFactory, | ||
); | ||
const [dynamicComponentFactoryExtensions, isFactoryComponentsResolved] = useResolvedExtensions< | ||
DynamicTopologyComponentFactory | ||
>(isDynamicTopologyComponentFactory); |
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 we move away from useExtensions
for the old extension and make use of useResolvedExtensions
?
Then combine the results two variables: one for the resolved state and one for an array of factories.
This way it'll be two code paths for setup but consumption will be simple.
.catch(() => {}); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [componentFactoriesPromises, isFactoryComponentsResolved]); | ||
|
||
React.useEffect(() => { | ||
if (componentFactoriesPromises.length && !componentFactories.length) { |
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.
Since you've separated the static and dynamic extensions into different variables, this check is no longer valid as it only applies to one.
See other comment about using useResolvedExtensions
for both static and dynamic plugins.
const modelFactories = useExtensions<TopologyDataModelFactory>(isTopologyDataModelFactory); | ||
const [dynamicModelFactories, isModelResolved] = useResolvedExtensions< | ||
DynamicTopologyDataModelFactory | ||
>(isDynamicTopologyDataModelFactory); |
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 both paths use useResolvedExtensions
so that we don't have one path doing manual resolution.
const modelFactories = useExtensions<TopologyDataModelFactory>(isTopologyDataModelFactory); | ||
const [dynamicModelFactories] = useResolvedExtensions<DynamicTopologyDataModelFactory>( | ||
isDynamicTopologyDataModelFactory, | ||
); |
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 we update the static extension to make use of CodeRef
then simplified the resolution with useResolvedExtensions
We probably don't want to render the firehose component until all extensions have been resolved.
@christianvogt modified extensions, now consuming all with |
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.
@@ -35,3 +36,14 @@ export const applyHelmDisplayOptions = (model: Model, filters: DisplayFilters): | |||
}; | |||
|
|||
export const applyDisplayOptions = () => applyHelmDisplayOptions; | |||
|
|||
export const getHelmWatchedResources = (namespace: string): WatchK8sResources<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.
Why was this moved to a filters module?
@@ -19,3 +22,16 @@ export const getCreateConnector = (createHints: string[], source: Node, target: | |||
} | |||
return null; | |||
}; | |||
|
|||
export const getRhoasWatchedResources = ( |
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.
Moving to createConnector
doesn't seem like a logical home.
@@ -35,3 +39,25 @@ export const applyOperatorDisplayOptions = (model: Model, filters: DisplayFilter | |||
}; | |||
|
|||
export const applyDisplayOptions = () => applyOperatorDisplayOptions; | |||
|
|||
export const getOperatorWatchedResources = (namespace: string): WatchK8sResources<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.
Same comment about location.
@glekner the latest changes fixed the missing visuals. One outstanding issue remains. Flashing of the old value when switching from one namespace to another. |
hey again, |
/test e2e-gcp-console |
/retest |
/cc @rohitkrai03 |
/retest |
@@ -88,7 +88,7 @@ export const isTopologyCreateConnector = (e: Extension): e is TopologyCreateConn | |||
export const isTopologyDataModelFactory = (e: Extension): e is TopologyDataModelFactory => | |||
e.type === 'console.topology/data/factory'; | |||
|
|||
export const isTopologyDisplayFilters = (e: Extension): e is TopologyDisplayFilters => | |||
export const isTopologyDisplayFilter = (e: Extension): e is TopologyDisplayFilters => |
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 this change?
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.
to match the static extension
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.
Okay, I guess it was a typo in the static extensions. But we can keep it like this for now.
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 suggest changing the old static one instead of the new. That being said we will end up revisiting these extensiioons.
@@ -56,7 +69,9 @@ const ApplicationDropdown: React.FC<ApplicationDropdownProps> = ({ namespace, .. | |||
...watchedBaseResources[key], | |||
prop: key, | |||
})); | |||
}, [modelFactories, namespace]); | |||
|
|||
return []; |
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 this needed? Its unreachable.
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, removed
@@ -39,7 +39,7 @@ export type TopologyDataModelFactory = ExtensionDeclaration< | |||
/** Priority for the factory */ | |||
priority: number; | |||
/** Resources to be fetched from useK8sWatchResources hook. */ | |||
resources?: CodeRef<(namespace: string) => WatchK8sResources<any>>; | |||
resources?: WatchK8sResources<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.
Do we not need namespaced resources 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.
since you cant set a function without a CodeRef, i'm building the namespaced resources here
https://github.com/openshift/console/pull/9055/files#diff-281f5462e39247e7a7894ee5ad688563cf18b46d97e7707da0b660b79c236f41R17
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.
So why not make it a coderef?
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 talked to @glekner about this too. I don't see an issue with this change unless the extension wants to hard code a namespace. In which case we can make sure to not set the namespace if one is already provided.
I don't think we have such a use case at this time that will be negatively affected by this.
Note that we still need to review the topology extensions for their exposed API and at that time may change things.
827c8f3
to
70a6fb9
Compare
/retest |
/test e2e-gcp-console |
5fafe6b
to
6f5f9f9
Compare
/test frontend |
/test e2e-gcp-console |
/retest |
/test kubevirt-plugin |
1 similar comment
/test kubevirt-plugin |
/retest |
@@ -88,7 +88,7 @@ export const isTopologyCreateConnector = (e: Extension): e is TopologyCreateConn | |||
export const isTopologyDataModelFactory = (e: Extension): e is TopologyDataModelFactory => | |||
e.type === 'console.topology/data/factory'; | |||
|
|||
export const isTopologyDisplayFilters = (e: Extension): e is TopologyDisplayFilters => | |||
export const isTopologyDisplayFilter = (e: Extension): e is TopologyDisplayFilters => |
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 suggest changing the old static one instead of the new. That being said we will end up revisiting these extensiioons.
Object.assign( | ||
{}, | ||
...Object.entries(properties.resources).map(([k, v]) => ({ | ||
[k]: { ...v, namespace: ns }, |
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 should probably accept the namespace provided before overriding? Not sure we have a use case for this yet but if an extension wanted to pull resources from a specific namespace we'd have to do:
[k]: { ...v, namespace: ns }, | |
[k]: { namespace: ns, ...v }, |
/assign @rohitkrai03 |
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: glekner, rohitkrai03 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.