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
Conversation
/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'; |
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.
The topology package shouldn't have dependencies on other @console
packages (with the possible exception of shared, and then only with pure 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.
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.
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.
@jeff-phillips-18 @christianvogt Added the access check in BaseEdge component
420eaa4
to
a7c8687
Compare
|
||
return ( | ||
<g className="odc2-base-node"> | ||
<NodeShadows /> | ||
<g | ||
data-test-id="base-node-handler" | ||
onClick={onSelect} | ||
onContextMenu={onContextMenu} | ||
ref={refs} | ||
{...(editAccess ? { onContextMenu } : {})} |
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 isn't right. Context menu actions already have their own access checks built in.
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 for hiding the contextMenu
. Because we are hiding all the option which user has no access to.
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 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:
{...(editAccess ? { onContextMenu } : {})} | |
onContextMenu={editAccess && onContextMenu} |
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.
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.
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?
{...(editAccess ? { onContextMenu } : {})} | |
onContextMenu={editAccess && onContextMenu || null} |
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 really, ternaries are the only other option... but it's essentially the same thing. But it might be cleaner to read:
{...(editAccess ? { onContextMenu } : {})} | |
onContextMenu={editAccess ? onContextMenu : null} |
🤷♂
onContextMenu={onContextMenu} | ||
ref={refs} | ||
{...(editAccess ? { onContextMenu } : {})} | ||
{...(editAccess ? { ref: refs } : {})} |
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.
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.
name: element.getData().data.donutStatus.dc.metadata.name, | ||
namespace: element.getData().data.donutStatus.dc.metadata.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.
Using donutStatus
as the main resource is very odd.
I guess we don't have any other data point to read from here :(
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 have the only donutStatus
where resource data exist.
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.
element.getData().resources.obj.metadata
is available
Best to use the object returned from getTopologyResourceObject(element.getData())
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.
Done.
@@ -32,7 +49,7 @@ const BaseEdge: React.FC<BaseEdgeProps> = ({ | |||
return ( | |||
<Layer id={dragging || hover ? 'top' : undefined}> | |||
<g | |||
ref={hoverRef} | |||
{...editAccess && { ref: hoverRef }} |
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.
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.
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 do check editAccess
here because the delete connection option appears on hover.
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.
But we do other things on hover such as changing the color of the line to be blue and raised.
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.
removed the editAccess
checked from hoverRef
.
67591cc
to
e26d787
Compare
frontend/packages/dev-console/src/components/topology2/componentUtils.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/topology2/components/nodes/BaseNode.tsx
Outdated
Show resolved
Hide resolved
@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:
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. |
/retest Please review the full test history for this PR and help us cut down flakes. |
14 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
6 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@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:
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.3 |
@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:
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. |
Bug - https://jira.coreos.com/browse/ODC-1791
This PR
TODO
- Disabled Drag and drop.- Hide delete connector