Tiers permission UI fix (#2310)
This commit is contained in:
@@ -368,13 +368,14 @@ export const IAM_PAGES_PERMISSIONS = {
|
||||
],
|
||||
[IAM_PAGES.TIERS]: [
|
||||
IAM_SCOPES.ADMIN_LIST_TIERS, // display tiers list
|
||||
IAM_SCOPES.ADMIN_SET_TIER, // display "add tier" button
|
||||
],
|
||||
[IAM_PAGES.TIERS_ADD]: [
|
||||
IAM_SCOPES.ADMIN_SET_TIER, // display "add tier" button / shows add service tier page
|
||||
IAM_SCOPES.ADMIN_LIST_TIERS, // display tiers list
|
||||
],
|
||||
[IAM_PAGES.TIERS_ADD_SERVICE]: [
|
||||
IAM_SCOPES.ADMIN_SET_TIER, // display "add tier" button / shows add service tier page
|
||||
IAM_SCOPES.ADMIN_LIST_TIERS, // display tiers list
|
||||
],
|
||||
[IAM_PAGES.TOOLS]: [
|
||||
IAM_SCOPES.S3_LISTEN_NOTIFICATIONS, // displays watch notifications
|
||||
|
||||
@@ -58,6 +58,8 @@ import { tierTypes } from "./utils";
|
||||
import { selDistSet, setErrorSnackMessage } from "../../../../systemSlice";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAppDispatch } from "../../../../store";
|
||||
import { hasPermission } from "../../../../common/SecureComponent";
|
||||
import TooltipWrapper from "../../Common/TooltipWrapper/TooltipWrapper";
|
||||
|
||||
const UpdateTierCredentialsModal = withSuspense(
|
||||
React.lazy(() => import("./UpdateTierCredentialsModal"))
|
||||
@@ -109,6 +111,10 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
|
||||
type: "unsupported",
|
||||
});
|
||||
|
||||
const hasSetTier = hasPermission(CONSOLE_UI_RESOURCE, [
|
||||
IAM_SCOPES.ADMIN_SET_TIER,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoading) {
|
||||
if (distributedSetup) {
|
||||
@@ -285,20 +291,29 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
|
||||
setIsLoading(true);
|
||||
}}
|
||||
/>
|
||||
|
||||
<SecureComponent
|
||||
scopes={[IAM_SCOPES.ADMIN_SET_TIER]}
|
||||
resource={CONSOLE_UI_RESOURCE}
|
||||
errorProps={{ disabled: true }}
|
||||
<TooltipWrapper
|
||||
tooltip={
|
||||
hasSetTier
|
||||
? ""
|
||||
: "You require additional permissions in order to create a new Tier. Please ask your MinIO administrator to grant you " +
|
||||
IAM_SCOPES.ADMIN_SET_TIER +
|
||||
" permission in order to create a Tier."
|
||||
}
|
||||
>
|
||||
<Button
|
||||
id={"add-tier"}
|
||||
icon={<AddIcon />}
|
||||
label={`Create Tier`}
|
||||
onClick={addTier}
|
||||
variant="callAction"
|
||||
/>
|
||||
</SecureComponent>
|
||||
<SecureComponent
|
||||
scopes={[IAM_SCOPES.ADMIN_SET_TIER]}
|
||||
resource={CONSOLE_UI_RESOURCE}
|
||||
errorProps={{ disabled: true }}
|
||||
>
|
||||
<Button
|
||||
id={"add-tier"}
|
||||
icon={<AddIcon />}
|
||||
label={`Create Tier`}
|
||||
onClick={addTier}
|
||||
variant="callAction"
|
||||
/>
|
||||
</SecureComponent>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
</Grid>
|
||||
{isLoading && <LinearProgress />}
|
||||
@@ -442,8 +457,15 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
|
||||
tier.
|
||||
<br />
|
||||
<br />
|
||||
To get started,{" "}
|
||||
<AButton onClick={addTier}>Create Tier</AButton>.
|
||||
{hasSetTier ? (
|
||||
<div>
|
||||
To get started,{" "}
|
||||
<AButton onClick={addTier}>Create Tier</AButton>
|
||||
.
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Fragment>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user