-
Notifications
You must be signed in to change notification settings - Fork 657
CONSOLE-4697: Enable strickNullCheck for /console-app/components/resource-quota | quick-starts | tour | tabs | vpa | storage #15418
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?
Conversation
@krishagarwal278: This pull request references CONSOLE-4697 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.20.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/label docs-approved |
/retest |
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.
Nice work so far!: 👍
I did a first pass, and added comments. Let me know if you have any questions.
@@ -169,7 +169,7 @@ const QuickStartConfiguration: React.FC<{ readonly: boolean }> = ({ readonly }) | |||
/> | |||
|
|||
<LoadError error={consoleConfigError} /> | |||
<SaveStatus {...saveStatus} /> | |||
<SaveStatus {...(saveStatus as SaveStatusProps)} /> |
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 think we can avoid the use of as
here by first checking for saveStatus
. The type assertions with as
should be last resort solutions, not quick fixes for type errors.
{saveStatus && <SaveStatus {...saveStatus} />}
@@ -40,7 +40,7 @@ const QUICKSTART_REDUX_STATE_LOCAL_STORAGE_KEY = 'bridge/quick-start-redux-state | |||
|
|||
const getInitialState = () => | |||
localStorage.getItem(QUICKSTART_REDUX_STATE_LOCAL_STORAGE_KEY) | |||
? JSON.parse(localStorage.getItem(QUICKSTART_REDUX_STATE_LOCAL_STORAGE_KEY)) | |||
? JSON.parse(localStorage.getItem(QUICKSTART_REDUX_STATE_LOCAL_STORAGE_KEY) || '{}') |
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.
How about we refactor this to be a bit cleaner?
const getInitialState = () => {
const stored = localStorage.getItem(QUICKSTART_REDUX_STATE_LOCAL_STORAGE_KEY);
return stored ? JSON.parse(stored) : {};
};
@@ -117,5 +117,5 @@ export const useQuickStarts = (filterDisabledQuickStarts = true): WatchK8sResult | |||
); | |||
}, [quickStarts, quickStartsLoaded, filterDisabledQuickStarts, preferredLanguage]); | |||
|
|||
return [bestMatchQuickStarts, quickStartsLoaded, quickStartsError]; | |||
return [bestMatchQuickStarts as QuickStart[], quickStartsLoaded, quickStartsError]; |
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 getBestMatch
function's null return type is forcing us to use a type assertion as
. While we could remove the null return type to fix this, I'm unsure about the potential impact on other parts of the codebase where it's used.
IMO, I think it's better to filter out the null values after the map
function, since the useQuickStarts
hook doesn't have a corresponding null return type. Something like:
.filter((quickStart) => quickStart !== null);
const nsUsed = nsQuotas.status.used?.[resourceName]; | ||
const clusterUsage = getUsedPercentage(clusterHard, clusterUsed); | ||
const clusterHard = appliedClusterResourceQuota.status?.total?.hard?.[resourceName || '']; | ||
const clusterUsed = appliedClusterResourceQuota.status?.total?.used?.[resourceName || '']; |
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 am unsure of the need for empty strings ''
here. Was this done to fix other type issue? I ask because removing it doesn't seem to cause an error when "strictNullChecks": true
is enabled.
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.
yeah i tried another fix.
const clusterHard = clusterResourceQuota.status?.total?.hard?.[resourceName];
const clusterUsed = clusterResourceQuota.status?.total?.used?.[resourceName];
const { label, percent } = getLabelAndUsage({
resourceName,
used: clusterUsed ?? '',
hard: clusterHard ?? '',
const clusterHard = clusterResourceQuota.status.total.hard[resourceName]; | ||
const clusterUsed = clusterResourceQuota.status.total.used?.[resourceName]; | ||
const clusterHard = clusterResourceQuota.status?.total?.hard?.[resourceName || '']; | ||
const clusterUsed = clusterResourceQuota.status?.total?.used?.[resourceName || '']; |
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 as above.
const hard = resourceQuota.status.hard[resourceName]; | ||
const used = resourceQuota.status.used?.[resourceName]; | ||
const hard = resourceQuota.status?.hard?.[resourceName || '']; | ||
const used = resourceQuota.status?.used?.[resourceName || '']; |
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 as above.
@@ -32,7 +32,7 @@ const GuidedTour: React.FC = () => { | |||
backButtonText={t('console-app~Back')} | |||
/> | |||
); | |||
const step = steps[stepNumber - 1]; | |||
const step = steps?.[(stepNumber || 0) - 1]; |
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 prevent potential issues with negative values, could we assign a default value to stepNumber
before this block? This would ensure the if (startTour || stepNumber === 0) {
check runs first.
onClick: () => { | ||
onBack && onBack(); | ||
}, | ||
}} | ||
step={step} | ||
> | ||
{showStepBadge ? <StepBadge stepNumber={step} totalSteps={totalSteps} /> : null} | ||
{showStepBadge ? <StepBadge stepNumber={step || 0} totalSteps={totalSteps || 0} /> : null} |
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 default alternative mentioned above might work here as well.
/retest |
Local tsc check passed against the files in pr code. |
96f9a02
to
af7ce6c
Compare
af7ce6c
to
328ac59
Compare
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 work looks good👍, although I added a nit.
Thank you.😁
/lgtm
onClick: () => { | ||
onBack && onBack(); | ||
}, | ||
}} | ||
step={step} | ||
> | ||
{showStepBadge ? <StepBadge stepNumber={step} totalSteps={totalSteps} /> : null} | ||
{showStepBadge ? <StepBadge stepNumber={step ?? 0} totalSteps={totalSteps ?? 0} /> : null} |
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.
nit: The props default values might be cleaner than Nullish Coalescing Operator.
@krishagarwal278 Could you squash the commits? |
/label tide/merge-method-squash |
/lgtm |
/label acknowledge-critical-fixes-only |
/test frontend |
Checked the pr again, there is not regression issue now. |
@krishagarwal278: This pull request references CONSOLE-4697 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.20.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
2 similar comments
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cajieh, krishagarwal278 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 |
1 similar comment
@krishagarwal278: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
/hold Revision d3f5043 was retested 3 times: holding |
Fixed SNC errors in storage, resource-quota, quick-starts, tour, tab, vpa