feat: prevent users from selecting mounted devices (#987) (#990)

(cherry picked from commit 7d09cb714225f9b721c49005cb72533c5fa5d079)

Signed-off-by: Jack Yu <jack.yu@suse.com>
Co-authored-by: Jack Yu <jack.yu@suse.com>
This commit is contained in:
mergify[bot] 2026-07-14 11:58:48 +08:00 committed by GitHub
parent d3b77e2e41
commit e71d12f67f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -468,10 +468,15 @@ export default {
const size = formatSi(sizeBytes, { increment: 1024, suffix: UNIT_SUFFIX }); const size = formatSi(sizeBytes, { increment: 1024, suffix: UNIT_SUFFIX });
const parentDevice = d.status?.deviceStatus?.parentDevice; const parentDevice = d.status?.deviceStatus?.parentDevice;
const isChildAdded = this.newDisks.find((newDisk) => newDisk.blockDevice?.status?.deviceStatus?.parentDevice === devPath); const isChildAdded = this.newDisks.find((newDisk) => newDisk.blockDevice?.status?.deviceStatus?.parentDevice === devPath);
const mountPoint = d.status?.deviceStatus?.fileSystem?.mountPoint;
const name = d.displayName; const name = d.displayName;
let label = `${ name } (Type: ${ deviceType }, Size: ${ size })`; let label = `${ name } (Type: ${ deviceType }, Size: ${ size })`;
if (mountPoint) {
label = `${ label } - ${ this.t('harvester.host.disk.mounted') }`;
}
if (parentDevice) { if (parentDevice) {
label = `- ${ label }`; label = `- ${ label }`;
} }
@ -481,7 +486,7 @@ export default {
value: d.id, value: d.id,
action: this.addDisk, action: this.addDisk,
kind: !parentDevice ? 'group' : '', kind: !parentDevice ? 'group' : '',
disabled: !!isChildAdded, disabled: !!isChildAdded || !!mountPoint,
group: parentDevice || devPath, group: parentDevice || devPath,
isParent: !!parentDevice, isParent: !!parentDevice,
}; };

View File

@ -640,6 +640,7 @@ harvester:
notification: notification:
success: 'Update host "{name}" storage configurations successfully.' success: 'Update host "{name}" storage configurations successfully.'
error: Host has unready or unschedulable disks. error: Host has unready or unschedulable disks.
mounted: Already Mounted
fileSystem: fileSystem:
info: Current file system is {system}, You can format it manually. info: Current file system is {system}, You can format it manually.
formatting: Disk is formatting, please wait. formatting: Disk is formatting, please wait.

View File

@ -53,7 +53,6 @@ export default {
devices() { devices() {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;
const data = this.$store.getters[`${ inStore }/all`](HCI.USB_DEVICE) || []; const data = this.$store.getters[`${ inStore }/all`](HCI.USB_DEVICE) || [];
data.forEach((row) => { data.forEach((row) => {