Skip to content
Merged
Changes from 3 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
12 changes: 11 additions & 1 deletion src/panels/lovelace/editor/view-editor/hui-edit-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ export class HuiEditView extends LitElement {
return this.shadowRoot!.querySelector("ha-paper-dialog")!;
}

private get _viewConfigTitle(): string {
if (!this._config || !this._config.title || this._config.title === "") {

@bramkragten bramkragten Oct 21, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no config we might want to change the header to Add new view?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty string is falsy in javascript so this._config.title === "" is not needed.

Suggested change
if (!this._config || !this._config.title || this._config.title === "") {
if (!this._config || !this._config.title) {

return this.hass!.localize(
"ui.panel.lovelace.editor.edit_view.header"
);;
}

return this.hass!.localize("ui.panel.lovelace.editor.edit_view.header_name", this._config.title)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the key header_name exist? You have to add it to src/translations/en.json: Edit view {name}
And you have to pass the name of the placeholder you want to replace:

Suggested change
return this.hass!.localize("ui.panel.lovelace.editor.edit_view.header_name", this._config.title)
return this.hass!.localize("ui.panel.lovelace.editor.edit_view.header_name", name, this._config.title)

}

protected render(): TemplateResult | void {
let content;
switch (this._curTab) {
Expand Down Expand Up @@ -118,7 +128,7 @@ export class HuiEditView extends LitElement {
return html`
<ha-paper-dialog with-backdrop>
<h2>
${this.hass!.localize("ui.panel.lovelace.editor.edit_view.header")}
${this._viewConfigTitle}
</h2>
<paper-tabs
scrollable
Expand Down