From 4b8960c2366359cd52892ad9ad03649adc5cc4df Mon Sep 17 00:00:00 2001
From: Paul Bottein
Date: Mon, 19 Sep 2022 14:39:05 +0200
Subject: [PATCH] Update Move datadisk (not found) dialog (#13812)
---
.../config/storage/dialog-move-datadisk.ts | 89 ++++++++++---------
src/translations/en.json | 3 +-
2 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/src/panels/config/storage/dialog-move-datadisk.ts b/src/panels/config/storage/dialog-move-datadisk.ts
index a005f29ebd..cfe29c95ca 100644
--- a/src/panels/config/storage/dialog-move-datadisk.ts
+++ b/src/panels/config/storage/dialog-move-datadisk.ts
@@ -52,7 +52,23 @@ class MoveDatadiskDialog extends LitElement {
try {
this._osInfo = await fetchHassioHassOsInfo(this.hass);
+
+ const data = await listDatadisks(this.hass);
+ if (data.devices.length > 0) {
+ this._devices = data.devices;
+ } else {
+ this.closeDialog();
+ await showAlertDialog(this, {
+ title: this.hass.localize(
+ "ui.panel.config.storage.datadisk.no_devices_title"
+ ),
+ text: this.hass.localize(
+ "ui.panel.config.storage.datadisk.no_devices_text"
+ ),
+ });
+ }
} catch (err: any) {
+ this.closeDialog();
await showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.hardware.available_hardware.failed_to_get"
@@ -60,10 +76,6 @@ class MoveDatadiskDialog extends LitElement {
text: extractApiErrorMessage(err),
});
}
-
- listDatadisks(this.hass).then((data) => {
- this._devices = data.devices;
- });
}
public closeDialog(): void {
@@ -76,9 +88,10 @@ class MoveDatadiskDialog extends LitElement {
}
protected render(): TemplateResult {
- if (!this._hostInfo || !this._osInfo) {
+ if (!this._hostInfo || !this._osInfo || !this._devices) {
return html``;
}
+
return html`
${this._moving
- ? html`
+ ? html`
+
${this.hass.localize(
"ui.panel.config.storage.datadisk.moving_desc"
)}
-
`
- : html`${this._devices?.length
- ? html`
- ${this.hass.localize(
- "ui.panel.config.storage.datadisk.description",
- {
- current_path: this._osInfo.data_disk,
- time: calculateMoveTime(this._hostInfo),
- }
- )}
-
+
+ `
+ : html`
+ ${this.hass.localize(
+ "ui.panel.config.storage.datadisk.description",
+ {
+ current_path: this._osInfo.data_disk,
+ time: calculateMoveTime(this._hostInfo),
+ }
+ )}
+
-
- ${this._devices.map(
- (device) =>
- html`${device}`
- )}
-
- `
- : this._devices === undefined
- ? this.hass.localize(
- "ui.panel.config.storage.datadisk.loading_devices"
- )
- : this.hass.localize(
- "ui.panel.config.storage.datadisk.no_devices"
- )}
+
+ ${this._devices.map(
+ (device) =>
+ html`${device}`
+ )}
+
${this.hass.localize("ui.panel.config.storage.datadisk.move")}
- `}
+
+ `}
`;
}
diff --git a/src/translations/en.json b/src/translations/en.json
index 08396ef1ab..289b08e6a4 100755
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -3507,7 +3507,8 @@
"title": "Move datadisk",
"description": "You are currently using ''{current_path}'' as datadisk. Moving data disks will reboot your device and it's estimated to take {time} minutes. Your Home Assistant installation will not be accessible during this period. Do not disconnect the power during the move!",
"select_device": "Select new datadisk",
- "no_devices": "No suitable attached devices found",
+ "no_devices_title": "No suitable storage found",
+ "no_devices_text": "There is no suitable external device found. The storage capacity of the external data disk must be larger than the storage capacity of the existing disk",
"moving_desc": "Rebooting and moving datadisk. Please have patience",
"moving": "Moving datadisk",
"loading_devices": "Loading devices",