mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Use progress button when adding/updating mount (#18182)
This commit is contained in:
parent
ceaceaf47b
commit
4293192e74
@ -1,6 +1,13 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { mdiAlertOctagram, mdiCheckBold } from "@mdi/js";
|
import { mdiAlertOctagram, mdiCheckBold } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import {
|
||||||
|
css,
|
||||||
|
CSSResultGroup,
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
nothing,
|
||||||
|
TemplateResult,
|
||||||
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../ha-circular-progress";
|
import "../ha-circular-progress";
|
||||||
import "../ha-svg-icon";
|
import "../ha-svg-icon";
|
||||||
@ -27,7 +34,7 @@ export class HaProgressButton extends LitElement {
|
|||||||
<slot></slot>
|
<slot></slot>
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
${!overlay
|
${!overlay
|
||||||
? ""
|
? nothing
|
||||||
: html`
|
: html`
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
${this._result === "success"
|
${this._result === "success"
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
|
import { mdiHelpCircle } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { mdiHelpCircle } from "@mdi/js";
|
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
import { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
|
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||||
|
import "../../../components/buttons/ha-progress-button";
|
||||||
|
import type { HaProgressButton } from "../../../components/buttons/ha-progress-button";
|
||||||
import "../../../components/ha-form/ha-form";
|
import "../../../components/ha-form/ha-form";
|
||||||
|
import type { SchemaUnion } from "../../../components/ha-form/types";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
||||||
import {
|
import {
|
||||||
@ -16,11 +21,8 @@ import {
|
|||||||
} from "../../../data/supervisor/mounts";
|
} from "../../../data/supervisor/mounts";
|
||||||
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { MountViewDialogParams } from "./show-dialog-view-mount";
|
|
||||||
import { LocalizeFunc } from "../../../common/translations/localize";
|
|
||||||
import type { SchemaUnion } from "../../../components/ha-form/types";
|
|
||||||
import { documentationUrl } from "../../../util/documentation-url";
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
import { MountViewDialogParams } from "./show-dialog-view-mount";
|
||||||
|
|
||||||
const mountSchema = memoizeOne(
|
const mountSchema = memoizeOne(
|
||||||
(
|
(
|
||||||
@ -269,8 +271,8 @@ class ViewMountDialog extends LitElement {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mwc-button
|
<ha-progress-button
|
||||||
.disabled=${this._waiting}
|
.progress=${this._waiting}
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
@click=${this._connectMount}
|
@click=${this._connectMount}
|
||||||
>
|
>
|
||||||
@ -281,7 +283,7 @@ class ViewMountDialog extends LitElement {
|
|||||||
: this.hass.localize(
|
: this.hass.localize(
|
||||||
"ui.panel.config.storage.network_mounts.connect"
|
"ui.panel.config.storage.network_mounts.connect"
|
||||||
)}
|
)}
|
||||||
</mwc-button>
|
</ha-progress-button>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -333,7 +335,8 @@ class ViewMountDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _connectMount() {
|
private async _connectMount(ev) {
|
||||||
|
const progressButton = ev.target as HaProgressButton;
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._waiting = true;
|
this._waiting = true;
|
||||||
const mountData = { ...this._data! };
|
const mountData = { ...this._data! };
|
||||||
@ -349,6 +352,7 @@ class ViewMountDialog extends LitElement {
|
|||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._error = extractApiErrorMessage(err);
|
this._error = extractApiErrorMessage(err);
|
||||||
this._waiting = false;
|
this._waiting = false;
|
||||||
|
progressButton.actionError();
|
||||||
if (this._data!.type === "cifs" && !this._showCIFSVersion) {
|
if (this._data!.type === "cifs" && !this._showCIFSVersion) {
|
||||||
this._showCIFSVersion = true;
|
this._showCIFSVersion = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user