Repository navigation
fix(folders): keep empty folders visible and in JSON exports (#338) - #342
Merged
Merged
Conversation
The hosts and snippets pages swapped the whole view for the empty state whenever they had no items, hiding any empty folders. The empty state now requires no folders too. A full JSON export only carried folders an exported item lived in, and import only recreated those. Handlers now report every folder of their type in the exported vaults, and import creates every folder in the bundle unless it is deduplicating (the snippet catalog install).
#338) Creating every bundle folder on import meant a re-import, where each duplicate row defaults to "skip", rebuilt the whole folder tree empty. - A folder no imported item needs now maps onto a live folder of the same name, type and parent in the target vault instead of being saved. - The import screen drops folders whose items were all skipped, keeping empty leaf folders and their ancestors (importableFolders). - newImportCtx builds the eid maps so the three callers stop spelling them out. - selectionMethods' folderType is the four-value union.
The backend returns root folders with parent_folder_id: null, so the strict comparison against undefined never matched one and a re-import still duplicated the whole tree.
… panel During a search the panel listed every snippet folder, including ones with zero matches. byFolder is already built from the filtered list, so both branches collapse into one and an empty folder is hidden either way.
…338) A folder an imported item needed was always created, so a re-import that brought one new host put it in a second copy of its folder. Every bundle folder now reuses a live folder of the same name, type and parent in the target vault.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #338.
Problem
Folders exist on four object pages: Hosts, Keychain, Port Forwarding and Snippets. Two things went wrong with empty ones.
EmptyState) in place of the folder view. Empty folders vanished, creating a folder with no items looked like it did nothing, and the folder came back once an item existed.buildBundleonly emitted folders that an exported item referenced, so empty folders of every type were dropped ("folders": []). Import likewise only recreated folders that an imported item needed.Fix
Pages.
HostsPageandSnippetsPageshow the empty state only when there are no items and no scoped folders.Export.
selectionMethodsnow takes the folderobject_type(connection,keychain,port_forwardingorsnippet, typed as that union) and exposesaccumulateVaultFolderIds.Import. Bundle folders are created unless
skipDupesis set. Only the snippet catalogue install sets it.parent_folder_id: null, so the match treatsnulland a missing parent the same.importableFolders): ancestors of a kept item, plus empty leaf folders and their ancestors. Unticking every item of a folder no longer recreates that folder.newImportCtxbuilds the eid maps, so the threerunImportcallers stop spelling them out.Terminal snippets panel. During a search, the panel listed every snippet folder, including ones with zero matches. Folders with no matching snippet are now hidden. Without a search, the panel still hides empty folders as before; it can't create folders.
Tests
registry.spec.ts:null, like the backend), puts an imported item into it, and does not reuse one with a different parent or type.importableFoldersdrops folders whose items were all skipped, and keeps empty ones, their ancestors, and the folders of kept items.HostsPage.folders.test.tsxandSnippetsPage.folders.test.tsx: an empty folder is listed when there are zero items. Both tests fail without the fix.SnippetsPanel.search.test.tsx: a search hides a folder with no matching snippet. It fails without the fix.tscis clean. The import-export, plugin-domain, hosts, snippets, catalogue-install and right-panel suites pass (426/426).Live verification (headless build, fresh profile, 0 hosts)
buildBundle/runImportdirectly with live stores; the save-file dialog can't be driven headless.nullparent bug: before that fix, the re-import duplicated all 4 folders.