diff --git a/docs/images/config_store.png b/docs/images/config_store.png new file mode 100644 index 0000000..e5aaa9b Binary files /dev/null and b/docs/images/config_store.png differ diff --git a/docs/users/user_guide.md b/docs/users/user_guide.md index a9c493e..ddf191c 100644 --- a/docs/users/user_guide.md +++ b/docs/users/user_guide.md @@ -304,6 +304,22 @@ _Note: Importing replaces the current workspace without asking. Save first if yo --- +## Config Store + +The config store saves a workspace to the server and gives you a link to share it, instead of a `.trc.json` file. + +- Click the **Config Store** icon in the header to open it. +- **Save & copy share link** saves the current workspace and copies a link to your clipboard. Anyone with the link gets the same plots, axes, traces, styles, time ranges, and theme. +- **Saved configs** lists what's been saved, newest first. Use **Search** to filter the list by name. Each row has **Load**, **Rename**, copy-link, and delete actions. + +
+ +_Note: The list shows at most 200 configs. If there are more, the header says so (e.g. "showing 200 of 340") — use **Search** to find a config past that cutoff._ + +--- + ## Export and Print - **Export CSV** — downloads one CSV file per plot, named after the plot title. Each row has the PV name, the time (in nanoseconds and as a date), and the value. Archive and formula data are included; traces with only live data are not. For ranges longer than 30 minutes, the archive values are the averaged bins shown on the plot. diff --git a/src/components/ConfigStoreModal.test.tsx b/src/components/ConfigStoreModal.test.tsx index bed095c..7fd2bff 100644 --- a/src/components/ConfigStoreModal.test.tsx +++ b/src/components/ConfigStoreModal.test.tsx @@ -292,6 +292,46 @@ describe('ConfigStoreModal', () => { ); }); + it('debounces search input into a server-side listConfigs search query', async () => { + vi.mocked(listConfigs).mockResolvedValue({ + results: [listedConfig], + continuationToken: null, + totalCount: 1, + }); + renderModal(); + await screen.findByText('test-config'); + vi.mocked(listConfigs).mockClear(); + + fireEvent.change(screen.getByRole('searchbox', { name: 'Search saved configs' }), { + target: { value: 'klystron' }, + }); + + await waitFor(() => + expect(listConfigs).toHaveBeenCalledWith(expect.objectContaining({ search: 'klystron' })) + ); + }); + + it('shows a search-specific empty state when a query has no matches', async () => { + vi.mocked(listConfigs).mockResolvedValueOnce({ + results: [listedConfig], + continuationToken: null, + totalCount: 1, + }); + renderModal(); + await screen.findByText('test-config'); + + vi.mocked(listConfigs).mockResolvedValue({ + results: [], + continuationToken: null, + totalCount: 0, + }); + fireEvent.change(screen.getByRole('searchbox', { name: 'Search saved configs' }), { + target: { value: 'no-such-config' }, + }); + + await screen.findByText('No configs match your search.'); + }); + it('aborts a pending load when the modal unmounts', async () => { vi.mocked(listConfigs).mockResolvedValue({ results: [listedConfig], diff --git a/src/components/ConfigStoreModal.tsx b/src/components/ConfigStoreModal.tsx index eb7bace..62e9bce 100644 --- a/src/components/ConfigStoreModal.tsx +++ b/src/components/ConfigStoreModal.tsx @@ -14,6 +14,7 @@ import { StructuredListBody, StructuredListRow, StructuredListCell, + Search, } from '@carbon/react'; import { Copy, TrashCan, Renew } from '@carbon/icons-react'; @@ -49,6 +50,10 @@ interface ConfigStoreModalProps { // silently hidden; real paging is slaclab/react-trace#80. const PAGE_SIZE = 200; +// Delay before a search keystroke triggers a refetch, so typing doesn't fire +// a request per character. +const SEARCH_DEBOUNCE_MS = 300; + // Marks the delete confirmation, which opens as a second modal over the store. // The store's Carbon focus wrap treats focus leaving for an element outside it // as Tab-past-the-end and pulls it back to its own first button. Listing this @@ -95,6 +100,9 @@ export function ConfigStoreModal({ const [configs, setConfigs] = useStateNo saved configs yet.
++ {debouncedSearch.trim() + ? 'No configs match your search.' + : 'No saved configs yet.'} +
) : (