Repository navigation
feat(overview): let the user choose the folder for new files - #211
Open
seecker-ionos wants to merge 1 commit into
Open
seecker-ionos wants to merge 1 commit into
seecker-ionos wants to merge 1 commit into
Conversation
New files were always created in the user's root folder, so anyone who keeps documents in folders, project folders or team folders had to move every file afterwards. The create dialog now shows the target folder with a "Change" button that opens the Nextcloud file picker. Only folders the user may create files in can be picked, so team folders and shares work through their own permissions. The last used folder is remembered per user in Nextcloud's scoped browser storage, which the server clears on logout, and is re-checked when the dialog opens; if it is gone or no longer writable, the dialog says so and falls back to the root folder. The dialog still opens at once, and a late check never overrides a folder the user picked or a create already sent. @nextcloud/dialogs is imported on demand together with its stylesheet, so the file picker is only downloaded when the folder is changed. Folder names go into labels as plain text, without escaping or sanitizing. The tests now run against the real translate() instead of a stand-in that skipped its escaping and sanitizing. Closes nextcloud#205 Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Sebastian Ecker <sebastian.ecker@world4you.com>
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.
Closes #205
Problem
New files from the Office overview are always created in the user's root folder. Anyone who keeps documents in folders, project folders or team folders has to move every file afterwards.
Change
@nextcloud/dialogs), folders only; only folders with create permission can be picked (setCanPick, also applied to the folder being browsed), so team folders and shares follow their own permissions, including groupfolder ACLs.@nextcloud/browser-storage(persist().clearOnLogout(), key includes the user id). When the dialog opens it is re-checked (depth-0 PROPFIND with the default properties,oc:permissionsparsed withparsePermissions()); if it was deleted, unshared or lost create permission, the dialog shows a note and falls back to the root folder. Stored values that are not a plain absolute path (.., empty segments) are ignored.translate(…, { escape: false, sanitize: false }), since they are only rendered as text (aria-label, the picker's button label) — otherwiseR&DreadsR&Dand<Drafts>disappears. The current folder is announced viaaria-live="polite". If the picker cannot be opened (e.g. its chunk fails to load), a note appears below the folder.Relation to #210
Independent of #210 (free filename suggestion); both touch
OfficeOverview.vue, so whichever lands second needs a small rebase. Once both are in, the free name should be looked up in the chosen folder instead of the root — a few lines, since #210'snameExists(folder, name)already takes the folder. Happy to do that in the rebase.Reuse
Rung 2 throughout: the standard file picker from
@nextcloud/dialogs(getFilePickerBuilder) — the same picker Files, Talk and Text use —@nextcloud/browser-storagefor the remembered folder, andparsePermissions()from@nextcloud/files/dav.New dependencies and bundle size — contestable call
@nextcloud/dialogs7.6.0 (AGPL-3.0-or-later). 7.5.0 is deprecated on npm; 8.0.0 does not satisfy@nextcloud/vue9'speerOptional @nextcloud/dialogs ^7.4.0, so I stayed on 7.x. 7.6.0 brings its own@vueuse/core15 (nested; the app uses 14.4) and requiresvue ^3.5.44, so the lockfile also bumpsvue3.5.43 → 3.5.44 (and@babel/parser|types).@nextcloud/browser-storage0.5.0 (GPL-3.0-or-later), already in the tree via@nextcloud/auth; now a direct dependency.@nextcloud/dialogs/style.css) are imported on demand, so they are only downloaded when Change is clicked: ~98 KB gzip in 6 JS chunks plus ~9 KB gzip in 3 new CSS chunks. The entry chunkoffice-main.mjsgrows from 623 KB to 649 KB raw, 206.5 KB → 215.1 KB gzip (+8.6 KB) — code shared with the lazy chunks that Rollup keeps in the entry./compilewill therefore add those chunk files (with their.licensefiles) tojs/andcss/; Vite also emits astyle-*.chunk.mjs.licensewithout a matching chunk.OC.dialogs.filepicker, but it is deprecated, so I did not use it. Happy to switch if you prefer.Tests
TargetFolderPicker.spec.ts: label for root/nested folders, folder names with&/<shown as-is (label,aria-label, picker button),aria-live, folder-only picker started at the current folder,canPick(team folder with create permission ✓, read-only ✗), disabled button when nothing can be picked, root called "All files" instead of the user id,disabledprop, emit on pick,erroron picker failure, no change on close.folders.spec.ts:canCreateIn()against realistic stat results — writable folder (RGDNVCK), team folder mount (MGCK), read-only (RG), file, missing permissions, failed stat.config.spec.ts: default, round-trip, rejected values (..,//, relative, trailing slash,.), separate per user, stored in the logout-cleared scope.OfficeOverview.spec.ts: root without check, remembered folder used when still usable, fallback with note for read-only and deleted folders, no note when usable, Change disabled during the check and not re-enabled by an older check, folder picked during the check wins, create during the check keeps the folder, picker error shown below the folder (not on the filename) and cleared on pick, create path in picked folder and root (no double slash), folder remembered only on success. The race tests fail when their guards are removed.vitest.setup.ts:@nextcloud/l10nis no longer mocked — the stand-in skipped escaping/sanitizing, so a label test could pass here and still render mangled in a browser. All existing tests pass against the realtranslate().npm run test:unit,npm run lint,npm run stylelint,npm run buildpass locally;vue-tsc --noEmitreports the same 4 errors as onmain.Team Folders/<team folder>, the file was created there, the folder was preselected on the next create; a remembered folder that no longer exists shows the note and falls back to "All files"; a folderR&D <Test>is shown unescaped in the label,aria-labeland picker button; the picker loads its own stylesheet chunks and renders correctly. A read-only team folder was not available on that instance; that case is covered by the unit tests.js/andcss/are not committed — please/compile.