web/user: fix broken search on application library (#5743)

web: fix broken search on application library

This is *mortifying*.  I didn't test this well enough, and apparently
broke it again once I'd tested it.  This patch restores the original
behavior ("no match" means "just show everything"), and fixes a
small bit of semantic lint -- the "search" feature should not be
assigning meaning to what it finds; it's enough to pass back the
prioritized list to whatever client wanted it, and let the client
decide what to do with it.
This commit is contained in:
Ken Sternberg
2023-05-24 11:51:49 -07:00
committed by GitHub
parent 4230d8ee20
commit 7c43c1a05b
2 changed files with 10 additions and 10 deletions

View File

@ -16,10 +16,6 @@ import type { Application } from "@goauthentik/api";
import { SEARCH_ITEM_SELECTED, SEARCH_UPDATED } from "./constants";
import { customEvent } from "./helpers";
function fuseToApps(apps: Fuse.FuseResult<Application>[]): Application[] {
return apps.map((item) => item.item);
}
@customElement("ak-library-list-search")
export class LibraryPageApplicationList extends AKElement {
static styles = [PFBase, PFDisplay];
@ -55,16 +51,15 @@ export class LibraryPageApplicationList extends AKElement {
}
onSelected(apps: Fuse.FuseResult<Application>[]) {
const items = fuseToApps(apps);
this.dispatchEvent(
customEvent(SEARCH_UPDATED, {
selectedApp: items[0],
filteredApps: items,
apps: apps.map((app) => app.item),
}),
);
}
connectedCallback() {
super.connectedCallback();
this.fuse.setCollection(this.apps);
if (!this.query) {
return;