mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +00:00
Fetch supervisor info directly (#12751)
This commit is contained in:
parent
da106d278c
commit
0623e7dce4
@ -17,7 +17,10 @@ import {
|
|||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
} 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 {
|
||||||
|
fetchHassioSupervisorInfo,
|
||||||
|
setSupervisorOption,
|
||||||
|
} from "../../../src/data/hassio/supervisor";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||||
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
import "../../../src/layouts/hass-error-screen";
|
import "../../../src/layouts/hass-error-screen";
|
||||||
@ -169,38 +172,40 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
if (this.route.path === "") {
|
if (this.route.path === "") {
|
||||||
const requestedAddon = extractSearchParam("addon");
|
const requestedAddon = extractSearchParam("addon");
|
||||||
const requestedAddonRepository = extractSearchParam("repository_url");
|
const requestedAddonRepository = extractSearchParam("repository_url");
|
||||||
if (
|
if (requestedAddonRepository) {
|
||||||
requestedAddonRepository &&
|
const supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
|
||||||
!this.supervisor.supervisor.addons_repositories.find(
|
|
||||||
(repo) => repo === requestedAddonRepository
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (
|
if (
|
||||||
!(await showConfirmationDialog(this, {
|
!supervisorInfo.addons_repositories.find(
|
||||||
title: this.supervisor.localize("my.add_addon_repository_title"),
|
(repo) => repo === requestedAddonRepository
|
||||||
text: this.supervisor.localize(
|
)
|
||||||
"my.add_addon_repository_description",
|
|
||||||
{ addon: requestedAddon, repository: requestedAddonRepository }
|
|
||||||
),
|
|
||||||
confirmText: this.supervisor.localize("common.add"),
|
|
||||||
dismissText: this.supervisor.localize("common.cancel"),
|
|
||||||
}))
|
|
||||||
) {
|
) {
|
||||||
this._error = this.supervisor.localize(
|
if (
|
||||||
"my.error_repository_not_found"
|
!(await showConfirmationDialog(this, {
|
||||||
);
|
title: this.supervisor.localize("my.add_addon_repository_title"),
|
||||||
return;
|
text: this.supervisor.localize(
|
||||||
}
|
"my.add_addon_repository_description",
|
||||||
|
{ addon: requestedAddon, repository: requestedAddonRepository }
|
||||||
|
),
|
||||||
|
confirmText: this.supervisor.localize("common.add"),
|
||||||
|
dismissText: this.supervisor.localize("common.cancel"),
|
||||||
|
}))
|
||||||
|
) {
|
||||||
|
this._error = this.supervisor.localize(
|
||||||
|
"my.error_repository_not_found"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setSupervisorOption(this.hass, {
|
await setSupervisorOption(this.hass, {
|
||||||
addons_repositories: [
|
addons_repositories: [
|
||||||
...this.supervisor.supervisor.addons_repositories,
|
...supervisorInfo.addons_repositories,
|
||||||
requestedAddonRepository,
|
requestedAddonRepository,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._error = extractApiErrorMessage(err);
|
this._error = extractApiErrorMessage(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user