Skip to content

Commit

Permalink
Add installed, available and status columns (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jan 5, 2023
1 parent a68464f commit 454df4a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"name": "Repository Name",
"downloads": "Downloads",
"stars": "Stars",
"installed_version": "Installed version",
"available_version": "Available version",
"status": "Status",
"category": "Category",
"last_updated": "Updated"
},
Expand Down Expand Up @@ -107,6 +110,10 @@
"report": "Request for removal",
"update_information": "Update information"
},
"repository_status": {
"pending-restart": "Pending restart",
"pending-upgrade": "Pending update"
},
"menu": {
"about": "About HACS",
"custom_repositories": "Custom repositories",
Expand Down
37 changes: 37 additions & 0 deletions src/panels/hacs-experimental-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const tableColumnDefaults = {
downloads: true,
stars: true,
last_updated: true,
installed_version: false,
available_version: false,
status: false,
category: true,
};

Expand Down Expand Up @@ -405,6 +408,40 @@ export class HacsExperimentalPanel extends LitElement {
template: (last_updated: string, repository: RepositoryBase) =>
repository.new ? "-" : relativeTime(new Date(last_updated), this.hass.locale),
},
installed_version: {
...defaultKeyData,
title: this.hacs.localize("column.installed_version"),
hidden: narrow || !tableColumnsOptions.installed_version,
sortable: true,
direction:
this.activeSort?.column === "installed_version" ? this.activeSort.direction : null,
width: "10%",
template: (installed_version: string, repository: RepositoryBase) =>
repository.installed ? installed_version : "-",
},
available_version: {
...defaultKeyData,
title: this.hacs.localize("column.available_version"),
hidden: narrow || !tableColumnsOptions.available_version,
sortable: true,
direction:
this.activeSort?.column === "available_version" ? this.activeSort.direction : null,
width: "10%",
template: (available_version: string, repository: RepositoryBase) =>
repository.installed ? available_version : "-",
},
status: {
...defaultKeyData,
title: this.hacs.localize("column.status"),
hidden: narrow || !tableColumnsOptions.status,
sortable: true,
direction: this.activeSort?.column === "status" ? this.activeSort.direction : null,
width: "10%",
template: (status: string) =>
["pending-restart", "pending-upgrade"].includes(status)
? this.hacs.localize(`repository_status.${status}`)
: "-",
},
category: {
...defaultKeyData,
title: this.hacs.localize("column.category"),
Expand Down

0 comments on commit 454df4a

Please sign in to comment.