mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 04:06:35 +00:00
Update join beta dialog (#13847)
This commit is contained in:
parent
fc86a66c33
commit
5146fa1d9e
@ -23,6 +23,7 @@ import {
|
|||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
} from "../../../src/dialogs/generic/show-dialog-box";
|
} from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
|
import { showJoinBetaDialog } from "../../../src/panels/config/core/updates/show-dialog-join-beta";
|
||||||
import {
|
import {
|
||||||
UNHEALTHY_REASON_URL,
|
UNHEALTHY_REASON_URL,
|
||||||
UNSUPPORTED_REASON_URL,
|
UNSUPPORTED_REASON_URL,
|
||||||
@ -230,36 +231,27 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
button.progress = true;
|
button.progress = true;
|
||||||
|
|
||||||
if (this.supervisor.supervisor.channel === "stable") {
|
if (this.supervisor.supervisor.channel === "stable") {
|
||||||
const confirmed = await showConfirmationDialog(this, {
|
showJoinBetaDialog(this, {
|
||||||
title: this.supervisor.localize("system.supervisor.warning"),
|
join: async () => {
|
||||||
text: html`${this.supervisor.localize("system.supervisor.beta_warning")}
|
await this._setChannel("beta");
|
||||||
<br />
|
button.progress = false;
|
||||||
<b> ${this.supervisor.localize("system.supervisor.beta_backup")} </b>
|
},
|
||||||
<br /><br />
|
cancel: () => {
|
||||||
${this.supervisor.localize("system.supervisor.beta_release_items")}
|
button.progress = false;
|
||||||
<ul>
|
},
|
||||||
<li>Home Assistant Core</li>
|
});
|
||||||
<li>Home Assistant Supervisor</li>
|
} else {
|
||||||
<li>Home Assistant Operating System</li>
|
await this._setChannel("stable");
|
||||||
</ul>
|
|
||||||
<br />
|
|
||||||
${this.supervisor.localize("system.supervisor.beta_join_confirm")}`,
|
|
||||||
confirmText: this.supervisor.localize(
|
|
||||||
"system.supervisor.join_beta_action"
|
|
||||||
),
|
|
||||||
dismissText: this.supervisor.localize("common.cancel"),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
button.progress = false;
|
button.progress = false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setChannel(
|
||||||
|
channel: SupervisorOptions["channel"]
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const data: Partial<SupervisorOptions> = {
|
const data: Partial<SupervisorOptions> = {
|
||||||
channel:
|
channel,
|
||||||
this.supervisor.supervisor.channel === "stable" ? "beta" : "stable",
|
|
||||||
};
|
};
|
||||||
await setSupervisorOption(this.hass, data);
|
await setSupervisorOption(this.hass, data);
|
||||||
await this._reloadSupervisor();
|
await this._reloadSupervisor();
|
||||||
@ -270,8 +262,6 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
),
|
),
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
});
|
});
|
||||||
} finally {
|
|
||||||
button.progress = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,13 +24,11 @@ import {
|
|||||||
checkForEntityUpdates,
|
checkForEntityUpdates,
|
||||||
filterUpdateEntitiesWithInstall,
|
filterUpdateEntitiesWithInstall,
|
||||||
} from "../../../data/update";
|
} from "../../../data/update";
|
||||||
import {
|
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||||
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 "../dashboard/ha-config-updates";
|
import "../dashboard/ha-config-updates";
|
||||||
|
import { showJoinBetaDialog } from "./updates/show-dialog-join-beta";
|
||||||
|
|
||||||
@customElement("ha-config-section-updates")
|
@customElement("ha-config-section-updates")
|
||||||
class HaConfigSectionUpdates extends LitElement {
|
class HaConfigSectionUpdates extends LitElement {
|
||||||
@ -46,9 +44,7 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
if (isComponentLoaded(this.hass, "hassio")) {
|
if (isComponentLoaded(this.hass, "hassio")) {
|
||||||
fetchHassioSupervisorInfo(this.hass).then((data) => {
|
this._refreshSupervisorInfo();
|
||||||
this._supervisorInfo = data;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +122,10 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _refreshSupervisorInfo() {
|
||||||
|
this._supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
|
||||||
|
}
|
||||||
|
|
||||||
private _toggleSkipped(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _toggleSkipped(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||||
if (ev.detail.source !== "property") {
|
if (ev.detail.source !== "property") {
|
||||||
return;
|
return;
|
||||||
@ -142,35 +142,23 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._supervisorInfo!.channel === "stable") {
|
if (this._supervisorInfo!.channel === "stable") {
|
||||||
const confirmed = await showConfirmationDialog(this, {
|
showJoinBetaDialog(this, {
|
||||||
title: this.hass.localize("ui.dialogs.join_beta_channel.title"),
|
join: async () => this._setChannel("beta"),
|
||||||
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"),
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
if (!confirmed) {
|
this._setChannel("stable");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setChannel(
|
||||||
|
channel: SupervisorOptions["channel"]
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const data: Partial<SupervisorOptions> = {
|
await setSupervisorOption(this.hass, {
|
||||||
channel: this._supervisorInfo!.channel === "stable" ? "beta" : "stable",
|
channel,
|
||||||
};
|
});
|
||||||
await setSupervisorOption(this.hass, data);
|
|
||||||
await reloadSupervisor(this.hass);
|
await reloadSupervisor(this.hass);
|
||||||
|
await this._refreshSupervisorInfo();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
|
108
src/panels/config/core/updates/dialog-join-beta.ts
Normal file
108
src/panels/config/core/updates/dialog-join-beta.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
import "@material/mwc-button/mwc-button";
|
||||||
|
import { mdiOpenInNew } from "@mdi/js";
|
||||||
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
|
import "../../../../components/ha-alert";
|
||||||
|
import { createCloseHeading } from "../../../../components/ha-dialog";
|
||||||
|
import "../../../../components/ha-header-bar";
|
||||||
|
import { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||||
|
import { haStyleDialog } from "../../../../resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../types";
|
||||||
|
import { documentationUrl } from "../../../../util/documentation-url";
|
||||||
|
import { JoinBetaDialogParams } from "./show-dialog-join-beta";
|
||||||
|
|
||||||
|
@customElement("dialog-join-beta")
|
||||||
|
export class DialogJoinBeta
|
||||||
|
extends LitElement
|
||||||
|
implements HassDialog<JoinBetaDialogParams>
|
||||||
|
{
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@state() private _dialogParams?: JoinBetaDialogParams;
|
||||||
|
|
||||||
|
public showDialog(dialogParams: JoinBetaDialogParams): void {
|
||||||
|
this._dialogParams = dialogParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public closeDialog(): void {
|
||||||
|
this._dialogParams = undefined;
|
||||||
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
if (!this._dialogParams) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<ha-dialog
|
||||||
|
open
|
||||||
|
@closed=${this.closeDialog}
|
||||||
|
.heading=${createCloseHeading(
|
||||||
|
this.hass,
|
||||||
|
this.hass.localize("ui.dialogs.join_beta_channel.title")
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<ha-alert alert-type="warning">
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.backup")}
|
||||||
|
</ha-alert>
|
||||||
|
<p>
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.warning")}
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.release_items")}
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>Home Assistant Core</li>
|
||||||
|
<li>Home Assistant Supervisor</li>
|
||||||
|
<li>Home Assistant Operating System</li>
|
||||||
|
</ul>
|
||||||
|
<a
|
||||||
|
href=${documentationUrl(this.hass!, "/faq/release/")}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.dialogs.join_beta_channel.view_documentation"
|
||||||
|
)}
|
||||||
|
<ha-svg-icon .path=${mdiOpenInNew}></ha-svg-icon>
|
||||||
|
</a>
|
||||||
|
<mwc-button slot="primaryAction" @click=${this._cancel}>
|
||||||
|
${this.hass.localize("ui.common.cancel")}
|
||||||
|
</mwc-button>
|
||||||
|
<mwc-button slot="primaryAction" @click=${this._join}>
|
||||||
|
${this.hass.localize("ui.dialogs.join_beta_channel.join")}
|
||||||
|
</mwc-button>
|
||||||
|
</ha-dialog>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _cancel() {
|
||||||
|
this._dialogParams?.cancel?.();
|
||||||
|
this.closeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _join() {
|
||||||
|
this._dialogParams?.join?.();
|
||||||
|
this.closeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResultGroup {
|
||||||
|
return [
|
||||||
|
haStyleDialog,
|
||||||
|
css`
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a ha-svg-icon {
|
||||||
|
--mdc-icon-size: 16px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"dialog-join-beta": DialogJoinBeta;
|
||||||
|
}
|
||||||
|
}
|
18
src/panels/config/core/updates/show-dialog-join-beta.ts
Normal file
18
src/panels/config/core/updates/show-dialog-join-beta.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
|
import "./dialog-join-beta";
|
||||||
|
|
||||||
|
export interface JoinBetaDialogParams {
|
||||||
|
join?: () => any;
|
||||||
|
cancel?: () => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const showJoinBetaDialog = (
|
||||||
|
element: HTMLElement,
|
||||||
|
dialogParams: JoinBetaDialogParams
|
||||||
|
): void => {
|
||||||
|
fireEvent(element, "show-dialog", {
|
||||||
|
dialogTag: "dialog-join-beta",
|
||||||
|
dialogImport: () => import("./dialog-join-beta"),
|
||||||
|
dialogParams,
|
||||||
|
});
|
||||||
|
};
|
@ -1090,10 +1090,11 @@
|
|||||||
},
|
},
|
||||||
"join_beta_channel": {
|
"join_beta_channel": {
|
||||||
"title": "Join the beta channel",
|
"title": "Join the beta channel",
|
||||||
"warning": "[%key:supervisor::system::supervisor::beta_warning%]",
|
"backup": "Make sure you have backups of your data before you activate this feature.",
|
||||||
"backup": "[%key:supervisor::system::supervisor::beta_backup%]",
|
"warning": "Beta releases are for testers and early adopters and can contain unstable code changes",
|
||||||
"release_items": "[%key:supervisor::system::supervisor::beta_release_items%]",
|
"release_items": "This includes beta releases for:",
|
||||||
"confirm": "[%key:supervisor::system::supervisor::beta_join_confirm%]"
|
"view_documentation": "View documentation",
|
||||||
|
"join": "Join"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"duration": {
|
"duration": {
|
||||||
@ -4999,10 +5000,6 @@
|
|||||||
"reload_supervisor": "Reload Supervisor",
|
"reload_supervisor": "Reload Supervisor",
|
||||||
"warning": "WARNING",
|
"warning": "WARNING",
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"beta_warning": "Beta releases are for testers and early adopters and can contain unstable code changes",
|
|
||||||
"beta_backup": "Make sure you have backups of your data before you activate this feature.",
|
|
||||||
"beta_release_items": "This includes beta releases for:",
|
|
||||||
"beta_join_confirm": "Do you want to join the beta channel?",
|
|
||||||
"share_diagonstics_title": "Help Improve Home Assistant",
|
"share_diagonstics_title": "Help Improve Home Assistant",
|
||||||
"share_diagonstics_description": "Would you want to automatically share crash reports and diagnostic information when the Supervisor encounters unexpected errors? {line_break} This will allow us to fix the problems, the information is only accessible to the Home Assistant Core team and will not be shared with others.{line_break} The data does not include any private/sensitive information and you can disable this in settings at any time you want.",
|
"share_diagonstics_description": "Would you want to automatically share crash reports and diagnostic information when the Supervisor encounters unexpected errors? {line_break} This will allow us to fix the problems, the information is only accessible to the Home Assistant Core team and will not be shared with others.{line_break} The data does not include any private/sensitive information and you can disable this in settings at any time you want.",
|
||||||
"unsupported_reason": {
|
"unsupported_reason": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user