Skip to content

Commit

Permalink
fix(iso) limit iso storage volumes per project -- they are not access…
Browse files Browse the repository at this point in the history
…ible accross projects
  • Loading branch information
edlerd committed Aug 30, 2023
1 parent c83ff9e commit da698ae
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/api/storage-pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ export const deleteStoragePool = (pool: string, project: string) => {
};

export const fetchStorageVolumes = (
pool: string
pool: string,
project: string
): Promise<LxdStorageVolume[]> => {
return new Promise((resolve, reject) => {
fetch(`/1.0/storage-pools/${pool}/volumes?all-projects=true&recursion=1`)
fetch(`/1.0/storage-pools/${pool}/volumes?project=${project}&recursion=1`)
.then(handleResponse)
.then((data: LxdApiResponse<LxdStorageVolume[]>) =>
resolve(data.metadata)
Expand Down
2 changes: 1 addition & 1 deletion src/context/loadIsoImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const loadIsoImages = async (
const result: RemoteImage[] = [];
const pools = await fetchStoragePools(project);
for (const pool of pools) {
const volumes = await fetchStorageVolumes(pool.name);
const volumes = await fetchStorageVolumes(pool.name, project);

volumes.forEach((volume) => {
if (volume.content_type === "iso") {
Expand Down
5 changes: 4 additions & 1 deletion src/pages/storage/StorageUsedBy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ const StorageUsedBy: FC<Props> = ({ storage, project }) => {
<td>
<ExpandableList
items={data[CUSTOM].map((item) => (
<div key={item.name}>{item.name}</div>
<div key={item.name}>
{item.name}
{item.project !== project && ` (project ${item.project})`}
</div>
))}
/>
</td>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/storage/StorageVolumes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const StorageVolumes: FC = () => {
error,
isLoading,
} = useQuery({
queryKey: [queryKeys.storage, pool, queryKeys.volumes],
queryFn: () => fetchStorageVolumes(pool),
queryKey: [queryKeys.storage, pool, queryKeys.volumes, project],
queryFn: () => fetchStorageVolumes(pool, project),
});

if (error) {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/storage/UploadCustomImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ const UploadCustomImage: FC<Props> = ({ onCancel, onFinish }) => {
notify.clear();
}, []);

const projectName = project?.name ?? "";

const {
data: pools = [],
isLoading: arePoolsLoading,
error: poolError,
} = useQuery({
queryKey: [queryKeys.storage],
queryFn: () => fetchStoragePools(project?.name ?? ""),
queryFn: () => fetchStoragePools(projectName),
});

if (poolError) {
Expand Down Expand Up @@ -71,7 +73,7 @@ const UploadCustomImage: FC<Props> = ({ onCancel, onFinish }) => {
pool,
file,
name,
project?.name ?? "",
projectName,
setUploadState,
uploadController
)
Expand All @@ -88,6 +90,7 @@ const UploadCustomImage: FC<Props> = ({ onCancel, onFinish }) => {
queryKeys.storage,
pool,
queryKeys.volumes,
projectName,
]);
});
};
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/actions/DeleteStorageVolumeBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DeleteStorageVolumeBtn: FC<Props> = ({ pool, project, volume }) => {
queryKeys.storage,
pool,
queryKeys.volumes,
project,
]);
});
};
Expand Down

0 comments on commit da698ae

Please sign in to comment.