Skip to content

CONSOLE-4580: Refactor PVCActionFactory to hook form. #15078

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Mylanos
Copy link
Contributor

@Mylanos Mylanos commented May 22, 2025

Moved away from using the generic kebabFactory for PVC actions that were used inside of the PVC and VolumeSnapshot page. Created hook providers that are being used in these two resource pages to access PVC actions instead. Converted persistent-volume-claim.jsx to TS.
after:

Screen.Recording.2025-05-22.at.11.38.55.mov

Possible tests:

  1. Do all of the actions in PVCs and VolumeSnapshot list and details page behave as expected?
  2. Does the PVC and VolumeSnapshot list and details page contain all of the expected actions?

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 22, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 22, 2025

@Mylanos: This pull request references CONSOLE-4580 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.20.0" version, but no target version was set.

In response to this:

Moved away from using the generic kebabFactory for PVC actions that were used inside of the PVC and VolumeSnapshot page. Created hook providers for these two resources that are being used to access PVC actions instead. Converted persistent-volume-claim.jsx to ts.
after:

Screen.Recording.2025-05-22.at.11.38.55.mov

Possible tests:

  1. Do all of the actions in PVCs and VolumeSnapshot behave as expected?
  2. Does the PVC and VolumeSnapshot page contain all of the expected actions?

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-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2025
…sourceActionCreators, replace deprecated K8sKind type, introduce generic type for K8sResourceKind to make the type assertions explicite.
@openshift-ci openshift-ci bot requested review from cajieh and rhamilto May 22, 2025 09:45
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label May 22, 2025
Copy link
Contributor

openshift-ci bot commented May 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Mylanos

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 22, 2025
@Mylanos Mylanos force-pushed the PVCActionFactory-refactor branch from 3910a30 to 2c04374 Compare May 22, 2025 09:49
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented May 22, 2025

@Mylanos: This pull request references CONSOLE-4580 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.20.0" version, but no target version was set.

In response to this:

Moved away from using the generic kebabFactory for PVC actions that were used inside of the PVC and VolumeSnapshot page. Created hook providers that are being used in these two resource pages to access PVC actions instead. Converted persistent-volume-claim.jsx to TS.
after:

Screen.Recording.2025-05-22.at.11.38.55.mov

Possible tests:

  1. Do all of the actions in PVCs and VolumeSnapshot behave as expected?
  2. Does the PVC and VolumeSnapshot page contain all of the expected actions?

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
Copy link
Contributor

openshift-ci-robot commented May 22, 2025

@Mylanos: This pull request references CONSOLE-4580 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.20.0" version, but no target version was set.

In response to this:

Moved away from using the generic kebabFactory for PVC actions that were used inside of the PVC and VolumeSnapshot page. Created hook providers that are being used in these two resource pages to access PVC actions instead. Converted persistent-volume-claim.jsx to TS.
after:

Screen.Recording.2025-05-22.at.11.38.55.mov

Possible tests:

  1. Do all of the actions in PVCs and VolumeSnapshot list and details page behave as expected?
  2. Does the PVC and VolumeSnapshot list and details page contain all of the expected actions?

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
Copy link
Contributor

openshift-ci-robot commented May 22, 2025

@Mylanos: This pull request references CONSOLE-4580 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.20.0" version, but no target version was set.

In response to this:

Moved away from using the generic kebabFactory for PVC actions that were used inside of the PVC and VolumeSnapshot page. Created hook providers that are being used in these two resource pages to access PVC actions instead. Converted persistent-volume-claim.jsx to TS.
after:

Screen.Recording.2025-05-22.at.11.38.55.mov

Possible tests:

  1. Do all of the actions in PVCs and VolumeSnapshot list and details page behave as expected?
  2. Does the PVC and VolumeSnapshot list and details page contain all of the expected actions?

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.

Mylanos added 2 commits May 22, 2025 13:06
…s, convert persistent-volume-claim.jsx to persistent-volume-claim.tsx, update i18n
…ourceProvider, consume actions from ActionsResourceProvider inside VolumeSnapshots, update i18n, remove PVC and VolumeSnapshot actions from kebabFactory.
@Mylanos Mylanos force-pushed the PVCActionFactory-refactor branch from 2c04374 to 40e05c5 Compare May 22, 2025 11:06
@Mylanos
Copy link
Contributor Author

Mylanos commented May 26, 2025

/retest

Copy link
Contributor

openshift-ci bot commented May 26, 2025

@Mylanos: all tests passed!

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.


const [columns] = useActiveColumns({
columns: getTableColumns(rowData.customData?.disableItems),
const columns = getTableColumns(t, props.rowData.customData.disableItems);
Copy link
Contributor Author

@Mylanos Mylanos May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make the getTableColumns an inner function to have the t available through the closure. Or explore utilization of useMemo to memoize the columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getTableColumns is used at multiple places - FilteredSnapshotTable and VolumeSnapshotTable, these components don't even share a shared parent, so passing it via props from parent is also not an option. Moving it inside of the both components won't by as DRY as having the function separated in the global scope, so I would opt in for keeping it in the scope outside the components @vojtechszocs

@@ -81,7 +81,7 @@ export type NodeMetrics = {
};

export type PVCMetrics = {
usedCapacity: MetricValuesByName;
usedCapacity?: MetricValuesByName;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revisit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be optional, as the pvcMetric fallback value is {}, which causes type errors when dispatching the created pvcMetric. See code.

@@ -186,7 +174,7 @@ const Details_ = ({ flags, obj: pvc }) => {
const totalCapacityMetric = convertToBaseValue(storage);
const totalRequestMetric = convertToBaseValue(requestedStorage);
const usedMetrics = response?.data?.result?.[0]?.value?.[1];
Copy link
Contributor Author

@Mylanos Mylanos May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback value to 0, to never have an empty value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, having no fallback value has not caused issues in the past, also the added cast to Number inside of the availableMetrics metrics is protected by fallback value. So I will opt in for keeping the changes, only replacing the casting part from the parseInt() to Number()

@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2025
@Mylanos
Copy link
Contributor Author

Mylanos commented May 28, 2025

Review comments above are made on behalf of @vojtechszocs, @jon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants