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
Bug 1797652: Fix crash on Edit of applications #4207
Conversation
@jeff-phillips-18: This pull request references Bugzilla bug 1797652, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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/test-infra repository. |
22322c4
to
d8d3876
Compare
/kind bug |
d8d3876
to
a92aeb7
Compare
@jeff-phillips-18: This pull request references Bugzilla bug 1797652, which is valid. In response to this:
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/test-infra repository. |
}; | ||
|
||
export const shouldTruncate = (text, options = {}): boolean => { | ||
const { length, minTruncateChars } = Object.assign({}, DEFAULT_OPTIONS, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I prefer the es6 spread syntax:
const { length, minTruncateChars } = Object.assign({}, DEFAULT_OPTIONS, options); | |
const { length, minTruncateChars } = {...DEFAULT_OPTIONS, ...options}; |
So much better with the middle truncation. |
/approve |
a92aeb7
to
66641d3
Compare
Updated per comments. Includes change to truncation length for topology objects to 20 (from 16) to maintain consistency between topology objects and the menus and the rest of the UI (per slack discussion with @serenamarie125). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UX requested that we have middle truncation as well as be sure that the number of chars was consistent in the Edit Menu and the Component Label in topology.
This looks great!
// is greater than the `maxLength` + `minTruncateChars` values. | ||
// By default the middle is truncated, set the options.middle to false to truncate at the end. | ||
// Truncated text is replaced with the provided omission option (ellipsis character by default); | ||
export const truncateText = (text: string, options: TruncateOptions = {}): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, we do have an existing truncateMiddle
helper: https://github.com/spadgett/console/blob/master/frontend/public/components/utils/truncate-middle.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this util is a bit different. I tried to use truncateMiddle
but it fails as this is done as part of initialization of the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ya there's that util...
@jeff-phillips-18 can you explain further what the issue is with using that util?
Can we enhance the existing util with what we need. There shouldn't be an issue re-using the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was having some issues importing it from @console/internal/components/utils
, but it works fine if I import it from @console/internal/components/utils/truncate-middle
.
I've enhanced the existing util and imported as above.
label: 'Edit', | ||
href: `/edit?name=${obj.metadata.name}&kind=${obj.kind}`, | ||
label: `Edit ${truncateText(obj.metadata.name)}`, | ||
href: `/edit?name=${obj.metadata.name}&kind=${obj.kind || model.kind}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just use model.kind
always. But should we be using referenceForModel
? kind
isn't unique.
It sounds like the menu shouldn't have shown up, though, since the particular resource in the bug wasn't creating through the dev console "Add" flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't have. I've removed it at https://github.com/openshift/console/pull/4207/files#diff-2c9504a8d75ebb51fe3d613cf73328f2L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm not clear on the fix in that case. Should we be looking at an annotation or label on the resource to know it was created from the console add flow? I see the Edit action showing up for deployments and other resources that were created outside console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly we should. This PR does not fix that only the know crashing issue. I can file a separate issue for that or fix as part of this PR if you'd prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm good tracking it as a separate BZ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
66641d3
to
11ae105
Compare
11ae105
to
e19f218
Compare
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, jeff-phillips-18, serenamarie125 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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
4 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@jeff-phillips-18: All pull requests linked via external trackers have merged. Bugzilla bug 1797652 has been moved to the MODIFIED state. In response to this:
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/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-2932
Analysis / Root cause:
The
kind
field for the given object is optional and if not set an invalid navigation location was being derived. Also, k8s services should not have theEdit
action, only workloads should have this option.Solution Description:
If the kind field for the object is not set, get the value from the given model.
Remove the k8s service model from the kinds list that the
Edit
item supports.It was also determined that
Edit
is confusing given the other options in the kebab menu. Added the name of the object being edited to theEdit
label (nowEdit ${resource name}
).Included is a change to the node labels to truncate the middle text to be consistent with other instances of name truncation throughout the console UI.
Browser conformance:
Sample Screenshots:
cc @openshift/team-devconsole-ux