Skip to content

Commit

Permalink
Fixes issue with adding custom repos, closes hacs/integration/issues/…
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed May 11, 2020
1 parent 18754c5 commit e191b5b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 66 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@typescript-eslint/parser": "^2.31.0",
"card-tools": "github:thomasloven/card-tools",
"custom-card-helpers": "^1.6.4",
"chokidar": "^3.4.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint": "^6.5.1",
Expand Down
22 changes: 14 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ const isdev = process.env.ROLLUP_WATCH;

const opts_json = {
compact: true,
preferConst: true
preferConst: true,
};

const opts_terser = {};

const opts_dev = {
dirs: ["hacs_frontend"],
port: 5000,
host: "0.0.0.0"
host: "0.0.0.0",
poll: true,
};

const opts_cleanup = {
comments: "none"
comments: "none",
};

const opts_sizes = {
details: true
details: true,
};

const AwesomePlugins = [
Expand All @@ -43,16 +44,21 @@ const AwesomePlugins = [
isdev && sizes(),
isdev && sizes(opts_sizes),
isdev && dev(opts_dev),
!isdev && gzipPlugin()
!isdev && gzipPlugin(),
];

export default [
{
watch: {
chokidar: {
usePolling: true,
},
},
input: ["src/main.ts"],
output: {
file: `hacs_frontend/main.js`,
format: "iife"
format: "iife",
},
plugins: [...AwesomePlugins]
}
plugins: [...AwesomePlugins],
},
];
115 changes: 58 additions & 57 deletions src/misc/CustomRepositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CSSResultArray,
css,
TemplateResult,
html
html,
} from "lit-element";
import swal from "sweetalert";

Expand Down Expand Up @@ -45,7 +45,7 @@ export class CustomRepositories extends LitElement {
getCustomRepositories(): RepositoryData[] {
return this.hacs.repositories
.sort((a, b) => (a.full_name > b.full_name ? 1 : -1))
.filter(repo => {
.filter((repo) => {
if (repo.custom) return true;
else return false;
});
Expand All @@ -63,15 +63,15 @@ export class CustomRepositories extends LitElement {
swal(this.hacs.localize("confirm.delete", "{item}", RepoFullName), {
buttons: [
this.hacs.localize("confirm.no"),
this.hacs.localize("confirm.yes")
]
}).then(value => {
this.hacs.localize("confirm.yes"),
],
}).then((value) => {
if (!this.hacs.isnullorempty(value)) {
this.dispatchEvent(
new CustomEvent("hacs-repository-action", {
detail: { repo: RepoID, action: "delete" },
bubbles: true,
composed: true
composed: true,
})
);
}
Expand All @@ -91,18 +91,19 @@ export class CustomRepositories extends LitElement {
}

Save(ev) {
var selected = ev.composedPath()[2].children[1].selectedItem;
const elems = ev.composedPath()[4].children;
var selected = elems[1].selectedItem;
if (selected === undefined) {
swal(this.hacs.localize("settings.missing_category"));
return;
}
var category = selected.category;
var repo = ev.composedPath()[2].children[0].value;
var repo = elems[0].value;
this.dispatchEvent(
new CustomEvent("hacs-repository-action", {
detail: { repo: repo, action: "add", data: category },
bubbles: true,
composed: true
composed: true,
})
);
swal(
Expand All @@ -129,7 +130,7 @@ export class CustomRepositories extends LitElement {
new CustomEvent("hacs-location-change", {
detail: { value: `repository/${RepoID}` },
bubbles: true,
composed: true
composed: true,
})
);
}
Expand All @@ -153,52 +154,52 @@ export class CustomRepositories extends LitElement {
`
: html`
${this.custom &&
this.custom.map(
repo =>
html`
<div
class="row"
.RepoID=${repo.id}
.RepoFullName=${repo.full_name}
>
<paper-item class="customlistitem">
<div
@click=${this.ShowRepository}
class="link flexy"
title="${this.hacs.localize(
"settings.open_repository"
)}"
>
<div class="MobileHide">
[${repo.category}]&nbsp;
</div>
${repo.full_name}
this.custom.map(
(repo) =>
html`
<div
class="row"
.RepoID=${repo.id}
.RepoFullName=${repo.full_name}
>
<paper-item class="customlistitem">
<div
@click=${this.ShowRepository}
class="link flexy"
title="${this.hacs.localize(
"settings.open_repository"
)}"
>
<div class="MobileHide">
[${repo.category}]&nbsp;
</div>
${repo.installed
? html`
<ha-icon
title="${this.hacs.localize(
"settings.delete"
)}"
class="listicon disabled"
icon="mdi:delete"
@click=${this.DeleteInstalled}
></ha-icon>
`
: html`
<ha-icon
title="${this.hacs.localize(
"settings.delete"
)}"
class="listicon"
icon="mdi:delete"
@click=${this.Delete}
></ha-icon>
`}
</paper-item>
</div>
`
)}
${repo.full_name}
</div>
${repo.installed
? html`
<ha-icon
title="${this.hacs.localize(
"settings.delete"
)}"
class="listicon disabled"
icon="mdi:delete"
@click=${this.DeleteInstalled}
></ha-icon>
`
: html`
<ha-icon
title="${this.hacs.localize(
"settings.delete"
)}"
class="listicon"
icon="mdi:delete"
@click=${this.Delete}
></ha-icon>
`}
</paper-item>
</div>
`
)}
`}
</div>
</div>
Expand All @@ -219,7 +220,7 @@ export class CustomRepositories extends LitElement {
>
<paper-listbox slot="dropdown-content" selected="-1">
${this.hacs.configuration.categories.map(
category => html`
(category) => html`
<paper-item class="categoryitem" .category=${category}>
${this.hacs.localize(`common.${category}`)}
</paper-item>
Expand Down Expand Up @@ -294,7 +295,7 @@ export class CustomRepositories extends LitElement {
paper-item.customlistitem {
display: flex;
}
`
`,
];
}
}
2 changes: 1 addition & 1 deletion src/misc/HacsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class HacsMenu extends LitElement {
aria-disabled="false"
>
<paper-icon-button
icon="hass:dots-vertical"
icon="mdi:dots-vertical"
slot="dropdown-trigger"
role="button"
></paper-icon-button>
Expand Down

0 comments on commit e191b5b

Please sign in to comment.