Skip to content

Conversation

@terrerox
Copy link
Contributor

@terrerox terrerox commented Dec 9, 2025

Description

  • Add version download, delete, and restore functionality
  • Implement file version service with API integration
  • Add version action dialogs for delete and restore confirmations
  • Add loading skeleton component for version history sidebar
  • Replace mock data with real API integration
  • Add UI state management for version dialogs
  • Pass userName prop to version components to avoid duplication
  • Update name collision dialog to use replaceFile endpoint instead of delete-and-reupload
  • Add replace-file service for efficient file replacement
  • Upgrade @internxt/sdk from 1.11.17 to 1.11.18

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Additional Notes

@terrerox terrerox marked this pull request as draft December 9, 2025 03:26
@terrerox terrerox self-assigned this Dec 9, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 9, 2025

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 34d61ea
Status: ✅  Deploy successful!
Preview URL: https://51b05822.drive-web.pages.dev
Branch Preview URL: https://feature-file-version-history-4jkx.drive-web.pages.dev

View logs

…wnload functionality

  Adds complete file version management system with API integration for viewing, restoring, deleting, and downloading file
  versions. Updates name collision dialog to use replaceFile endpoint instead of delete-and-reupload for file replacements.
@terrerox terrerox force-pushed the feature/file-version-history-v2 branch from 0fc701b to 1612aff Compare December 10, 2025 04:55
@terrerox terrerox marked this pull request as ready for review December 10, 2025 05:04
"restoreVersion": "Restore version",
"downloadVersion": "Download version",
"deleteVersion": "Delete version"
"deleteVersion": "Delete version",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining translations are included in this PR: #1773

@terrerox terrerox force-pushed the feature/file-version-history-v2 branch from 48361a6 to f59d219 Compare December 10, 2025 05:31
const user = localStorageService.getUser();
if (!user) throw new Error('User not found');

const fileStream = await downloadFile({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the multipart download for this? Imagine the file has 5GB or more. It would be better to download it in parallel-small chunks instead of the full file at once. You can do it by using the DownloadManager.downloadItem if I'm not mistaken.

Check that as we need to download the items using the actual method since it solves a lot of speed/memory issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to add tests to this service.

},
});

const blob = await binaryStreamToBlob(fileStream);
Copy link
Contributor

@xabg2 xabg2 Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloading it as blob and then save it will causes memory issues, specially for Firefox. Also, it won't work for big files in Safari - the file will be downloaded but only 700 bytes (or even 0) will be saved to the disk as Safari does not allow saving big blobs.

Try the method I mentioned above as it already handles all these things, such as saving the downloaded + decrypted chunk directly to the user disk instead of saving it in memory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function in this service? It is a part of file versioning, isn't it? Also, remember to add tests to this service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This service is used in the name-collision modal, which belongs to Drive and isn’t necessarily part of the file-version history flow. That’s why I placed it inside the Drive module. It could live under Version History as well, but keeping it in Drive makes more sense in this context. What do you think?

The tests will be added in a separate PR.

…etter UX

  - Replace direct download with DownloadManager for efficient multipart downloads
  - Add workspace credentials support for version downloads
  - Position TaskLogger at bottom-right
  - Refactor: rename service files to camelCase convention (file-version.service.ts → fileVersion.service.ts,
  replace-file.service.ts → replaceFile.service.ts)
  - Pass file item and workspace context to downloadVersion for proper credential handling
@terrerox terrerox requested a review from xabg2 December 10, 2025 15:00
terrerox and others added 12 commits December 10, 2025 11:21
Remove try-catch block and error handling from useVersionItemActions since DownloadManager already handles error reporting,
notifications, and task status updates internally. This prevents duplicate error notifications from being shown to the user.
[PB-5465]: enhance internationalization for version management
…ration

  - Update @internxt/sdk to 1.11.21 for improved version history support
  - Add batch delete functionality for multiple version selections
  - Implement version limits display showing used/total allowed versions
  - Fix file replace operation to properly upload new file content
  - Migrate from local FileVersion type to SDK types for better consistency
  - Add indeterminate checkbox state for partial selections
  - Improve version restoration to update current version state
  - Enhance skeleton loading to show more realistic version count
  - Add getLimits API call to fetch version constraints
  - Refactor CurrentVersionItem to use version info instead of full item data
