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

Bug 1835425: Don't show Remove Trigger when there are no triggers #5433

Merged
merged 1 commit into from May 27, 2020

Conversation

vikram-raj
Copy link
Member

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:
pipeline-detail-trigger
pipeline-trigger

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vikram-raj
Copy link
Member Author

/retitle Bug 1835425: Don't show Remove Trigger when there are no triggers

@openshift-ci-robot openshift-ci-robot changed the title Don't show Remove Trigger when there are no triggers Bug 1835425: Don't show Remove Trigger when there are no triggers May 13, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 13, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1835425: Don't show Remove Trigger when there are no triggers

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.

@vikram-raj vikram-raj force-pushed the odc-3589 branch 2 times, most recently from 1ec11aa to 049d53d Compare May 14, 2020 05:16
Comment on lines 19 to 22
const {
metadata: { name, namespace },
} = pipeline;
const routeTemplates: RouteTemplate[] = usePipelineTriggerTemplateNames(name, namespace) || [];
Copy link
Contributor

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.

Suggested change
const {
metadata: { name, namespace },
} = pipeline;
const routeTemplates: RouteTemplate[] = usePipelineTriggerTemplateNames(name, namespace) || [];

Copy link
Member Author

Choose a reason for hiding this comment

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

@vikram-raj
Copy link
Member Author

/assign @andrewballantyne

@@ -228,11 +228,14 @@ const removeTrigger: KebabAction = (kind: K8sKind, pipeline: Pipeline) => ({
verb: 'delete',
},
});
export const getPipelineKebabActions = (pipelineRun?: PipelineRun): KebabAction[] => [
export const getPipelineKebabActions = (
Copy link
Contributor

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?

Copy link
Member Author

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)),
Copy link
Contributor

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.

Suggested change
getPipelineKebabActions(latestPipelineRun, !_.isEmpty(templateNames)),
getPipelineKebabActions(latestPipelineRun, templateNames.length > 0),

Recommend doing this for both cases you did this.

Comment on lines -86 to +83
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);
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Really? 🤔 That seems odd.

Copy link
Member Author

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.

Comment on lines 83 to 86
const PipelineRow: RowFunction<Pipeline> = ({ obj, index, style }) => {
return <PipelineTableRow obj={obj} index={index} style={style} />;
};

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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 🤔

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

@vikram-raj vikram-raj force-pushed the odc-3589 branch 3 times, most recently from 674fd6c to 21c9fab Compare May 22, 2020 18:01
pipeline: Pipeline;
};

const PipelineRowKebabActions: React.FC<PipelineRowKebabActionsProps> = ({ pipeline }) => {
Copy link
Contributor

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.

Copy link
Contributor

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 😛

Copy link
Contributor

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).

Copy link
Member Author

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.

@andrewballantyne
Copy link
Contributor

/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.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 27, 2020
@karthikjeeyar
Copy link
Contributor

verfied locally, works as expected.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 24c9cce into openshift:master May 27, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1835425: Don't show Remove Trigger when there are no triggers

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.

@vikram-raj vikram-raj deleted the odc-3589 branch May 27, 2020 12:58
@spadgett spadgett added this to the v4.5 milestone Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants