Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dismiss new to overflow menu #706

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/components/hacs-repository-owerflow-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
mdiGithub,
mdiInformation,
mdiLanguageJavascript,
mdiMoonNew,
mdiReload,
} from "@mdi/js";
import memoizeOne from "memoize-one";
Expand All @@ -18,14 +19,18 @@ import {
} from "../../homeassistant-frontend/src/data/lovelace/resource";
import { showConfirmationDialog } from "../../homeassistant-frontend/src/dialogs/generic/show-dialog-box";
import type { RepositoryBase } from "../data/repository";
import { repositoryUninstall, repositoryUpdate } from "../data/websocket";
import {
repositoriesClearNewRepository,
repositoryUninstall,
repositoryUpdate,
} from "../data/websocket";
import type { HacsDashboard } from "../dashboards/hacs-dashboard";
import type { HacsRepositoryDashboard } from "../dashboards/hacs-repository-dashboard";
import { showHacsDownloadDialog, showHacsFormDialog } from "./dialogs/show-hacs-dialog";

export const repositoryMenuItems = memoizeOne(
(element: HacsRepositoryDashboard | HacsDashboard, repository: RepositoryBase) => [
...(element.nodeName === "HACS-EXPERIMENTAL-PANEL"
...(element.nodeName === "HACS-DASHBOARD"
? [
{
path: mdiInformation,
Expand Down Expand Up @@ -58,7 +63,15 @@ export const repositoryMenuItems = memoizeOne(
hideForUninstalled: true,
},
]
: []),
: repository.new
? [
{
path: mdiMoonNew,
label: element.hacs.localize("repository_card.dismiss_new"),
action: () => repositoriesClearNewRepository(element.hass, repository.id),
},
]
: []),
...(repository.category === "plugin" && repository.installed_version
? [
{
Expand Down
19 changes: 8 additions & 11 deletions src/dashboards/hacs-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,14 @@ export class HacsDashboard extends LitElement {
title: "",
width: this.narrow ? undefined : "10%",
type: "overflow-menu",
template: (repository: RepositoryBase) =>
repository.installed
? html`
<ha-icon-overflow-menu
.hass=${this.hass}
.items=${repositoryMenuItems(this, repository) as IconOverflowMenuItem[]}
narrow
>
</ha-icon-overflow-menu>
`
: "",
template: (repository: RepositoryBase) => html`
<ha-icon-overflow-menu
.hass=${this.hass}
.items=${repositoryMenuItems(this, repository) as IconOverflowMenuItem[]}
narrow
>
</ha-icon-overflow-menu>
`,
},
}),
);
Expand Down
8 changes: 7 additions & 1 deletion src/data/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ export const repositoriesClearNew = async (hass: HomeAssistant, hacs: Hacs) =>
categories: hacs.info.categories,
});

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

export const websocketSubscription = (
hass: HomeAssistant,
onChange: (result: Record<any, any> | null) => void,
event: HacsDispatchEvent
event: HacsDispatchEvent,
) =>
hass.connection.subscribeMessage(onChange, {
type: "hacs/subscribe",
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 @@ -120,6 +120,7 @@
},
"repository_card": {
"dismiss": "dismiss",
"dismiss_new": "Dismiss new",
"information": "Information",
"new_repository": "New repository",
"not_loaded": "Not loaded",
Expand Down