Skip to content

Commit

Permalink
Add restart to safe mode in restart dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Oct 24, 2023
1 parent c2b2343 commit 93b82ae
Showing 1 changed file with 94 additions and 78 deletions.
172 changes: 94 additions & 78 deletions src/dialogs/restart/dialog-restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ class DialogRestart extends LitElement {
}

const showReload = this.hass.userData?.showAdvanced;
const showSafeMode = this.hass.userData?.showAdvanced;
const showRebootShutdown = !!this._hostInfo;

// Present restart core dialog if no host actions and not advanced mode as it's the only option
if (!showReload && !showRebootShutdown) {
if (!showReload && !showSafeMode && !showRebootShutdown) {
this._open = false;
this._showRestartDialog().then(() => this.closeDialog());
return;
Expand All @@ -86,6 +87,7 @@ class DialogRestart extends LitElement {
}

const showReload = this.hass.userData?.showAdvanced;
const showSafeMode = this.hass.userData?.showAdvanced;
const showRebootShutdown = !!this._hostInfo;

return html`
Expand Down Expand Up @@ -152,84 +154,98 @@ class DialogRestart extends LitElement {
</ha-list-item>
</mwc-list>
<ha-expansion-panel
.header=${this.hass.localize(
"ui.dialogs.restart.advanced_options"
)}
>
<mwc-list>
${showRebootShutdown
? html`
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._hostReboot}
>
<div slot="graphic" class="icon-background reboot">
<ha-svg-icon .path=${mdiPowerCycle}></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.reboot.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.reboot.description"
)}
</span>
</ha-list-item>
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._hostShutdown}
>
<div slot="graphic" class="icon-background shutdown">
<ha-svg-icon .path=${mdiPower}></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.shutdown.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.shutdown.description"
)}
</span>
</ha-list-item>
`
: nothing}
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._restartSafeMode}
${showRebootShutdown || showSafeMode
? html`<ha-expansion-panel
.header=${this.hass.localize(
"ui.dialogs.restart.advanced_options"
)}
>
<div
slot="graphic"
class="icon-background restart-safe-mode"
>
<ha-svg-icon .path=${mdiLifebuoy}></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.restart-safe-mode.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.restart-safe-mode.description"
)}
</span>
</ha-list-item>
</mwc-list>
</ha-expansion-panel>
<mwc-list>
${showRebootShutdown
? html`
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._hostReboot}
>
<div
slot="graphic"
class="icon-background reboot"
>
<ha-svg-icon
.path=${mdiPowerCycle}
></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.reboot.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.reboot.description"
)}
</span>
</ha-list-item>
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._hostShutdown}
>
<div
slot="graphic"
class="icon-background shutdown"
>
<ha-svg-icon .path=${mdiPower}></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.shutdown.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.shutdown.description"
)}
</span>
</ha-list-item>
`
: nothing}
${showSafeMode
? html`
<ha-list-item
graphic="avatar"
twoline
multiline-secondary
hasMeta
@request-selected=${this._restartSafeMode}
>
<div
slot="graphic"
class="icon-background restart-safe-mode"
>
<ha-svg-icon .path=${mdiLifebuoy}></ha-svg-icon>
</div>
<span>
${this.hass.localize(
"ui.dialogs.restart.restart-safe-mode.title"
)}
</span>
<span slot="secondary">
${this.hass.localize(
"ui.dialogs.restart.restart-safe-mode.description"
)}
</span>
</ha-list-item>
`
: nothing}
</mwc-list>
</ha-expansion-panel>`
: nothing}
`}
</ha-dialog>
`;
Expand Down

0 comments on commit 93b82ae

Please sign in to comment.