mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Move add-on rebuild over to WS for newer core versions (#16180)
This commit is contained in:
parent
fa4550a848
commit
3a1fff81b8
@ -29,7 +29,6 @@ import memoizeOne from "memoize-one";
|
||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import { navigate } from "../../../../src/common/navigate";
|
||||
import "../../../../src/components/buttons/ha-call-api-button";
|
||||
import "../../../../src/components/buttons/ha-progress-button";
|
||||
import "../../../../src/components/ha-alert";
|
||||
import "../../../../src/components/ha-card";
|
||||
@ -47,6 +46,7 @@ import {
|
||||
HassioAddonSetOptionParams,
|
||||
HassioAddonSetSecurityParams,
|
||||
installHassioAddon,
|
||||
rebuildLocalAddon,
|
||||
restartHassioAddon,
|
||||
setHassioAddonOption,
|
||||
setHassioAddonSecurity,
|
||||
@ -640,13 +640,12 @@ class HassioAddonInfo extends LitElement {
|
||||
</ha-progress-button>
|
||||
${this.addon.build
|
||||
? html`
|
||||
<ha-call-api-button
|
||||
<ha-progress-button
|
||||
class="warning"
|
||||
.hass=${this.hass}
|
||||
.path="hassio/addons/${this.addon.slug}/rebuild"
|
||||
@click=${this._rebuildClicked}
|
||||
>
|
||||
${this.supervisor.localize("addon.dashboard.rebuild")}
|
||||
</ha-call-api-button>
|
||||
</ha-progress-button>
|
||||
`
|
||||
: ""}`
|
||||
: ""}
|
||||
@ -966,6 +965,21 @@ class HassioAddonInfo extends LitElement {
|
||||
button.progress = false;
|
||||
}
|
||||
|
||||
private async _rebuildClicked(ev: CustomEvent): Promise<void> {
|
||||
const button = ev.currentTarget as any;
|
||||
button.progress = true;
|
||||
|
||||
try {
|
||||
await rebuildLocalAddon(this.hass, this.addon.slug);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, {
|
||||
title: this.supervisor.localize("addon.dashboard.action_error.rebuild"),
|
||||
text: extractApiErrorMessage(err),
|
||||
});
|
||||
}
|
||||
button.progress = false;
|
||||
}
|
||||
|
||||
private async _startClicked(ev: CustomEvent): Promise<void> {
|
||||
const button = ev.currentTarget as any;
|
||||
button.progress = true;
|
||||
@ -1124,10 +1138,6 @@ class HassioAddonInfo extends LitElement {
|
||||
ha-svg-icon.stopped {
|
||||
color: var(--error-color);
|
||||
}
|
||||
ha-call-api-button {
|
||||
font-weight: 500;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
protection-enable mwc-button {
|
||||
--mdc-theme-primary: white;
|
||||
}
|
||||
|
@ -381,3 +381,23 @@ export const fetchAddonInfo = (
|
||||
? `/store/addons/${addonSlug}` // Use /store/addons when add-on is not installed
|
||||
: `/addons/${addonSlug}/info` // Use /addons when add-on is installed
|
||||
);
|
||||
|
||||
export const rebuildLocalAddon = async (
|
||||
hass: HomeAssistant,
|
||||
slug: string
|
||||
): Promise<void> => {
|
||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||
return hass.callWS<void>({
|
||||
type: "supervisor/api",
|
||||
endpoint: `/addons/${slug}/rebuild`,
|
||||
method: "post",
|
||||
timeout: null,
|
||||
});
|
||||
}
|
||||
return (
|
||||
await hass.callApi<HassioResponse<void>>(
|
||||
"POST",
|
||||
`hassio/addons/${slug}rebuild`
|
||||
)
|
||||
).data;
|
||||
};
|
||||
|
@ -5373,6 +5373,7 @@
|
||||
"uninstall": "Failed to uninstall add-on",
|
||||
"install": "Failed to install add-on",
|
||||
"stop": "Failed to stop add-on",
|
||||
"rebuild": "Failed to rebuild add-on",
|
||||
"restart": "Failed to restart add-on",
|
||||
"start": "Failed to start add-on",
|
||||
"go_to_config": "Edit Config",
|
||||
|
Loading…
x
Reference in New Issue
Block a user