fix: scope storage type picker to the target organization
The storage create form fetched persistent-volume types once with no tenant scope, so in the platform-admin "All" view the dropdown listed every org's types and never re-scoped when the create-scope picker retargeted the form — letting an org with no cluster-access grant pick another org's types. The inline "add storage" sub-drawer in the instance create form had the same gap plus a redundant org picker that could retarget the storage away from the instance's org. Both surfaces now pin the storage-type list to the chosen org (via the X-Organization-Id header); the sub-drawer inherits the instance's scope and hides its own picker. Page/table listings stay unscoped so every row's type label still renders.
This commit is contained in:
@@ -10,12 +10,18 @@ import useOverlayLayout from '../hooks/use-overlay-layout';
|
||||
|
||||
interface StorageOverlayProps {
|
||||
open: boolean;
|
||||
// Org the surrounding instance create form targets (platform admin "All"
|
||||
// view). The storage inherits this scope, so the type list is pinned to
|
||||
// it — the picker only offers types that org can reference. Undefined
|
||||
// when there's no create-scope picker (the ambient org context applies).
|
||||
scopeOrgId?: number | null;
|
||||
onCancel: () => void;
|
||||
onSubmit: (values: StorageFormData) => Promise<void> | void;
|
||||
}
|
||||
|
||||
const StorageOverlay: React.FC<StorageOverlayProps> = ({
|
||||
open,
|
||||
scopeOrgId,
|
||||
onCancel,
|
||||
onSubmit
|
||||
}) => {
|
||||
@@ -28,9 +34,14 @@ const StorageOverlay: React.FC<StorageOverlayProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
fetchStorageClass({ page: -1 });
|
||||
fetchStorageClass(
|
||||
{ page: -1 },
|
||||
scopeOrgId != null
|
||||
? { headers: { 'X-Organization-Id': String(scopeOrgId) } }
|
||||
: undefined
|
||||
);
|
||||
}
|
||||
}, [open]);
|
||||
}, [open, scopeOrgId]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
formRef.current?.submit();
|
||||
@@ -75,6 +86,7 @@ const StorageOverlay: React.FC<StorageOverlayProps> = ({
|
||||
ref={formRef}
|
||||
action={PageAction.CREATE}
|
||||
open={open}
|
||||
showOrgScope={false}
|
||||
onFinish={handleFinish}
|
||||
/>
|
||||
</FormContext.Provider>
|
||||
|
||||
@@ -30,6 +30,10 @@ const StorageVolume = ({
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const form = Form.useFormInstance<FormData>();
|
||||
const storageMode = Form.useWatch('storageMode', form);
|
||||
// Owned by the instance create-scope picker (platform admin "All" view).
|
||||
// A storage added inline belongs to the same org as the instance, so pass
|
||||
// it to the overlay to scope the storage-type list to that org.
|
||||
const scopeOrgId = Form.useWatch('organization_id', form);
|
||||
const { fetchData: createStorage } = useCreateStorage();
|
||||
const { detailData: storageData, fetchData: fetchStorage } =
|
||||
useQueryStorage();
|
||||
@@ -232,6 +236,7 @@ const StorageVolume = ({
|
||||
|
||||
<StorageOverlay
|
||||
open={overlayOpen}
|
||||
scopeOrgId={scopeOrgId}
|
||||
onCancel={() => setOverlayOpen(false)}
|
||||
onSubmit={handleCreateStorage}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user