Skip to content

Keep the rows of the submit dialog in its view model - #183

Merged
vesnicancz merged 3 commits into
masterfrom
refactor/worklog-preview-out-of-orchestrator
Nov 5, 2026
Merged

vesnicancz merged 3 commits into
masterfrom
refactor/worklog-preview-out-of-orchestrator

Conversation

@vesnicancz

Copy link
Copy Markdown
Owner

WorklogPreviewItem was the last view model type passing through an orchestrator. WorklogSubmissionOrchestrator built the rows of the dialog, wrote errors into them, inverted their selection and even formatted the total. The submit and retry paths also each kept their own copy of the row handling.

What changes

  • The orchestrator takes and returns plain data: LoadPreviewAsync returns the days from the service, and SubmitAsync takes WorklogDto and returns a SubmissionOutcome. Retry is the same call with fewer worklogs, so RetryFailedAsync goes, along with ResetItems, InvertSelection, SelectAll, FormatDuration and PreviewLoadResult.
  • SubmissionOutcome now says what the provider answered: Delivered, the status message and the errors by position. Whether any row has failed is for the view model to work out.
  • SubmitWorklogViewModel builds the rows and shows the results on them, with one SubmitRowsAsync for both Submit and Retry.
  • WorklogPreviewItem gets FromWorklog, DateHeader, ToWorklog and ClearError.
  • Orchestrators_DoNotUseViewModels now also forbids the WorkTracker.Avalonia.ViewModels namespace, which this makes possible.

The rules stay the same:

  • Submit clears the errors of every row once the provider answers, and Retry only those of the rows it sent.
  • With no answer from the provider, the errors stay.
  • An error without a position marks no row.

One difference that the dialog can't reach: Retry with nothing to send used to report success with an empty message, and it now sends nothing and leaves the status alone. The button is disabled in that state.

Testing

  • All 1452 tests pass on Windows. The tests of rows, selection and errors moved from the orchestrator to SubmitWorklogViewModelTests, where they go through the commands. There are 8 fewer tests overall, because some asserted things that no longer exist, such as helpers skipping date headers, and others were covered twice.
  • I opened the dialog in the Debug GUI through UI Automation: it loaded the preview for an empty day and showed 0m. I sent nothing.
  • Not tried in the running app: a day with real rows, editing them, and a real upload or retry. Tests with a mocked orchestrator cover those, so one upload on a real day is worth doing.

@vesnicancz
vesnicancz merged commit b4e8265 into master Nov 5, 2026
5 checks passed
@vesnicancz
vesnicancz deleted the refactor/worklog-preview-out-of-orchestrator branch November 5, 2026 13:09
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.

1 participant