feat(app): Edit opens workspace projects, with versions, sync and the project menu
Owner review 2, phase 5a (R8), desktop package: editing moves out of the library. A sequence of this PC's archive now opens in Edit as a project of the workspace (%LOCALAPPDATA%\Chronos\workspace, .\data\workspace when portable), with this PC's archive as its home; the editor writes the workspace's working state, never the library. - WorkspaceHost composes WorkspaceStore and WorkspaceSync over Settings > Workspace's folder: checkout and the WorkspaceCopy job, status, Save version with the sync after it (Sync automatically, on by default), sync (pull, then push), conflicts, restore, history, new / rename / delete project, and Remove local copy, which refuses while work is unsent unless the user sends it first or discards it, reads back the home's head and base and checks their hashes, and keeps discarded work in <workspace>/.trash; versions past Kept versions are pruned only once the home returns them with the same content. - WorkspaceSequenceSource: frames and pixels of the media (proxies), the working state saved atomically under the project's lease and merged against the basis, the home's deep report while its frames are the media's, renders at the home with the portable settings recording the project and the version. - Edit: the project opened last for the sequence, else "Open in workspace" (Main made from the sequence's settings, another project or a new one; proxies) checks out, copies and opens once the copy is done. The picker lists the workspace's projects with their state above the library. The title's project menu: Save version (Ctrl+S, note), Sync, History (compare, restore as one undo step), New project, Rename, Delete project, Remove local copy; a conflict dialog only on real conflicts (keep mine, take the library's, save both, later); Update media when the library's frames moved. .chronos files: format 2 opens its project, format 1 gives its settings to Main. - Settings > Workspace: folder (shown, Open), Sync automatically, Kept versions. Strings in English and Italian. - A capture (sample data without an engine) keeps editing the library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit da47a580ba9db3ce2a1db2f11c30cf7344c8b394)
This commit is contained in:
1 parent
03d32f18d3
commit
b9d1c396a1
37 files changed
+4547
-104
No files matched your search
@@ -0,0 +1,502 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Chronos.App.Archiving;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>What "Open in workspace" chose: an existing project of the home (<see cref="ProjectId"/>) or a new one (<see cref="NewName"/>), and the media.</summary>
|
||||
public sealed record OpenChoice(Guid? ProjectId, string? NewName, string Media);
|
||||
|
||||
/// <summary>A project of the home offered by "Open in workspace" (Main in the UI language).</summary>
|
||||
public sealed record ProjectOption(SequenceProject Project)
|
||||
{
|
||||
public string Label => WorkspaceText.ProjectName(Project.Name, Project.IsMain);
|
||||
|
||||
public override string ToString() => Label;
|
||||
}
|
||||
|
||||
/// <summary>Project names as the home takes them: 1 to 60 characters, no control character, each once per sequence (case does not count).</summary>
|
||||
public static class ProjectNames
|
||||
{
|
||||
/// <summary>The problem of <paramref name="name"/>, or null when the home takes it.</summary>
|
||||
public static string? Validate(string name, IEnumerable<string> others)
|
||||
{
|
||||
var trimmed = name?.Trim() ?? string.Empty;
|
||||
if (trimmed.Length is 0 or > ProjectService.MaxNameLength || trimmed.Any(char.IsControl)) return Loc.L("Errors.Workspace.InvalidName");
|
||||
return others.Any(o => string.Equals(o, trimmed, StringComparison.OrdinalIgnoreCase)) ? Loc.L("Errors.Workspace.NameTaken") : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Open in workspace" (owner review 2, R8), asked when a sequence has no project in the workspace yet: which project of
|
||||
/// its home (Main, made from the sequence's settings as they are, or another) or a new one with its name, and the media
|
||||
/// to copy (proxies; the originals come in phase 5c). Open queues the copy; the sequence opens once it is done.
|
||||
/// </summary>
|
||||
public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly TaskCompletionSource<OpenChoice?> _choice = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private ProjectOption? _selected;
|
||||
private bool _isNew;
|
||||
|
||||
public OpenInWorkspaceDialogViewModel(string sequenceTitle, IReadOnlyList<SequenceProject> projects, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
SequenceTitle = sequenceTitle;
|
||||
Projects = [.. projects.OrderByDescending(p => p.IsMain).Select(p => new ProjectOption(p))];
|
||||
_selected = Projects.FirstOrDefault();
|
||||
_isNew = Projects.Count == 0;
|
||||
NewName = new EditableField(string.Empty, n => ProjectNames.Validate(n, projects.Select(p => p.Name)), _ => { }, () => Loc.L("Tooltips.Editor.OpenWorkspace.Name"));
|
||||
NewName.PropertyChanged += (_, _) => Refresh();
|
||||
OpenCommand = new RelayCommand(Open, () => CanOpen);
|
||||
}
|
||||
|
||||
/// <summary>Completes with the user's choice, or null when the dialog was closed without one.</summary>
|
||||
public Task<OpenChoice?> Choice => _choice.Task;
|
||||
|
||||
public string SequenceTitle { get; }
|
||||
|
||||
public string Heading => Loc.L("Editor.OpenWorkspace.Title");
|
||||
|
||||
public IReadOnlyList<ProjectOption> Projects { get; }
|
||||
|
||||
public bool HasProjects => Projects.Count > 0;
|
||||
|
||||
public ProjectOption? SelectedProject
|
||||
{
|
||||
get => _selected;
|
||||
set
|
||||
{
|
||||
if (Set(ref _selected, value) && value is not null) IsExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A project the home has.</summary>
|
||||
public bool IsExisting
|
||||
{
|
||||
get => !_isNew;
|
||||
set
|
||||
{
|
||||
if (value) IsNew = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A new project, named in <see cref="NewName"/>.</summary>
|
||||
public bool IsNew
|
||||
{
|
||||
get => _isNew;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _isNew, value || !HasProjects)) return;
|
||||
OnPropertyChanged(nameof(IsExisting));
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public EditableField NewName { get; }
|
||||
|
||||
/// <summary>The proxies, the only media this phase copies.</summary>
|
||||
public bool IsProxies => true;
|
||||
|
||||
/// <summary>The originals: offered from phase 5c, to render on this PC.</summary>
|
||||
public bool CanCopyOriginals => false;
|
||||
|
||||
public ICommand OpenCommand { get; }
|
||||
|
||||
public bool CanOpen => _isNew ? !NewName.HasErrors : _selected is not null;
|
||||
|
||||
public string OpenToolTip => _isNew && NewName.Error is { } error ? error : Loc.L("Tooltips.Editor.OpenWorkspace.Open");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
// Closed without a choice (Cancel, Esc, another sequence asked for).
|
||||
_choice.TrySetResult(null);
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void Open()
|
||||
{
|
||||
if (!CanOpen) return;
|
||||
_choice.TrySetResult(_isNew ? new OpenChoice(null, NewName.Text.Trim(), BundleMedia.Proxies) : new OpenChoice(_selected!.Project.Id, null, BundleMedia.Proxies));
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
OnPropertyChanged(nameof(CanOpen));
|
||||
OnPropertyChanged(nameof(OpenToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Names a project: "New project" (made from the open project's last version at the home) or "Rename".</summary>
|
||||
public sealed class ProjectNameDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<string, Task> _save;
|
||||
|
||||
/// <param name="others">The names of the sequence's other projects (each name is used once).</param>
|
||||
public ProjectNameDialogViewModel(bool rename, string name, IEnumerable<string> others, Func<string, Task> save, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
IsRename = rename;
|
||||
_save = save;
|
||||
var taken = others.ToList();
|
||||
Name = new EditableField(name, n => ProjectNames.Validate(n, taken), _ => { }, () => Loc.L("Tooltips.Editor.ProjectName.Name"));
|
||||
Name.PropertyChanged += (_, _) =>
|
||||
{
|
||||
OnPropertyChanged(nameof(SaveToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
};
|
||||
SaveCommand = new AsyncRelayCommand(SaveAsync, () => !IsBusy && !Name.HasErrors);
|
||||
}
|
||||
|
||||
public bool IsRename { get; }
|
||||
|
||||
public string Heading => Loc.L(IsRename ? "Editor.ProjectName.Rename" : "Editor.ProjectName.New");
|
||||
|
||||
public string SaveText => Loc.L(IsRename ? "Editor.ProjectName.Apply" : "Editor.ProjectName.Create");
|
||||
|
||||
public EditableField Name { get; }
|
||||
|
||||
public ICommand SaveCommand { get; }
|
||||
|
||||
public string SaveToolTip => Name.Error ?? Loc.L(IsRename ? "Tooltips.Editor.ProjectName.Apply" : "Tooltips.Editor.ProjectName.Create");
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await _save(Name.Text.Trim());
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", "Naming a project failed", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Save version" (Ctrl+S): an optional note, then the version is saved (and sent when Sync automatically is on).</summary>
|
||||
public sealed class SaveVersionDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
/// <summary>A note is a line of the history: longer text is cut there.</summary>
|
||||
public const int MaxNoteLength = 200;
|
||||
|
||||
private readonly Func<string?, Task> _save;
|
||||
private string _note = string.Empty;
|
||||
|
||||
public SaveVersionDialogViewModel(string projectName, Func<string?, Task> save, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
ProjectName = projectName;
|
||||
_save = save;
|
||||
SaveCommand = new AsyncRelayCommand(SaveAsync, () => !IsBusy);
|
||||
}
|
||||
|
||||
public string ProjectName { get; }
|
||||
|
||||
public string Heading => Loc.L("Editor.SaveVersion.Title", ProjectName);
|
||||
|
||||
public string Note
|
||||
{
|
||||
get => _note;
|
||||
set => Set(ref _note, (value ?? string.Empty).Length > MaxNoteLength ? value![..MaxNoteLength] : value ?? string.Empty);
|
||||
}
|
||||
|
||||
public ICommand SaveCommand { get; }
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await _save(string.IsNullOrWhiteSpace(_note) ? null : _note.Trim());
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", "Saving a version failed", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A version in the History flyout: number, author, time, note, what made it, and Compare and Restore.</summary>
|
||||
public sealed class HistoryRowViewModel(ProjectVersion version, bool unsent, bool isCurrent, ICommand compare, ICommand restore) : ObservableObject
|
||||
{
|
||||
public ProjectVersion Version { get; } = version;
|
||||
|
||||
public string Number => Formatting.Count(Version.Number);
|
||||
|
||||
public string Author => WorkspaceText.Author(Version);
|
||||
|
||||
public string When => WorkspaceText.When(Version.CreatedAt);
|
||||
|
||||
public string Note => Version.Note ?? string.Empty;
|
||||
|
||||
public string KindText => WorkspaceText.VersionKind(Version.Kind);
|
||||
|
||||
/// <summary>Saved here, waiting to be sent.</summary>
|
||||
public bool IsUnsent { get; } = unsent;
|
||||
|
||||
/// <summary>The version the working state was last saved as (nothing differs).</summary>
|
||||
public bool IsCurrent { get; } = isCurrent;
|
||||
|
||||
/// <summary>"Version 3 · Saved · STUDIO-PC · 28/10/2026 18:02 · note": the row for screen readers and its tooltip.</summary>
|
||||
public string Description => string.Join(Loc.Separator, new[] { Loc.L("Editor.History.Version", Number), KindText, Author, When, Note }.Where(s => s.Length > 0));
|
||||
|
||||
public ICommand CompareCommand { get; } = compare;
|
||||
|
||||
public ICommand RestoreCommand { get; } = restore;
|
||||
|
||||
public string CompareToolTip => Loc.L("Tooltips.Editor.History.Compare", Number);
|
||||
|
||||
public string RestoreToolTip => Loc.L("Tooltips.Editor.History.Restore", Number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The History flyout of a workspace project: its versions newest first (those not sent yet marked), Compare (the
|
||||
/// settings that differ from the project now) and Restore (the version as the project again, one undo step).
|
||||
/// </summary>
|
||||
public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<ProjectVersion, Task<IReadOnlyList<string>>> _compare;
|
||||
private readonly Func<ProjectVersion, Task> _restore;
|
||||
private string? _comparedTitle;
|
||||
private IReadOnlyList<string> _compared = [];
|
||||
private bool _isLoaded;
|
||||
|
||||
public HistoryDialogViewModel(string projectName, Func<ProjectVersion, Task<IReadOnlyList<string>>> compare, Func<ProjectVersion, Task> restore,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
ProjectName = projectName;
|
||||
_compare = compare;
|
||||
_restore = restore;
|
||||
}
|
||||
|
||||
public string ProjectName { get; }
|
||||
|
||||
public string Heading => Loc.L("Editor.History.Title", ProjectName);
|
||||
|
||||
public ObservableCollection<HistoryRowViewModel> Rows { get; } = [];
|
||||
|
||||
/// <summary>The home could not be asked: only this PC's versions are listed.</summary>
|
||||
public bool IsOffline { get; private set; }
|
||||
|
||||
public bool IsEmpty => _isLoaded && Rows.Count == 0;
|
||||
|
||||
/// <summary>"Version 3 → now" over the comparison; null before one.</summary>
|
||||
public string? ComparedTitle { get => _comparedTitle; private set => Set(ref _comparedTitle, value); }
|
||||
|
||||
public IReadOnlyList<string> Compared { get => _compared; private set => Set(ref _compared, value); }
|
||||
|
||||
/// <summary>Lists <paramref name="history"/>; <paramref name="currentHash"/> marks the version the project is now.</summary>
|
||||
public void Show(WorkspaceHistory history, string? currentHash)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(history);
|
||||
Rows.Clear();
|
||||
foreach (var version in history.Versions)
|
||||
{
|
||||
var current = currentHash is not null && string.Equals(version.ContentHash, currentHash, StringComparison.OrdinalIgnoreCase);
|
||||
Rows.Add(new HistoryRowViewModel(version, history.Unsent.Contains(version.Id), current,
|
||||
new AsyncRelayCommand(() => CompareAsync(version), () => !IsBusy), new AsyncRelayCommand(() => RestoreAsync(version), () => !IsBusy)));
|
||||
}
|
||||
IsOffline = history.Offline;
|
||||
_isLoaded = true;
|
||||
OnPropertyChanged(nameof(IsOffline));
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
}
|
||||
|
||||
/// <summary>A failure of the read that lists the versions, shown in the flyout.</summary>
|
||||
public void ShowFailure(Exception ex)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ex);
|
||||
_isLoaded = true;
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
}
|
||||
|
||||
public async Task CompareAsync(ProjectVersion version)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(version);
|
||||
ClearError();
|
||||
try
|
||||
{
|
||||
var lines = await _compare(version);
|
||||
ComparedTitle = Loc.L("Editor.History.Compared", Formatting.Count(version.Number));
|
||||
Compared = lines.Count == 0 ? [Loc.L("Editor.History.Same")] : lines;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"Version {version.Number} could not be compared", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RestoreAsync(ProjectVersion version)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(version);
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await _restore(version);
|
||||
IsBusy = false;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"Version {version.Number} could not be restored", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A sync that met settings both sides changed (owner review 2, R8: asked only on real conflicts): what differs, then
|
||||
/// Keep mine, Take the library's, or Save both (this workspace's versions go to a sibling project). Later leaves the
|
||||
/// conflict for the next Sync; editing goes on meanwhile.
|
||||
/// </summary>
|
||||
public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<ConflictChoice, Task> _resolve;
|
||||
|
||||
public ConflictDialogViewModel(string projectName, string siblingName, IReadOnlyList<string> differences, Func<ConflictChoice, Task> resolve,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
ProjectName = projectName;
|
||||
SiblingName = siblingName;
|
||||
Differences = differences;
|
||||
_resolve = resolve;
|
||||
KeepMineCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.KeepMine), () => !IsBusy);
|
||||
TakeHomeCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.TakeServer), () => !IsBusy);
|
||||
SaveBothCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.SaveBoth), () => !IsBusy);
|
||||
}
|
||||
|
||||
public string ProjectName { get; }
|
||||
|
||||
/// <summary>The project Save both makes for this workspace's versions.</summary>
|
||||
public string SiblingName { get; }
|
||||
|
||||
public string Heading => Loc.L("Editor.Workspace.Conflict.Title");
|
||||
|
||||
public string Message => Loc.L("Editor.Workspace.Conflict.Message", ProjectName);
|
||||
|
||||
public IReadOnlyList<string> Differences { get; }
|
||||
|
||||
public ICommand KeepMineCommand { get; }
|
||||
|
||||
public ICommand TakeHomeCommand { get; }
|
||||
|
||||
public ICommand SaveBothCommand { get; }
|
||||
|
||||
public string SaveBothToolTip => Loc.L("Tooltips.Editor.Workspace.SaveBoth", SiblingName);
|
||||
|
||||
private async Task ResolveAsync(ConflictChoice choice)
|
||||
{
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await _resolve(choice);
|
||||
IsBusy = false;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"The conflict of '{ProjectName}' could not be settled ({choice})", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Remove local copy": the plan (files and size of the copy; versions not sent and changes not saved), then Remove
|
||||
/// (only when everything is at the library), Send first (sends, then removes), or Discard changes (removes; the unsent
|
||||
/// work is kept aside in the workspace's trash).
|
||||
/// </summary>
|
||||
public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<bool, Task> _remove;
|
||||
private readonly Func<Task> _sendFirst;
|
||||
|
||||
public RemoveCopyDialogViewModel(WorkspaceRemovalPlan plan, Func<bool, Task> remove, Func<Task> sendFirst, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
Plan = plan;
|
||||
_remove = remove;
|
||||
_sendFirst = sendFirst;
|
||||
Facts =
|
||||
[
|
||||
new DialogFact(Loc.L("Editor.RemoveCopy.Files"), Formatting.Count(plan.Files)),
|
||||
new DialogFact(Loc.L("Editor.RemoveCopy.Size"), Formatting.Bytes(plan.Bytes)),
|
||||
new DialogFact(Loc.L("Editor.RemoveCopy.Unsent"), Formatting.Count(plan.Unsent)),
|
||||
new DialogFact(Loc.L("Editor.RemoveCopy.Changed"), Loc.L(plan.Modified ? "Editor.RemoveCopy.Yes" : "Editor.RemoveCopy.No")),
|
||||
];
|
||||
RemoveCommand = new AsyncRelayCommand(() => RunAsync(() => _remove(false)), () => !IsBusy && plan.IsSafe && !plan.Offline);
|
||||
SendFirstCommand = new AsyncRelayCommand(() => RunAsync(_sendFirst), () => !IsBusy && !plan.IsSafe && !plan.Conflict && !plan.Offline);
|
||||
DiscardCommand = new AsyncRelayCommand(() => RunAsync(() => _remove(true)), () => !IsBusy && !plan.IsSafe);
|
||||
}
|
||||
|
||||
public WorkspaceRemovalPlan Plan { get; }
|
||||
|
||||
public string Heading => Loc.L("Editor.RemoveCopy.Title", WorkspaceText.ProjectName(Plan.Name, false));
|
||||
|
||||
public IReadOnlyList<DialogFact> Facts { get; }
|
||||
|
||||
public bool HasUnsent => !Plan.IsSafe;
|
||||
|
||||
public ICommand RemoveCommand { get; }
|
||||
|
||||
public ICommand SendFirstCommand { get; }
|
||||
|
||||
public ICommand DiscardCommand { get; }
|
||||
|
||||
public string RemoveToolTip => Plan.IsSafe ? Plan.Offline ? Loc.L("Errors.Workspace.Offline") : Loc.L("Tooltips.Editor.RemoveCopy.Remove") : Loc.L("Errors.Workspace.Unsent");
|
||||
|
||||
public string SendFirstToolTip => Plan.Conflict ? Loc.L("Errors.Workspace.Conflict") : Plan.Offline ? Loc.L("Errors.Workspace.Offline") : Loc.L("Tooltips.Editor.RemoveCopy.SendFirst");
|
||||
|
||||
public string DiscardToolTip => Loc.L("Tooltips.Editor.RemoveCopy.Discard");
|
||||
|
||||
private async Task RunAsync(Func<Task> action)
|
||||
{
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await action();
|
||||
IsBusy = false;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"The local copy of project {Plan.ProjectId} was not removed", ex);
|
||||
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user