using Chronos.App.Shell; namespace Chronos.App.Archiving; /// /// The Archive views that --capture renders (archive-<view>-<theme>.png) and the screen smoke /// tests check, on the sample archive: the tree with figures and charts, the maintenance view with its reports, the /// rebuild dialog, the Reorganize dialog with its dry run, and the trash (Maintenance › Trash…) with deleted sequences. /// public static class ArchiveScenes { public static readonly IReadOnlyList Views = ["overview", "maintenance", "rebuild", "reorganize", "trash"]; public static async Task ShowAsync(ShellViewModel shell, string view) { var archive = shell.Archive; shell.Navigate(SectionKey.Archive); archive.Dialog?.CloseCommand.Execute(null); await archive.LoadAsync(); var db = shell.Services.Database ?? throw new InvalidOperationException("The sample index is not open."); var locations = archive.SelectedArchive is { } selected ? await db.Sequences.ListLocationsAsync(selected.Id) : []; switch (view) { case "overview": archive.ViewIndex = 0; break; case "maintenance": archive.ViewIndex = 1; archive.ShowReports(SampleReports.Duplicates(locations), SampleReports.Orphans(locations), locations); break; case "rebuild": archive.ViewIndex = 0; (await archive.OpenRebuildDialogAsync())?.ShowFolders(SampleReports.Folders(locations)); break; case "reorganize": archive.ViewIndex = 0; await archive.OpenReorganizeDialogAsync(); if (archive.Dialog is ReorganizeDialogViewModel reorganize) { reorganize.Folders.Field.Text = "{year}/{date} {title}"; await reorganize.PlanAsync(); } break; case "trash": archive.ViewIndex = 1; await archive.OpenTrashAsync(); if (archive.Dialog is TrashDialogViewModel trash && archive.SelectedArchive is { } shown) trash.Show(SampleReports.Trash(shown.Id, locations)); break; default: throw new ArgumentOutOfRangeException(nameof(view), view, "Unknown Archive view."); } } }