Skip to content
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

Use K8sNameDescriptionField in connection type page #3257

Conversation

emilys314
Copy link
Contributor

Closes https://issues.redhat.com/browse/RHOAIENG-13400

Description

Use the new K8sNameDescriptionField component. This prevents the user from entering a too long of a name which causes a resource name error when saving.

image
image
image
image

How Has This Been Tested?

Tested locally by running through the different connection type operations.
For the bug referenced in the jira issue, paste a lot of text https://www.lipsum.com/feed/html and click save. It will now truncate the resource name

Test Impact

No updates, existing tests cover the previous functionality. (and the long name is a server side error)

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Sep 25, 2024
Copy link
Contributor

openshift-ci bot commented Sep 25, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.95%. Comparing base (a0d40fd) to head (27bc5fa).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3257      +/-   ##
==========================================
- Coverage   84.96%   84.95%   -0.02%     
==========================================
  Files        1302     1302              
  Lines       29101    29099       -2     
  Branches     7828     7827       -1     
==========================================
- Hits        24727    24722       -5     
- Misses       4374     4377       +3     
Files with missing lines Coverage Δ
.../src/concepts/k8s/K8sNameDescriptionField/utils.ts 100.00% <100.00%> (ø)
frontend/src/concepts/k8s/utils.ts 100.00% <100.00%> (ø)
...onnectionTypes/manage/ManageConnectionTypePage.tsx 91.83% <100.00%> (-0.48%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0d40fd...27bc5fa. Read the comment docs.

@emilys314 emilys314 marked this pull request as ready for review September 25, 2024 21:25
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Sep 25, 2024
Copy link
Contributor

@christianvogt christianvogt left a comment

Choose a reason for hiding this comment

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

I can still submit the form if there are errors with the resource name.

Comment on lines 10 to 11
export const isK8sDSGResource = (x?: K8sResourceCommon): x is K8sDSGResource => !!x?.metadata?.name;
export const isK8sDSGResource = (x?: K8sResourceCommon): x is K8sDSGResource =>
!!x?.metadata && 'name' in x.metadata;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For prefilling the k8sNameDesc fields, it runs the following:

export const setupDefaults = ({
  initialData,
  limitNameResourceType,
  safePrefix,
}: UseK8sNameDescriptionDataConfiguration): K8sNameDescriptionFieldData => {
  let initialName = '';
  let initialDescription = '';
  let initialK8sNameValue = '';
  let configuredMaxLength = MAX_RESOURCE_NAME_LENGTH;

  if (isK8sDSGResource(initialData)) {
    initialName = getDisplayNameFromK8sResource(initialData);
    initialDescription = getDescriptionFromK8sResource(initialData);
    initialK8sNameValue = initialData.metadata.name;
  }
  if (limitNameResourceType != null) {
    configuredMaxLength = ROUTE_BASED_NAME_LENGTH;
  }

So specifically for the duplicate scenario, there will be data like the description and display name filled out, but no resource name is defined yet, and it will fail the check since "" is false. This change makes "" still count as true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I reverted this change due to other changes anyways. For duplicate, it will now pass in the resource name, so the type check will always pass.

Passing in the resource name would originally block you from editing it, but i added editK8sNameValue to allow edit of the prefilled value

@emilys314 emilys314 closed this Sep 26, 2024
@emilys314 emilys314 force-pushed the use-new-k8s-name-desc-in-connection-type branch from 2d97d04 to 47aabd3 Compare September 26, 2024 14:50
@emilys314 emilys314 reopened this Sep 26, 2024
@emilys314 emilys314 force-pushed the use-new-k8s-name-desc-in-connection-type branch 4 times, most recently from 2f10602 to d08c3a4 Compare September 26, 2024 20:03
@emilys314 emilys314 force-pushed the use-new-k8s-name-desc-in-connection-type branch from d08c3a4 to 27bc5fa Compare September 27, 2024 12:42
@christianvogt
Copy link
Contributor

/lgtm
/approve

Copy link
Contributor

openshift-ci bot commented Sep 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt

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-merge-bot openshift-merge-bot bot merged commit f1dfe7b into opendatahub-io:main Sep 27, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants