-
Notifications
You must be signed in to change notification settings - Fork 659
CONSOLE-4693: Enable strickNullCheck for packages/console-app/src/components/console-operator | dashboards-page | detect-namespace #15400
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
032c903
3cf5241
fa0c722
a46ab09
40a773a
775c7ec
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ const ConsolePluginEnabledStatusDetail: React.FC<DetailsItemComponentProps> = ({ | |
|
||
const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName), [ | ||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName ?? ''), [ | ||
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. The same as stated previously. |
||
pluginStore, | ||
pluginName, | ||
]); | ||
|
@@ -25,11 +25,11 @@ const ConsolePluginEnabledStatusDetail: React.FC<DetailsItemComponentProps> = ({ | |
|
||
return consoleOperatorConfigLoaded ? ( | ||
<ConsolePluginEnabledStatus | ||
pluginName={pluginName} | ||
pluginName={pluginName ?? ''} | ||
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. The same as stated previously. |
||
enabled={ | ||
developmentMode | ||
? (isLoadedDynamicPluginInfo(pluginInfo) && pluginInfo.enabled) ?? false | ||
: enabledPlugins.includes(pluginName) ?? false | ||
: enabledPlugins.includes(pluginName ?? '') ?? false | ||
} | ||
/> | ||
) : ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ export const ConsolePluginManifestPage: React.FC<PageComponentProps> = ({ obj }) | |
const pluginStore = usePluginStore(); | ||
const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
||
const pluginManifest = React.useMemo(() => pluginStore.getDynamicPluginManifest(pluginName), [ | ||
pluginStore, | ||
pluginName, | ||
]); | ||
const pluginManifest = React.useMemo( | ||
() => pluginStore.getDynamicPluginManifest(pluginName ?? ''), | ||
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. The same as stated previously. |
||
[pluginStore, pluginName], | ||
); | ||
|
||
return ( | ||
<PaneBody> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ const ConsolePluginStatusDetail: React.FC<DetailsItemComponentProps> = ({ obj }) | |
const pluginStore = usePluginStore(); | ||
const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName), [ | ||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName ?? ''), [ | ||
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. The same as stated previously. |
||
pluginStore, | ||
pluginName, | ||
]); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ const ConsolePluginVersionDetail: React.FC<DetailsItemComponentProps> = ({ obj } | |
const pluginStore = usePluginStore(); | ||
const pluginName = React.useMemo(() => obj?.metadata?.name, [obj?.metadata?.name]); | ||
|
||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName), [ | ||
const pluginInfo = React.useMemo(() => pluginStore.findDynamicPluginInfo(pluginName ?? ''), [ | ||
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. The same as stated previously. |
||
pluginStore, | ||
pluginName, | ||
]); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const ClusterOperatorStatusRow: React.FC<OperatorRowProps<ClusterOperator>> = ({ | |
<Status value={operatorStatus.status.title} icon={operatorStatus.status.icon}> | ||
<ResourceLink | ||
kind={referenceForModel(ClusterOperatorModel)} | ||
name={operatorStatus.operators[0].metadata.name} | ||
name={operatorStatus.operators[0]?.metadata?.name ?? ''} | ||
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. Could be fine without a fallback value. |
||
hideIcon | ||
className="co-status-popup__title" | ||
/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,13 @@ export const augmentExtension = <E extends Extension>( | |
}); | ||
|
||
export const isExtensionInUse = (e: Extension, flags: FlagsObject): boolean => | ||
e.flags.required.every((f) => flags[f]) && e.flags.disallowed.every((f) => !flags[f]); | ||
(e.flags?.required?.every((f) => flags[f]) ?? true) && | ||
(e.flags?.disallowed?.every((f) => !flags[f]) ?? true); | ||
|
||
export const getGatingFlagNames = (extensions: Extension[]): string[] => | ||
_.uniq([ | ||
..._.flatMap(extensions.map((e) => e.flags.required)), | ||
..._.flatMap(extensions.map((e) => e.flags.disallowed)), | ||
..._.flatMap(extensions.map((e) => e.flags?.required ?? [])), | ||
..._.flatMap(extensions.map((e) => e.flags?.disallowed ?? [])), | ||
]); | ||
|
||
export const isLoadedDynamicPluginInfo = (i: DynamicPluginInfo): i is LoadedDynamicPluginInfo => | ||
|
@@ -203,7 +204,7 @@ export class PluginStore { | |
|
||
const plugin = this.loadedDynamicPlugins.get(pluginID); | ||
|
||
if (plugin.enabled !== enabled) { | ||
if (plugin && plugin.enabled !== enabled) { | ||
plugin.enabled = enabled; | ||
|
||
this.updateExtensions(); | ||
|
@@ -213,13 +214,13 @@ export class PluginStore { | |
} | ||
} | ||
|
||
private getLoadedDynamicPlugin(pluginName: string) { | ||
private getLoadedDynamicPlugin(pluginName?: string) { | ||
return Array.from(this.loadedDynamicPlugins.values()).find( | ||
(plugin) => plugin.manifest.name === pluginName, | ||
); | ||
} | ||
|
||
private isDynamicPluginLoaded(pluginName: string) { | ||
private isDynamicPluginLoaded(pluginName?: string) { | ||
return this.getLoadedDynamicPlugin(pluginName) !== undefined; | ||
} | ||
|
||
|
@@ -306,15 +307,15 @@ export class PluginStore { | |
return [...loadedPluginEntries, ...failedPluginEntries, ...pendingPluginEntries]; | ||
} | ||
|
||
findDynamicPluginInfo(pluginName: string): DynamicPluginInfo { | ||
findDynamicPluginInfo(pluginName?: string): DynamicPluginInfo | undefined { | ||
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. I think this is a good use case for a union type to fix the SNC error, since the |
||
return this.getDynamicPluginInfo().find((entry) => | ||
isLoadedDynamicPluginInfo(entry) | ||
? entry.metadata.name === pluginName | ||
: entry.pluginName === pluginName, | ||
); | ||
} | ||
|
||
getDynamicPluginManifest(pluginName: string): DynamicPluginManifest { | ||
getDynamicPluginManifest(pluginName?: string): DynamicPluginManifest | undefined { | ||
return this.getLoadedDynamicPlugin(pluginName)?.manifest; | ||
} | ||
|
||
|
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.
Does this still throw an SNC error after making
plugin.metadata.name
optional?