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

Support better K8s Resource Name editing #3167

Conversation

andrewballantyne
Copy link
Member

@andrewballantyne andrewballantyne commented Sep 6, 2024

https://issues.redhat.com/browse/RHOAIENG-583

Description

Provides a new cleaner interface to manage DisplayNames & Descriptions & K8s Name generation. This component will provide a unified front for any element we need to manage K8s items with.

ONLY REFACTORS Project modal & Workbench form. There will be more that can use this.

Screenshots

Project Modal:
image

Click to expand more Project Screenshots

These are in chronological order of operation.

Initial State:
Screenshot 2024-09-09 at 8 26 02 AM
Just Display Name Added:
Screenshot 2024-09-09 at 8 26 16 AM
Looking at the resource name:
Screenshot 2024-09-09 at 8 26 22 AM
Make the display name too long:
image
Make the resource name exceed max characters:
Screenshot 2024-09-09 at 8 26 48 AM
Throw on an invalid character:
Screenshot 2024-09-09 at 8 26 53 AM
Trim it back to the max (no auto trimmed action, so no warning):
Screenshot 2024-09-09 at 8 27 01 AM
Clear out the resource name:
Screenshot 2024-09-09 at 8 27 14 AM
Make an invalid k8s name that is short:
Screenshot 2024-09-09 at 8 27 30 AM
Make it a valid k8s name:
Screenshot 2024-09-09 at 8 27 21 AM
After submit & editing:
image

Workbench screen (only the workbench name is configured this way -- other resources created here are not YET):
image

How Has This Been Tested?

Using the Create/Edit Project Modals & the Create/Edit Workbench Forms.

Test Impact

Added unit tests for the new component. Created a Cypress Page object and refactored the Project/Workbench page objects to use it. Existing Cypress tests should cover the Project modal & Workbench form; minor adjustments made for new design.

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

@andrewballantyne andrewballantyne force-pushed the support-better-resource-name branch 4 times, most recently from d375790 to 66eb345 Compare September 8, 2024 20:25
Copy link

codecov bot commented Sep 8, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 12 lines in your changes missing coverage. Please review.

Project coverage is 85.36%. Comparing base (f046e94) to head (42c5bd3).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ages/projects/screens/projects/ProjectListView.tsx 9.09% 10 Missing ⚠️
...ges/projects/screens/projects/NewProjectButton.tsx 80.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3167      +/-   ##
==========================================
+ Coverage   85.32%   85.36%   +0.03%     
==========================================
  Files        1270     1275       +5     
  Lines       27900    28010     +110     
  Branches     7422     7449      +27     
==========================================
+ Hits        23807    23912     +105     
- Misses       4093     4098       +5     
Files with missing lines Coverage Δ
frontend/src/api/k8s/notebooks.ts 97.45% <100.00%> (-0.03%) ⬇️
...K8sNameDescriptionField/HelperTextItemVariants.tsx 100.00% <100.00%> (ø)
...8sNameDescriptionField/K8sNameDescriptionField.tsx 100.00% <100.00%> (ø)
.../k8s/K8sNameDescriptionField/ResourceNameField.tsx 100.00% <100.00%> (ø)
.../src/concepts/k8s/K8sNameDescriptionField/utils.ts 100.00% <100.00%> (ø)
frontend/src/concepts/k8s/NameDescriptionField.tsx 92.50% <ø> (-2.96%) ⬇️
...src/concepts/k8s/ResourceNameDefinitionTooltip.tsx 100.00% <100.00%> (ø)
frontend/src/concepts/k8s/utils.ts 100.00% <100.00%> (ø)
...ontend/src/pages/home/projects/ProjectsSection.tsx 93.02% <100.00%> (ø)
...s/projects/screens/projects/ManageProjectModal.tsx 77.50% <100.00%> (-4.86%) ⬇️
... and 6 more

... and 4 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 f046e94...42c5bd3. Read the comment docs.

@andrewballantyne
Copy link
Member Author

andrewballantyne commented Sep 9, 2024

@xianli123 @kywalker-rh Please review the screenshots (they are mostly in a collapsed section, look for the expand text in the screenshot section of the description and expand it)

@andrewballantyne andrewballantyne changed the title [WIP] Support better K8s Resource Name editing Support better K8s Resource Name editing Sep 9, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Sep 9, 2024
@xianli123
Copy link

Thanks @andrewballantyne . It looks great.

There is one point we could discuss, and I have attached a graph below.
Is it possible that the input automatically truncates to the first 30 characters when the user inputs more than 30 characters? At this moment, the warning message is displayed below the input field. In this way, it could enhance the user experience by eliminating the need for users to manually remove excess characters. What do you think? cc @kywalker-rh
image

@andrewballantyne
Copy link
Member Author

andrewballantyne commented Sep 9, 2024

@xianli123 I don't understand the desire -- why don't we limit bad characters... why even have error states? I feel the feedback is most commonly done via when they manually type into the field not to "stop them" but to inform them?

(started a thread on slack -- there will be more questions about this direction)

@kywalker-rh
Copy link

Reviewed this with @andrewballantyne in the slack thread. Our decision is to remove the yellow warning text when the resource name has been truncated. Once that change is made this lgtm. cc: @xianli123

@andrewballantyne andrewballantyne changed the title Support better K8s Resource Name editing [WIP] Support better K8s Resource Name editing Sep 9, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Sep 9, 2024
@andrewballantyne
Copy link
Member Author

Changes needed to page objects & UX implementation

@xianli123
Copy link

I agree with you on the update. @kywalker-rh. After the change, it will LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dupe implementation from #3172

@andrewballantyne
Copy link
Member Author

@xianli123 @kywalker-rh Okay, updated the screenshot in the description.

New state when you type a too long display name (and we auto translate it for k8s):
image

@andrewballantyne andrewballantyne changed the title [WIP] Support better K8s Resource Name editing Support better K8s Resource Name editing Sep 11, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Sep 11, 2024
@kywalker-rh
Copy link

Looks great, thanks @andrewballantyne!

@xianli123
Copy link

LGTM! Thanks @andrewballantyne .

return (
<StackItem>
<FormGroup {...formGroupProps} isRequired>
<TextInput
Copy link
Member

Choose a reason for hiding this comment

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

Do you need id={`${dataTestId}-resourceName`} here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I had to swing back through with AXE support after I built this all from the ground up. I'll make that change 👍

@DaoDaoNoCode
Copy link
Member

I found an incorrect helper text condition. The second helper text should be an error in this situation.

Reproduce:
Don't touch the k8s name and input the display name as - (or anything ends with -)
The form is not able to be submitted, which is good because the name is invalid, we just need to update the logic to show the second helper text as an error state.

Screenshot 2024-09-12 at 2 33 19 PM

safeK8sPrefix: safePrefix,
});
changedData.k8sName = {
value: k8sValue,
Copy link
Member

Choose a reason for hiding this comment

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

I think you might need to add a check for invalidCharacters here.

@andrewballantyne
Copy link
Member Author

Last commit addresses the special character situation. I also rebased to get rid of the conflict

Copy link
Member

@DaoDaoNoCode DaoDaoNoCode left a comment

Choose a reason for hiding this comment

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

Nice handling with most of the edge cases we can find so far.
/lgtm

Copy link
Contributor

openshift-ci bot commented Sep 16, 2024

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: DaoDaoNoCode

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 7964daa into opendatahub-io:main Sep 16, 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.

6 participants