web/user: make search configurable
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
88de94f014
commit
84a800583c
|
@ -20,6 +20,8 @@ import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-sta
|
||||||
import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
||||||
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
||||||
import "./LibraryApplication";
|
import "./LibraryApplication";
|
||||||
|
import { until } from "lit-html/directives/until";
|
||||||
|
import { uiConfig } from "./config";
|
||||||
|
|
||||||
@customElement("ak-library")
|
@customElement("ak-library")
|
||||||
export class LibraryPage extends LitElement {
|
export class LibraryPage extends LitElement {
|
||||||
|
@ -102,26 +104,33 @@ export class LibraryPage extends LitElement {
|
||||||
return html`<main role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
|
return html`<main role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
|
||||||
<div class="pf-c-content header">
|
<div class="pf-c-content header">
|
||||||
<h1>${t`My applications`}</h1>
|
<h1>${t`My applications`}</h1>
|
||||||
<input
|
${until(
|
||||||
@input=${(ev: InputEvent) => {
|
uiConfig().then((config) => {
|
||||||
const query = (ev.target as HTMLInputElement).value;
|
if (!config.enabledFeatures.search) {
|
||||||
if (!this.fuse) return;
|
return html``;
|
||||||
const apps = this.fuse.search(query);
|
|
||||||
if (apps.length < 1) return;
|
|
||||||
this.selectedApp = apps[0].item;
|
|
||||||
}}
|
|
||||||
@keydown=${(ev: KeyboardEvent) => {
|
|
||||||
if (ev.key === "Enter" && this.selectedApp?.launchUrl) {
|
|
||||||
window.location.assign(this.selectedApp.launchUrl);
|
|
||||||
} else if (ev.key === "Escape") {
|
|
||||||
(ev.target as HTMLInputElement).value = "";
|
|
||||||
this.selectedApp = undefined;
|
|
||||||
}
|
}
|
||||||
}}
|
return html` <input
|
||||||
type="text"
|
@input=${(ev: InputEvent) => {
|
||||||
autofocus
|
const query = (ev.target as HTMLInputElement).value;
|
||||||
placeholder=${t`Search...`}
|
if (!this.fuse) return;
|
||||||
/>
|
const apps = this.fuse.search(query);
|
||||||
|
if (apps.length < 1) return;
|
||||||
|
this.selectedApp = apps[0].item;
|
||||||
|
}}
|
||||||
|
@keydown=${(ev: KeyboardEvent) => {
|
||||||
|
if (ev.key === "Enter" && this.selectedApp?.launchUrl) {
|
||||||
|
window.location.assign(this.selectedApp.launchUrl);
|
||||||
|
} else if (ev.key === "Escape") {
|
||||||
|
(ev.target as HTMLInputElement).value = "";
|
||||||
|
this.selectedApp = undefined;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
type="text"
|
||||||
|
autofocus
|
||||||
|
placeholder=${t`Search...`}
|
||||||
|
/>`;
|
||||||
|
}),
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<section class="pf-c-page__main-section">
|
<section class="pf-c-page__main-section">
|
||||||
${loading(
|
${loading(
|
||||||
|
|
|
@ -8,6 +8,8 @@ export interface UIConfig {
|
||||||
settings: boolean;
|
settings: boolean;
|
||||||
// Application edit in library (only shown when user is superuser)
|
// Application edit in library (only shown when user is superuser)
|
||||||
applicationEdit: boolean;
|
applicationEdit: boolean;
|
||||||
|
// Search bar
|
||||||
|
search: boolean;
|
||||||
};
|
};
|
||||||
navbar: {
|
navbar: {
|
||||||
userDisplay: "username" | "name" | "email";
|
userDisplay: "username" | "name" | "email";
|
||||||
|
@ -20,6 +22,7 @@ export const DefaultUIConfig: UIConfig = {
|
||||||
notificationDrawer: true,
|
notificationDrawer: true,
|
||||||
settings: true,
|
settings: true,
|
||||||
applicationEdit: true,
|
applicationEdit: true,
|
||||||
|
search: true,
|
||||||
},
|
},
|
||||||
navbar: {
|
navbar: {
|
||||||
userDisplay: "name",
|
userDisplay: "name",
|
||||||
|
|
Reference in New Issue