feat: owner review 2 phase 5b: the server as a project home (#17)
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
A Chronos Server keeps its sequences' projects, as a PC's archive does: Main and named projects with versions under /api/v1/sequences/{id}/projects, the projects capability and the projectChanged event. The desktop opens a server's sequences in the workspace (proxies downloaded, hash-checked, resumable) with Save version, Sync, conflicts, History, Restore and the project actions against the server. Renders can be of a project version. The admin panel lists a sequence's projects and versions. Strings in all 38 languages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #17.
This commit is contained in:
1 parent
255e149087
commit
81c303f484
325 files changed
+11477
-516
No files matched your search
@@ -1,27 +1,53 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Chronos.App.Archiving;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Ui.Controls;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>How the workspace's states, projects, versions and failures read in the UI (owner review 2, R8). WPF-free.</summary>
|
||||
/// <summary>
|
||||
/// How the workspace's states, projects, versions and failures read in the UI (owner review 2, R8). WPF-free. A text that
|
||||
/// names the project's home has a form for each: "the library" (this PC's archive) and, with <c>server</c>, "the server"
|
||||
/// (phase 5b: its key with <see cref="ServerSuffix"/>).
|
||||
/// </summary>
|
||||
public static class WorkspaceText
|
||||
{
|
||||
/// <summary>The suffix of a text's key in its form for a project whose home is a server.</summary>
|
||||
public const string ServerSuffix = ".Server";
|
||||
|
||||
/// <summary>The project's name; the Main project in the UI language.</summary>
|
||||
public static string ProjectName(string name, bool isMain) =>
|
||||
isMain && string.Equals(name, ProjectService.MainName, StringComparison.Ordinal) ? Loc.L("Editor.Project.Main") : name;
|
||||
|
||||
/// <summary>The state chip: "In sync", "Not sent", "Conflict"…; "Syncing" while a sync runs.</summary>
|
||||
public static string State(WorkspaceStatus? status, bool syncing = false) =>
|
||||
syncing ? Loc.L("Editor.Workspace.State.Syncing") : status is null ? Loc.L("Editor.Workspace.State.Reading") : Loc.L("Editor.Workspace.State." + status.State);
|
||||
/// <summary>
|
||||
/// The text of <paramref name="key"/> worded for the project's home: its server form (<see cref="ServerSuffix"/>) when
|
||||
/// <paramref name="server"/>, the key itself for a text that names no home.
|
||||
/// </summary>
|
||||
public static string ForHome(string key, bool server, params object?[] args)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(key);
|
||||
var worded = server && Loc.Get(key + ServerSuffix, Loc.Culture) is not null ? key + ServerSuffix : key;
|
||||
return args.Length == 0 ? Loc.L(worded) : Loc.L(worded, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The state chip: "In sync", "Not sent", "Conflict"…; "Syncing" while a sync runs; worded for a server's project where
|
||||
/// the state names the home ("Server newer", "Not on server").
|
||||
/// </summary>
|
||||
public static string State(WorkspaceStatus? status, bool syncing = false, bool server = false) =>
|
||||
syncing ? Loc.L("Editor.Workspace.State.Syncing")
|
||||
: status is null ? Loc.L("Editor.Workspace.State.Reading")
|
||||
: ForHome("Editor.Workspace.State." + status.State, server);
|
||||
|
||||
public static StatusKind Kind(WorkspaceStatus? status, bool syncing = false) => syncing ? StatusKind.Running : status?.State switch
|
||||
{
|
||||
@@ -36,15 +62,16 @@ public static class WorkspaceText
|
||||
_ => StatusKind.Queued,
|
||||
};
|
||||
|
||||
/// <summary>What the state means and what to do, with the counts behind it.</summary>
|
||||
public static string StateToolTip(WorkspaceStatus? status, bool syncing = false) => syncing ? Loc.L("Tooltips.Editor.Workspace.State.Syncing")
|
||||
: status is null ? Loc.L("Tooltips.Editor.Workspace.State.Reading")
|
||||
/// <summary>What the state means and what to do, with the counts behind it, worded for the project's home.</summary>
|
||||
public static string StateToolTip(WorkspaceStatus? status, bool syncing = false, bool server = false) =>
|
||||
syncing ? ForHome("Tooltips.Editor.Workspace.State.Syncing", server)
|
||||
: status is null ? ForHome("Tooltips.Editor.Workspace.State.Reading", server)
|
||||
: status.State switch
|
||||
{
|
||||
WorkspaceState.Ahead => Loc.L("Tooltips.Editor.Workspace.State.Ahead", Formatting.Count(status.Ahead)),
|
||||
WorkspaceState.Behind => Loc.L("Tooltips.Editor.Workspace.State.Behind", Formatting.Count(status.Behind)),
|
||||
WorkspaceState.Offline when status.Ahead > 0 => Loc.L("Tooltips.Editor.Workspace.State.OfflineAhead", Formatting.Count(status.Ahead)),
|
||||
var state => Loc.L("Tooltips.Editor.Workspace.State." + state),
|
||||
WorkspaceState.Ahead => ForHome("Tooltips.Editor.Workspace.State.Ahead", server, Formatting.Count(status.Ahead)),
|
||||
WorkspaceState.Behind => ForHome("Tooltips.Editor.Workspace.State.Behind", server, Formatting.Count(status.Behind)),
|
||||
WorkspaceState.Offline when status.Ahead > 0 => ForHome("Tooltips.Editor.Workspace.State.OfflineAhead", server, Formatting.Count(status.Ahead)),
|
||||
var state => ForHome("Tooltips.Editor.Workspace.State." + state, server),
|
||||
};
|
||||
|
||||
/// <summary>"Saved", "Merged", "Restored", "Imported", "Outside change".</summary>
|
||||
@@ -76,34 +103,40 @@ public static class WorkspaceText
|
||||
/// One line per setting both sides changed ("Deflicker window 41 here, 33 in the library"), at most <paramref name="max"/>.
|
||||
/// A conflict of format (<see cref="ProjectMerge.FormatPath"/>) reads as its cause, never as the format's numbers.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> ConflictLines(IEnumerable<SettingsDifference> differences, int max)
|
||||
public static IReadOnlyList<string> ConflictLines(IEnumerable<SettingsDifference> differences, int max, bool server = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(differences);
|
||||
var list = differences.ToList();
|
||||
if (list.Any(d => d.Path == ProjectMerge.FormatPath)) return [Loc.L("Editor.Workspace.Conflict.NewerFormat")];
|
||||
return SyncText.Differences(list, max, (label, mine, theirs) => Loc.L("Editor.Workspace.Difference", label, mine, theirs));
|
||||
return SyncText.Differences(list, max, (label, mine, theirs) => ForHome("Editor.Workspace.Difference", server, label, mine, theirs));
|
||||
}
|
||||
|
||||
/// <summary>One line per setting that differs between now and a version ("Deflicker window 41 now, 33 in that version").</summary>
|
||||
public static IReadOnlyList<string> CompareLines(IEnumerable<SettingsDifference> differences, int max) =>
|
||||
SyncText.Differences(differences, max, (label, now, then) => Loc.L("Editor.History.Difference", label, now, then));
|
||||
|
||||
/// <summary>Why a workspace operation stopped, as one localized sentence chosen by cause; the exception's own text goes to the log.</summary>
|
||||
public static string Failure(Exception ex) => ex switch
|
||||
/// <summary>
|
||||
/// Why a workspace operation stopped, as one localized sentence chosen by cause and worded for the project's home; the
|
||||
/// exception's own text goes to the log.
|
||||
/// </summary>
|
||||
public static string Failure(Exception ex, bool server = false) => ex switch
|
||||
{
|
||||
WorkspaceException or LeaseUnavailableException => ex.Message,
|
||||
// A library that can be read but not written (a read-only share, a write-protected disk): the work waits here as offline.
|
||||
HomeUnavailableException { InnerException: ArchiveOfflineException { Availability: ArchiveAvailability.ReadOnly } }
|
||||
or ArchiveOfflineException { Availability: ArchiveAvailability.ReadOnly } => Loc.L("Errors.Workspace.ReadOnlyHome"),
|
||||
HomeUnavailableException or ArchiveOfflineException => Loc.L("Errors.Workspace.Offline"),
|
||||
HomeUnavailableException or ArchiveOfflineException => ForHome("Errors.Workspace.Offline", server),
|
||||
ProjectException { Reason: ProjectError.NameTaken } => Loc.L("Errors.Workspace.NameTaken"),
|
||||
ProjectException { Reason: ProjectError.InvalidName } => Loc.L("Errors.Workspace.InvalidName"),
|
||||
ProjectException { Reason: ProjectError.MainCannotBeDeleted } => Loc.L("Errors.Workspace.MainKept"),
|
||||
ProjectException => Loc.L("Errors.Workspace.ProjectGone"),
|
||||
ProjectException => ForHome("Errors.Workspace.ProjectGone", server),
|
||||
// A version over the size one may be: saved here (refused before anything was written) or sent (the home stored nothing).
|
||||
ProjectVersionTooLargeException or WorkspaceSyncException { Outcome: PushOutcome.TooLarge } =>
|
||||
Loc.L("Errors.Workspace.VersionTooLarge", ProjectSidecars.MaxVersionBytes >> 20),
|
||||
WorkspaceSyncException => Loc.L("Errors.Workspace.Refused"),
|
||||
ForHome("Errors.Workspace.VersionTooLarge", server, ProjectSidecars.MaxVersionBytes >> 20),
|
||||
WorkspaceSyncException => ForHome("Errors.Workspace.Refused", server),
|
||||
// A server's refusal that keeps its meaning: an account that may not change projects there, above all.
|
||||
ChronosApiException { Status: HttpStatusCode.Forbidden } => Loc.L("Errors.Workspace.Forbidden"),
|
||||
ChronosApiException api => ErrorText.ForServer(api),
|
||||
InvalidDataException => Loc.L("Errors.Workspace.Damaged"),
|
||||
Editor.EditorException => ex.Message,
|
||||
_ => ArchiveFailures.Cause(ex),
|
||||
|
||||
Reference in new issue
Block a user