From 3109af2c7eac5b77a8d5382079bac31f3319103a Mon Sep 17 00:00:00 2001 From: kat Date: Thu, 17 Sep 2026 13:08:16 +0100 Subject: [PATCH] feat: add search box to filter down results in the table --- admin/src/components/ConfigList/index.jsx | 44 ++++++++++++++++++++--- admin/src/translations/en.json | 2 ++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/admin/src/components/ConfigList/index.jsx b/admin/src/components/ConfigList/index.jsx index 812d317..4c19359 100644 --- a/admin/src/components/ConfigList/index.jsx +++ b/admin/src/components/ConfigList/index.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react'; import { useIntl } from 'react-intl'; import { isEmpty } from 'lodash'; import { useDispatch } from 'react-redux'; +import styled from 'styled-components'; import { Table, @@ -13,8 +14,11 @@ import { Checkbox, Loader, Flex, + Box, + TextInput, + IconButton, } from '@strapi/design-system'; -import { CaretDown, CaretUp } from '@strapi/icons'; +import { CaretDown, CaretUp, Search, Cross } from '@strapi/icons'; import ConfigDiff from '../ConfigDiff'; import FirstExport from '../FirstExport'; @@ -22,6 +26,13 @@ import NoChanges from '../NoChanges'; import ConfigListRow from './ConfigListRow'; import { setConfigPartialDiffInState } from '../../state/actions/Config'; +const SearchBox = styled(Box)` + width: 100%; + + @media (min-width: 768px) { + width: 40%; + } +`; const ConfigList = ({ diff, isLoading }) => { const [originalConfig, setOriginalConfig] = useState({}); @@ -31,6 +42,7 @@ const ConfigList = ({ diff, isLoading }) => { const [checkedItems, setCheckedItems] = useState([]); const [sortBy, setSortBy] = useState('configName'); const [sortOrder, setSortOrder] = useState('asc'); + const [searchQuery, setSearchQuery] = useState(''); const dispatch = useDispatch(); const { formatMessage } = useIntl(); @@ -103,7 +115,13 @@ const ConfigList = ({ diff, isLoading }) => { const sortedRows = useMemo(() => { const rowsWithIndex = rows.map((row, originalIndex) => ({ ...row, originalIndex })); - return rowsWithIndex.sort((a, b) => { + const filteredRows = searchQuery + ? rowsWithIndex.filter((row) => ( + `${row.configType}.${row.configName}`.toLowerCase().includes(searchQuery.toLowerCase()) + )) + : rowsWithIndex; + + return filteredRows.sort((a, b) => { const aValue = (a[sortBy] || '').toLowerCase(); const bValue = (b[sortBy] || '').toLowerCase(); @@ -111,7 +129,7 @@ const ConfigList = ({ diff, isLoading }) => { if (aValue > bValue) return sortOrder === 'asc' ? 1 : -1; return 0; }); - }, [rows, sortBy, sortOrder]); + }, [rows, sortBy, sortOrder, searchQuery]); if (isLoading) { return ( @@ -139,7 +157,25 @@ const ConfigList = ({ diff, isLoading }) => { return (
- + + } + endAction={searchQuery ? ( + setSearchQuery('')} + variant="ghost" + > + + + ) : null} + aria-label={formatMessage({ id: 'config-sync.ConfigList.Search' })} + placeholder={formatMessage({ id: 'config-sync.ConfigList.Search' })} + value={searchQuery} + onChange={(e) => setSearchQuery(e.target.value)} + /> + +
diff --git a/admin/src/translations/en.json b/admin/src/translations/en.json index e043d09..0b4d20f 100644 --- a/admin/src/translations/en.json +++ b/admin/src/translations/en.json @@ -18,6 +18,8 @@ "ConfigList.Loading": "Loading content...", "ConfigList.SelectAll": "Select all entries", + "ConfigList.Search": "Search", + "ConfigList.ClearSearch": "Clear search", "ConfigList.ConfigName": "Config name", "ConfigList.ConfigType": "Config type", "ConfigList.State": "State",