Skip to content

Commit 75114ea

Browse files
authored
Merge pull request #264 from iceljc/features/refine-chat-window
add plugin search
2 parents 20b0d03 + 615050c commit 75114ea

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

src/lib/helpers/types/pluginTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/**
2323
* @typedef {Object} PluginFilter
2424
* @property {import('$commonTypes').Pagination} pager - Pagination
25+
* @property {string[]} [names] - The plugin names
2526
*/
2627

2728
export default {};

src/lib/scss/custom/pages/_chat.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
flex: 0 0 fit-content;
9090
flex-direction: column;
9191
height: 100%;
92+
gap: 5px;
9293

9394
.chat-head-agent {
9495
flex: 0.5;
@@ -108,6 +109,7 @@
108109
display: flex;
109110
gap: 5px;
110111
width: fit-content;
112+
font-size: 12px;
111113
}
112114
}
113115
}

src/lib/services/plugin-service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export async function getPlugins(filter) {
1111
let url = endpoints.pluginListUrl;
1212
const response = await axios.get(url, { params: filter,
1313
paramsSerializer: {
14-
dots: true
14+
dots: true,
15+
indexes: null
1516
}
1617
});
1718
return response.data;

src/routes/VerticalLayout/Sidebar.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@
201201
return path?.startsWith('/') ? path.substring(1) : path;
202202
};
203203
204-
/** @param {string} link */
205-
const goToPage = (link) => {
204+
const goToPage = () => {
206205
globalEventStore.reset();
207206
}
208207
</script>
@@ -231,19 +230,19 @@
231230
</Link>
232231
<ul class="sub-menu mm-collapse">
233232
{#each subMenu.childItems as childItem}
234-
<li><Link href={childItem.link} on:click={() => goToPage(childItem.link)}>{$_(childItem.label)}</Link></li>
233+
<li><Link href={childItem.link} on:click={() => goToPage()}>{$_(childItem.label)}</Link></li>
235234
{/each}
236235
</ul>
237236
</li>
238237
{:else}
239-
<li><Link href={subMenu.link} on:click={() => goToPage(subMenu.link)}>{$_(subMenu.label)}</Link></li>
238+
<li><Link href={subMenu.link} on:click={() => goToPage()}>{$_(subMenu.label)}</Link></li>
240239
{/if}
241240
{/each}
242241
</ul>
243242
</li>
244243
{:else}
245244
<li>
246-
<Link class="waves-effect" href={item.link} on:click={() => goToPage(item.link)} >
245+
<Link class="waves-effect" href={item.link} on:click={() => goToPage()} >
247246
<i class={item.icon} /> <span>{$_(item.label)}</span>
248247
</Link>
249248
</li>

src/routes/page/plugin/+page.svelte

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
33
import HeadTitle from '$lib/common/HeadTitle.svelte';
44
import Plugins from './plugin-list.svelte';
5-
import { onMount } from 'svelte';
5+
import { onDestroy, onMount } from 'svelte';
66
import { getPlugins } from '$lib/services/plugin-service';
77
import { PUBLIC_PLUGIN_DEFAULT_ICON } from '$env/static/public';
88
import PlainPagination from '$lib/common/PlainPagination.svelte';
99
import { _ } from 'svelte-i18n';
10+
import { globalEventStore } from '$lib/helpers/store';
11+
import { GlobalEvent } from '$lib/helpers/enums';
1012
1113
const firstPage = 1;
1214
const pageSize = 12;
@@ -25,10 +27,28 @@
2527
/** @type {import('$commonTypes').Pagination} */
2628
let pager = filter.pager;
2729
30+
/** @type {any} */
31+
let unsubscriber;
32+
2833
onMount(async () => {
2934
await getPagedPlugins();
35+
36+
unsubscriber = globalEventStore.subscribe((/** @type {import('$commonTypes').GlobalEvent} */ event) => {
37+
if (event.name !== GlobalEvent.Search) return;
38+
39+
const names = event.payload ? [event.payload] : undefined;
40+
filter = {
41+
pager: { page: firstPage, size: pageSize, count: 0 },
42+
names: names
43+
};
44+
getPagedPlugins();
45+
});
3046
});
3147
48+
onDestroy(() => {
49+
unsubscriber?.();
50+
});
51+
3252
async function getPagedPlugins() {
3353
plugins = await getPlugins(filter);
3454
refresh();

0 commit comments

Comments
 (0)