mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 06:17:20 +00:00
Add join/leave beta to updates panel (#12436)
This commit is contained in:
parent
bb1e6bf35b
commit
02ee731602
@ -1,22 +1,35 @@
|
|||||||
|
import type { ActionDetail } from "@material/mwc-list";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { mdiDotsVertical } from "@mdi/js";
|
import { mdiDotsVertical } from "@mdi/js";
|
||||||
import { HassEntities } from "home-assistant-js-websocket";
|
import { HassEntities } from "home-assistant-js-websocket";
|
||||||
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { css, html, LitElement, PropertyValues, TemplateResult } 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 { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-bar";
|
import "../../../components/ha-bar";
|
||||||
import "../../../components/ha-button-menu";
|
import "../../../components/ha-button-menu";
|
||||||
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-metric";
|
import "../../../components/ha-metric";
|
||||||
|
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
||||||
|
import {
|
||||||
|
fetchHassioSupervisorInfo,
|
||||||
|
HassioSupervisorInfo,
|
||||||
|
reloadSupervisor,
|
||||||
|
setSupervisorOption,
|
||||||
|
SupervisorOptions,
|
||||||
|
} from "../../../data/hassio/supervisor";
|
||||||
import { updateCanInstall, UpdateEntity } from "../../../data/update";
|
import { updateCanInstall, UpdateEntity } from "../../../data/update";
|
||||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
import {
|
||||||
|
showAlertDialog,
|
||||||
|
showConfirmationDialog,
|
||||||
|
} from "../../../dialogs/generic/show-dialog-box";
|
||||||
import "../../../layouts/hass-subpage";
|
import "../../../layouts/hass-subpage";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { showToast } from "../../../util/toast";
|
import { showToast } from "../../../util/toast";
|
||||||
import "../dashboard/ha-config-updates";
|
import "../dashboard/ha-config-updates";
|
||||||
import "./ha-config-analytics";
|
|
||||||
|
|
||||||
@customElement("ha-config-section-updates")
|
@customElement("ha-config-section-updates")
|
||||||
class HaConfigSectionUpdates extends LitElement {
|
class HaConfigSectionUpdates extends LitElement {
|
||||||
@ -26,8 +39,20 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
|
|
||||||
@state() private _showSkipped = false;
|
@state() private _showSkipped = false;
|
||||||
|
|
||||||
|
@state() private _supervisorInfo?: HassioSupervisorInfo;
|
||||||
|
|
||||||
private _notifyUpdates = false;
|
private _notifyUpdates = false;
|
||||||
|
|
||||||
|
protected firstUpdated(changedProps) {
|
||||||
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
|
if (isComponentLoaded(this.hass, "hassio")) {
|
||||||
|
fetchHassioSupervisorInfo(this.hass).then((data) => {
|
||||||
|
this._supervisorInfo = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const canInstallUpdates = this._filterUpdateEntitiesWithInstall(
|
const canInstallUpdates = this._filterUpdateEntitiesWithInstall(
|
||||||
this.hass.states,
|
this.hass.states,
|
||||||
@ -44,18 +69,27 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
<ha-button-menu
|
<ha-button-menu
|
||||||
corner="BOTTOM_START"
|
corner="BOTTOM_START"
|
||||||
slot="toolbar-icon"
|
slot="toolbar-icon"
|
||||||
@action=${this._toggleSkipped}
|
@action=${this._handleAction}
|
||||||
>
|
>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.panel.config.info.copy_menu")}
|
.label=${this.hass.localize("ui.panel.config.info.copy_menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<mwc-list-item>
|
<mwc-list-item id="skipped">
|
||||||
${this._showSkipped
|
${this._showSkipped
|
||||||
? this.hass.localize("ui.panel.config.updates.hide_skipped")
|
? this.hass.localize("ui.panel.config.updates.hide_skipped")
|
||||||
: this.hass.localize("ui.panel.config.updates.show_skipped")}
|
: this.hass.localize("ui.panel.config.updates.show_skipped")}
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
|
${this._supervisorInfo?.channel !== "dev"
|
||||||
|
? html`
|
||||||
|
<mwc-list-item id="beta">
|
||||||
|
${this._supervisorInfo?.channel === "stable"
|
||||||
|
? this.hass.localize("ui.panel.config.updates.join_beta")
|
||||||
|
: this.hass.localize("ui.panel.config.updates.leave_beta")}
|
||||||
|
</mwc-list-item>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
@ -111,8 +145,53 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _toggleSkipped(): void {
|
private _handleAction(ev: CustomEvent<ActionDetail>) {
|
||||||
this._showSkipped = !this._showSkipped;
|
switch (ev.detail.index) {
|
||||||
|
case 0:
|
||||||
|
this._showSkipped = !this._showSkipped;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this._toggleBeta();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _toggleBeta(): Promise<void> {
|
||||||
|
if (this._supervisorInfo!.channel === "stable") {
|
||||||
|
const confirmed = await showConfirmationDialog(this, {
|
||||||
|
title: this.hass.localize("ui.dialogs.join_beta_channel.title"),
|
||||||
|
text: html`${this.hass.localize("ui.dialogs.join_beta_channel.warning")}
|
||||||
|
<br />
|
||||||
|
<b> ${this.hass.localize("ui.dialogs.join_beta_channel.backup")} </b>
|
||||||
|
<br /><br />
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.release_items")}
|
||||||
|
<ul>
|
||||||
|
<li>Home Assistant Core</li>
|
||||||
|
<li>Home Assistant Supervisor</li>
|
||||||
|
<li>Home Assistant Operating System</li>
|
||||||
|
</ul>
|
||||||
|
<br />
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.confirm")}`,
|
||||||
|
confirmText: this.hass.localize("ui.panel.config.updates.join_beta"),
|
||||||
|
dismissText: this.hass.localize("ui.common.cancel"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data: Partial<SupervisorOptions> = {
|
||||||
|
channel: this._supervisorInfo!.channel === "stable" ? "beta" : "stable",
|
||||||
|
};
|
||||||
|
await setSupervisorOption(this.hass, data);
|
||||||
|
await reloadSupervisor(this.hass);
|
||||||
|
} catch (err: any) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _checkUpdates(): Promise<void> {
|
private async _checkUpdates(): Promise<void> {
|
||||||
|
@ -1026,6 +1026,13 @@
|
|||||||
"docker": "[%key:supervisor::system::supervisor::unhealthy_reason::docker%]",
|
"docker": "[%key:supervisor::system::supervisor::unhealthy_reason::docker%]",
|
||||||
"untrusted": "[%key:supervisor::system::supervisor::unhealthy_reason::untrusted%]"
|
"untrusted": "[%key:supervisor::system::supervisor::unhealthy_reason::untrusted%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"join_beta_channel": {
|
||||||
|
"title": "Join the beta channel",
|
||||||
|
"warning": "[%key:supervisor::system::supervisor::beta_warning%]",
|
||||||
|
"backup": "[%key:supervisor::system::supervisor::beta_backup%]",
|
||||||
|
"release_items": "[%key:supervisor::system::supervisor::beta_release_items%]",
|
||||||
|
"confirm": "[%key:supervisor::system::supervisor::beta_join_confirm%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"duration": {
|
"duration": {
|
||||||
@ -1169,6 +1176,8 @@
|
|||||||
"show": "show",
|
"show": "show",
|
||||||
"show_skipped": "Show skipped",
|
"show_skipped": "Show skipped",
|
||||||
"hide_skipped": "Hide skipped",
|
"hide_skipped": "Hide skipped",
|
||||||
|
"join_beta": "[%key:supervisor::system::supervisor::join_beta_action%]",
|
||||||
|
"leave_beta": "[%key:supervisor::system::supervisor::leave_beta_action%]",
|
||||||
"skipped": "Skipped"
|
"skipped": "Skipped"
|
||||||
},
|
},
|
||||||
"areas": {
|
"areas": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user