-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix managed cluster access button for read only users #146
Merged
niravparikh05
merged 11 commits into
paralus:main
from
mabhi:fix-managed-cluster-button-access
Dec 5, 2022
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f132af
Fix access to cluster manage buttons shown for NAMESPACE-READ-ONLY user
mabhi 2d4646b
Fix access to cluster manage buttons shown for NAMESPACE-READ-ONLY user
mabhi 5226492
Fix access to cluster manage buttons shown for READ-ONLY permission o…
mabhi 7b613b8
Update CHANGELOG.md
mabhi 07436a6
Fix access to cluster manage buttons shown for READ-ONLY permission o…
mabhi bd31841
Fix access to cluster manage buttons shown for READ-ONLY permission o…
mabhi 2b59d04
Fix access to cluster manage buttons shown for READ-ONLY permission o…
mabhi f3cb1cf
Fix access to cluster manage buttons shown for READ-ONLY permission o…
mabhi 810c566
write access to cluster modified using new scope attribute
mabhi 410c43b
hide New Cluster button for user without cluster write access
mabhi 479540c
removed unnecessary console log entry
mabhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1197,8 +1197,8 @@ class PrivateEdgeList extends React.Component { | |
const { order, orderBy, selected, rowsPerPage, page } = this.state; | ||
const { match, UserSession, Projects, sshEdges, partnerDetail } = | ||
this.props; | ||
console.log(this.props); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's remove this if it was used just for debugging |
||
let data = []; | ||
const roles = []; | ||
if (!this.state.edges) { | ||
return null; | ||
} | ||
|
@@ -1250,6 +1250,20 @@ class PrivateEdgeList extends React.Component { | |
return ready; | ||
}; | ||
|
||
const hasWriteAccessInCluster = (projectName) => { | ||
let hasWriteAccess = false; | ||
// if user has access to the current project or the user has org wide roles | ||
var allPermissions = this.props.userAndRoleDetail.spec.permissions | ||
.filter( | ||
(obj) => obj.project === projectName || obj.scope === "organization" | ||
) | ||
.map((item) => item.permissions); | ||
let deduplicatedPermissions = new Set(allPermissions.flat(1)); | ||
// only look out for cluster write permissions | ||
hasWriteAccess = deduplicatedPermissions.has("cluster.write"); | ||
return hasWriteAccess; | ||
}; | ||
|
||
return ( | ||
<Spinner loading={!this.state.edgesLoaded} hideChildren addHeight> | ||
<div> | ||
|
@@ -1273,6 +1287,9 @@ class PrivateEdgeList extends React.Component { | |
</div> | ||
<Paper className="mb-4"> | ||
<DataTableToolbar | ||
hasWriteAccessInCluster={hasWriteAccessInCluster( | ||
this.props.UserSession.projectId | ||
)} | ||
renderInTable={this.state.renderInTable} | ||
callGetEdges={this.callGetEdges} | ||
setDefaultValue={this.setDefaultValue} | ||
|
@@ -1349,7 +1366,7 @@ class PrivateEdgeList extends React.Component { | |
iconOnly={true} | ||
/> | ||
)} | ||
{this.state.userRole !== "READ_ONLY_OPS" && ( | ||
{hasWriteAccessInCluster(n.metadata.project) && ( | ||
<Tooltip title="Kubectl Settings"> | ||
<IconButton | ||
aria-label="edit" | ||
|
@@ -1362,7 +1379,7 @@ class PrivateEdgeList extends React.Component { | |
</IconButton> | ||
</Tooltip> | ||
)} | ||
{this.state.userRole !== "READ_ONLY_OPS" && ( | ||
{hasWriteAccessInCluster(n.metadata.project) && ( | ||
<DeleteIconComponent | ||
key={n.metadata.name} | ||
button={{ | ||
|
@@ -1411,6 +1428,9 @@ class PrivateEdgeList extends React.Component { | |
parentProps={{ ...this.props }} | ||
index={index} | ||
UserSession={this.props.UserSession} | ||
hasWriteAccessInCluster={hasWriteAccessInCluster( | ||
n.metadata.project | ||
)} | ||
isUpdateEndpointsSuccess={this.props.isUpdateEndpointsSuccess} | ||
isUpdateEndpointsError={this.props.isUpdateEndpointsError} | ||
UpdateEndpointsError={this.props.UpdateEndpointsError} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
remove this