-
Notifications
You must be signed in to change notification settings - Fork 2
Various small changes #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c3bbf9
Filter filters by scope, control, or component
ianmiell 607fee3
Store state of LHN
ianmiell 09437a0
Fix catalog page - edit buttons now work as expected
ianmiell e65355a
Add tests
ianmiell 8aa423e
Store the state of the catalog on refresh
ianmiell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { beforeEach, describe, expect, it } from 'vitest'; | ||
| import { nextTick } from 'vue'; | ||
| import { createPinia, setActivePinia } from 'pinia'; | ||
| import { useLeftNavCategoriesStore } from '../leftNavCategories'; | ||
|
|
||
| describe('useLeftNavCategoriesStore', () => { | ||
| beforeEach(() => { | ||
| localStorage.clear(); | ||
| setActivePinia(createPinia()); | ||
| }); | ||
|
|
||
| it('reports categories as closed by default', () => { | ||
| const store = useLeftNavCategoriesStore(); | ||
| expect(store.isOpen('Control Definitions')).toBe(false); | ||
| }); | ||
|
|
||
| it('remembers an opened category independently of others', () => { | ||
| const store = useLeftNavCategoriesStore(); | ||
| store.setOpen('Control Definitions', true); | ||
|
|
||
| expect(store.isOpen('Control Definitions')).toBe(true); | ||
| expect(store.isOpen('Workflows')).toBe(false); | ||
|
|
||
| store.setOpen('Control Definitions', false); | ||
| expect(store.isOpen('Control Definitions')).toBe(false); | ||
| }); | ||
|
|
||
| it('persists open categories to localStorage across a fresh store instance', async () => { | ||
| const first = useLeftNavCategoriesStore(); | ||
| first.setOpen('Admin', true); | ||
| // useLocalStorage writes to storage via a watcher, not synchronously on assignment. | ||
| await nextTick(); | ||
|
|
||
| // Simulates a hard refresh: a brand new Pinia instance, but the same localStorage. | ||
| setActivePinia(createPinia()); | ||
| const second = useLeftNavCategoriesStore(); | ||
|
|
||
| expect(second.isOpen('Admin')).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { defineStore } from 'pinia'; | ||
| import { useLocalStorage } from '@vueuse/core'; | ||
|
|
||
| // Generic persisted open/closed state for CollapsableGroup instances, keyed by an | ||
| // arbitrary caller-supplied string. Opt-in via CollapsableGroup's `persistKey` prop — used | ||
| // where a page wants its expand/collapse tree (e.g. a catalog's groups and controls) to | ||
| // survive a hard refresh, rather than always resetting collapsed on mount. | ||
| export const useCollapsibleGroupsStore = defineStore( | ||
| 'collapsibleGroups', | ||
| () => { | ||
| const openKeys = useLocalStorage<string[]>('collapsibleGroupsOpen', []); | ||
|
|
||
| function isOpen(key: string): boolean { | ||
| return openKeys.value.includes(key); | ||
| } | ||
|
|
||
| function setOpen(key: string, open: boolean) { | ||
| if (open === isOpen(key)) { | ||
| return; | ||
| } | ||
| openKeys.value = open | ||
| ? [...openKeys.value, key] | ||
| : openKeys.value.filter((openKey) => openKey !== key); | ||
| } | ||
|
|
||
| return { | ||
| openKeys, | ||
| isOpen, | ||
| setOpen, | ||
| }; | ||
| }, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { defineStore } from 'pinia'; | ||
| import { useLocalStorage } from '@vueuse/core'; | ||
|
|
||
| // Which left-hand-nav categories (keyed by their title, e.g. "Control Definitions") the | ||
| // user has expanded — persisted so a manually-opened submenu stays open across a hard | ||
| // refresh or a new session, even if nothing under it was ever selected. | ||
| export const useLeftNavCategoriesStore = defineStore( | ||
| 'leftNavCategories', | ||
| () => { | ||
| const openTitles = useLocalStorage<string[]>('leftNavOpenCategories', []); | ||
|
|
||
| function isOpen(title: string): boolean { | ||
| return openTitles.value.includes(title); | ||
| } | ||
|
|
||
| function setOpen(title: string, open: boolean) { | ||
| if (open === isOpen(title)) { | ||
| return; | ||
| } | ||
| openTitles.value = open | ||
| ? [...openTitles.value, title] | ||
| : openTitles.value.filter((openTitle) => openTitle !== title); | ||
| } | ||
|
|
||
| return { | ||
| openTitles, | ||
| isOpen, | ||
| setOpen, | ||
| }; | ||
| }, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.