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 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present #5258

Merged
merged 1 commit into from May 5, 2020

Conversation

vikram-raj
Copy link
Member

@vikram-raj vikram-raj commented May 1, 2020

Fixes:
https://issues.redhat.com/browse/ODC-2403

Analysis / Root cause:
When viewing the Pipeline Runs in the overview sidebar of topology, the consoledeveloper doesn't see the button when there are no pipeline runs, but does as soon as there are.

Solution Description:
Hide 'Start Last Run' button on topology overview page when no PLR present. For admin as well as for developer.

Screen shots / Gifs for design review:
Screenshot 2020-05-05 at 1 51 38 AM
Screenshot 2020-05-05 at 1 52 14 AM
Screenshot 2020-05-05 at 1 47 07 AM
Screenshot 2020-05-05 at 1 49 09 AM
Screenshot 2020-05-05 at 1 46 37 AM

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vikram-raj
Copy link
Member Author

/retitle Bug 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present

@openshift-ci-robot openshift-ci-robot changed the title Hide 'Start Last Run' button on topology overview page when no PLR present Bug 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present May 1, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. label May 1, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1830181, 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 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 1, 2020
Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

A change of the current UX needs to be run by @openshift/team-devconsole-ux @vikram-raj Please make sure you tag them when doing so.

With that said, I'm personally not in the favour of hiding the button. My stance on when to hide and when to disable a button is around "can the user find use in seeing a disabled button". I think in this case there isn't a lot, but there is some.

The user can head over to the Pipelines page (clicking on the Pipeline name/link provided) to start the Pipeline for the first time. This allows them to fix the disabled button. With no button, it breaks the current view expectations on "some are startable - they have buttons; some are not startable - they do not have buttons". Take Pods for instance, how do we know there is not supposed to be a button there and the user just needs to do one thing before making that happen?

To close off my rant 😄 I think our solution here is actually to show a disabled button if the current user permissions allow them to access that resource. So your 'consoledeveloper' (and 'kube:admin') user would see a disabled button even if there was not a Pipeline Run yet.

@openshift/team-devconsole-ux Please feel free to override what I just said if you'd prefer the button always hidden when it's disabled.

isAllowed && (
<Button variant="secondary" onClick={callback} isDisabled={pipelineRuns.length === 0}>
isAllowed &&
pipelineRuns.length && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid doing array.length && logic @vikram-raj - it is currently rendering 0 when it's false.

@@ -23,8 +23,9 @@ const TriggerLastRunButton: React.FC<TriggerLastRunButtonProps> = ({
const { label, callback, accessReview } = rerunPipelineAndStay(PipelineModel, latestRun);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also change this to PipelineRunModel I missed it in my original review of this code. We are not passing a Pipeline, but a Pipeline Run.

@vikram-raj
Copy link
Member Author

@andrewballantyne Currently, we are hiding all actions on the overview panel if the user has no access to edit.

@andrewballantyne
Copy link
Contributor

@andrewballantyne Currently, we are hiding all actions on the overview panel if the user has no access to edit.

If the user has no access to do any action no matter the state of things, then that's by design. They lack the permissions to do the action, and no matter the state of the app, their permissions do not grant them access to buttons / actions.

If you start hiding buttons that are not disabled because of permission reasons, you are giving the wrong impression imo. The user should see the disabled button if they are an Admin or a user with 'edit' access. Because the state of the app can change and present the button for use to that user.

Naturally all the above is conditional on their permissions not changing.

Please make sure UX provides feedback on this @vikram-raj

@beaumorley
Copy link

@vikram-raj Thanks for looping me in. I agree with @andrewballantyne that we should disable the button for the developer view instead of removing for the admin/developer view. If this was never an option (permission related) I think your solution would be correct. The disabled button gives them a cue that there is something they can do. I would ask @serenamarie125 to weigh in as well.

@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1830181, which is valid.

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 POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present

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
Copy link
Member Author

@andrewballantyne @beaumorley I updated the PR and screenshots PTAL.

<Button
variant="secondary"
onClick={callback}
isDisabled={!isAllowed || pipelineRuns.length === 0}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will show the button for View-only users. This breaks the first criteria of the sidebar.

If the user has no access to do any action no matter the state of things, then that's by design. They lack the permissions to do the action, and no matter the state of the app, their permissions do not grant them access to buttons / actions.

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

This solution aligns better with the desired UX. Just a couple minor changes left I think.

impersonate?;
};

const TriggerLastRunButton: React.FC<TriggerLastRunButtonProps> = ({
pipelineRuns,
namespace,
impersonate,
}) => {
const latestRun = usePipelineRunWithUserLabel(
Copy link
Contributor

Choose a reason for hiding this comment

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

While debugging the solution... I noticed a bug I accidentally made, can correct at the same time here?

In pipelineruns/triggered-by/hooks.ts:

// Today
  return mergeLabelsWithResource(labels, plr);
// Suggested Change
  return plr && mergeLabelsWithResource(labels, plr);

That way it doesn't merge a label onto nothing creating an invalid k8s object.

Comment on lines 23 to 36
const { label, callback, accessReview } = rerunPipelineAndStay(PipelineModel, latestRun);
const { label, callback } = rerunPipelineAndStay(PipelineRunModel, latestRun);
const accessReview: AccessReviewResourceAttributes = {
group: PipelineRunModel.apiGroup,
resource: PipelineRunModel.plural,
namespace,
verb: 'create',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we want to toss out the accessReview that the utility provides... perhaps we do this:

  const { label, callback, accessReview: utilityAccessReview } = rerunPipelineAndStay(PipelineRunModel, latestRun);
  const defaultAccessReview: AccessReviewResourceAttributes = {
    group: PipelineRunModel.apiGroup,
    resource: PipelineRunModel.plural,
    namespace,
    verb: 'create',
  };

  const accessReview = _.isEmpty(utilityAccessReview) ? defaultAccessReview : utilityAccessReview;

resource: PipelineRunModel.plural,
namespace,
verb: 'create',
};
const isAllowed = useAccessReview(accessReview, impersonate);
return (
isAllowed && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also change the button logic to be more deterministic?

<Button variant="secondary" onClick={callback} isDisabled={pipelineRuns.length === 0 && !callback}>

Making sure we have a callback to use before enabling the button will help if there is ever an issue with the callback, we don't have a button enabled without a callback.

EDIT: Updated the logic, thanks for catching the mistake

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

/lgtm

  • "consoledeveloper" does not see any button when only having View access
  • "consoledeveloper" see a disabled button when having Edit access and no Pipeline Runs
  • "consoledeveloper" see an enabled button when having Edit access and having at least 1 Pipeline Run
  • Admin is unaffected

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

/retest

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, 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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 325beb0 into openshift:master May 5, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: All pull requests linked via external trackers have merged: openshift/console#5258. Bugzilla bug 1830181 has been moved to the MODIFIED state.

In response to this:

Bug 1830181: Hide 'Start Last Run' button on topology overview page when no PLR present

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-2403 branch May 5, 2020 19:41
@spadgett spadgett added this to the v4.5 milestone May 11, 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-low Referenced Bugzilla bug's severity is low 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

7 participants