Commit the pending application, help and browser regression work. Pin the patched PKCS dependency for the production release.
59 lines
4.2 KiB
C#
59 lines
4.2 KiB
C#
using PlotLine.ViewModels;
|
|
namespace PlotLine.Services;
|
|
|
|
public sealed record RibbonCommand(string Label, string IconKey, string Controller, string Action,
|
|
string Scope = "project", bool OwnerOnly = false, string? ToolbarKey = null)
|
|
{
|
|
public bool Available(ApplicationNavigationViewModel model) => (Scope == "global" || model.Project is not null)
|
|
&& (Scope != "book" && Scope != "chapter" || model.Book is not null) && (!OwnerOnly || model.Project?.IsOwner == true);
|
|
public object Values(ApplicationNavigationViewModel model) => Scope switch
|
|
{
|
|
"global" => new { }, "id" => new { id = model.Project?.ProjectID },
|
|
"book" => new { id = model.Book?.BookID }, "chapter" => new { bookId = model.Book?.BookID },
|
|
_ => new { projectId = model.Project?.ProjectID }
|
|
};
|
|
public static RibbonCommand Shortcut(string key)
|
|
{
|
|
var command = ToolbarCommands.All.Single(x => x.Key == key);
|
|
return new(command.Label, key, command.Controller, command.Action, ToolbarKey: key);
|
|
}
|
|
}
|
|
public sealed record RibbonGroup(string Label, params RibbonCommand[] Commands);
|
|
public sealed record RibbonCategory(string Key, string Label, params RibbonGroup[] Groups);
|
|
public static class ApplicationRibbon
|
|
{
|
|
private static RibbonCommand S(string key) => RibbonCommand.Shortcut(key);
|
|
public static IReadOnlyList<RibbonCategory> Categories { get; } = [
|
|
new("project", "Project",
|
|
new("Workspace", S("overview"), S("projects"), S("writer"), new("Import", "assets", "Imports", "Index", "global")),
|
|
new("Project", new("Edit project", "writer", "Projects", "Edit", "id"), new("Add book", "bible", "Books", "Create"), new("Activity", "metrics", "Projects", "Activity", "id")),
|
|
new("Manage", new("Collaborators", "characters", "ProjectCollaborators", "Index", OwnerOnly: true), new("Backup", "archive", "Exports", "ProjectBackup", OwnerOnly: true), new("Restore points", "archive", "ProjectRestorePoints", "Index"))),
|
|
new("book", "Book",
|
|
new("Selected book", new("Book overview", "bible", "Books", "Details", "book"), new("Edit book", "writer", "Books", "Edit", "book"), new("Add chapter", "threads", "Chapters", "Create", "chapter")),
|
|
new("Manuscript review", S("review")), new("Library", S("overview"), new("Add book", "bible", "Books", "Create"))),
|
|
new("story", "Story", new("Story structure", S("timeline"), S("calendar"), S("plotlines"), S("threads"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity")), new("Writing", S("writer"))),
|
|
new("characters", "Characters", new("Cast", S("characters"), S("names")), new("Connections", S("relationships"))),
|
|
new("world", "World", new("Setting", S("locations"), S("floorplans")), new("Story world", S("assets"))),
|
|
new("tools", "Tools", new("Reference", S("bible")), new("Insights", S("metrics"), S("health"), S("warnings")), new("Organisation", S("archive"))),
|
|
new("help", "Help", new RibbonGroup("Support", new("Help Centre", "bible", "Help", "Index", "global"), new("Feature Requests", "review", "FeatureRequests", "Index", "global")))
|
|
];
|
|
public static string ActiveCategory(string controller, string section) => controller switch
|
|
{
|
|
"Books" or "Chapters" or "Scenes" => "book", "Help" or "FeatureRequests" => "help",
|
|
"Onboarding" => "story",
|
|
_ => section switch
|
|
{
|
|
"Timeline" or "Calendar" or "At This Point" or "Plot Lines" or "Threads" or "Scenarios" or "Continuity Explorer" => "story",
|
|
"Characters" or "Names" or "Relationships" => "characters",
|
|
"Locations" or "Assets" or "Floor Plans" => "world",
|
|
"Story Bible" or "Metrics" or "Health" or "Warnings" or "Archive" => "tools", _ => "project"
|
|
}
|
|
};
|
|
public static RibbonIcon Icon(string key) => RibbonPresentation.Icons.Single(x => x.Key == key);
|
|
public static string Tone(string key) => key switch
|
|
{
|
|
"calendar" or "point" => "calendar", "characters" or "names" => "characters", "locations" or "floorplans" => "locations",
|
|
"relationships" => "relationships", "warnings" => "warning", "review" => "review", "bible" or "overview" or "projects" => "books", _ => "planning"
|
|
};
|
|
}
|