using Titano.App.Shell; namespace Titano.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, and the Move dialog with its dry run. /// public static class ArchiveScenes { public static readonly IReadOnlyList Views = ["overview", "maintenance", "rebuild", "move"]; 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 "move": archive.ViewIndex = 0; await archive.OpenRenameDialogAsync(RenameMode.Folders); if (archive.Dialog is RenameDialogViewModel move) { move.Template.Text = "{year}/{date} {title}"; await move.PlanAsync(); } break; default: throw new ArgumentOutOfRangeException(nameof(view), view, "Unknown Archive view."); } } }