-
Notifications
You must be signed in to change notification settings - Fork 25
feat: File versioning - WPB-21660 #3973
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
base: develop
Are you sure you want to change the base?
Conversation
… assets when modified
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 57c5809. ♻️ This comment has been updated with latest results. |
| ) | ||
| } | ||
|
|
||
| func `It returns a collection of WireCellsNodeVersion`() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I think you are missing @test prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
| #expect(result == WireCellsNodeVersion.mock) | ||
| } | ||
|
|
||
| func `It fails retrieving node versions`() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: Using the new style tests.
| do { | ||
| try await localAssetRepository.downloadAsset(source: source) | ||
| cacheKey = try localAssetRepository.asset(nodeID: source.id)?.downloadState.cacheKey | ||
| } catch WireCellsLocalAssetRepositoryError.downloadAlreadyInProgress { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This branch is not necessary as downloadAlreadyInProgress can no longer be thrown. I thought I had already deleted it, but perhaps not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, no longer here in latest commits, it's up to date.
| private func awaitDownload(id: UUID) async throws { | ||
| for await item in localAssetRepository.observeAsset(nodeID: id).values { | ||
| try Task.checkCancellation() | ||
|
|
||
| switch item?.downloadState { | ||
| case .downloaded: | ||
| return | ||
| case let .failed(error): | ||
| throw error | ||
| default: | ||
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This code can be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, updated with latest commits
.../Sources/WireMessagingDomain/WireCells/Protocols/WireCellsLocalAssetRepositoryProtocol.swift
Outdated
Show resolved
Hide resolved
| WireLogger.wireCells.error("Unable to restore node version: \(error)") | ||
| throw Failure.unableToRestoreNodeVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we have to throw and log here? What type of error is catched, consider if this can be logged publicly
samwyndham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. A few comments to address but pre-approving as I will soon be on vacation
| state = .restoringVersion | ||
|
|
||
| // Keep the view visible for a couple of seconds to avoid a quick glitch. | ||
| try? await Task.sleep(nanoseconds: 2_000_000_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Use try? await Task.sleep(for: .seconds(2))
question: Do you have any idea what is the cause of this glitch? 2 seconds is a long time. What does the user see during this period?
|
|
||
| private func makeVersionItem(version: WireCellsNodeVersion) -> FileVersionItem { | ||
| let title = version.modified.map(formattedItemDate) ?? "" | ||
| let subtitle = (version.ownerName ?? "") + " · " + (version.size.map(formattedFileSize) ?? "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The subtitle will be funny here if one of the components is missing. How about something like...
// rough code
[version.ownerName, version.size.map(formattedFileSize)].compactMap {. $0 }.joined(" · ")
| ) -> [Date: [WireCellsNodeVersion]] { | ||
| Dictionary(grouping: versions) { version in | ||
| let date = version.modified ?? Date.distantPast | ||
| let components = Calendar.current.dateComponents([.year, .month, .day], from: date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can you use Date.startOfDay(for:) here?
| } | ||
| } | ||
|
|
||
| if canOpenVersionHistory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I think you might also need to check !viewModel.isInRecycleBin so that it doesnt show when in the recycle bin
|
issue: Could you also put this feature behind the |
Issue
This PR introduces File versioning, specifically the ability for a user to :
note: video taken before merging latest changes from develop also opening and viewing a version has been recently removed from the implementation
https://github.com/user-attachments/assets/6c2defce-cb7b-414b-94b8-00c069cd2d1a
Testing
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: