Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

feat(admin): plugin browse search and reordered category filter

Gabe Kangas8b70720d7408
diff --git a/web/components/admin/plugins/BrowseRegistry.module.scss b/web/components/admin/plugins/BrowseRegistry.module.scss
index 060b476622..6b4b6910e4 100644
--- a/web/components/admin/plugins/BrowseRegistry.module.scss
+++ b/web/components/admin/plugins/BrowseRegistry.module.scss
@@ -12,7 +12,7 @@
padding: 32px 0;
}
-// Filter bar (permissions / author / category Selects) above the
+// Filter bar (search box + category / permissions / author Selects) above the
// plugin cards.
.filters {
width: 100%;
diff --git a/web/components/admin/plugins/BrowseRegistry.tsx b/web/components/admin/plugins/BrowseRegistry.tsx
index 971b9de732..752e846ed8 100644
--- a/web/components/admin/plugins/BrowseRegistry.tsx
+++ b/web/components/admin/plugins/BrowseRegistry.tsx
@@ -1,5 +1,17 @@
import React, { useMemo, useState } from 'react';
-import { Alert, Button, Card, Empty, Select, Space, Spin, Tag, Tooltip, Typography } from 'antd';
+import {
+ Alert,
+ Button,
+ Card,
+ Empty,
+ Input,
+ Select,
+ Space,
+ Spin,
+ Tag,
+ Tooltip,
+ Typography,
+} from 'antd';
import { useTranslation } from 'next-export-i18n';
import { Localization } from '../../../types/localization';
import { isPluginUpdateAvailable } from '../../../utils/apis';
@@ -128,6 +140,8 @@ export const BrowseRegistry = ({
const [permissionFilter, setPermissionFilter] = useState<string[]>([]);
const [authorFilter, setAuthorFilter] = useState<string>();
const [categoryFilter, setCategoryFilter] = useState<string>();
+ // Free-text search over plugin names and summaries.
+ const [searchTerm, setSearchTerm] = useState('');
// Unknown slug falls back to the raw value so a newer registry
// doesn't render blank labels.
@@ -169,19 +183,28 @@ export const BrowseRegistry = ({
const filteredRegistry = useMemo(
() =>
registry.filter(p => {
+ const search = searchTerm.trim().toLowerCase();
+ if (
+ search &&
+ !p.name.toLowerCase().includes(search) &&
+ !(p.summary ?? '').toLowerCase().includes(search)
+ ) {
+ return false;
+ }
if (authorFilter && p.authorName !== authorFilter) return false;
if (categoryFilter && pluginCategory(p) !== categoryFilter) return false;
const perms = p.latest?.manifest?.permissions ?? [];
// A plugin matches when it declares ALL selected permissions.
return permissionFilter.every(perm => perms.includes(perm));
}),
- [registry, permissionFilter, authorFilter, categoryFilter],
+ [registry, permissionFilter, authorFilter, categoryFilter, searchTerm],
);
const clearFilters = () => {
setPermissionFilter([]);
setAuthorFilter(undefined);
setCategoryFilter(undefined);
+ setSearchTerm('');
};
const triggerInstall = async (plugin: RegistryPlugin) => {
@@ -240,6 +263,23 @@ export const BrowseRegistry = ({
const filterBar = (
<Space wrap className={s.filters}>
+ <Input
+ allowClear
+ className={s.filterSelect}
+ placeholder={t(Localization.Admin.Plugins.browseSearch)}
+ value={searchTerm}
+ onChange={e => setSearchTerm(e.target.value)}
+ />
+ {categoryOptions.length > 0 && (
+ <Select
+ allowClear
+ className={s.filterSelect}
+ placeholder={t(Localization.Admin.Plugins.browseFilterCategory)}
+ value={categoryFilter}
+ onChange={setCategoryFilter}
+ options={categoryOptions}
+ />
+ )}
<Select
mode="multiple"
allowClear
@@ -257,16 +297,6 @@ export const BrowseRegistry = ({
onChange={setAuthorFilter}
options={authorOptions}
/>
- {categoryOptions.length > 0 && (
- <Select
- allowClear
- className={s.filterSelect}
- placeholder={t(Localization.Admin.Plugins.browseFilterCategory)}
- value={categoryFilter}
- onChange={setCategoryFilter}
- options={categoryOptions}
- />
- )}
</Space>
);
diff --git a/web/i18n/en/translation.json b/web/i18n/en/translation.json
index d530898ff3..1ca2ce5d77 100644
--- a/web/i18n/en/translation.json
+++ b/web/i18n/en/translation.json
@@ -263,6 +263,7 @@
"browseInstall": "Install",
"browseInstalled": "Installed",
"browsePreviewAlt": "{{name}} preview screenshot",
+ "browseSearch": "Search plugins",
"browseUnavailableDescription": "Owncast can't reach the plugin catalog right now. You can still upload .ocpkg files directly from the Installed tab.",
"browseUnavailableRetry": "Retry",
"browseUnavailableTitle": "The plugin catalog is currently unavailable",
diff --git a/web/tests/BrowseRegistryFilters.test.tsx b/web/tests/BrowseRegistryFilters.test.tsx
index f9b8ce5129..76cc44dcc8 100644
--- a/web/tests/BrowseRegistryFilters.test.tsx
+++ b/web/tests/BrowseRegistryFilters.test.tsx
@@ -42,6 +42,7 @@ const plugins: RegistryPlugin[] = [
{
slug: 'gamma',
name: 'Gamma Plugin',
+ summary: 'Charts viewer counts over time.',
latest: { version: '3.0.0' },
},
];
@@ -62,6 +63,7 @@ const renderRegistry = (registry: RegistryPlugin[] = plugins) =>
const PERMISSIONS_PLACEHOLDER = 'Admin.Plugins.browseFilterPermissions';
const AUTHOR_PLACEHOLDER = 'Admin.Plugins.browseFilterAuthor';
const CATEGORY_PLACEHOLDER = 'Admin.Plugins.browseFilterCategory';
+const SEARCH_PLACEHOLDER = 'Admin.Plugins.browseSearch';
const openSelect = (placeholder: string) => {
// antd v6 renders the placeholder inside .ant-select-content; the
@@ -110,6 +112,26 @@ describe('BrowseRegistry filters', () => {
expect(visiblePlugins()).toEqual(['Alpha Plugin']);
});
+ it('searches by plugin name, case-insensitively', () => {
+ renderRegistry();
+ fireEvent.change(screen.getByPlaceholderText(SEARCH_PLACEHOLDER), {
+ target: { value: 'BETA' },
+ });
+ expect(visiblePlugins()).toEqual(['Beta Plugin']);
+ });
+
+ it('searches by summary text and clears with the other filters', () => {
+ renderRegistry();
+ const search = screen.getByPlaceholderText(SEARCH_PLACEHOLDER);
+ fireEvent.change(search, { target: { value: 'viewer counts' } });
+ expect(visiblePlugins()).toEqual(['Gamma Plugin']);
+ fireEvent.change(search, { target: { value: 'no such plugin' } });
+ expect(visiblePlugins()).toEqual([]);
+ fireEvent.click(screen.getByText('Admin.Plugins.browseClearFilters'));
+ expect(visiblePlugins()).toEqual(['Alpha Plugin', 'Beta Plugin', 'Gamma Plugin']);
+ expect((search as HTMLInputElement).value).toBe('');
+ });
+
it('shows the filtered-empty state and clears filters', () => {
renderRegistry();
// Alice + overlays matches nothing: Alice authored a chat-bot.
diff --git a/web/types/localization.ts b/web/types/localization.ts
index 1f02fd132c..8669bff974 100644
--- a/web/types/localization.ts
+++ b/web/types/localization.ts
@@ -510,6 +510,7 @@ export const Localization = {
browseFilterCategory: 'Admin.Plugins.browseFilterCategory',
browseFilteredEmpty: 'Admin.Plugins.browseFilteredEmpty',
browseClearFilters: 'Admin.Plugins.browseClearFilters',
+ browseSearch: 'Admin.Plugins.browseSearch',
updateAvailable: 'Admin.Plugins.updateAvailable',
updateConfirmTitle: 'Admin.Plugins.updateConfirmTitle',
updateConfirmOk: 'Admin.Plugins.updateConfirmOk',