Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions portal-ui/src/common/SecureComponent/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,13 @@ export const IAM_PAGES_PERMISSIONS = {

export const S3_ALL_RESOURCES = "arn:aws:s3:::*";
export const CONSOLE_UI_RESOURCE = "console-ui";

export const permissionTooltipHelper = (scopes: string[], name: string) => {
return (
"You require additional permissions in order to enable " +
name +
". Please ask your MinIO administrator to grant you " +
scopes +
" permission in order to enable Versioning."
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ import {
} from "./addBucketsSlice";
import { addBucketAsync } from "./addBucketThunks";
import AddBucketName from "./AddBucketName";
import { IAM_SCOPES } from "../../../../../common/SecureComponent/permissions";
import {
IAM_SCOPES,
permissionTooltipHelper,
} from "../../../../../common/SecureComponent/permissions";
import { hasPermission } from "../../../../../common/SecureComponent";
import BucketNamingRules from "./BucketNamingRules";

Expand Down Expand Up @@ -323,10 +326,13 @@ const AddBucket = ({ classes }: IsetProps) => {
<TooltipWrapper
tooltip={
versioningAllowed
? ""
: "You require additional permissions in order to enable Versioning. Please ask your MinIO administrator to grant you " +
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING +
" permission in order to enable Versioning."
? lockingEnabled && versioningEnabled
? "You must disable Locking before Versioning can be disabled"
: ""
: permissionTooltipHelper(
[IAM_SCOPES.S3_PUT_BUCKET_VERSIONING],
"Versioning"
)
}
>
<FormSwitchWrapper
Expand All @@ -352,12 +358,13 @@ const AddBucket = ({ classes }: IsetProps) => {
tooltip={
lockingAllowed
? ""
: "You require additional permissions in order to enable Locking. Please ask your MinIO administrator to grant you " +
(versioningAllowed
? ""
: IAM_SCOPES.S3_PUT_BUCKET_VERSIONING + " and ") +
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION +
" permissions in order to enable Locking."
: permissionTooltipHelper(
[
IAM_SCOPES.S3_PUT_BUCKET_VERSIONING,
IAM_SCOPES.S3_PUT_BUCKET_OBJECT_LOCK_CONFIGURATION,
],
"Locking"
)
}
>
<FormSwitchWrapper
Expand Down Expand Up @@ -501,19 +508,27 @@ const AddBucket = ({ classes }: IsetProps) => {
onClick={resForm}
label={"Clear"}
/>
<Button
id={"create-bucket"}
type="submit"
variant="callAction"
color="primary"
disabled={
addLoading ||
invalidFields.length > 0 ||
!isDirty ||
hasErrors
<TooltipWrapper
tooltip={
invalidFields.length > 0 || !isDirty || hasErrors
? "You must apply a valid name to the bucket"
: ""
}
label={"Create Bucket"}
/>
>
<Button
id={"create-bucket"}
type="submit"
variant="callAction"
color="primary"
disabled={
addLoading ||
invalidFields.length > 0 ||
!isDirty ||
hasErrors
}
label={"Create Bucket"}
/>
</TooltipWrapper>
</Grid>
{addLoading && (
<Grid item xs={12}>
Expand Down