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

Display services as services and not devices #6798

Merged
merged 6 commits into from
Sep 6, 2020
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
34 changes: 30 additions & 4 deletions src/panels/config/integrations/ha-integration-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class HaIntegrationCard extends LitElement {

private _renderSingleEntry(item: ConfigEntryExtended): TemplateResult {
const devices = this._getDevices(item);
const services = this._getServices(item);
const entities = this._getEntities(item);

return html`
Expand Down Expand Up @@ -168,7 +169,7 @@ export class HaIntegrationCard extends LitElement {
<h3>
${item.localized_domain_name === item.title ? "" : item.title}
</h3>
${devices.length || entities.length
${devices.length || services.length || entities.length
? html`
<div>
${devices.length
Expand All @@ -180,10 +181,22 @@ export class HaIntegrationCard extends LitElement {
"count",
devices.length
)}</a
>${services.length ? "," : ""}
`
: ""}
${services.length
? html`
<a
href=${`/config/devices/dashboard?historyBack=1&config_entry=${item.entry_id}`}
>${this.hass.localize(
"ui.panel.config.integrations.config_entry.services",
"count",
services.length
)}</a
>
`
: ""}
${devices.length && entities.length
${(devices.length || services.length) && entities.length
? this.hass.localize("ui.common.and")
: ""}
Comment on lines +199 to 201
Copy link
Member

Choose a reason for hiding this comment

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

We should also render an and when there is both a service and a device.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had that first, but if the integration has both you end up with:
"x services and x devices and x entities" which feels weird 🤷
Add a comma maybe?

Copy link
Member

@bramkragten bramkragten Sep 5, 2020

Choose a reason for hiding this comment

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

yeah:

2 devices, 1 service and 5 entities

${entities.length
Expand Down Expand Up @@ -304,8 +317,21 @@ export class HaIntegrationCard extends LitElement {
if (!this.deviceRegistryEntries) {
return [];
}
return this.deviceRegistryEntries.filter((device) =>
device.config_entries.includes(configEntry.entry_id)
return this.deviceRegistryEntries.filter(
(device) =>
device.config_entries.includes(configEntry.entry_id) &&
device.entry_type !== "service"
);
}

private _getServices(configEntry: ConfigEntry): DeviceRegistryEntry[] {
if (!this.deviceRegistryEntries) {
return [];
}
return this.deviceRegistryEntries.filter(
(device) =>
device.config_entries.includes(configEntry.entry_id) &&
device.entry_type === "service"
);
}

Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@
"config_entry": {
"devices": "{count} {count, plural,\n one {device}\n other {devices}\n}",
"entities": "{count} {count, plural,\n one {entity}\n other {entities}\n}",
"services": "{count} {count, plural,\n one {service}\n other {services}\n}",
"rename": "Rename",
"options": "Options",
"system_options": "System options",
Expand Down