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 1835425: Don't show Remove Trigger when there are no triggers #5433
Conversation
/retitle Bug 1835425: Don't show Remove Trigger when there are no triggers |
@vikram-raj: This pull request references Bugzilla bug 1835425, 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. 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. |
1ec11aa
to
049d53d
Compare
const { | ||
metadata: { name, namespace }, | ||
} = pipeline; | ||
const routeTemplates: RouteTemplate[] = usePipelineTriggerTemplateNames(name, namespace) || []; |
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 are already calling usePipelineTriggerTemplateNames
hook in the parent component PipelineDetailsPage.tsx
, instead of calling it again here, we can pass the routeTemplates
data to the child component via customData
property in the DetailsPage component in the pipelineDetailsPage.tsx
.
const { | |
metadata: { name, namespace }, | |
} = pipeline; | |
const routeTemplates: RouteTemplate[] = usePipelineTriggerTemplateNames(name, namespace) || []; |
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.
@karthikjeeyar Done.
/assign @andrewballantyne |
@@ -228,11 +228,14 @@ const removeTrigger: KebabAction = (kind: K8sKind, pipeline: Pipeline) => ({ | |||
verb: 'delete', | |||
}, | |||
}); | |||
export const getPipelineKebabActions = (pipelineRun?: PipelineRun): KebabAction[] => [ | |||
export const getPipelineKebabActions = ( |
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 functionality, it works as expected. can we add tests for getPipelineKebabActions utils?
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.
Added tests for this utils.
@@ -42,7 +44,9 @@ const PipelineDetailsPage: React.FC<DetailsPageProps> = (props) => { | |||
.catch((error) => setErrorCode(error.response.status)); | |||
}, [name, namespace]); | |||
|
|||
const augmentedMenuActions: KebabAction[] = useMenuActionsWithUserLabel(menuActions); | |||
const augmentedMenuActions: KebabAction[] = useMenuActionsWithUserLabel( | |||
getPipelineKebabActions(latestPipelineRun, !_.isEmpty(templateNames)), |
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: No need to use lodash.
getPipelineKebabActions(latestPipelineRun, !_.isEmpty(templateNames)), | |
getPipelineKebabActions(latestPipelineRun, templateNames.length > 0), |
Recommend doing this for both cases you did this.
export const usePipelineTriggerTemplateNames = (pipeline: Pipeline): RouteTemplate[] | null => { | ||
const eventListenerResources = useAllEventListeners(pipeline); | ||
const { | ||
metadata: { namespace }, | ||
} = pipeline; | ||
export const usePipelineTriggerTemplateNames = ( | ||
pipelineName: string, | ||
namespace: string, | ||
): RouteTemplate[] | null => { | ||
const eventListenerResources = useAllEventListeners(namespace); |
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.
Why did you make this change? As far as I can tell you possessed the Pipeline object in all cases where you used this function. These changes are undesirable and lead to coupling of functionality.
Prior to this change, the caller just knew they had a Pipeline and needed to get related objects of type X
. usePipelineTriggerTemplates
makes a lot less sense when you're passing a name and a namespace, rather than the whole Pipeline.
I disagree with this change, and unless you have a solid reason I can't see, I recommend undoing this.
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 make this change so that I can use this usePipelineTriggerTemplateNames
hook in PipelineDetailsPage
as the whole pipeline object is not present on pipeline details age.
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.
Really? 🤔 That seems odd.
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.
Yes, this is the only reason to make this change.
const PipelineRow: RowFunction<Pipeline> = ({ obj, index, style }) => { | ||
return <PipelineTableRow obj={obj} index={index} style={style} />; | ||
}; | ||
|
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.
This is my biggest concern of this PR. This is not the pattern we are used to for Table rows. Perhaps we need Christian to comment on the architecture of this decision. I'm going to investigate an alternative for the table rows.
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 wonder if we just override my solution for the hook injection of the user label. I wrapped the Kebab component instead of the whole row. Most of the content is unaffected by this state and thus doesn't need this change.
Recommend you try that, maybe another wrapper 🤔 Maybe a prop 🤔 Consider this path instead of making the whole row a component. Let me know if you want to discuss 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.
Ah - crud. This may be actually more difficult. This is done all up front AND on scroll (if there are enough to be virtually rendered). This solution may need to focus on a hover of the Kebab. Perhaps we can use a useEffect
and a useRef
hook on a wrapping div 🤔
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.
As PipelineRow
is not a FC
so, I am not able to use hooks. That is why I make this change.
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 understand that @vikram-raj This pattern of creating a component off a function to use hooks... especially for the row component and always on the row component is a performance issue. We need to do better otherwise we'll just be trading bugs.
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.
@andrewballantyne Updated this. Now, I wrap only the pipeline kebab component instead of wrapping the whole row component.
674fd6c
to
21c9fab
Compare
pipeline: Pipeline; | ||
}; | ||
|
||
const PipelineRowKebabActions: React.FC<PipelineRowKebabActionsProps> = ({ pipeline }) => { |
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.
This needs to be in a new file. Also as discussed on slack, we need to lazy do this hook fetch as we cannot be fetching always for every row... it's too much.
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.
@vikram-raj We discussed this on slack. For posterity, I'll look into this more this weekend. There is something off about this and I will figure out what it is or retract my request 😛
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.
Looks like there is caching in play here that prevents too much duplicate action. We still need to convert this component into it's own file, but let's run with this design for now. It doesn't seem to have too much problems. At least none more than the current Pipeline (which fetches all Pipeline Runs and gets the latest).
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.
Moved the PipelineRowKebabActions
to separate files.
/approve Make the needed new component and look for a peer review to get this underway tomorrow during India day @vikram-raj If needed, I'll be available reasonably early for additional questions / feedback. |
verfied locally, works as expected. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, karthikjeeyar, vikram-raj 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 |
@vikram-raj: All pull requests linked via external trackers have merged: openshift/console#5433. Bugzilla bug 1835425 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-3589
Analysis / Root cause:
When there are no triggers, the modal opens with a disabled dropdown.
We should do better, like disabling the kebab menu option... unfortunately the information is not readably available... so we'll have to fetch it which may not be cheap. Some thinking needs to be done here.
Solution Description:
Remove the
Remove Trigger
option from the kebab menu of the pipeline when there are no triggers.Remove the
Remove Trigger
option from the actions menu of the pipeline details page when there are no triggers.Screen shots / Gifs for design review:
Browser conformance: