console icon indicating copy to clipboard operation
console copied to clipboard

CONSOLE-4712: Remove PromiseComponent and convert its dependent components to functional components

Open krishagarwal278 opened this issue 1 month ago โ€ข 43 comments

Summary

Tech Debt

This PR aims to remove PromiseComponent and convert its dependent components to function components.

Checklist:

  • [X] Remove PromiseComponent and its test
  • [X] Convert its dependent components to function components using usePromiseHandler for promise action. Number of files/components: 8
  • [X] Components refactored(6/6): EditApplicationModal, MoveConnectionModal, DeleteResourceModal, ConfirmModal, ConfigureNamespacePullSecret, Environment
  • [X] Verified that usePromiseHandler hook provides the same promise handling behavior as the old PromiseComponent class

krishagarwal278 avatar Nov 20 '25 18:11 krishagarwal278

@krishagarwal278: This pull request references CONSOLE-4712 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 story to target the "4.21.0" version, but no target version was set.

In response to this:

Summary

Tech Debt

This PR aims to remove PromiseComponent and convert its dependent components to function components.

Checklist:

  • [X] Remove PromiseComponent and its test
  • [ ] Convert its dependent components to function components using usePromiseHandler for promise action. Number of files/components: 8
  • [X] Components refactored(5/6): EditApplicationModal, MoveConnectionModal, DeleteResourceModal, ConfirmModal, ConfigureNamespacePullSecret

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.

openshift-ci-robot avatar Nov 20 '25 18:11 openshift-ci-robot

Walkthrough

Converted several class-based PromiseComponent modals to functional components using usePromiseHandler; removed PromiseComponent and its tests; replaced legacy JSX Environment and namespace pull-secret modal with TypeScript implementations; updated dynamic import paths, i18n entries, and a Cypress test cleanup command.

Changes

