From 6880c57bf355dccf8efe25a011a86093d71a85cb Mon Sep 17 00:00:00 2001 From: Thomas Castiglione Date: Wed, 20 Mar 2024 18:39:20 +0800 Subject: [PATCH] configurable disconnect border --- CHANGELOG.md | 8 +++++--- TODO.md | 1 + src-tauri/src/config/gg.toml | 3 +++ src-tauri/src/config/mod.rs | 7 +++++++ src-tauri/src/messages/mod.rs | 1 + src-tauri/src/worker/gui_util.rs | 3 ++- src/App.svelte | 6 +++++- src/messages/RepoConfig.ts | 2 +- src/objects/BranchObject.svelte | 8 +++++++- 9 files changed, 32 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc043c7..16897ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,16 +3,18 @@ ## [0.15.3](releases/tag/v0.15.3) ### Added -- Git remotes in the status bar, with push & fetch commands. -- Display Git tags (readonly; they aren't really a Jujutsu concept). - Relatively comprehensive branch management support - create them, delete them, push and fetch them. Delete doesn't work quite the same way as in `jj`; removing local and remote branches are separate gestures, rather than deleting the remote on a later push. +- Show Git remotes in the status bar, with push & fetch commands. +- Display Git tags (readonly; they aren't really a Jujutsu concept). - Display edges to commits that aren't in the queried revset, by drawing a line to nowhere. - Detect changes made by other Jujutsu clients and merge the operation log automatically. - Window title includes the workspace path (when one is open). -- New config option gg.queries.log-page-size for tuning performance on large repositories. - Improved keyboard support and focus behaviour. +- New config options: + * `gg.queries.log-page-size` for tuning performance on large repositories. + * `gg.ui.indicate-disconnected-branches` to control whether local-only branches are marked. ### Fixed - GG now understands divergent changes, and can act on commits that have a shared change id. diff --git a/TODO.md b/TODO.md index 1200468..990dc3d 100644 --- a/TODO.md +++ b/TODO.md @@ -33,4 +33,5 @@ These changes may or may not be implemented in the future. * design: decide whether to remove edit menu and maybe add others * design: consider common signature control * epic: categorical expansion - trays, modals, pinned commits etc +* epic: config editor UI (for core stuff, as well as gg's own settings) * chore: windows codesigning will break in august 2024; needs a new approach \ No newline at end of file diff --git a/src-tauri/src/config/gg.toml b/src-tauri/src/config/gg.toml index 9ef72ea..43260ad 100644 --- a/src-tauri/src/config/gg.toml +++ b/src-tauri/src/config/gg.toml @@ -14,5 +14,8 @@ large-repo-heuristic = 100000 # auto-snapshot = [gg.ui] +# When set, branches that aren't pushed anywhere will be visually marked. +indicate-disconnected-branches = true + # "light" or "dark". If not set, your OS settings will be used. # theme-override = diff --git a/src-tauri/src/config/mod.rs b/src-tauri/src/config/mod.rs index 7a41ec3..a426617 100644 --- a/src-tauri/src/config/mod.rs +++ b/src-tauri/src/config/mod.rs @@ -6,6 +6,7 @@ pub trait GGSettings { fn query_auto_snapshot(&self) -> Option; fn query_check_immutable(&self) -> Option; fn ui_theme_override(&self) -> Option; + fn ui_indicate_disconnected_branches(&self) -> bool; } impl GGSettings for UserSettings { @@ -32,4 +33,10 @@ impl GGSettings for UserSettings { fn ui_theme_override(&self) -> Option { self.config().get_string("gg.ui.theme-override").ok() } + + fn ui_indicate_disconnected_branches(&self) -> bool { + self.config() + .get_bool("gg.ui.indicate-disconnected-branches") + .unwrap_or(true) + } } diff --git a/src-tauri/src/messages/mod.rs b/src-tauri/src/messages/mod.rs index e215bcb..1426f2a 100644 --- a/src-tauri/src/messages/mod.rs +++ b/src-tauri/src/messages/mod.rs @@ -84,6 +84,7 @@ pub enum RepoConfig { latest_query: String, status: RepoStatus, theme: Option, + indicate_disconnected_branches: bool, }, #[allow(dead_code)] TimeoutError, diff --git a/src-tauri/src/worker/gui_util.rs b/src-tauri/src/worker/gui_util.rs index 19d58d9..bc4202f 100644 --- a/src-tauri/src/worker/gui_util.rs +++ b/src-tauri/src/worker/gui_util.rs @@ -350,7 +350,8 @@ impl WorkspaceSession<'_> { default_query, latest_query, status: self.format_status(), - theme: self.settings.ui_theme_override() + theme: self.settings.ui_theme_override(), + indicate_disconnected_branches: self.settings.ui_indicate_disconnected_branches() }) } diff --git a/src/App.svelte b/src/App.svelte index 7828c23..ee8c663 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -22,7 +22,7 @@ import StatusBar from "./shell/StatusBar.svelte"; import ModalOverlay from "./shell/ModalOverlay.svelte"; import ErrorDialog from "./shell/ErrorDialog.svelte"; - import { onMount } from "svelte"; + import { onMount, setContext } from "svelte"; import IdSpan from "./controls/IdSpan.svelte"; import InputDialog from "./shell/InputDialog.svelte"; import type { InputRequest } from "./messages/InputRequest"; @@ -53,6 +53,9 @@ } }); + let theme = { indicate_disconnected_branches: true }; + setContext("theme", theme); + onEvent("gg://context/revision", mutateRevision); onEvent("gg://context/tree", mutateTree); onEvent("gg://context/branch", mutateRef); @@ -69,6 +72,7 @@ $revisionSelectEvent = undefined; if (config.type == "Workspace") { + theme.indicate_disconnected_branches = config.indicate_disconnected_branches; $repoStatusEvent = config.status; } } diff --git a/src/messages/RepoConfig.ts b/src/messages/RepoConfig.ts index 5cb8781..0277260 100644 --- a/src/messages/RepoConfig.ts +++ b/src/messages/RepoConfig.ts @@ -2,4 +2,4 @@ import type { DisplayPath } from "./DisplayPath"; import type { RepoStatus } from "./RepoStatus"; -export type RepoConfig = { "type": "Initial" } | { "type": "Workspace", absolute_path: DisplayPath, git_remotes: Array, default_query: string, latest_query: string, status: RepoStatus, theme: string | null, } | { "type": "TimeoutError" } | { "type": "LoadError", absolute_path: DisplayPath, message: string, } | { "type": "WorkerError", message: string, }; \ No newline at end of file +export type RepoConfig = { "type": "Initial" } | { "type": "Workspace", absolute_path: DisplayPath, git_remotes: Array, default_query: string, latest_query: string, status: RepoStatus, theme: string | null, indicate_disconnected_branches: boolean, } | { "type": "TimeoutError" } | { "type": "LoadError", absolute_path: DisplayPath, message: string, } | { "type": "WorkerError", message: string, }; \ No newline at end of file diff --git a/src/objects/BranchObject.svelte b/src/objects/BranchObject.svelte index 383d2cf..0478381 100644 --- a/src/objects/BranchObject.svelte +++ b/src/objects/BranchObject.svelte @@ -6,10 +6,14 @@ import Chip from "../controls/Chip.svelte"; import Object from "./Object.svelte"; import Zone from "./Zone.svelte"; + import { getContext } from "svelte"; + import { repoConfigEvent } from "../stores"; export let header: RevHeader; export let ref: Extract; + let operand: Operand = { type: "Ref", header, ref }; + let label: string; let state: "add" | "change" | "remove"; let disconnected: boolean; @@ -59,7 +63,9 @@ break; } - let operand: Operand = { type: "Ref", header, ref }; + if (!getContext("theme").indicate_disconnected_branches) { + disconnected = false; + }