mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Add supervisor_add_addon_repository redirect (#8545)
This commit is contained in:
parent
3853cc9214
commit
c91779dffe
@ -14,7 +14,9 @@ import { html, TemplateResult } from "lit-html";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||||
|
import { navigate } from "../../../src/common/navigate";
|
||||||
import "../../../src/common/search/search-input";
|
import "../../../src/common/search/search-input";
|
||||||
|
import { extractSearchParam } from "../../../src/common/url/search-params";
|
||||||
import "../../../src/components/ha-button-menu";
|
import "../../../src/components/ha-button-menu";
|
||||||
import "../../../src/components/ha-svg-icon";
|
import "../../../src/components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
@ -137,6 +139,12 @@ class HassioAddonStore extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
const repositoryUrl = extractSearchParam("repository_url");
|
||||||
|
navigate(this, "/hassio/store", true);
|
||||||
|
if (repositoryUrl) {
|
||||||
|
this._manageRepositories(repositoryUrl);
|
||||||
|
}
|
||||||
|
|
||||||
this.addEventListener("hass-api-called", (ev) => this.apiCalled(ev));
|
this.addEventListener("hass-api-called", (ev) => this.apiCalled(ev));
|
||||||
this._loadData();
|
this._loadData();
|
||||||
}
|
}
|
||||||
@ -170,7 +178,7 @@ class HassioAddonStore extends LitElement {
|
|||||||
private _handleAction(ev: CustomEvent<ActionDetail>) {
|
private _handleAction(ev: CustomEvent<ActionDetail>) {
|
||||||
switch (ev.detail.index) {
|
switch (ev.detail.index) {
|
||||||
case 0:
|
case 0:
|
||||||
this._manageRepositories();
|
this._manageRepositoriesClicked();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
this.refreshData();
|
this.refreshData();
|
||||||
@ -187,9 +195,14 @@ class HassioAddonStore extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _manageRepositories() {
|
private _manageRepositoriesClicked() {
|
||||||
|
this._manageRepositories();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _manageRepositories(url?: string) {
|
||||||
showRepositoriesDialog(this, {
|
showRepositoriesDialog(this, {
|
||||||
supervisor: this.supervisor,
|
supervisor: this.supervisor,
|
||||||
|
url,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import {
|
|||||||
} from "../../../../src/data/hassio/addon";
|
} from "../../../../src/data/hassio/addon";
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import { setSupervisorOption } from "../../../../src/data/hassio/supervisor";
|
import { setSupervisorOption } from "../../../../src/data/hassio/supervisor";
|
||||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../src/types";
|
import type { HomeAssistant } from "../../../../src/types";
|
||||||
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
||||||
@ -36,12 +35,12 @@ import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
|||||||
class HassioRepositoriesDialog extends LitElement {
|
class HassioRepositoriesDialog extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
|
||||||
|
|
||||||
@query("#repository_input", true) private _optionInput?: PaperInputElement;
|
@query("#repository_input", true) private _optionInput?: PaperInputElement;
|
||||||
|
|
||||||
@internalProperty() private _repositories?: HassioAddonRepository[];
|
@internalProperty() private _repositories?: HassioAddonRepository[];
|
||||||
|
|
||||||
|
@internalProperty() private _dialogParams?: HassioRepositoryDialogParams;
|
||||||
|
|
||||||
@internalProperty() private _opened = false;
|
@internalProperty() private _opened = false;
|
||||||
|
|
||||||
@internalProperty() private _prosessing = false;
|
@internalProperty() private _prosessing = false;
|
||||||
@ -51,13 +50,14 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
public async showDialog(
|
public async showDialog(
|
||||||
dialogParams: HassioRepositoryDialogParams
|
dialogParams: HassioRepositoryDialogParams
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.supervisor = dialogParams.supervisor;
|
this._dialogParams = dialogParams;
|
||||||
this._opened = true;
|
this._opened = true;
|
||||||
await this._loadData();
|
await this._loadData();
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
|
this._dialogParams = undefined;
|
||||||
this._opened = false;
|
this._opened = false;
|
||||||
this._error = "";
|
this._error = "";
|
||||||
}
|
}
|
||||||
@ -69,9 +69,8 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (this._repositories === undefined) {
|
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
|
||||||
return html`<ha-circular-progress alt="loading" size="large" active>
|
return html``;
|
||||||
</ha-circular-progress>`;
|
|
||||||
}
|
}
|
||||||
const repositories = this._filteredRepositories(this._repositories);
|
const repositories = this._filteredRepositories(this._repositories);
|
||||||
return html`
|
return html`
|
||||||
@ -82,7 +81,7 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
escapeKeyAction
|
escapeKeyAction
|
||||||
.heading=${createCloseHeading(
|
.heading=${createCloseHeading(
|
||||||
this.hass,
|
this.hass,
|
||||||
this.supervisor.localize("dialog.repositories.title")
|
this._dialogParams!.supervisor.localize("dialog.repositories.title")
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
${this._error ? html`<div class="error">${this._error}</div>` : ""}
|
${this._error ? html`<div class="error">${this._error}</div>` : ""}
|
||||||
@ -98,7 +97,7 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
</paper-item-body>
|
</paper-item-body>
|
||||||
<mwc-icon-button
|
<mwc-icon-button
|
||||||
.slug=${repo.slug}
|
.slug=${repo.slug}
|
||||||
.title=${this.supervisor.localize(
|
.title=${this._dialogParams!.supervisor.localize(
|
||||||
"dialog.repositories.remove"
|
"dialog.repositories.remove"
|
||||||
)}
|
)}
|
||||||
@click=${this._removeRepository}
|
@click=${this._removeRepository}
|
||||||
@ -117,18 +116,23 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
<paper-input
|
<paper-input
|
||||||
class="flex-auto"
|
class="flex-auto"
|
||||||
id="repository_input"
|
id="repository_input"
|
||||||
.label=${this.supervisor.localize("dialog.repositories.add")}
|
.value=${this._dialogParams!.url || ""}
|
||||||
|
.label=${this._dialogParams!.supervisor.localize(
|
||||||
|
"dialog.repositories.add"
|
||||||
|
)}
|
||||||
@keydown=${this._handleKeyAdd}
|
@keydown=${this._handleKeyAdd}
|
||||||
></paper-input>
|
></paper-input>
|
||||||
<mwc-button @click=${this._addRepository}>
|
<mwc-button @click=${this._addRepository}>
|
||||||
${this._prosessing
|
${this._prosessing
|
||||||
? html`<ha-circular-progress active></ha-circular-progress>`
|
? html`<ha-circular-progress active></ha-circular-progress>`
|
||||||
: this.supervisor.localize("dialog.repositories.add")}
|
: this._dialogParams!.supervisor.localize(
|
||||||
|
"dialog.repositories.add"
|
||||||
|
)}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<mwc-button slot="primaryAction" @click="${this.closeDialog}">
|
<mwc-button slot="primaryAction" @click=${this.closeDialog}>
|
||||||
Close
|
${this._dialogParams?.supervisor.localize("common.close")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
|
@ -4,6 +4,7 @@ import "./dialog-hassio-repositories";
|
|||||||
|
|
||||||
export interface HassioRepositoryDialogParams {
|
export interface HassioRepositoryDialogParams {
|
||||||
supervisor: Supervisor;
|
supervisor: Supervisor;
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const showRepositoriesDialog = (
|
export const showRepositoriesDialog = (
|
||||||
|
@ -22,6 +22,9 @@ import { HomeAssistant, Route } from "../../src/types";
|
|||||||
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
||||||
|
|
||||||
const REDIRECTS: Redirects = {
|
const REDIRECTS: Redirects = {
|
||||||
|
supervisor: {
|
||||||
|
redirect: "/hassio/dashboard",
|
||||||
|
},
|
||||||
supervisor_logs: {
|
supervisor_logs: {
|
||||||
redirect: "/hassio/system",
|
redirect: "/hassio/system",
|
||||||
},
|
},
|
||||||
@ -34,15 +37,18 @@ const REDIRECTS: Redirects = {
|
|||||||
supervisor_store: {
|
supervisor_store: {
|
||||||
redirect: "/hassio/store",
|
redirect: "/hassio/store",
|
||||||
},
|
},
|
||||||
supervisor: {
|
|
||||||
redirect: "/hassio/dashboard",
|
|
||||||
},
|
|
||||||
supervisor_addon: {
|
supervisor_addon: {
|
||||||
redirect: "/hassio/addon",
|
redirect: "/hassio/addon",
|
||||||
params: {
|
params: {
|
||||||
addon: "string",
|
addon: "string",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
supervisor_add_addon_repository: {
|
||||||
|
redirect: "/hassio/store",
|
||||||
|
params: {
|
||||||
|
repository_url: "url",
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("hassio-my-redirect")
|
@customElement("hassio-my-redirect")
|
||||||
|
@ -3609,7 +3609,8 @@
|
|||||||
"restart_name": "Restart {name}",
|
"restart_name": "Restart {name}",
|
||||||
"restart": "Restart",
|
"restart": "Restart",
|
||||||
"running_version": "You are currently running version {version}",
|
"running_version": "You are currently running version {version}",
|
||||||
"save": "Save",
|
"save": "[%key:ui::common::save%]",
|
||||||
|
"close": "[%key:ui::common::close%]",
|
||||||
"show_more": "Show more information about this",
|
"show_more": "Show more information about this",
|
||||||
"update_available": "{count, plural,\n one {Update}\n other {{count} Updates}\n} pending",
|
"update_available": "{count, plural,\n one {Update}\n other {{count} Updates}\n} pending",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user