-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: [WD-19336] Storage volumes permission checks #1134
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Nkeiruka <[email protected]>
Signed-off-by: Nkeiruka <[email protected]>
Signed-off-by: Nkeiruka <[email protected]>
1322d75
to
64663ef
Compare
Signed-off-by: Nkeiruka <[email protected]>
64663ef
to
d3efcd7
Compare
Signed-off-by: Nkeiruka <[email protected]>
…n permissions Signed-off-by: Nkeiruka <[email protected]>
Signed-off-by: Nkeiruka <[email protected]>
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 a good direction. Some comments on the draft below.
@@ -21,6 +21,7 @@ export const instanceEntitlements = [ | |||
"can_delete", | |||
"can_edit", | |||
"can_exec", | |||
"can_view", |
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.
"can_view", |
We never check view permission explicitly. If a user knows an entity exists, they can view it. We can always infer this permission.
@@ -157,7 +159,7 @@ const MigrateVolumeBtn: FC<Props> = ({ | |||
type="button" | |||
className={classname} | |||
loading={isVolumeLoading} | |||
disabled={isVolumeLoading} | |||
disabled={!canEditVolume(storageVolume) || isVolumeLoading} |
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 should always add a title explaining why something is disabled. In this new case, add a copy about the missing permission. See other places in the codebase for example copy. The loading state has other cues for why the button is disabled, so we don't need a title for those.
@@ -123,7 +125,9 @@ const StorageVolumeHeader: FC<Props> = ({ volume, project }) => { | |||
renameDisabledReason={ | |||
(volume.used_by?.length ?? 0) > 0 | |||
? "Can not rename, volume is currently in use." | |||
: undefined | |||
: !canEditVolume(volume) |
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.
Readability will benefit from extracting the logic into a function with early exits instead of nested ternaries.
|
||
return ( | ||
<div className={classnames("u-flex", className)}> | ||
<div | ||
className={classnames("u-truncate", "volume-name-link")} | ||
title={caption} | ||
title={volume.name} |
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 title should match the truncated contents.
title={volume.name} | |
title={caption} |
const caption = overrideName | ||
? displayLink | ||
? overrideName | ||
: "" | ||
: volume.name; |
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.
If I understand correctly, this is to not render anything in the right-hand column on the volume list. Currently, we still render some markup with titles and empty string as content in the case that link should be hidden. Better simplify and avoid the empty markup, as suggested below?
Might be worth adding a comment or solving this in a more straight forward way to make it easy to understand.
const caption = overrideName | |
? displayLink | |
? overrideName | |
: "" | |
: volume.name; | |
const caption = overrideName ? overrideName : volume.name; | |
if (overrideName && !displayLink) { | |
return null; | |
} |
@@ -27,6 +35,7 @@ const CreateVolumeBtn: FC<Props> = ({ project, className, defaultPool }) => { | |||
hasIcon={!isSmallScreen} | |||
onClick={handleAdd} | |||
className={className} | |||
disabled={!canCreateStorageVolumes(project)} |
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.
Please add a title.
@@ -31,6 +33,7 @@ const DuplicateVolumeBtn: FC<Props> = ({ volume, className, onClose }) => { | |||
className={className} | |||
onClick={openPortal} | |||
title="Duplicate volume" | |||
disabled={!canCreateStorageVolumes(volume)} |
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.
Title please
: !canManageStorageVolumeSnapshots(volume) | ||
? "You do not have permission to create or delete snapshots of this volume." | ||
: "Add Snapshot" |
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.
Probably better to extract this into a function with early exits as well. Then the disabled check below can use that same function. See how DeleteStoragePoolBtn
is doing it for an example.
Done
Storage Volumes page
See Storage Volume Permission Actions for full list of implemented / pending actions to permission check.
QA
Screenshots