-
Notifications
You must be signed in to change notification settings - Fork 160
feat(notes): expose file versions in the note sidebar #1972
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
Open
karlitschek
wants to merge
1
commit into
main
Choose a base branch
from
feat/noid/expose-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+176
−48
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import logger from './Logger.js' | ||
|
|
||
| /** | ||
| * Files sidebar tabs the Notes sidebar hosts, and nothing else. | ||
| * | ||
| * Notes dispatches OCA\Files\Event\LoadSidebar when rendering its page, so every | ||
| * app that registers a sidebar tab has registered one by the time this runs — | ||
| * including tabs that make no sense for a note. This is an allow-list so a newly | ||
| * installed app cannot start appearing in the Notes sidebar unannounced. | ||
| * | ||
| * @type {string[]} | ||
| */ | ||
| export const NOTE_SIDEBAR_TAB_IDS = ['sharing', 'files_versions'] | ||
|
|
||
| /** | ||
| * The tabs to render, in the order the registering apps asked for. | ||
| * | ||
| * A tab's own `enabled()` predicate has the final say — the versions tab for | ||
| * instance hides itself on public shares and for anything that is not a file — | ||
| * but it needs a node to judge, so while the node is still loading the tabs are | ||
| * kept and filtered again once it arrives. A predicate that throws is treated as | ||
| * "not usable" rather than being allowed to take the sidebar down. | ||
| * | ||
| * @param {Array<object>} tabs all registered tabs, from getSidebarTabs() | ||
| * @param {object} context what the tab is being asked about | ||
| * @param {object|null} context.node the note's DAV node, null while loading | ||
| * @param {object|null} context.folder the note's parent folder | ||
| * @param {object|null} context.view the pseudo view Notes reports | ||
| * @return {Array<object>} tabs to render, sorted by their declared order | ||
| */ | ||
| export function selectNoteSidebarTabs(tabs, { node = null, folder = null, view = null } = {}) { | ||
| return (tabs ?? []) | ||
| .filter((tab) => NOTE_SIDEBAR_TAB_IDS.includes(tab?.id)) | ||
| .filter((tab) => { | ||
| if (typeof tab.enabled !== 'function' || node === null) { | ||
| return true | ||
| } | ||
| try { | ||
| return tab.enabled({ node, folder, view }) | ||
| } catch (error) { | ||
| logger.error('Sidebar tab predicate failed in Notes, dropping the tab', { error, tab: tab.id }) | ||
| return false | ||
| } | ||
|
AndyScherzinger marked this conversation as resolved.
|
||
| }) | ||
| .sort((a, b) => (a.order ?? 0) - (b.order ?? 0)) | ||
| } | ||
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.