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 1779493: Disabled edit actions if the user has no permission #3484

Merged
merged 5 commits into from Dec 5, 2019

Conversation

vikram-raj
Copy link
Member

@vikram-raj vikram-raj commented Nov 20, 2019

Bug - https://jira.coreos.com/browse/ODC-1791

This PR

  • Hide connector arrow
  • Hide context menu for node
  • Disabled drag and drop
  • Hide delete connector

TODO
- Disabled Drag and drop.
- Hide delete connector

Peek 2019-11-20 10-56

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 20, 2019
@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Nov 20, 2019
@vikram-raj
Copy link
Member Author

/cc @christianvogt @jeff-phillips-18

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 21, 2019
@vikram-raj vikram-raj changed the title [WIP]Bug fix: disabled edit actions if user has no permission Bug fix: disabled edit actions if user has no permission Nov 21, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 21, 2019
@vikram-raj
Copy link
Member Author

/assign @christianvogt

@@ -1,5 +1,7 @@
import * as React from 'react';
import { observer } from 'mobx-react';
import { referenceFor, modelFor } from '@console/internal/module/k8s';
import { useAccessReview } from '@console/internal/components/utils';
Copy link
Member

Choose a reason for hiding this comment

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

The topology package shouldn't have dependencies on other @console packages (with the possible exception of shared, and then only with pure utils).

Copy link
Contributor

Choose a reason for hiding this comment

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

Even shared we want to avoid because we eventually want to move it to PF.
There is a small dependency on popper because recently I moved that code and didn't want to duplicate.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jeff-phillips-18 @christianvogt Added the access check in BaseEdge component


return (
<g className="odc2-base-node">
<NodeShadows />
<g
data-test-id="base-node-handler"
onClick={onSelect}
onContextMenu={onContextMenu}
ref={refs}
{...(editAccess ? { onContextMenu } : {})}
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't right. Context menu actions already have their own access checks built in.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for hiding the contextMenu. Because we are hiding all the option which user has no access to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we don't have any context menu actions that don't act directly on the resource itself, so it's probably ok to hide it.
However:

Suggested change
{...(editAccess ? { onContextMenu } : {})}
onContextMenu={editAccess && onContextMenu}

Copy link
Member Author

Choose a reason for hiding this comment

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

Got this warning when I change it to onContextMenu={editAccess && onContextMenu}

Screenshot from 2019-11-24 09-47-31

Copy link
Contributor

Choose a reason for hiding this comment

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

How about this then.
The other way just doesn't seem very clear but maybe it's just me. @andrewballantyne @rohitkrai03 what do you suggest?

Suggested change
{...(editAccess ? { onContextMenu } : {})}
onContextMenu={editAccess && onContextMenu || null}

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really, ternaries are the only other option... but it's essentially the same thing. But it might be cleaner to read:

Suggested change
{...(editAccess ? { onContextMenu } : {})}
onContextMenu={editAccess ? onContextMenu : null}

🤷‍♂

onContextMenu={onContextMenu}
ref={refs}
{...(editAccess ? { onContextMenu } : {})}
{...(editAccess ? { ref: refs } : {})}
Copy link
Contributor

Choose a reason for hiding this comment

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

refs provides drag to move behavior AND regroup behavior.
The regroup behavior needs to suppressed but not the drag.

Look at componentUtils#nodeDragSourceSpec. This is where the REGROUP_OPERATION is installed.
We may need to move to hooks instead of HOCs to gain better control of the behaviors.

Comment on lines 72 to 73
name: element.getData().data.donutStatus.dc.metadata.name,
namespace: element.getData().data.donutStatus.dc.metadata.namespace,
Copy link
Contributor

Choose a reason for hiding this comment

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

Using donutStatus as the main resource is very odd.
I guess we don't have any other data point to read from here :(

Copy link
Member Author

Choose a reason for hiding this comment

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

We have the only donutStatus where resource data exist.

Copy link
Member

Choose a reason for hiding this comment

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

element.getData().resources.obj.metadata is available
Best to use the object returned from getTopologyResourceObject(element.getData())

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -32,7 +49,7 @@ const BaseEdge: React.FC<BaseEdgeProps> = ({
return (
<Layer id={dragging || hover ? 'top' : undefined}>
<g
ref={hoverRef}
{...editAccess && { ref: hoverRef }}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does hover have to do with editAccess?!
We need hover to provide a hover style treatment.
You need to prevent showing the connector if the user doesn't have edit access.
Furthermore, editing the visual connector edits the source node while the service request binding connector creates a new SBR. Two completely different access control scenarios that require different checks.

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 do check editAccess here because the delete connection option appears on hover.

Copy link
Contributor

Choose a reason for hiding this comment

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

But we do other things on hover such as changing the color of the line to be blue and raised.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed the editAccess checked from hoverRef.

@vikram-raj vikram-raj force-pushed the odc-1791 branch 2 times, most recently from 67591cc to e26d787 Compare November 25, 2019 20:18
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 26, 2019
@openshift-ci-robot openshift-ci-robot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Dec 4, 2019
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1779493, 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:

/bugzilla refresh

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-bot
Copy link
Contributor

/retest

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

14 similar comments
@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@spadgett spadgett added this to the v4.4 milestone Dec 4, 2019
@openshift-bot
Copy link
Contributor

/retest

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

6 similar comments
@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@openshift-bot
Copy link
Contributor

/retest

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

@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 a023f0c into openshift:master Dec 5, 2019
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: All pull requests linked via external trackers have merged. Bugzilla bug 1779493 has been moved to the MODIFIED state.

In response to this:

Bug 1779493: Disabled edit actions if the user has no permission

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

/cherrypick release-4.3

@openshift-cherrypick-robot

@vikram-raj: failed to push cherry-picked changes in GitHub: pushing failed, output: "remote: Not Found\nfatal: repository 'https://openshift-cherrypick-robot:CENSORED@github.com/openshift-cherrypick-robot/openshift/console/' not found\n", error: exit status 128

In response to this:

/cherrypick release-4.3

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.

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/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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants