diff --git a/src/panels/lovelace/editor/view-editor/hui-edit-view.ts b/src/panels/lovelace/editor/view-editor/hui-edit-view.ts index 3387326208..0ce183e582 100644 --- a/src/panels/lovelace/editor/view-editor/hui-edit-view.ts +++ b/src/panels/lovelace/editor/view-editor/hui-edit-view.ts @@ -207,7 +207,7 @@ export class HuiEditView extends LitElement { deleteView(this.lovelace!.config, this.viewIndex!) ); this._closeDialog(); - navigate(this, `/lovelace/0`); + navigate(this, `/${window.location.pathname.split("/")[1]}`); } catch (err) { showAlertDialog(this, { text: `Deleting failed: ${err.message}`, @@ -216,15 +216,21 @@ export class HuiEditView extends LitElement { } private _deleteConfirm(): void { - if (this._cards && this._cards.length > 0) { - showAlertDialog(this, { - text: this.hass!.localize("ui.panel.lovelace.views.existing_cards"), - }); - return; - } - showConfirmationDialog(this, { - text: this.hass!.localize("ui.panel.lovelace.views.confirm_delete"), + title: this.hass!.localize( + `ui.panel.lovelace.views.confirm_delete${ + this._cards?.length ? `_existing_cards` : "" + }` + ), + text: this.hass!.localize( + `ui.panel.lovelace.views.confirm_delete${ + this._cards?.length ? `_existing_cards` : "" + }_text`, + "name", + this._config?.title || "Unnamed view", + "number", + this._cards?.length || 0 + ), confirm: () => this._delete(), }); } diff --git a/src/translations/en.json b/src/translations/en.json index 7021bf57fc..11d6338bec 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1875,8 +1875,10 @@ "saving_failed": "Saving Lovelace UI configuration failed." }, "views": { - "confirm_delete": "Are you sure you want to delete this view?", - "existing_cards": "You can't delete a view that has cards in it. Remove the cards first." + "confirm_delete": "Delete view?", + "confirm_delete_text": "Are you sure you want to delete your '{name}' view?", + "confirm_delete_existing_cards": "Deleting this view will also remove the cards", + "confirm_delete_existing_cards_text": "Are you sure you want to delete your '{name}' view? The view contains {number} cards that will be deleted. This action cannot be undone." }, "menu": { "configure_ui": "Configure UI",