Skip to content

Commit

Permalink
Remove version selector (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jul 4, 2024
1 parent 1454f72 commit 984bd39
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 111 deletions.
93 changes: 4 additions & 89 deletions src/components/dialogs/hacs-download-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "../../../homeassistant-frontend/src/components/ha-alert";
import "../../../homeassistant-frontend/src/components/ha-button";
import "../../../homeassistant-frontend/src/components/ha-dialog";
import "../../../homeassistant-frontend/src/components/ha-form/ha-form";
import { HaFormSchema } from "../../../homeassistant-frontend/src/components/ha-form/types";
import { showConfirmationDialog } from "../../../homeassistant-frontend/src/dialogs/generic/show-dialog-box";
import type { HomeAssistant } from "../../../homeassistant-frontend/src/types";
import { HacsDispatchEvent } from "../../data/common";
Expand All @@ -19,13 +18,11 @@ import {
RepositoryBase,
repositoryDownloadVersion,
RepositoryInfo,
repositorySetVersion,
} from "../../data/repository";
import { repositoryBeta, websocketSubscription } from "../../data/websocket";
import { websocketSubscription } from "../../data/websocket";
import { HacsStyles } from "../../styles/hacs-common-style";
import { generateFrontendResourceURL } from "../../tools/frontend-resource";
import type { HacsDownloadDialogParams } from "./show-hacs-dialog";
import { documentationUrl } from "../../tools/documentation";

@customElement("hacs-download-dialog")
export class HacsDonwloadDialog extends LitElement {
Expand Down Expand Up @@ -95,28 +92,7 @@ export class HacsDonwloadDialog extends LitElement {
if (!this._dialogParams || !this._repository) {
return nothing;
}

const installPath = this._getInstallPath(this._repository);
const donwloadRepositorySchema: HaFormSchema[] = [
{
name: "beta",
selector: { boolean: {} },
},
{
name: "version",
selector: {
select: {
options: this._repository.releases.concat(
this._repository.full_name === "hacs/integration" ||
this._repository.hide_default_branch
? []
: [this._repository.default_branch],
),
mode: "dropdown",
},
},
},
];
return html`
<ha-dialog
open
Expand All @@ -126,40 +102,6 @@ export class HacsDonwloadDialog extends LitElement {
@closed=${this.closeDialog}
>
<div class="content">
${this._repository.version_or_commit === "version" && this._repository.installed
? html`
<ha-form
.disabled=${this._waiting}
.data=${this._repository.version_or_commit === "version"
? {
beta: this._repository.beta,
version: this._selectedVersion,
}
: {}}
.schema=${donwloadRepositorySchema}
.computeLabel=${(schema: HaFormSchema) =>
schema.name === "beta"
? this._dialogParams!.hacs.localize("dialog_download.show_beta")
: this._dialogParams!.hacs.localize("dialog_download.select_version")}
@value-changed=${this._valueChanged}
>
</ha-form>
<ha-alert alert-type="info" .rtl=${computeRTL(this.hass)}>
${this._dialogParams!.hacs.localize("dialog_download.selector_note")}
<a
class="learn_more"
href=${documentationUrl({
path: "/docs/use/entities/update/#install-service",
})}
slot="action"
target="_blank"
rel="noreferrer"
>
${this._dialogParams!.hacs.localize("common.learn_more")}</a
>
</ha-alert>
`
: nothing}
${!this._repository.can_download
? html`<ha-alert alert-type="error" .rtl=${computeRTL(this.hass)}>
${this._dialogParams.hacs.localize("confirm.home_assistant_version_not_correct", {
Expand Down Expand Up @@ -210,30 +152,6 @@ export class HacsDonwloadDialog extends LitElement {
`;
}

private async _valueChanged(ev) {
let updateNeeded = false;
if (this._repository!.beta !== ev.detail.value.beta) {
updateNeeded = true;
this._waiting = true;
await repositoryBeta(this.hass, this._dialogParams!.repositoryId, ev.detail.value.beta);
}
if (ev.detail.value.version) {
updateNeeded = true;
this._waiting = true;

await repositorySetVersion(
this.hass,
this._dialogParams!.repositoryId,
ev.detail.value.version,
);
this._selectedVersion = ev.detail.value.version;
}
if (updateNeeded) {
await this._fetchRepository();
this._waiting = false;
}
}

private async _installRepository(): Promise<void> {
if (!this._repository) {
return;
Expand All @@ -257,16 +175,13 @@ export class HacsDonwloadDialog extends LitElement {
this._installing = true;
this._error = undefined;

const selectedVersion =
this._repository.selected_tag ||
this._repository.available_version ||
this._repository.default_branch;

try {
await repositoryDownloadVersion(
this.hass,
String(this._repository.id),
this._repository?.version_or_commit !== "commit" ? this._selectedVersion : undefined,
this._repository?.version_or_commit !== "commit"
? this._repository.available_version
: undefined,
);
} catch (err: any) {
this._error = err || {
Expand Down
12 changes: 0 additions & 12 deletions src/data/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface RepositoryBase {

export interface RepositoryInfo extends RepositoryBase {
additional_info: string;
beta: boolean;
default_branch: string;
hide_default_branch: boolean;
issues: number;
Expand Down Expand Up @@ -69,14 +68,3 @@ export const repositoryDownloadVersion = async (
repository: repository,
version,
});

export const repositorySetVersion = async (
hass: HomeAssistant,
repository: string,
version: string,
) =>
hass.connection.sendMessagePromise<void>({
type: "hacs/repository/version",
repository: repository,
version,
});
7 changes: 0 additions & 7 deletions src/data/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ export const repositoryAdd = async (hass: HomeAssistant, repository: string, cat
category,
});

export const repositoryBeta = async (hass: HomeAssistant, repository: string, beta: boolean) =>
hass.connection.sendMessagePromise<void>({
type: "hacs/repository/beta",
repository,
show_beta: beta,
});

export const repositoryUpdate = async (hass: HomeAssistant, repository: string) =>
hass.connection.sendMessagePromise<void>({
type: "hacs/repository/refresh",
Expand Down
4 changes: 1 addition & 3 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
"dialog_download": {
"type": "Type",
"url": "URL",
"select_version": "Select version",
"show_beta": "Show beta versions",
"restart": "Remember that you need to restart Home Assistant before changes to integrations (custom_components) are applied.",
"selector_note": "The version selector will be removed in a future release. If you need to install a specific version, you can do so by using the service call for update entities.",
"note_downloaded": "When downloaded, this will be located in {location}",
Expand Down Expand Up @@ -133,4 +131,4 @@
"confirm": "Go to integrations"
}
}
}
}

0 comments on commit 984bd39

Please sign in to comment.