Skip to content

Commit 36ea34c

Browse files
rhamiltoclaude
andcommitted
CONSOLE-4447: Address code review feedback for OLM modals
- Use unique form IDs with useId() in ResourceRequirementsModal to prevent ID collisions when multiple modal instances mount - Prevent modal dismissal during async operations in UninstallOperatorModal by disabling onClose when operations are in progress - Remove redundant onClick handlers from submit buttons in disable-default-source-modal and edit-default-sources-modal - Simplify Radio onChange handlers in installplan-approval-modal to use closures with known constant values instead of reading e.target.value - Remove duplicate InfoCircleIcon from operator-hub-community-provider-modal since titleIconVariant="info" already displays the icon Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 16ae1fc commit 36ea34c

8 files changed

Lines changed: 33 additions & 56 deletions

File tree

frontend/packages/operator-lifecycle-manager/locales/en/olm.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
"Manual update approval is required when not installing the latest version for the selected channel.": "Manual update approval is required when not installing the latest version for the selected channel.",
258258
"Show community Operator": "Show community Operator",
259259
"Community Operators are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.": "Community Operators are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.",
260-
"Learn more about Red Hats third party software support policy": "Learn more about Red Hats third party software support policy",
260+
"Learn more about Red Hat's third party software support policy": "Learn more about Red Hat's third party software support policy",
261261
"Do not show this warning again": "Do not show this warning again",
262262
"Continue": "Continue",
263263
"OperatorHub details": "OperatorHub details",
@@ -278,6 +278,7 @@
278278
"This Operator is being installed on the cluster.": "This Operator is being installed on the cluster.",
279279
"Community Operator": "Community Operator",
280280
"This is a community provided Operator. These are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.": "This is a community provided Operator. These are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.",
281+
"Learn more about Red Hat’s third party software support policy": "Learn more about Red Hat’s third party software support policy",
281282
"Cluster in STS Mode": "Cluster in STS Mode",
282283
"This cluster is using AWS Security Token Service to reach the cloud API. In order for this operator to take the actions it requires directly with the cloud API, you must provide a role ARN (with an attached policy) during installation. Please see the operator description for more details.": "This cluster is using AWS Security Token Service to reach the cloud API. In order for this operator to take the actions it requires directly with the cloud API, you must provide a role ARN (with an attached policy) during installation. Please see the operator description for more details.",
283284
"Cluster in Azure Workload Identity / Federated Identity Mode": "Cluster in Azure Workload Identity / Federated Identity Mode",

