Skip to content

Commit

Permalink
fix: fix host path device display
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Hu <[email protected]>
  • Loading branch information
mas-who committed Dec 11, 2024
1 parent 54551b5 commit 626aa70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/DeviceDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { FC } from "react";
import { isRootDisk } from "util/instanceValidation";
import { isHostPath, isRootDisk } from "util/instanceValidation";
import { FormDevice } from "util/formDevices";
import { LxdDeviceValue } from "types/device";
import ResourceLink from "components/ResourceLink";
import ResourceLabel from "./ResourceLabel";

interface Props {
device: LxdDeviceValue;
Expand All @@ -24,6 +25,15 @@ const DeviceDetails: FC<Props> = ({ device, project }) => {
);
}

if (isHostPath(device as FormDevice)) {
return (
<>
Host path{" "}
<ResourceLabel type={"volume"} value={device.source as string} />
</>
);
}

return (
<>
Volume{" "}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourceLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ResourceLabel: FC<Props> = ({ type, value, bold }) => {
return (
<span className="resource-label u-truncate">
<ResourceIcon type={type} />
<ValueWrapper>{value}</ValueWrapper>
<ValueWrapper title={value}>{value}</ValueWrapper>
</span>
);
};
Expand Down
4 changes: 4 additions & 0 deletions src/util/instanceValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const isRootDisk = (device: FormDevice): device is FormDiskDevice => {
return device.type === "disk" && device.path === "/" && !device.source;
};

export const isHostPath = (device: FormDevice): boolean => {
return device.type === "disk" && !!device.source && device.pool === undefined;
};

const missingRoot = (devices: FormDevice[]): boolean => {
return !devices.some(isRootDisk);
};
Expand Down

0 comments on commit 626aa70

Please sign in to comment.