Cohort / File(s) Summary
Modal component migrations (functional + hooks)
frontend/packages/console-shared/src/components/modals/DeleteResourceModal.tsx, frontend/packages/topology/src/components/modals/EditApplicationModal.tsx, frontend/packages/topology/src/components/modals/MoveConnectionModal.tsx, frontend/public/components/modals/confirm-modal.tsx
Replaced class components that extended PromiseComponent with functional React.FC components using usePromiseHandler. Removed per-component inProgress/errorMessage state and PromiseComponent base; moved submit handlers into component scope, wrapped async submits with the promise handler, updated prop access and Formik integrations, and adjusted i18n usage.
Configure namespace pull secret modal (deleted + added)
frontend/public/components/modals/configure-ns-pull-secret-modal.jsx (deleted), frontend/public/components/modals/configure-ns-pull-secret-modal.tsx (added)
Deleted legacy JSX modal and added a TypeScript modal implementing form/file-upload modes, JSON validation/preview, generateSecretData helper, base64 handling, Secret creation and ServiceAccount patching, async flow via promise handler, and a modal launcher export.
Environment page refactor / new module
frontend/public/components/environment.jsx (deleted), frontend/public/components/environment.tsx (added), frontend/public/components/__tests__/environment.spec.tsx
Removed the old JSX EnvironmentPage and introduced a TypeScript EnvironmentPage with CurrentEnvVars utilities, lazy-loaded NameValueEditor/EnvFromEditor wrappers, RBAC edit checks, on-demand ConfigMap/Secret loading, patch generation and create-payload logic, and corresponding test updates to the new rawEnvData shape and props.
PromiseComponent infra removal
frontend/public/components/utils/promise-component.tsx (deleted), frontend/public/components/utils/__tests__/promise-component.spec.tsx (deleted), frontend/public/components/utils/index.tsx
Deleted the PromiseComponent class and its state type, removed its unit tests, and removed the export * from './promise-component'; re-export from the utils barrel.
Lazy import path updates
frontend/public/components/build.tsx, frontend/public/components/daemon-set.tsx, frontend/public/components/deployment-config.tsx, frontend/public/components/deployment.tsx, frontend/public/components/pod.tsx, frontend/public/components/replicaset.jsx, frontend/public/components/replication-controller.jsx, frontend/public/components/stateful-set.tsx
Updated dynamic imports to load the environment module from ./environment (removed explicit .jsx extension) to match the new module file.
i18n changes
frontend/public/locales/en/public.json
Added "owners:" translation entry and removed two stale page-staleness entries.
Test / CI tweak
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts
Replaced cy.deleteProjectWithCLI(testName) with cy.exec(\oc delete project ${testName} --wait=false`)` in test cleanup.
Misc tests & small fixes
frontend/public/components/__tests__/pod.spec.tsx
Adjusted test selectors to use getAllByText and widened the time regex to accept alternate values; assertions otherwise unchanged.
Integration test view tweak
frontend/packages/integration-tests-cypress/views/secret.ts
Changed a dropdown item interaction to click({ force: true }) to ensure selection in the secrets UI test helper.

Estimated code review effort

๐ŸŽฏ 5 (Critical) | โฑ๏ธ ~120 minutes

  • Focus review on:
    • frontend/public/components/environment.tsx โ€” CurrentEnvVars transformations, patch generation (create vs update), RBAC checks, on-demand resource loading, and correctness of generated Kubernetes patches/payloads.
    • frontend/public/components/modals/configure-ns-pull-secret-modal.tsx โ€” generateSecretData correctness, base64 encoding, Secret object shape, and ServiceAccount patch semantics.
    • Modal migrations โ€” ensure usePromiseHandler reproduces previous PromiseComponent behavior (inProgress, errorMessage, rejection propagation) and Formik integration correctness.
    • Remove/replace occurrences of the deleted promise-component (imports, barrels, tests) to avoid dangling references.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 20 '25 18:11 coderabbitai[bot]

/jira refresh

krishagarwal278 avatar Nov 20 '25 18:11 krishagarwal278

@krishagarwal278: This pull request references CONSOLE-4712 which is a valid jira issue.

In response to this:

/jira refresh

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.

openshift-ci-robot avatar Nov 20 '25 18:11 openshift-ci-robot

@krishagarwal278: This pull request references CONSOLE-4712 which is a valid jira issue.

In response to this:

Summary

Tech Debt

This PR aims to remove PromiseComponent and convert its dependent components to function components.

Checklist:

  • [X] Remove PromiseComponent and its test
  • [X] Convert its dependent components to function components using usePromiseHandler for promise action. Number of files/components: 8
  • [X] Components refactored(6/6): EditApplicationModal, MoveConnectionModal, DeleteResourceModal, ConfirmModal, ConfigureNamespacePullSecret, Environment

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.

openshift-ci-robot avatar Nov 21 '25 00:11 openshift-ci-robot

@krishagarwal278: This pull request references CONSOLE-4712 which is a valid jira issue.

In response to this:

Summary

Tech Debt

This PR aims to remove PromiseComponent and convert its dependent components to function components.

Checklist:

  • [X] Remove PromiseComponent and its test
  • [X] Convert its dependent components to function components using usePromiseHandler for promise action. Number of files/components: 8
  • [X] Components refactored(6/6): EditApplicationModal, MoveConnectionModal, DeleteResourceModal, ConfirmModal, ConfigureNamespacePullSecret, Environment
  • [X] Verified locally as seen on shared cluster that all refactored components/modals are working as expected

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.

openshift-ci-robot avatar Nov 21 '25 00:11 openshift-ci-robot

@krishagarwal278: This pull request references CONSOLE-4712 which is a valid jira issue.

In response to this:

Summary

Tech Debt

This PR aims to remove PromiseComponent and convert its dependent components to function components.

Checklist:

  • [X] Remove PromiseComponent and its test
  • [X] Convert its dependent components to function components using usePromiseHandler for promise action. Number of files/components: 8
  • [X] Components refactored(6/6): EditApplicationModal, MoveConnectionModal, DeleteResourceModal, ConfirmModal, ConfigureNamespacePullSecret, Environment
  • [X] Verified that usePromiseHandler hook provides the same promise handling behavior as the old PromiseComponent class

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.

openshift-ci-robot avatar Nov 21 '25 00:11 openshift-ci-robot

/label px-approved /label docs-approved

logonoff avatar Nov 21 '25 18:11 logonoff

/retest

krishagarwal278 avatar Nov 25 '25 14:11 krishagarwal278

/label tide/merge-method-squash

krishagarwal278 avatar Nov 25 '25 16:11 krishagarwal278

/verified later @yapei @yanpzhan

krishagarwal278 avatar Nov 25 '25 20:11 krishagarwal278

@krishagarwal278: This PR has been marked to be verified later by @yapei @yanpzhan.

In response to this:

/verified later @yapei @yanpzhan

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.

openshift-ci-robot avatar Nov 25 '25 20:11 openshift-ci-robot

/retest-required

Remaining retests: 0 against base HEAD 2243c0611dd1c08b078c8d04cf6cf08fb6a927a0 and 2 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 26 '25 00:11 openshift-ci-robot

/retest-required

Remaining retests: 0 against base HEAD 229604a0050c4c537344bb8be70743062c8b2aee and 1 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 26 '25 04:11 openshift-ci-robot

/test e2e-gcp-console

krishagarwal278 avatar Nov 26 '25 05:11 krishagarwal278

/retest-required

Remaining retests: 0 against base HEAD c6881d1ca4c1ff37b61bfe6a7fe448d5f0beee7d and 0 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 26 '25 13:11 openshift-ci-robot

This looks good! ๐Ÿ‘

QE Approver: /assign @yapei

cajieh avatar Nov 26 '25 19:11 cajieh

/hold

Revision 3004a0857769b29ad8615430aaecbedba65ef738 was retested 3 times: holding

openshift-ci-robot avatar Nov 27 '25 00:11 openshift-ci-robot

/unhold

krishagarwal278 avatar Nov 27 '25 14:11 krishagarwal278

/retest-required

Remaining retests: 0 against base HEAD 846beeb42703e54a4a388c9de263cfd6e376bdc1 and 2 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 27 '25 14:11 openshift-ci-robot

/retest-required

Remaining retests: 0 against base HEAD 24ccbf9675c24a8089a91cc31cd404c37e3d8d85 and 1 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 27 '25 21:11 openshift-ci-robot

covered following scenarios in PR testing

  • Workloads -> Environment tab, Add/Edit/Delete env vars
  • Delete resources
  • Edit Application group and drag node into and out of application, confirm and cancel

no regression issues found /verified by @yapei

yapei avatar Nov 28 '25 08:11 yapei

@yapei: This PR has been marked as verified by @yapei.

In response to this:

covered following scenarios in PR testing

  • Workloads -> Environment tab, Add/Edit/Delete env vars
  • Delete resources
  • Edit Application group and drag node into and out of application, confirm and cancel

no regression issues found /verified by @yapei

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.

openshift-ci-robot avatar Nov 28 '25 08:11 openshift-ci-robot

/retest-required

Remaining retests: 0 against base HEAD 971f0fa6bf7a7b762bf59ab5171aa5c04147fd09 and 0 for PR HEAD 3004a0857769b29ad8615430aaecbedba65ef738 in total

openshift-ci-robot avatar Nov 29 '25 05:11 openshift-ci-robot

/hold

Revision 3004a0857769b29ad8615430aaecbedba65ef738 was retested 3 times: holding

openshift-ci-robot avatar Nov 29 '25 14:11 openshift-ci-robot

/retest-required

yapei avatar Dec 01 '25 01:12 yapei

/retest

krishagarwal278 avatar Dec 01 '25 09:12 krishagarwal278

/unhold

krishagarwal278 avatar Dec 01 '25 14:12 krishagarwal278

/lgtm

cajieh avatar Dec 01 '25 15:12 cajieh

re-verified with latest changes /verified by @yapei

yapei avatar Dec 02 '25 02:12 yapei