Skip to content

Commit

Permalink
review: revert config row changes, permissions are checked from insta…
Browse files Browse the repository at this point in the history
…nce permissions PR already

Signed-off-by: Mason Hu <[email protected]>
  • Loading branch information
MasWho committed Feb 17, 2025
1 parent 872a32f commit fda5c05
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 53 deletions.
6 changes: 3 additions & 3 deletions src/pages/storage/actions/CreateStoragePoolBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ interface Props {
const CreateStoragePoolBtn: FC<Props> = ({ project, className }) => {
const navigate = useNavigate();
const isSmallScreen = useSmallScreen();
const { cancreateStoragePools } = useServerEntitlements();
const { canCreateStoragePools } = useServerEntitlements();

return (
<Button
appearance="positive"
className={className}
hasIcon={!isSmallScreen}
title={
!cancreateStoragePools()
!canCreateStoragePools()
? "You do not have permission to create storage pools"
: ""
}
onClick={() => navigate(`/ui/project/${project}/storage/pools/create`)}
disabled={!cancreateStoragePools()}
disabled={!canCreateStoragePools()}
>
{!isSmallScreen && <Icon name="plus" light />}
<span>Create pool</span>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/actions/DeleteStoragePoolBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const DeleteStoragePoolBtn: FC<Props> = ({
loading={isLoading}
shiftClickEnabled
showShiftClickHint
disabled={Boolean(disabledReason()) || !canDeletePool(pool)}
disabled={Boolean(disabledReason())}
onHoverText={disabledReason()}
>
{(!isSmallScreen || !shouldExpand) && <Icon name="delete" />}
Expand Down
10 changes: 0 additions & 10 deletions src/pages/storage/forms/StoragePoolFormCeph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const StoragePoolFormCeph: FC<Props> = ({ formik }) => {
name: "ceph_cluster_name",
defaultValue: "",
children: <Input type="text" placeholder="Enter cluster name" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
Expand All @@ -34,35 +32,27 @@ const StoragePoolFormCeph: FC<Props> = ({ formik }) => {
placeholder="Enter number of placement groups"
/>
),
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "RBD clone copy",
name: "ceph_rbd_clone_copy",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Ceph user name",
name: "ceph_user_name",
defaultValue: "",
children: <Input type="text" placeholder="Enter Ceph user name" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "RBD features",
name: "ceph_rbd_features",
defaultValue: "",
children: <Input type="text" placeholder="Enter RBD features" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
]}
/>
Expand Down
12 changes: 0 additions & 12 deletions src/pages/storage/forms/StoragePoolFormCephFS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,41 @@ const StoragePoolFormCephFS: FC<Props> = ({ formik }) => {
name: "cephfs_cluster_name",
defaultValue: "",
children: <Input type="text" placeholder="Enter cluster name" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Create missing",
name: "cephfs_create_missing",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "FS cache",
name: "cephfs_fscache",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Number of placement groups",
name: "cephfs_osd_pg_num",
defaultValue: "",
children: <Input type="text" placeholder="Enter number" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Path",
name: "cephfs_path",
defaultValue: "",
children: <Input type="text" placeholder="Enter path" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Ceph user name",
name: "cephfs_user_name",
defaultValue: "",
children: <Input type="text" placeholder="Enter pool name" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
]}
/>
Expand Down
8 changes: 0 additions & 8 deletions src/pages/storage/forms/StoragePoolFormPowerflex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,27 @@ const StoragePoolFormPowerflex: FC<Props> = ({ formik }) => {
name: "powerflex_clone_copy",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "SDT",
name: "powerflex_sdt",
defaultValue: "",
children: <Input type="text" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Gateway verify",
name: "powerflex_gateway_verify",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Mode",
name: "powerflex_mode",
defaultValue: "",
children: <Select options={optionNvmeSdc} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
]}
/>
Expand Down
8 changes: 1 addition & 7 deletions src/pages/storage/forms/StoragePoolFormPure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,21 @@ const StoragePoolFormPure: FC<Props> = ({ formik }) => {
name: "pure_gateway_verify",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Mode",
name: "pure_mode",
defaultValue: "",
disabled:
!!formik.values.editRestriction || !formik.values.isCreating,
disabled: !formik.values.isCreating,
children: <Select options={optionIscsiNvme} />,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Target",
name: "pure_target",
defaultValue: "",
children: <Input type="text" />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
]}
/>
Expand Down
12 changes: 2 additions & 10 deletions src/pages/storage/forms/StoragePoolFormZFS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,22 @@ const StoragePoolFormZFS: FC<Props> = ({ formik }) => {
) : (
<>{value}</>
),
disabled:
!!formik.values.editRestriction ||
!formik.values.isCreating ||
formik.values.readOnly,
disabledReason:
formik.values.editRestriction ?? "ZFS pool name cannot be modified",
disabled: !formik.values.isCreating || formik.values.readOnly,
disabledReason: "ZFS pool name cannot be modified",
}),
getConfigurationRow({
formik,
label: "Clone copy",
name: "zfs_clone_copy",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
getConfigurationRow({
formik,
label: "Export",
name: "zfs_export",
defaultValue: "",
children: <Select options={optionTrueFalse} />,
disabled: !!formik.values.editRestriction,
disabledReason: formik.values.editRestriction,
}),
]}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/util/entitlements/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useServerEntitlements = () => {
hasEntitlement(isFineGrained, "admin", serverEntitlements) ||
hasEntitlement(isFineGrained, "viewer", serverEntitlements);

const cancreateStoragePools = () =>
const canCreateStoragePools = () =>
hasEntitlement(
isFineGrained,
"can_create_storage_pools",
Expand All @@ -28,7 +28,7 @@ export const useServerEntitlements = () => {
hasEntitlement(isFineGrained, "storage_pool_manager", serverEntitlements);

return {
cancreateStoragePools,
canCreateStoragePools,
canEditServerConfiguration,
canViewMetrics,
canViewResources,
Expand Down

0 comments on commit fda5c05

Please sign in to comment.