-
Notifications
You must be signed in to change notification settings - Fork 666
CONSOLE-3769: More openshift/dynamic-plugin-sdk prep work #15738
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
Changes from all commits
98c6cb4
dbffeb7
3ab883f
b9d20b0
648d381
7475969
4087fcb
ea8f8e2
ece51f7
4babc26
f36db8f
d0c0da1
2b444de
86835a7
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 |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import * as React from 'react'; | ||
| import { DASH } from '@console/dynamic-plugin-sdk/src/app/constants'; | ||
| import { DetailsItemComponentProps } from '@console/dynamic-plugin-sdk/src/extensions/details-item'; | ||
| import { isLoadedDynamicPluginInfo } from '@console/plugin-sdk/src'; | ||
| import { usePluginInfo } from '@console/plugin-sdk/src/api/usePluginInfo'; | ||
| import { | ||
| ConsolePluginEnabledStatus, | ||
|
|
@@ -10,15 +9,15 @@ import { | |
| } from './ConsoleOperatorConfig'; | ||
|
|
||
| const ConsolePluginEnabledStatusDetail: React.FC<DetailsItemComponentProps> = ({ obj }) => { | ||
| const [pluginInfoEntries] = usePluginInfo(); | ||
| const pluginInfoEntries = usePluginInfo(); | ||
| const { consoleOperatorConfig, consoleOperatorConfigLoaded } = useConsoleOperatorConfigData(); | ||
|
|
||
| const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
|
||
| const pluginInfo = React.useMemo( | ||
| () => | ||
| pluginInfoEntries.find((entry) => | ||
| isLoadedDynamicPluginInfo(entry) | ||
| entry.status === 'loaded' | ||
| ? entry.metadata.name === pluginName | ||
| : entry.pluginName === pluginName, | ||
| ), | ||
|
|
@@ -28,12 +27,12 @@ const ConsolePluginEnabledStatusDetail: React.FC<DetailsItemComponentProps> = ({ | |
| consoleOperatorConfig?.spec?.plugins, | ||
| ]); | ||
|
|
||
| return consoleOperatorConfigLoaded ? ( | ||
| return consoleOperatorConfigLoaded && pluginName ? ( | ||
|
Contributor
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. All k8s objects should have a name, do we really need to check up on
Member
Author
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. We have null checks for |
||
| <ConsolePluginEnabledStatus | ||
| pluginName={pluginName} | ||
| enabled={ | ||
| developmentMode | ||
| ? (isLoadedDynamicPluginInfo(pluginInfo) && pluginInfo.enabled) ?? false | ||
| ? (pluginInfo?.status === 'loaded' && pluginInfo.enabled) ?? false | ||
| : enabledPlugins.includes(pluginName) ?? false | ||
| } | ||
| /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,24 @@ | ||
| import * as React from 'react'; | ||
| import { DetailsItemComponentProps } from '@console/dynamic-plugin-sdk/src/extensions/details-item'; | ||
| import { isLoadedDynamicPluginInfo } from '@console/plugin-sdk/src'; | ||
| import { usePluginInfo } from '@console/plugin-sdk/src/api/usePluginInfo'; | ||
| import { DASH } from '@console/shared/src/constants'; | ||
|
|
||
| const ConsolePluginVersionDetail: React.FC<DetailsItemComponentProps> = ({ obj }) => { | ||
| const [pluginInfoEntries] = usePluginInfo(); | ||
| const pluginInfoEntries = usePluginInfo(); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
|
||
| const pluginInfo = React.useMemo( | ||
| () => | ||
| pluginInfoEntries.find((entry) => | ||
| isLoadedDynamicPluginInfo(entry) | ||
| entry.status === 'loaded' | ||
| ? entry.metadata.name === pluginName | ||
| : entry.pluginName === pluginName, | ||
| ), | ||
| [pluginInfoEntries, pluginName], | ||
| ); | ||
|
|
||
| return isLoadedDynamicPluginInfo(pluginInfo) ? <>{pluginInfo.metadata.version}</> : <>{DASH}</>; | ||
| return pluginInfo?.status === 'loaded' ? <>{pluginInfo.metadata.version}</> : <>{DASH}</>; | ||
| }; | ||
|
|
||
| export default ConsolePluginVersionDetail; | ||
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.
The
loadedprop value comes fromusePluginInfohook's second tuple elementwhich is
trueonce all Console plugins have finished loading, i.e. there are no plugins in "pending" state.So currently
<ConsolePluginsTable>renders a loading state until all plugins are done loading.I think it makes more sense for
<ConsolePluginsTable>to render plugin information regardless of the plugin state so 👍 on this change.