Skip to content

Add search to integrations 🔍#5593

Merged
bramkragten merged 20 commits intohome-assistant:devfrom
timmo001:search-integrations
Apr 27, 2020
Merged

Add search to integrations 🔍#5593
bramkragten merged 20 commits intohome-assistant:devfrom
timmo001:search-integrations

Conversation

@timmo001
Copy link
Copy Markdown
Member

Proposed change

As requested 😄

integrations-search

Type of change

  • New feature (thank you!)

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

@timmo001 timmo001 changed the title Add search to integrations Add search to integrations 🔍 Apr 23, 2020
`;
})
: html`
: !this._configEntries
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.

Config entries will always be defined, it is inited as an empty array.

Comment thread src/panels/config/integrations/ha-config-integrations.ts Outdated
: ""}
${this._filter &&
!configEntriesInProgress.length &&
!configEntries.length
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.

&& this._configEntries.length

(configEntries: ConfigEntry[], filter?: string): ConfigEntry[] => {
if (filter) {
const options: Fuse.FuseOptions<ConfigEntry> = {
keys: ["entry_id", "domain", "title", "source"],
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.

ideally, you would be able to search for the translated integration (domain) name. I don't think the source and entry_id needs to searchable. Just title and integration name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll translate this in here then and swap out the HTML to the domain returned

Comment on lines +138 to +166
let keys: any[] = ["handler"];
configEntriesInProgress.map(
(entry: DataEntryFlowProgress): DataEntryFlowProgress => {
keys = mergeArrays(
keys,
Object.keys(entry.context).map((key: string) => `context.${key}`)
);
return entry;
}
);
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.

Let's restrict this to localizeConfigFlowTitle(this.hass.localize, entry) and domainToName(this.hass.localize, entry.handler) and maybe entry.handler.

@bramkragten
Copy link
Copy Markdown
Member

Can we make the search bar look the same as the other config pages?

@timmo001
Copy link
Copy Markdown
Member Author

Can we make the search bar look the same as the other config pages?

I can add no-underline but I don't think it suits this page:

Screenshot_20200423_135953

@timmo001

This comment has been minimized.

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Apr 23, 2020

I mean the search bar white, and in mobile in the header:
image

image

@timmo001 timmo001 requested a review from bramkragten April 23, 2020 20:57
(configEntry: ConfigEntry) => {
return {
...configEntry,
domain: domainToName(this.hass.localize, configEntry.domain),
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.

Let's add this when we fetch the config entries and also use it in the render.

Comment on lines +134 to +139
configEntries = configEntries.filter(
(configEntry: ConfigEntry) =>
configEntriesSearch.findIndex(
(ce: ConfigEntry) => ce.entry_id === configEntry.entry_id
) !== -1
);
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.

Also means we don't have to do this.

filter?: string
): DataEntryFlowProgress[] => {
if (filter) {
let configEntriedInProgressSearch: DataEntryFlowProgressSearch[] = configEntriesInProgress.map(
Copy link
Copy Markdown
Member

@bramkragten bramkragten Apr 24, 2020

Choose a reason for hiding this comment

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

Same here, add it in the subscribe function to the configEntry objects. Make a new extended type.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Struggling here to get translations to load after subscribe change level (line 107). Its an async function is called but even if I try to move around and await that call (this.hass.loadBackendTranslation) it still returns blank, like the translation hasn't loaded yet.

The only way I've been able to get the translation is to load it at render or filter level like it is now.. 😕

Any ideas?

Comment thread src/panels/config/integrations/ha-config-integrations.ts
@timmo001
Copy link
Copy Markdown
Member Author

timmo001 commented Apr 25, 2020

Got it in a working state. Added suggestions all but _configEntriesInProgress. Having issues with loading titles in the subscribe function. (see above review comment)

@timmo001 timmo001 requested a review from bramkragten April 25, 2020 15:46
@timmo001
Copy link
Copy Markdown
Member Author

Ah promises. Did attempt those but I think I was having one of those days 😄

Thanks @bramkragten! 🍻

@bramkragten bramkragten merged commit 8821747 into home-assistant:dev Apr 27, 2020
@timmo001 timmo001 deleted the search-integrations branch April 28, 2020 21:34
@lock lock Bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants