-
Notifications
You must be signed in to change notification settings - Fork 605
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 1869600: add resource icon to the items in the select task
dropdown in the pipeline builder page
#6345
Bug 1869600: add resource icon to the items in the select task
dropdown in the pipeline builder page
#6345
Conversation
/kind bug |
select task
dropdown in the pipeline builder page
@debsmita1: This pull request references Bugzilla bug 1869600, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
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. |
@debsmita1 I think we should also add the resource badge to the builder nodes as without the badge the user wont be able to distinguish between the resources with same name just by looking at the pipeline. For example in the attached image one resource is a cc: @beaumorley @bgliwa01 |
|
No, I think at this point it does not matter. Selecting in a mixed list is a problem because you don't know which is which... but the name in the bubble is a custom name (it just pre-selects as the name of task you took). If you click on the bubble the badge is at the top of the sidebar and the "name" field is a custom name you can use for this task irrespective of what it was originally named. So I think we are good with just the badge in the dropdown list. @bgliwa01 Please let me know your thoughts. |
Agreed @andrewballantyne |
c065fd2
to
4283248
Compare
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'm going to test around a bit and see how this idea goes... but I think this solves the layout issue if we always generate a new name (with a hash if conflicted).
@@ -82,7 +84,7 @@ const TaskListNode: React.FC<TaskListNodeProps> = ({ element, unselectedText }) | |||
<div className="pf-c-dropdown pf-m-expanded"> | |||
<ul className="pf-c-dropdown__menu pf-m-align-right oc-kebab__popper-items odc-task-list-node__list-items"> | |||
{options.map((option) => ( | |||
<li key={option.label}> | |||
<li key={`${option.label}-${option.icon?.['props']?.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.
Not a fan of digging into props unless you absolutely have to... I think since we have a little sandbox of code here, we could change things up a bit with the help of TypeScript.
type KeyedKebabOption = KebabOption & { key: string };
const taskToOption = (task: PipelineResourceTask, callback: NewTaskNodeCallback): KeyedKebabOption => {
That way we return a option.key
value that we can use. You can set key
simply to ${kind}-${name}
with the data.
return { | ||
name: resource.metadata.name, | ||
name: `${resource.metadata.name}-${kind.toLowerCase()}`, |
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.
If we do this, we are not really avoiding the problem entirely. We are likely to be okay, but let's avoid anything that will lead to potentially another bug (or if QE is on game, a failure of the QE Review).
Recommend a generate name function (maybe we can put this in shared, or here -- wherever for now):
export const safeName = (reservedNames: string[], desiredName: string): string => {
if (reservedNames.includes(desiredName)) {
const newName = `${desiredName}-${getRandomChars()}`; // maybe `getRandomChars(3)`?
if (reservedNames.includes(newName)) {
return safeName(reservedNames, desiredName);
}
return newName;
}
return desiredName;
};
// use like:
name: safeName(reservedNames, resource.metadata.name),
Then you update the two uses of convertResourceToTask
to include a 3rd param (I'd make it the first param personally) of a string[]
.
Sample usage:
const usedNames = tasks.map((t) => t.name);
const newPipelineTask: PipelineTask = convertResourceToTask(usedNames, resource, runAfter);
@@ -135,7 +135,10 @@ export const useNodes = ( | |||
|
|||
// TODO: Fix id collisions then remove this utility; we shouldn't need to trim the tasks | |||
const noDuplicates = (resource: PipelineResourceTask) => | |||
!taskGroupRef.current.tasks.find((pt) => pt.name === resource.metadata.name); | |||
!taskGroupRef.current.tasks.find( | |||
(pt) => pt.taskRef.name === resource.metadata.name && pt.taskRef.kind === resource.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.
We can't do resource.metadata.name
against pt.taskRef.name
because this will prevent any double uses of a given task. This isn't the end of the world, but likely will be a problem for some use-cases.
However! With my recent changes suggested, I think we can actually get rid of this function since we'll always will generate a new name.
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.
removing this piece of code should fix this bug https://issues.redhat.com/browse/ODC-3182, isn't it ?
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.
That is correct @debsmita1 good find of that ticket. That should indeed resolve that issue.
4283248
to
af64a03
Compare
/retest |
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.
Couple tiny feedback points.
@@ -201,14 +201,16 @@ const addListNode: UpdateOperationAction<UpdateOperationAddData> = (tasks, listT | |||
} | |||
}; | |||
|
|||
const getTaskNames = (tasks: PipelineTask[]) => tasks.map((t) => t.name); |
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.
Not sure this was needed as it's a single operation, but technically it is DRY 😄 So nicely done 👍
@@ -10,6 +10,7 @@ import { | |||
import { getTaskParameters } from '../resource-utils'; | |||
import { TASK_ERROR_STRINGS, TaskErrorType } from './const'; | |||
import { PipelineBuilderFormikValues, PipelineBuilderFormValues, TaskErrorMap } from './types'; | |||
import { getRandomChars } from '@console/shared'; |
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: Sort
@@ -528,6 +528,8 @@ export type KebabOption = { | |||
icon?: React.ReactNode; | |||
}; | |||
|
|||
export type KeyedKebabOption = KebabOption & { key: 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.
Not sure we needed to add this to the common code. This was just for our use-case. I think it's probably best to move this back to TaskListNode.tsx
. The current KebabOption uses the label as the key... so this feels a little weird in the common code.
@@ -29,15 +30,28 @@ export const taskParamIsRequired = (param: PipelineResourceTaskParam): boolean = | |||
return !('default' in param); | |||
}; | |||
|
|||
export const safeName = (reservedNames: string[], desiredName: string): string => { | |||
if (reservedNames.includes(desiredName)) { | |||
const newName = `${desiredName}-${getRandomChars(5)}`; |
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'd have gone with the default (6) or shorten it to 3 (half). Not sure this makes really any difference though. Was there a scenario you were worried about using less characters? (ie, any specific reason for 5?)
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.
No specific reason. Changed it to 3
af64a03
to
dd1e7ed
Compare
@debsmita1: This pull request references Bugzilla bug 1869600, which is valid. 3 validation(s) were run on this bug
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. |
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.
/lgtm
/lgtm cancel @divyanshiGupta Actually could you do a review here as well. Trying to encourage two point reviews. Didn't see you didn't add a lgtm until I did. |
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.
Verified the changes looks good !!
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, debsmita1, invincibleJai 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 |
/test e2e-gcp-console |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@debsmita1: All pull requests linked via external trackers have merged: openshift/console#6345. Bugzilla bug 1869600 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. |
/cherrypick release-4.5 |
@debsmita1: #6345 failed to apply on top of branch "release-4.5":
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:
Root Analysis:
Tasks and ClusterTasks are not visually distinguishable in the
Select Task
dropdown list in the pipeline builder page.Solution Description:
Select Task
dropdownGIF: