Fix missing column headers for various data tables (#20160)

* Fix missing column headers for automation/scene/script/blueprint

* more tables

* Update ha-automation-picker.ts

* Update ha-script-picker.ts

* Update ha-scene-dashboard.ts
This commit is contained in:
karwosts 2024-03-27 09:04:45 -07:00 committed by GitHub
parent 64c3fb1723
commit b662512995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 146 additions and 115 deletions

View File

@ -33,6 +33,7 @@ import {
import "../../../layouts/hass-loading-screen"; import "../../../layouts/hass-loading-screen";
import "../../../layouts/hass-tabs-subpage-data-table"; import "../../../layouts/hass-tabs-subpage-data-table";
import { HomeAssistant, Route } from "../../../types"; import { HomeAssistant, Route } from "../../../types";
import { LocalizeFunc } from "../../../common/translations/localize";
import { fileDownload } from "../../../util/file_download"; import { fileDownload } from "../../../util/file_download";
@customElement("ha-config-backup") @customElement("ha-config-backup")
@ -48,9 +49,13 @@ class HaConfigBackup extends LitElement {
@state() private _backupData?: BackupData; @state() private _backupData?: BackupData;
private _columns = memoize( private _columns = memoize(
(narrow, _language): DataTableColumnContainer<BackupContent> => ({ (
narrow,
_language,
localize: LocalizeFunc
): DataTableColumnContainer<BackupContent> => ({
name: { name: {
title: this.hass.localize("ui.panel.config.backup.name"), title: localize("ui.panel.config.backup.name"),
main: true, main: true,
sortable: true, sortable: true,
filterable: true, filterable: true,
@ -60,7 +65,7 @@ class HaConfigBackup extends LitElement {
<div class="secondary">${backup.path}</div>`, <div class="secondary">${backup.path}</div>`,
}, },
size: { size: {
title: this.hass.localize("ui.panel.config.backup.size"), title: localize("ui.panel.config.backup.size"),
width: "15%", width: "15%",
hidden: narrow, hidden: narrow,
filterable: true, filterable: true,
@ -68,7 +73,7 @@ class HaConfigBackup extends LitElement {
template: (backup) => Math.ceil(backup.size * 10) / 10 + " MB", template: (backup) => Math.ceil(backup.size * 10) / 10 + " MB",
}, },
date: { date: {
title: this.hass.localize("ui.panel.config.backup.created"), title: localize("ui.panel.config.backup.created"),
width: "15%", width: "15%",
direction: "desc", direction: "desc",
hidden: narrow, hidden: narrow,
@ -139,7 +144,11 @@ class HaConfigBackup extends LitElement {
.narrow=${this.narrow} .narrow=${this.narrow}
back-path="/config/system" back-path="/config/system"
.route=${this.route} .route=${this.route}
.columns=${this._columns(this.narrow, this.hass.language)} .columns=${this._columns(
this.narrow,
this.hass.language,
this.hass.localize
)}
.data=${this._getItems(this._backupData.backups)} .data=${this._getItems(this._backupData.backups)}
.noDataText=${this.hass.localize("ui.panel.config.backup.no_backups")} .noDataText=${this.hass.localize("ui.panel.config.backup.no_backups")}
.searchLabel=${this.hass.localize( .searchLabel=${this.hass.localize(

View File

@ -49,6 +49,7 @@ import {
import "../../../layouts/hass-tabs-subpage-data-table"; import "../../../layouts/hass-tabs-subpage-data-table";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types"; import { HomeAssistant, Route } from "../../../types";
import { LocalizeFunc } from "../../../common/translations/localize";
import { documentationUrl } from "../../../util/documentation-url"; import { documentationUrl } from "../../../util/documentation-url";
import { showToast } from "../../../util/toast"; import { showToast } from "../../../util/toast";
import { configSections } from "../ha-panel-config"; import { configSections } from "../ha-panel-config";
@ -120,11 +121,13 @@ class HaBlueprintOverview extends LitElement {
); );
private _columns = memoizeOne( private _columns = memoizeOne(
(narrow, _language): DataTableColumnContainer<BlueprintMetaDataPath> => ({ (
narrow,
_language,
localize: LocalizeFunc
): DataTableColumnContainer<BlueprintMetaDataPath> => ({
name: { name: {
title: this.hass.localize( title: localize("ui.panel.config.blueprint.overview.headers.name"),
"ui.panel.config.blueprint.overview.headers.name"
),
main: true, main: true,
sortable: true, sortable: true,
filterable: true, filterable: true,
@ -138,9 +141,7 @@ class HaBlueprintOverview extends LitElement {
: undefined, : undefined,
}, },
type: { type: {
title: this.hass.localize( title: localize("ui.panel.config.blueprint.overview.headers.type"),
"ui.panel.config.blueprint.overview.headers.type"
),
template: (blueprint) => template: (blueprint) =>
html`${this.hass.localize( html`${this.hass.localize(
`ui.panel.config.blueprint.overview.types.${blueprint.type}` `ui.panel.config.blueprint.overview.types.${blueprint.type}`
@ -152,9 +153,7 @@ class HaBlueprintOverview extends LitElement {
width: "10%", width: "10%",
}, },
path: { path: {
title: this.hass.localize( title: localize("ui.panel.config.blueprint.overview.headers.file_name"),
"ui.panel.config.blueprint.overview.headers.file_name"
),
sortable: true, sortable: true,
filterable: true, filterable: true,
hidden: narrow, hidden: narrow,
@ -252,7 +251,11 @@ class HaBlueprintOverview extends LitElement {
back-path="/config" back-path="/config"
.route=${this.route} .route=${this.route}
.tabs=${configSections.automations} .tabs=${configSections.automations}
.columns=${this._columns(this.narrow, this.hass.language)} .columns=${this._columns(
this.narrow,
this.hass.language,
this.hass.localize
)}
.data=${this._processedBlueprints(this.blueprints)} .data=${this._processedBlueprints(this.blueprints)}
id="fullpath" id="fullpath"
.noDataText=${this.hass.localize( .noDataText=${this.hass.localize(

View File

@ -40,6 +40,7 @@ import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-
import "../../../../layouts/hass-loading-screen"; import "../../../../layouts/hass-loading-screen";
import "../../../../layouts/hass-tabs-subpage-data-table"; import "../../../../layouts/hass-tabs-subpage-data-table";
import { HomeAssistant, Route } from "../../../../types"; import { HomeAssistant, Route } from "../../../../types";
import { LocalizeFunc } from "../../../../common/translations/localize";
import { getLovelaceStrategy } from "../../../lovelace/strategies/get-strategy"; import { getLovelaceStrategy } from "../../../lovelace/strategies/get-strategy";
import { showNewDashboardDialog } from "../../dashboard/show-dialog-new-dashboard"; import { showNewDashboardDialog } from "../../dashboard/show-dialog-new-dashboard";
import { lovelaceTabs } from "../ha-config-lovelace"; import { lovelaceTabs } from "../ha-config-lovelace";
@ -74,11 +75,16 @@ export class HaConfigLovelaceDashboards extends LitElement {
} }
private _columns = memoize( private _columns = memoize(
(narrow: boolean, _language, dashboards): DataTableColumnContainer => { (
narrow: boolean,
_language,
dashboards,
localize: LocalizeFunc
): DataTableColumnContainer => {
const columns: DataTableColumnContainer<DataTableItem> = { const columns: DataTableColumnContainer<DataTableItem> = {
icon: { icon: {
title: "", title: "",
label: this.hass.localize( label: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.icon" "ui.panel.config.lovelace.dashboards.picker.headers.icon"
), ),
type: "icon", type: "icon",
@ -98,7 +104,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
: nothing, : nothing,
}, },
title: { title: {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.title" "ui.panel.config.lovelace.dashboards.picker.headers.title"
), ),
main: true, main: true,
@ -140,7 +146,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
if (!narrow) { if (!narrow) {
columns.mode = { columns.mode = {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.conf_mode" "ui.panel.config.lovelace.dashboards.picker.headers.conf_mode"
), ),
sortable: true, sortable: true,
@ -154,7 +160,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
}; };
if (dashboards.some((dashboard) => dashboard.filename)) { if (dashboards.some((dashboard) => dashboard.filename)) {
columns.filename = { columns.filename = {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.filename" "ui.panel.config.lovelace.dashboards.picker.headers.filename"
), ),
width: "15%", width: "15%",
@ -163,7 +169,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
}; };
} }
columns.require_admin = { columns.require_admin = {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.require_admin" "ui.panel.config.lovelace.dashboards.picker.headers.require_admin"
), ),
sortable: true, sortable: true,
@ -175,7 +181,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
: html``, : html``,
}; };
columns.show_in_sidebar = { columns.show_in_sidebar = {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.sidebar" "ui.panel.config.lovelace.dashboards.picker.headers.sidebar"
), ),
type: "icon", type: "icon",
@ -189,7 +195,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
columns.url_path = { columns.url_path = {
title: "", title: "",
label: this.hass.localize( label: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.url" "ui.panel.config.lovelace.dashboards.picker.headers.url"
), ),
filterable: true, filterable: true,
@ -283,7 +289,8 @@ export class HaConfigLovelaceDashboards extends LitElement {
.columns=${this._columns( .columns=${this._columns(
this.narrow, this.narrow,
this.hass.language, this.hass.language,
this._dashboards this._dashboards,
this.hass.localize
)} )}
.data=${this._getItems(this._dashboards)} .data=${this._getItems(this._dashboards)}
@row-click=${this._editDashboard} @row-click=${this._editDashboard}

View File

@ -33,6 +33,7 @@ import "../../../../layouts/hass-subpage";
import "../../../../layouts/hass-tabs-subpage-data-table"; import "../../../../layouts/hass-tabs-subpage-data-table";
import { haStyle } from "../../../../resources/styles"; import { haStyle } from "../../../../resources/styles";
import { HomeAssistant, Route } from "../../../../types"; import { HomeAssistant, Route } from "../../../../types";
import { LocalizeFunc } from "../../../../common/translations/localize";
import { loadLovelaceResources } from "../../../lovelace/common/load-resources"; import { loadLovelaceResources } from "../../../lovelace/common/load-resources";
import { lovelaceResourcesTabs } from "../ha-config-lovelace"; import { lovelaceResourcesTabs } from "../ha-config-lovelace";
import { showResourceDetailDialog } from "./show-dialog-lovelace-resource-detail"; import { showResourceDetailDialog } from "./show-dialog-lovelace-resource-detail";
@ -50,9 +51,12 @@ export class HaConfigLovelaceRescources extends LitElement {
@state() private _resources: LovelaceResource[] = []; @state() private _resources: LovelaceResource[] = [];
private _columns = memoize( private _columns = memoize(
(_language): DataTableColumnContainer<LovelaceResource> => ({ (
_language,
localize: LocalizeFunc
): DataTableColumnContainer<LovelaceResource> => ({
url: { url: {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.resources.picker.headers.url" "ui.panel.config.lovelace.resources.picker.headers.url"
), ),
sortable: true, sortable: true,
@ -62,7 +66,7 @@ export class HaConfigLovelaceRescources extends LitElement {
forceLTR: true, forceLTR: true,
}, },
type: { type: {
title: this.hass.localize( title: localize(
"ui.panel.config.lovelace.resources.picker.headers.type" "ui.panel.config.lovelace.resources.picker.headers.type"
), ),
sortable: true, sortable: true,
@ -118,7 +122,7 @@ export class HaConfigLovelaceRescources extends LitElement {
.narrow=${this.narrow} .narrow=${this.narrow}
.route=${this.route} .route=${this.route}
.tabs=${lovelaceResourcesTabs} .tabs=${lovelaceResourcesTabs}
.columns=${this._columns(this.hass.language)} .columns=${this._columns(this.hass.language, this.hass.localize)}
.data=${this._resources} .data=${this._resources}
.noDataText=${this.hass.localize( .noDataText=${this.hass.localize(
"ui.panel.config.lovelace.resources.picker.no_resources" "ui.panel.config.lovelace.resources.picker.no_resources"

View File

@ -30,6 +30,7 @@ import {
import "../../../layouts/hass-tabs-subpage-data-table"; import "../../../layouts/hass-tabs-subpage-data-table";
import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import { HomeAssistant, Route } from "../../../types"; import { HomeAssistant, Route } from "../../../types";
import { LocalizeFunc } from "../../../common/translations/localize";
import { documentationUrl } from "../../../util/documentation-url"; import { documentationUrl } from "../../../util/documentation-url";
import { configSections } from "../ha-panel-config"; import { configSections } from "../ha-panel-config";
import { showTagDetailDialog } from "./show-dialog-tag-detail"; import { showTagDetailDialog } from "./show-dialog-tag-detail";
@ -56,16 +57,17 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
return this.hass.auth.external?.config.canWriteTag; return this.hass.auth.external?.config.canWriteTag;
} }
private _columns = memoizeOne((narrow: boolean, _language) => { private _columns = memoizeOne(
(narrow: boolean, _language, localize: LocalizeFunc) => {
const columns: DataTableColumnContainer<TagRowData> = { const columns: DataTableColumnContainer<TagRowData> = {
icon: { icon: {
title: "", title: "",
label: this.hass.localize("ui.panel.config.tag.headers.icon"), label: localize("ui.panel.config.tag.headers.icon"),
type: "icon", type: "icon",
template: (tag) => html`<tag-image .tag=${tag}></tag-image>`, template: (tag) => html`<tag-image .tag=${tag}></tag-image>`,
}, },
display_name: { display_name: {
title: this.hass.localize("ui.panel.config.tag.headers.name"), title: localize("ui.panel.config.tag.headers.name"),
main: true, main: true,
sortable: true, sortable: true,
filterable: true, filterable: true,
@ -87,7 +89,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
}; };
if (!narrow) { if (!narrow) {
columns.last_scanned_datetime = { columns.last_scanned_datetime = {
title: this.hass.localize("ui.panel.config.tag.headers.last_scanned"), title: localize("ui.panel.config.tag.headers.last_scanned"),
sortable: true, sortable: true,
direction: "desc", direction: "desc",
width: "20%", width: "20%",
@ -105,7 +107,7 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
if (this._canWriteTags) { if (this._canWriteTags) {
columns.write = { columns.write = {
title: "", title: "",
label: this.hass.localize("ui.panel.config.tag.headers.write"), label: localize("ui.panel.config.tag.headers.write"),
type: "icon-button", type: "icon-button",
template: (tag) => template: (tag) =>
html` <ha-icon-button html` <ha-icon-button
@ -123,7 +125,9 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
html` <ha-icon-button html` <ha-icon-button
.tag=${tag} .tag=${tag}
@click=${this._handleAutomationClick} @click=${this._handleAutomationClick}
.label=${this.hass.localize("ui.panel.config.tag.create_automation")} .label=${this.hass.localize(
"ui.panel.config.tag.create_automation"
)}
.path=${mdiRobot} .path=${mdiRobot}
></ha-icon-button>`, ></ha-icon-button>`,
}; };
@ -139,7 +143,8 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
></ha-icon-button>`, ></ha-icon-button>`,
}; };
return columns; return columns;
}); }
);
private _data = memoizeOne((tags: Tag[]): TagRowData[] => private _data = memoizeOne((tags: Tag[]): TagRowData[] =>
tags.map((tag) => ({ tags.map((tag) => ({
@ -178,7 +183,11 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
back-path="/config" back-path="/config"
.route=${this.route} .route=${this.route}
.tabs=${configSections.tags} .tabs=${configSections.tags}
.columns=${this._columns(this.narrow, this.hass.language)} .columns=${this._columns(
this.narrow,
this.hass.language,
this.hass.localize
)}
.data=${this._data(this._tags)} .data=${this._data(this._tags)}
.noDataText=${this.hass.localize("ui.panel.config.tag.no_tags")} .noDataText=${this.hass.localize("ui.panel.config.tag.no_tags")}
hasFab hasFab

View File

@ -56,6 +56,7 @@ import "../../../layouts/hass-tabs-subpage-data-table";
import type { HaTabsSubpageDataTable } from "../../../layouts/hass-tabs-subpage-data-table"; import type { HaTabsSubpageDataTable } from "../../../layouts/hass-tabs-subpage-data-table";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types"; import { HomeAssistant, Route } from "../../../types";
import { LocalizeFunc } from "../../../common/translations/localize";
import "./expose/expose-assistant-icon"; import "./expose/expose-assistant-icon";
import { voiceAssistantTabs } from "./ha-config-voice-assistants"; import { voiceAssistantTabs } from "./ha-config-voice-assistants";
import { showExposeEntityDialog } from "./show-dialog-expose-entity"; import { showExposeEntityDialog } from "./show-dialog-expose-entity";
@ -127,7 +128,8 @@ export class VoiceAssistantsExpose extends LitElement {
string[] | undefined string[] | undefined
> >
| undefined, | undefined,
_language: string _language: string,
localize: LocalizeFunc
): DataTableColumnContainer => ({ ): DataTableColumnContainer => ({
icon: { icon: {
title: "", title: "",
@ -143,9 +145,7 @@ export class VoiceAssistantsExpose extends LitElement {
}, },
name: { name: {
main: true, main: true,
title: this.hass.localize( title: localize("ui.panel.config.voice_assistants.expose.headers.name"),
"ui.panel.config.voice_assistants.expose.headers.name"
),
sortable: true, sortable: true,
filterable: true, filterable: true,
direction: "asc", direction: "asc",
@ -156,16 +156,14 @@ export class VoiceAssistantsExpose extends LitElement {
`, `,
}, },
area: { area: {
title: this.hass.localize( title: localize("ui.panel.config.voice_assistants.expose.headers.area"),
"ui.panel.config.voice_assistants.expose.headers.area"
),
sortable: true, sortable: true,
hidden: narrow, hidden: narrow,
filterable: true, filterable: true,
width: "15%", width: "15%",
}, },
assistants: { assistants: {
title: this.hass.localize( title: localize(
"ui.panel.config.voice_assistants.expose.headers.assistants" "ui.panel.config.voice_assistants.expose.headers.assistants"
), ),
sortable: true, sortable: true,
@ -192,7 +190,7 @@ export class VoiceAssistantsExpose extends LitElement {
})}`, })}`,
}, },
aliases: { aliases: {
title: this.hass.localize( title: localize(
"ui.panel.config.voice_assistants.expose.headers.aliases" "ui.panel.config.voice_assistants.expose.headers.aliases"
), ),
sortable: true, sortable: true,
@ -527,7 +525,8 @@ export class VoiceAssistantsExpose extends LitElement {
this.narrow, this.narrow,
this._availableAssistants(this.cloudStatus), this._availableAssistants(this.cloudStatus),
this._supportedEntities, this._supportedEntities,
this.hass.language this.hass.language,
this.hass.localize
)} )}
.data=${filteredEntities} .data=${filteredEntities}
.activeFilters=${activeFilters} .activeFilters=${activeFilters}