Skip to content

Commit

Permalink
Add ignore repo functionality (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Feb 20, 2022
1 parent 72fd057 commit 19bb3ae
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
31 changes: 30 additions & 1 deletion src/components/dialogs/hacs-removed-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { css, html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { Repository } from "../../data/common";
import { deleteResource, fetchResources, repositoryUninstall } from "../../data/websocket";
import {
deleteResource,
fetchResources,
getRemovedRepositories,
repositoryIgnore,
repositoryUninstall,
} from "../../data/websocket";
import { HacsStyles } from "../../styles/hacs-common-style";
import "./hacs-dialog";
import { HacsDialogBase } from "./hacs-dialog-base";
Expand Down Expand Up @@ -43,6 +49,9 @@ export class HacsRemovedDialog extends HacsDialogBase {
</div>`
: ""}
</div>
<mwc-button slot="secondaryaction" @click=${this._ignoreRepository}>
${this.hacs.localize("common.ignore")}
</mwc-button>
<mwc-button class="uninstall" slot="primaryaction" @click=${this._uninstallRepository}
>${this._updating
? html`<ha-circular-progress active size="small"></ha-circular-progress>`
Expand All @@ -67,6 +76,26 @@ export class HacsRemovedDialog extends HacsDialogBase {
return `/hacsfiles/${this.repository?.full_name.split("/")[1]}/${this.repository?.file_name}`;
}

private async _ignoreRepository(): Promise<void> {
await repositoryIgnore(this.hass, this.repository.full_name);

const removed = await getRemovedRepositories(this.hass);
this.dispatchEvent(
new CustomEvent("update-hacs", {
detail: { removed },
bubbles: true,
composed: true,
})
);

this.dispatchEvent(
new Event("hacs-dialog-closed", {
bubbles: true,
composed: true,
})
);
}

private async _uninstallRepository(): Promise<void> {
this._updating = true;
if (
Expand Down
7 changes: 7 additions & 0 deletions src/data/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export const repositoryUninstall = async (hass: HomeAssistant, repository: strin
});
};

export const repositoryIgnore = async (hass: HomeAssistant, repository: string) => {
await hass.connection.sendMessagePromise<void>({
type: "hacs/repository/ignore",
repository: repository,
});
};

export const repositoryReleasenotes = async (hass: HomeAssistant, repository: string) => {
const response = await hass.connection.sendMessagePromise<
{ name: string; body: string; tag: string }[]
Expand Down
1 change: 1 addition & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"remove": "Remove",
"repositories": "Repositories",
"repository": "Repository",
"show": "Show",
"theme": "Theme",
"update": "Update",
"updates": "Updates",
Expand Down
2 changes: 1 addition & 1 deletion src/panels/hacs-entry-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class HacsEntryPanel extends LitElement {
.label=${message.path
? this.hacs.localize("common.navigate")
: message.dialog
? this.hacs.localize(`common.${message.dialog}`)
? this.hacs.localize("common.show")
: ""}
@click=${() =>
message.path ? navigate(message.path) : this._openDialog(message)}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/get-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const getMessages = memoizeOne((hacs: Hacs): Message[] => {
repository: removedrepo.repository,
}),
info: removedrepo.reason,
severity: "error",
severity: "warning",
dialog: "remove",
repository: repo,
});
Expand Down

0 comments on commit 19bb3ae

Please sign in to comment.