Skip to content

Commit

Permalink
Adjust selector
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Apr 13, 2022
1 parent 9e4b3be commit 9098be2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 39 deletions.
3 changes: 2 additions & 1 deletion script/gulp/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const outputconfig = (isDev) => {
entryFileNames: !isDev ? "[name]-[hash].js" : "[name]-dev.js",
format: "es",
intro: `const __DEMO__ = false;
const __SUPERVISOR__ = true`,
const __SUPERVISOR__ = true;
const __BUILD__ = "latest"`,
};
};

Expand Down
17 changes: 10 additions & 7 deletions src/components/dialogs/hacs-custom-repositories-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ export class HacsCustomRepositoriesDialog extends HacsDialogBase {
if (!this.active) return html``;
const addRepositorySchema: HaFormSchema[] = [
{
type: "string",
name: "repository",
selector: { text: {} },
},
{
type: "select",
name: "category",
optional: true,
options: this.hacs.configuration.categories.map((category) => [
category,
this.hacs.localize(`common.${category}`),
]),
selector: {
select: {
mode: "dropdown",
options: this.hacs.configuration.categories.map((category) => ({
value: category,
label: this.hacs.localize(`common.${category}`),
})),
},
},
},
];
return html`
Expand Down
30 changes: 15 additions & 15 deletions src/components/dialogs/hacs-download-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ export class HacsDonwloadDialog extends HacsDialogBase {

const donwloadRepositorySchema: HaFormSchema[] = [
{
type: "boolean",
name: "beta",
selector: { boolean: {} },
},
{
type: "select",
name: "version",
optional: true,
//@ts-ignore
options:
this._repository.version_or_commit === "version"
? this._repository.releases
.map((version) => [version, version])
.concat(
this._repository.full_name === "hacs/integration" ||
this._repository.hide_default_branch
? []
: [[this._repository.default_branch, this._repository.default_branch]]
)
: [],
selector: {
select: {
options:
this._repository.version_or_commit === "version"
? this._repository.releases.concat(
this._repository.full_name === "hacs/integration" ||
this._repository.hide_default_branch
? []
: [this._repository.default_branch]
)
: [],
mode: "dropdown",
},
},
},
];
return html`
Expand Down
26 changes: 10 additions & 16 deletions src/hacs-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ import { navigate } from "../homeassistant-frontend/src/common/navigate";

@customElement("hacs-resolver")
export class HacsResolver extends LitElement {
@property({ attribute: false }) public configuration: Configuration;
@property({ attribute: false }) public configuration!: Configuration;

@property({ attribute: false }) public critical!: Critical[];

@property({ attribute: false }) public hass!: HomeAssistant;

@property({ attribute: false }) public lovelace: LovelaceResource[];
@property({ attribute: false }) public lovelace!: LovelaceResource[] | null;

@property({ type: Boolean }) public narrow!: boolean;

@property({ attribute: false }) public repositories: Repository[];
@property({ attribute: false }) public repositories!: Repository[];

@property({ attribute: false }) public route!: Route;

@property({ attribute: false }) public status: Status;
@property({ attribute: false }) public status!: Status;

@property({ attribute: false }) public removed: RemovedRepository[];
@property({ attribute: false }) public removed!: RemovedRepository[];

@query("#hacs-dialog") private _hacsDialog?: any;

Expand Down Expand Up @@ -81,17 +81,11 @@ export class HacsResolver extends LitElement {
};

/* Backend event subscription */
this.hass.connection.subscribeEvents(async () => await this._updateProperties(), "hacs/config");
this.hass.connection.subscribeEvents(async () => await this._updateProperties(), "hacs/status");
this.hass.connection.subscribeEvents(async () => this._updateProperties(), "hacs/config");
this.hass.connection.subscribeEvents(async () => this._updateProperties(), "hacs/status");

this.hass.connection.subscribeEvents(
async () => await this._updateProperties(),
"hacs/repository"
);
this.hass.connection.subscribeEvents(
async () => await this._updateProperties(),
"lovelace_updated"
);
this.hass.connection.subscribeEvents(async () => this._updateProperties(), "hacs/repository");
this.hass.connection.subscribeEvents(async () => this._updateProperties(), "lovelace_updated");
await this._updateProperties();
}

Expand Down Expand Up @@ -184,7 +178,7 @@ export class HacsResolver extends LitElement {
}

private _setRoute(ev: LocationChangedEvent): void {
this.route = ev.detail.route;
this.route = ev.detail!.route;
navigate(this.route.prefix + this.route.path);
this.requestUpdate();
}
Expand Down

0 comments on commit 9098be2

Please sign in to comment.