…tory menu with lock state

  Add VersioningLimitsProvider to DriveView and implement version history menu configuration with locked
  state support. The version history menu now shows a lock icon and handles locked state when versioning
  is not available or extension is not allowed.
… context API

  Replace VersioningLimitsContext with Redux store for consistent state management and improved
  performance. Add fileVersions slice to cache API responses and prevent redundant fetches.

  - Create fileVersions Redux slice with caching for versions and limits
  - Add thunks for fetching file versions and versioning limits
  - Implement cache invalidation on version create, delete, and restore
  - Optimize Sidebar to use cached data and avoid infinite loops
  - Memoize VersionItem component to prevent unnecessary re-renders
  - Remove VersioningLimitsContext and consolidate all state in Redux
  - Update all components to use Redux selectors instead of context
  - Create fileVersions selectors for centralized state access
  - Rename state properties for clarity:
    - loadingStates → isLoadingByFileId
    - errors → errorsByFileId
    - limitsLoading → isLimitsLoading
  - Update type imports to use FileLimitsResponse (SDK v1.11.24)
  - Use NonNullable for Record keys to prevent null index types
  - Refactor version history menu config:
    - Rename properties: locked → isLocked, allowedExtension → isExtensionAllowed, onLockedClick → onUpgradeClick
    - Simplify getVersionHistoryMenuItem with early return pattern
  - Replace direct state access with selectors across components
  - Export getDaysUntilExpiration utility function
  - Add type assertion for restored version fileId
Add unit tests for date service, version history hooks, and file version service to ensure
reliability of the file versioning functionality. Tests cover dropdown positioning logic, version
history menu configuration, file version operations, and date utility functions including expiration
calculations.
…ctions hook

Add comprehensive test coverage for fileVersions Redux slice and useVersionItemActions hook. Tests include thunk
operations (fetch versions, fetch limits), reducer state management (loading, errors, cache invalidation), and
menu action handlers (restore, download, delete). Uses icon-based menu item selection for robust, maintainable
tests.
yarn.lock Outdated
integrity sha512-91iEUvZizlwX6KBEFJ3JdFiGrhMBQ9R54sTc3Pei9QtV2FYTU8nTVEPYAg39tLOGzT/kVuplYOtBxfk6wFtSDA==
"@internxt/sdk@1.11.19":
version "1.11.19"
resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.11.19/f9033c8bf0849d414a3865806bacd79026a38769#f9033c8bf0849d414a3865806bacd79026a38769"
Copy link
Contributor

@larryrider larryrider Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is breaking your cloudflare build, and it also breaking the PR's that depend on this one. You are using an .npmrc file so you are changing the internxt registry from yarnpkg to github.

You should use this one:

registry=https://registry.yarnpkg.com/
@internxt:registry=https://registry.yarnpkg.com/

Copy link
Contributor Author

@terrerox terrerox Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Since this is an old PR, I made the change in this one instead: #1779

@terrerox terrerox requested a review from larryrider December 18, 2025 13:09
<VersionHistorySidebar />
</div>
<TaskLogger />
<div className="absolute bottom-0 right-0 z-50 w-80">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this div wrapping the task logger in necessary? I think could cause wrong behaviours

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When downloading a version, the task logger was located under the File Versions sidebar, making it difficult to cancel the download.

Comment on lines 153 to 155
await replaceFileService.replaceFile(itemToReplace.uuid, {
fileId: itemToReplace.fileId,
size: file.size,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this change. The file data is replaced, but when is the new one uploaded?
Maybe is in another PR?d

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend has that upload new version logic

name: translate('modals.versionHistory.deleteVersion'),
icon: Trash,
action: handleDelete,
action: handleDeleteClick,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the hooks and services outside the components folder, add it to Drive services and hooks.
Otherwise, it would be crazy to maintain this. The components would be full of hooks and services, and components should not have business logic or API services

Copy link
Contributor Author

@terrerox terrerox Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid conflicts, im going to merge all these approved PRs and then work this comment in a new PR

@terrerox terrerox requested a review from CandelR January 9, 2026 14:27
[PB-5542]: add unit tests for Redux file versions slice and version item actions hook
[PB-5542]: add versioning limits context and premium feature gating
  [PB-5466]: enhance version history with batch operations and SDK integration
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

@terrerox terrerox merged commit 039ce89 into feature/file-version-history Jan 10, 2026
4 of 5 checks passed
@terrerox terrerox deleted the feature/file-version-history-v2 branch January 10, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants