mirror of
https://github.com/home-assistant/frontend.git
synced 2025-05-03 01:28:43 +00:00
Improve integration search (#11140)
This commit is contained in:
parent
04f2e2e70c
commit
1520b5832a
@ -252,6 +252,7 @@ class DataEntryFlowDialog extends LitElement {
|
|||||||
<step-flow-pick-handler
|
<step-flow-pick-handler
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.handlers=${this._handlers}
|
.handlers=${this._handlers}
|
||||||
|
.initialFilter=${this._params.searchQuery}
|
||||||
@handler-picked=${this._handlerPicked}
|
@handler-picked=${this._handlerPicked}
|
||||||
></step-flow-pick-handler>
|
></step-flow-pick-handler>
|
||||||
`
|
`
|
||||||
|
@ -96,6 +96,7 @@ export type LoadingReason =
|
|||||||
|
|
||||||
export interface DataEntryFlowDialogParams {
|
export interface DataEntryFlowDialogParams {
|
||||||
startFlowHandler?: string;
|
startFlowHandler?: string;
|
||||||
|
searchQuery?: string;
|
||||||
continueFlowId?: string;
|
continueFlowId?: string;
|
||||||
dialogClosedCallback?: (params: {
|
dialogClosedCallback?: (params: {
|
||||||
flowFinished: boolean;
|
flowFinished: boolean;
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
import "@polymer/paper-item/paper-icon-item";
|
import "@polymer/paper-item/paper-icon-item";
|
||||||
import "@polymer/paper-item/paper-item-body";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import {
|
||||||
|
css,
|
||||||
|
CSSResultGroup,
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
TemplateResult,
|
||||||
|
PropertyValues,
|
||||||
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -36,6 +43,8 @@ class StepFlowPickHandler extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public handlers!: string[];
|
@property({ attribute: false }) public handlers!: string[];
|
||||||
|
|
||||||
|
@property() public initialFilter?: string;
|
||||||
|
|
||||||
@state() private _filter?: string;
|
@state() private _filter?: string;
|
||||||
|
|
||||||
private _width?: number;
|
private _width?: number;
|
||||||
@ -138,6 +147,13 @@ class StepFlowPickHandler extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public willUpdate(changedProps: PropertyValues): void {
|
||||||
|
if (this._filter === undefined && this.initialFilter !== undefined) {
|
||||||
|
this._filter = this.initialFilter;
|
||||||
|
}
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
setTimeout(
|
setTimeout(
|
||||||
|
@ -425,6 +425,34 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
|||||||
.deviceRegistryEntries=${this._deviceRegistryEntries}
|
.deviceRegistryEntries=${this._deviceRegistryEntries}
|
||||||
></ha-integration-card>`
|
></ha-integration-card>`
|
||||||
)
|
)
|
||||||
|
: this._filter &&
|
||||||
|
!configEntriesInProgress.length &&
|
||||||
|
!groupedConfigEntries.size &&
|
||||||
|
this._configEntries.length
|
||||||
|
? html`
|
||||||
|
<div class="empty-message">
|
||||||
|
<h1>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.integrations.none_found"
|
||||||
|
)}
|
||||||
|
</h1>
|
||||||
|
<p>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.integrations.none_found_detail"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<mwc-button
|
||||||
|
@click=${this._createFlow}
|
||||||
|
unelevated
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.integrations.add_integration"
|
||||||
|
)}
|
||||||
|
></mwc-button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: // If we have a filter, never show a card
|
||||||
|
this._filter
|
||||||
|
? ""
|
||||||
: // If we're showing 0 cards, show empty state text
|
: // If we're showing 0 cards, show empty state text
|
||||||
(!this._showIgnored || ignoredConfigEntries.length === 0) &&
|
(!this._showIgnored || ignoredConfigEntries.length === 0) &&
|
||||||
(!this._showDisabled || disabledConfigEntries.size === 0) &&
|
(!this._showDisabled || disabledConfigEntries.size === 0) &&
|
||||||
@ -449,25 +477,6 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this._filter &&
|
|
||||||
!configEntriesInProgress.length &&
|
|
||||||
!groupedConfigEntries.size &&
|
|
||||||
this._configEntries.length
|
|
||||||
? html`
|
|
||||||
<div class="empty-message">
|
|
||||||
<h1>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.integrations.none_found"
|
|
||||||
)}
|
|
||||||
</h1>
|
|
||||||
<p>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.integrations.none_found_detail"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: ""}
|
|
||||||
</div>
|
</div>
|
||||||
<ha-fab
|
<ha-fab
|
||||||
slot="fab"
|
slot="fab"
|
||||||
@ -562,6 +571,7 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private _createFlow() {
|
private _createFlow() {
|
||||||
showConfigFlowDialog(this, {
|
showConfigFlowDialog(this, {
|
||||||
|
searchQuery: this._filter,
|
||||||
dialogClosedCallback: () => {
|
dialogClosedCallback: () => {
|
||||||
this._handleFlowUpdated();
|
this._handleFlowUpdated();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user