frontend/packages/operator-lifecycle-manager/src/components/descriptors/spec/resource-requirements.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC } from 'react';
2-
import { useState } from 'react';
2+
import { useState, useId } from 'react';
33
import {
44
Button,
55
Form,
@@ -97,6 +97,7 @@ export const ResourceRequirementsModal = (props: ResourceRequirementsModalProps)
9797
const [storage, setStorage] = useState<string>(
9898
_.get(obj.spec, `${path}.${type}.ephemeral-storage`, ''),
9999
);
100+
const formId = useId();
100101

101102
const submit = (e) => {
102103
e.preventDefault();
@@ -116,7 +117,7 @@ export const ResourceRequirementsModal = (props: ResourceRequirementsModalProps)
116117
<>
117118
<ModalHeader title={props.title} data-test-id="modal-title" />
118119
<ModalBody>
119-
<Form id="resource-requirements-form" onSubmit={(e) => submit(e)}>
120+
<Form id={formId} onSubmit={(e) => submit(e)}>
120121
<Grid hasGutter>
121122
<GridItem>{props.description}</GridItem>
122123
<ResourceRequirements
@@ -135,7 +136,7 @@ export const ResourceRequirementsModal = (props: ResourceRequirementsModalProps)
135136
<Button
136137
type="submit"
137138
variant="primary"
138-
form="resource-requirements-form"
139+
form={formId}
139140
isLoading={inProgress}
140141
isDisabled={inProgress}
141142
data-test="confirm-action"

frontend/packages/operator-lifecycle-manager/src/components/modals/disable-default-source-modal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const DisableDefaultSourceModal: FC<DisableDefaultSourceModalProps> = ({
6464
<Button
6565
type="submit"
6666
variant="danger"
67-
onClick={submit}
6867
form="disable-default-source-form"
6968
isLoading={inProgress}
7069
isDisabled={inProgress}

frontend/packages/operator-lifecycle-manager/src/components/modals/edit-default-sources-modal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ const EditDefaultSourcesModal: FC<EditDefaultSourcesModalProps> = ({
107107
<Button
108108
type="submit"
109109
variant="primary"
110-
onClick={submit}
111110
form="edit-default-sources-form"
112111
isLoading={inProgress}
113112
isDisabled={inProgress}

frontend/packages/operator-lifecycle-manager/src/components/modals/installplan-approval-modal.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export const InstallPlanApprovalModal: FC<InstallPlanApprovalModalProps> = ({
7070
value={InstallPlanApproval.Automatic}
7171
label={`${t(`olm~Automatic`)} (${t('public~default')})`}
7272
description={t('olm~New updates will be installed as soon as they become available.')}
73-
onChange={(e) =>
74-
setSelectedApprovalStrategy(
75-
(e.target as HTMLInputElement).value as InstallPlanApproval,
76-
)
77-
}
73+
onChange={() => setSelectedApprovalStrategy(InstallPlanApproval.Automatic)}
7874
isChecked={selectedApprovalStrategy === InstallPlanApproval.Automatic}
7975
data-checked-state={selectedApprovalStrategy === InstallPlanApproval.Automatic}
8076
/>
@@ -86,11 +82,7 @@ export const InstallPlanApprovalModal: FC<InstallPlanApprovalModalProps> = ({
8682
description={t(
8783
'olm~New updates need to be manually approved before installation begins.',
8884
)}
89-
onChange={(e) =>
90-
setSelectedApprovalStrategy(
91-
(e.target as HTMLInputElement).value as InstallPlanApproval,
92-
)
93-
}
85+
onChange={() => setSelectedApprovalStrategy(InstallPlanApproval.Manual)}
9486
isChecked={selectedApprovalStrategy === InstallPlanApproval.Manual}
9587
data-checked-state={selectedApprovalStrategy === InstallPlanApproval.Manual}
9688
/>

frontend/packages/operator-lifecycle-manager/src/components/modals/uninstall-operator-modal.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export const UninstallOperatorModal: FC<UninstallOperatorModalProps> = ({
383383
);
384384

385385
return (
386-
<>
386+
<Modal variant={ModalVariant.small} isOpen onClose={isSubmitInProgress ? undefined : close}>
387387
<ModalHeader
388388
title={t('olm~Uninstall Operator?')}
389389
titleIconVariant="warning"
@@ -445,7 +445,7 @@ export const UninstallOperatorModal: FC<UninstallOperatorModalProps> = ({
445445
{t('public~Cancel')}
446446
</Button>
447447
</ModalFooterWithAlerts>
448-
</>
448+
</Modal>
449449
);
450450
};
451451

@@ -664,9 +664,7 @@ export const UninstallOperatorModalOverlay: OverlayComponent<UninstallOperatorMo
664664
props,
665665
) => {
666666
return (
667-
<Modal variant={ModalVariant.small} isOpen onClose={props.closeOverlay}>
668-
<UninstallOperatorModal {...props} close={props.closeOverlay} cancel={props.closeOverlay} />
669-
</Modal>
667+
<UninstallOperatorModal {...props} close={props.closeOverlay} cancel={props.closeOverlay} />
670668
);
671669
};
672670

frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-community-provider-modal.tsx

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ import {
66
Content,
77
ContentVariants,
88
Form,
9-
Icon,
109
Modal,
1110
ModalBody,
1211
ModalFooter,
1312
ModalHeader,
1413
ModalVariant,
15-
Split,
16-
SplitItem,
1714
} from '@patternfly/react-core';
18-
import { InfoCircleIcon } from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
1915
import { useTranslation } from 'react-i18next';
2016
import type { OverlayComponent } from '@console/dynamic-plugin-sdk/src/app/modal-support/OverlayProvider';
2117
import type { ModalComponentProps } from '@console/internal/components/factory/modal';
@@ -47,36 +43,27 @@ export const OperatorHubCommunityProviderModal: FC<OperatorHubCommunityProviderM
4743
/>
4844
<ModalBody>
4945
<Form id="community-provider-form" onSubmit={submit}>
50-
<Split hasGutter>
51-
<SplitItem>
52-
<Icon size="xl" status="info">
53-
<InfoCircleIcon />
54-
</Icon>
55-
</SplitItem>
56-
<SplitItem>
57-
<Content component={ContentVariants.p}>
58-
{t(
59-
'olm~Community Operators are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.',
60-
)}
61-
</Content>
62-
{RH_OPERATOR_SUPPORT_POLICY_LINK && (
63-
<Content component={ContentVariants.p}>
64-
<ExternalLink
65-
href={RH_OPERATOR_SUPPORT_POLICY_LINK}
66-
text={t("olm~Learn more about Red Hat's third party software support policy")}
67-
/>
68-
</Content>
69-
)}
70-
<Checkbox
71-
className="co-modal-ignore-warning__checkbox"
72-
onChange={(_event, value) => setIgnoreWarnings(value)}
73-
isChecked={ignoreWarnings}
74-
data-checked-state={ignoreWarnings}
75-
id="do-not-show-warning"
76-
label={t('olm~Do not show this warning again')}
46+
<Content component={ContentVariants.p}>
47+
{t(
48+
'olm~Community Operators are Operators which have not been vetted or verified by Red Hat. Community Operators should be used with caution because their stability is unknown. Red Hat provides no support for community Operators.',
49+
)}
50+
</Content>
51+
{RH_OPERATOR_SUPPORT_POLICY_LINK && (
52+
<Content component={ContentVariants.p}>
53+
<ExternalLink
54+
href={RH_OPERATOR_SUPPORT_POLICY_LINK}
55+
text={t("olm~Learn more about Red Hat's third party software support policy")}
7756
/>
78-
</SplitItem>
79-
</Split>
57+
</Content>
58+
)}
59+
<Checkbox
60+
className="co-modal-ignore-warning__checkbox"
61+
onChange={(_event, value) => setIgnoreWarnings(value)}
62+
isChecked={ignoreWarnings}
63+
data-checked-state={ignoreWarnings}
64+
id="do-not-show-warning"
65+
label={t('olm~Do not show this warning again')}
66+
/>
8067
</Form>
8168
</ModalBody>
8269
<ModalFooter>

frontend/public/locales/en/public.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,6 @@
18021802
"Disable": "Disable",
18031803
"Disabled": "Disabled",
18041804
"Enabled": "Enabled",
1805-
"Select service account": "Select service account",
18061805
"Failed to load kubecontrollermanager": "Failed to load kubecontrollermanager",
18071806
"Failed to parse cloud provider config {{cm}}": "Failed to parse cloud provider config {{cm}}",
18081807
"The following content was expected to be defined in the configMap: {{ expectedValues }}": "The following content was expected to be defined in the configMap: {{ expectedValues }}",
@@ -1811,5 +1810,6 @@
18111810
"Failed to patch cloud provider config": "Failed to patch cloud provider config",
18121811
"Failed to add taint to nodes": "Failed to add taint to nodes",
18131812
"Failed to patch infrastructure spec": "Failed to patch infrastructure spec",
1814-
"Unexpected error": "Unexpected error"
1813+
"Unexpected error": "Unexpected error",
1814+
"Select service account": "Select service account"
18151815
}

0 commit comments

Comments
 (0)