mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-27 07:46:13 +00:00
feat: manage namespaces/providers and open worktrees in editors
- grove group add|remove|list and grove provider add|remove|list edit config.toml (validated first, previous file kept as config.toml.bak) - grove open [group/]repo[@branch] launches Zed, VS Code, Claude Code (in a terminal) or Claude Desktop; [open] config for defaults, terminal and own launchers; grove new --open - GUI: provider/namespace forms and removal in Settings, Open buttons on repos and worktrees, open-after-create on New repository - docs/phase8.md, DECISIONS 10-11 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GZUAGhGYoiLvmfXweQnDY
This commit is contained in:
13 files changed
+2075
-25
No files matched your search
@@ -18,6 +18,9 @@ const ALLOWED: &[&str] = &[
|
||||
"secrets",
|
||||
"sync",
|
||||
"status",
|
||||
"group",
|
||||
"provider",
|
||||
"open",
|
||||
];
|
||||
|
||||
pub struct Bridge {
|
||||
@@ -53,6 +56,17 @@ impl Bridge {
|
||||
Err(e) => return json!({"ok": false, "output": format!("rejected: {e}")}),
|
||||
}
|
||||
}
|
||||
// `open` only for a directory under the workspace root, in canonical form.
|
||||
if sub == "open" {
|
||||
let checked_path = self
|
||||
.loaded_config()
|
||||
.ok_or_else(|| "no readable configuration".to_string())
|
||||
.and_then(|cfg| check_open_path(&cfg, Path::new(&args[1])));
|
||||
match checked_path {
|
||||
Ok(canon) => checked[1] = canon.to_string_lossy().into_owned(),
|
||||
Err(e) => return json!({"ok": false, "output": format!("rejected: {e}")}),
|
||||
}
|
||||
}
|
||||
let args = &checked[..];
|
||||
let mut cmd = Command::new(&self.grove_bin);
|
||||
if let Some(c) = &self.config {
|
||||
@@ -106,6 +120,26 @@ impl Bridge {
|
||||
check_migrate_path(&cfg, Path::new(path))
|
||||
}
|
||||
|
||||
/// Installed launchers (name, label) for "Open in" buttons, the default one first.
|
||||
pub fn launchers(&self) -> Vec<(String, String)> {
|
||||
use grove_core::launch::{System, launchers, pick};
|
||||
let Some(cfg) = self.loaded_config() else {
|
||||
return Vec::new();
|
||||
};
|
||||
let all = launchers(&cfg.open, &System);
|
||||
let default = pick(&all, &cfg.open, None).ok().map(|l| l.name.clone());
|
||||
let mut out: Vec<(String, String)> = all
|
||||
.into_iter()
|
||||
.filter(|l| l.available)
|
||||
.map(|l| (l.name, l.label))
|
||||
.collect();
|
||||
if let Some(i) = out.iter().position(|(n, _)| Some(n) == default.as_ref()) {
|
||||
let d = out.remove(i);
|
||||
out.insert(0, d);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Where `grove add` writes its safety backup.
|
||||
pub fn backup_dir() -> Option<PathBuf> {
|
||||
grove_core::config::Config::state_dir().map(|d| d.join("backups"))
|
||||
@@ -135,7 +169,20 @@ fn flag_spec(sub: &str) -> (&'static [&'static str], &'static [&'static str]) {
|
||||
"--url",
|
||||
],
|
||||
),
|
||||
"new" => (&["--public"], &[]),
|
||||
"new" => (&["--public"], &["--open"]),
|
||||
"open" => (&[], &["--with"]),
|
||||
"group" => (
|
||||
&["--replace", "--no-materialize"],
|
||||
&[
|
||||
"--primary",
|
||||
"--mirror-to",
|
||||
"--owner",
|
||||
"--public-primary",
|
||||
"--public-mirror-to",
|
||||
"--snapshots",
|
||||
],
|
||||
),
|
||||
"provider" => (&["--replace"], &["--kind", "--url", "--protocol"]),
|
||||
"resolve" => (&["--take-remote", "--keep-local"], &["--save-as"]),
|
||||
_ => (&[], &[]),
|
||||
}
|
||||
@@ -159,11 +206,22 @@ pub fn validate(args: &[String]) -> Result<(), String> {
|
||||
}
|
||||
} else if sub == "secrets" && i == 0 && !["init", "pull", "rekey"].contains(&a.as_str()) {
|
||||
return Err(format!("secrets {a:?} is not allowed from the GUI"));
|
||||
} else if (sub == "group" || sub == "provider")
|
||||
&& i == 0
|
||||
&& !["add", "remove"].contains(&a.as_str())
|
||||
{
|
||||
return Err(format!("{sub} {a:?} is not allowed from the GUI"));
|
||||
}
|
||||
}
|
||||
if sub == "secrets" && args.len() != 2 {
|
||||
return Err("secrets takes exactly one action".into());
|
||||
}
|
||||
if (sub == "group" || sub == "provider") && args.len() < 3 {
|
||||
return Err(format!("{sub} needs an action and a name"));
|
||||
}
|
||||
if sub == "open" && args.get(1).is_none_or(|p| p.starts_with('-')) {
|
||||
return Err("open needs a path first".into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -192,6 +250,27 @@ pub fn check_migrate_path(
|
||||
}
|
||||
}
|
||||
|
||||
/// A directory the GUI may open in an editor: an existing directory inside the workspace root.
|
||||
pub fn check_open_path(cfg: &grove_core::config::Config, path: &Path) -> Result<PathBuf, String> {
|
||||
let canon = path
|
||||
.canonicalize()
|
||||
.map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
if !canon.is_dir() {
|
||||
return Err(format!("{} is not a directory", path.display()));
|
||||
}
|
||||
let root = cfg.root_path();
|
||||
let root = root.canonicalize().unwrap_or(root);
|
||||
if canon.starts_with(&root) && canon != root {
|
||||
Ok(canon)
|
||||
} else {
|
||||
Err(format!(
|
||||
"{} is not inside {}",
|
||||
path.display(),
|
||||
root.display()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn grove_core_default_config() -> Option<PathBuf> {
|
||||
let base = std::env::var_os("XDG_CONFIG_HOME")
|
||||
.map(PathBuf::from)
|
||||
@@ -215,6 +294,48 @@ mod tests {
|
||||
assert!(v(&["resolve", "/p", "--save-as", "b", "--take-remote"]).is_ok());
|
||||
assert!(v(&["new", "g", "n", "--public"]).is_ok());
|
||||
assert!(v(&["secrets", "pull"]).is_ok());
|
||||
assert!(v(&["group", "list"]).is_err());
|
||||
assert!(v(&["group", "add"]).is_err());
|
||||
assert!(v(&["group", "add", "g", "--primary", "p", "--force"]).is_err());
|
||||
assert!(
|
||||
v(&[
|
||||
"group",
|
||||
"add",
|
||||
"g",
|
||||
"--primary",
|
||||
"p",
|
||||
"--mirror-to",
|
||||
"q",
|
||||
"--replace"
|
||||
])
|
||||
.is_ok()
|
||||
);
|
||||
assert!(v(&["provider", "remove", "p"]).is_ok());
|
||||
assert!(v(&["provider", "add", "p", "--url", "--kind"]).is_err());
|
||||
assert!(v(&["open", "/p", "--with", "zed"]).is_ok());
|
||||
assert!(v(&["open", "/p", "--print"]).is_err());
|
||||
assert!(v(&["open", "--with", "zed"]).is_err());
|
||||
assert!(v(&["new", "g", "n", "--open", "zed"]).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_path_must_be_inside_the_root() {
|
||||
let tmp = crate::test_tmp::TempDir::new("grove-open");
|
||||
let base = tmp.path().canonicalize().unwrap();
|
||||
std::fs::create_dir_all(base.join("ws/work/app/main")).unwrap();
|
||||
std::fs::create_dir_all(base.join("elsewhere")).unwrap();
|
||||
let cfg = grove_core::config::Config::parse(&format!(
|
||||
"[machine]\nname=\"m\"\n[root]\npath=\"{}/ws\"\n",
|
||||
base.display()
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
check_open_path(&cfg, &base.join("ws/work/app/../app/main")).unwrap(),
|
||||
base.join("ws/work/app/main")
|
||||
);
|
||||
for bad in ["ws", "elsewhere", "ws/work/../../elsewhere", "ws/none"] {
|
||||
assert!(check_open_path(&cfg, &base.join(bad)).is_err(), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -47,6 +47,8 @@ struct Snapshot {
|
||||
status: Option<Value>,
|
||||
log: Vec<Value>,
|
||||
config: Option<Value>,
|
||||
/// Installed launchers (name, label), the default one first.
|
||||
launchers: Vec<(String, String)>,
|
||||
alerts: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
@@ -141,6 +143,7 @@ struct UiState {
|
||||
toast_gen: u32,
|
||||
last_groups: Vec<String>,
|
||||
last_providers: Vec<String>,
|
||||
last_launchers: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -161,6 +164,7 @@ thread_local! {
|
||||
import_current: String::new(),
|
||||
toast_gen: 0,
|
||||
last_groups: Vec::new(),
|
||||
last_launchers: Vec::new(),
|
||||
last_providers: Vec::new(),
|
||||
});
|
||||
}
|
||||
@@ -428,6 +432,9 @@ fn render(ui: &MainWindow) {
|
||||
}
|
||||
if providers != st.last_providers {
|
||||
ui.set_providers(str_model(&providers));
|
||||
let mut mirrors = vec!["No mirror".to_string()];
|
||||
mirrors.extend(providers.iter().cloned());
|
||||
ui.set_mirror_choices(str_model(&mirrors));
|
||||
st.last_providers = providers;
|
||||
}
|
||||
let secs: Vec<Section> = model::settings_sections(cfg)
|
||||
@@ -446,6 +453,21 @@ fn render(ui: &MainWindow) {
|
||||
.collect();
|
||||
ui.set_sections(ModelRc::from(Rc::new(VecModel::from(secs))));
|
||||
}
|
||||
if snap.launchers != st.last_launchers {
|
||||
let rows: Vec<Launch> = snap
|
||||
.launchers
|
||||
.iter()
|
||||
.map(|(n, l)| Launch {
|
||||
name: n.into(),
|
||||
label: l.into(),
|
||||
})
|
||||
.collect();
|
||||
ui.set_launchers(ModelRc::from(Rc::new(VecModel::from(rows))));
|
||||
let mut choices = vec!["Don't open".to_string()];
|
||||
choices.extend(snap.launchers.iter().map(|(_, l)| format!("Open in {l}")));
|
||||
ui.set_open_choices(str_model(&choices));
|
||||
st.last_launchers = snap.launchers.clone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -539,6 +561,15 @@ fn run_cli(
|
||||
});
|
||||
}
|
||||
|
||||
/// A config-editing command from Settings: output below the forms, a toast either way.
|
||||
fn run_settings_cli(ctx: &Ctx, ui: &MainWindow, args: Vec<String>, done_msg: &'static str) {
|
||||
run_cli(ctx, ui, None, args, String::new(), move |ui, ok, text| {
|
||||
let first = text.lines().next().unwrap_or("").to_string();
|
||||
toast(ui, if ok { done_msg } else { &first }, !ok);
|
||||
ui.set_settings_out(out(ok, text));
|
||||
});
|
||||
}
|
||||
|
||||
fn out(ok: bool, text: String) -> Out {
|
||||
Out {
|
||||
ok,
|
||||
@@ -743,13 +774,23 @@ fn wire(ui: &MainWindow, ctx: &Ctx) {
|
||||
|
||||
ui.on_create_repo({
|
||||
let c = ctx.clone();
|
||||
move |group, name, public| {
|
||||
move |group, name, public, open| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let group = model::group_name(&first_or(group.as_str(), &ui.get_groups())).to_string();
|
||||
let mut args = vec!["new".to_string(), group, name.trim().to_string()];
|
||||
if public {
|
||||
args.push("--public".into());
|
||||
}
|
||||
let launcher = ST.with(|st| {
|
||||
st.borrow()
|
||||
.last_launchers
|
||||
.iter()
|
||||
.find(|(_, l)| format!("Open in {l}") == open.as_str())
|
||||
.map(|(n, _)| n.clone())
|
||||
});
|
||||
if let Some(n) = launcher {
|
||||
args.extend(["--open".into(), n]);
|
||||
}
|
||||
ui.set_new_out(out(true, String::new()));
|
||||
run_cli(&c, &ui, None, args, String::new(), |ui, ok, text| {
|
||||
ui.set_new_out(out(ok, text));
|
||||
@@ -760,6 +801,23 @@ fn wire(ui: &MainWindow, ctx: &Ctx) {
|
||||
}
|
||||
});
|
||||
|
||||
ui.on_open_in({
|
||||
let c = ctx.clone();
|
||||
move |path, launcher| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let args = vec![
|
||||
"open".to_string(),
|
||||
path.to_string(),
|
||||
"--with".into(),
|
||||
launcher.to_string(),
|
||||
];
|
||||
run_cli(&c, &ui, None, args, String::new(), |ui, ok, text| {
|
||||
let first = text.lines().last().unwrap_or("").to_string();
|
||||
toast(ui, &first, !ok);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ui.on_scan_import({
|
||||
let c = ctx.clone();
|
||||
move |group, force| {
|
||||
@@ -973,6 +1031,63 @@ fn wire(ui: &MainWindow, ctx: &Ctx) {
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.on_add_provider({
|
||||
let c = ctx.clone();
|
||||
move |id, kind, url, protocol, replace| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let mut args: Vec<String> = vec![
|
||||
"provider".into(),
|
||||
"add".into(),
|
||||
id.trim().to_string(),
|
||||
"--kind".into(),
|
||||
kind.to_string(),
|
||||
"--protocol".into(),
|
||||
protocol.to_string(),
|
||||
];
|
||||
if !url.trim().is_empty() {
|
||||
args.extend(["--url".into(), url.trim().to_string()]);
|
||||
}
|
||||
if replace {
|
||||
args.push("--replace".into());
|
||||
}
|
||||
run_settings_cli(&c, &ui, args, "Provider saved");
|
||||
}
|
||||
});
|
||||
ui.on_remove_provider({
|
||||
let c = ctx.clone();
|
||||
move |id| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let args = vec!["provider".into(), "remove".into(), id.to_string()];
|
||||
run_settings_cli(&c, &ui, args, "Provider removed");
|
||||
}
|
||||
});
|
||||
ui.on_add_group({
|
||||
let c = ctx.clone();
|
||||
move |name, primary, mirror, owner, mirror_owner, snapshots, replace| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let primary = first_or(primary.as_str(), &ui.get_providers());
|
||||
let args = model::group_add_args(&model::GroupForm {
|
||||
name: name.to_string(),
|
||||
primary,
|
||||
mirror: mirror.to_string(),
|
||||
owner: owner.to_string(),
|
||||
mirror_owner: mirror_owner.to_string(),
|
||||
snapshots: snapshots.to_string(),
|
||||
replace,
|
||||
});
|
||||
run_settings_cli(&c, &ui, args, "Namespace saved");
|
||||
}
|
||||
});
|
||||
ui.on_remove_group({
|
||||
let c = ctx.clone();
|
||||
move |label| {
|
||||
let Some(ui) = c.weak.upgrade() else { return };
|
||||
let name = model::group_name(&first_or(label.as_str(), &ui.get_groups())).to_string();
|
||||
let args = vec!["group".into(), "remove".into(), name];
|
||||
run_settings_cli(&c, &ui, args, "Namespace removed");
|
||||
}
|
||||
});
|
||||
|
||||
ui.on_login({
|
||||
let c = ctx.clone();
|
||||
move |provider, token| {
|
||||
@@ -1200,6 +1315,7 @@ fn worker(
|
||||
status,
|
||||
log,
|
||||
config: core.bridge.config_json(),
|
||||
launchers: core.bridge.launchers(),
|
||||
alerts,
|
||||
};
|
||||
let w = weak.clone();
|
||||
|
||||
@@ -336,6 +336,53 @@ pub fn group_name(entry: &str) -> &str {
|
||||
entry.split(" → ").next().unwrap_or(entry)
|
||||
}
|
||||
|
||||
/// What the "Add or change a namespace" form holds.
|
||||
pub struct GroupForm {
|
||||
pub name: String,
|
||||
pub primary: String,
|
||||
/// Empty: no mirror.
|
||||
pub mirror: String,
|
||||
pub owner: String,
|
||||
pub mirror_owner: String,
|
||||
/// "default" leaves the global policy in force.
|
||||
pub snapshots: String,
|
||||
pub replace: bool,
|
||||
}
|
||||
|
||||
/// `grove group add ...` for the namespace form.
|
||||
pub fn group_add_args(f: &GroupForm) -> Vec<String> {
|
||||
let mut a: Vec<String> = vec![
|
||||
"group".into(),
|
||||
"add".into(),
|
||||
f.name.trim().to_string(),
|
||||
"--primary".into(),
|
||||
f.primary.clone(),
|
||||
];
|
||||
let mirror = f.mirror.trim();
|
||||
if !mirror.is_empty() {
|
||||
a.extend(["--mirror-to".into(), mirror.to_string()]);
|
||||
}
|
||||
if !f.owner.trim().is_empty() {
|
||||
a.extend([
|
||||
"--owner".into(),
|
||||
format!("{}={}", f.primary, f.owner.trim()),
|
||||
]);
|
||||
}
|
||||
if !mirror.is_empty() && !f.mirror_owner.trim().is_empty() {
|
||||
a.extend([
|
||||
"--owner".into(),
|
||||
format!("{mirror}={}", f.mirror_owner.trim()),
|
||||
]);
|
||||
}
|
||||
if !f.snapshots.is_empty() && f.snapshots != "default" {
|
||||
a.extend(["--snapshots".into(), f.snapshots.clone()]);
|
||||
}
|
||||
if f.replace {
|
||||
a.push("--replace".into());
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -501,4 +548,46 @@ mod tests {
|
||||
assert_eq!(s[3].1[0].1, "grove-config on gitea");
|
||||
assert_eq!(group_name("work → gitea"), "work");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_form_becomes_group_add_args() {
|
||||
let mut f = GroupForm {
|
||||
name: " oss ".into(),
|
||||
primary: "gh".into(),
|
||||
mirror: String::new(),
|
||||
owner: String::new(),
|
||||
mirror_owner: "ignored without a mirror".into(),
|
||||
snapshots: "default".into(),
|
||||
replace: false,
|
||||
};
|
||||
assert_eq!(
|
||||
group_add_args(&f),
|
||||
["group", "add", "oss", "--primary", "gh"]
|
||||
);
|
||||
f.mirror = "gitea".into();
|
||||
f.owner = "Zenvairo".into();
|
||||
f.mirror_owner = "Org".into();
|
||||
f.snapshots = "none".into();
|
||||
f.replace = true;
|
||||
assert_eq!(
|
||||
group_add_args(&f),
|
||||
[
|
||||
"group",
|
||||
"add",
|
||||
"oss",
|
||||
"--primary",
|
||||
"gh",
|
||||
"--mirror-to",
|
||||
"gitea",
|
||||
"--owner",
|
||||
"gh=Zenvairo",
|
||||
"--owner",
|
||||
"gitea=Org",
|
||||
"--snapshots",
|
||||
"none",
|
||||
"--replace"
|
||||
]
|
||||
);
|
||||
assert!(crate::bridge::validate(&group_add_args(&f)).is_ok());
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,11 @@ export struct MigRow {
|
||||
msg: string,
|
||||
}
|
||||
|
||||
export struct Launch {
|
||||
name: string,
|
||||
label: string,
|
||||
}
|
||||
|
||||
export struct Out {
|
||||
text: string,
|
||||
ok: bool,
|
||||
@@ -195,6 +200,12 @@ export component MainWindow inherits Window {
|
||||
in property <[LogRow]> log;
|
||||
in property <[string]> groups;
|
||||
in property <[string]> providers;
|
||||
// "No mirror" followed by the providers.
|
||||
in property <[string]> mirror-choices;
|
||||
// Installed editors/tools, the default one first.
|
||||
in property <[Launch]> launchers;
|
||||
// "Don't open" followed by the launcher labels.
|
||||
in property <[string]> open-choices;
|
||||
in property <[Section]> sections;
|
||||
in property <[Pick]> picks;
|
||||
in property <string> import-note;
|
||||
@@ -209,6 +220,7 @@ export component MainWindow inherits Window {
|
||||
in property <Repo> detail;
|
||||
in property <bool> detail-found;
|
||||
in-out property <string> selected-path;
|
||||
property <string> prov-url-text;
|
||||
in property <Out> new-out;
|
||||
in property <Out> import-out;
|
||||
in property <Out> settings-out;
|
||||
@@ -220,7 +232,12 @@ export component MainWindow inherits Window {
|
||||
callback sync-all();
|
||||
callback toggle-pause();
|
||||
callback filter-changed(string);
|
||||
callback create-repo(string, string, bool);
|
||||
callback create-repo(string, string, bool, string);
|
||||
callback open-in(string, string);
|
||||
callback add-provider(string, string, string, string, bool);
|
||||
callback remove-provider(string);
|
||||
callback add-group(string, string, string, string, string, string, bool);
|
||||
callback remove-group(string);
|
||||
callback scan-import(string, bool);
|
||||
callback import-selected(string);
|
||||
callback pick-toggled(int, bool);
|
||||
@@ -491,6 +508,13 @@ export component MainWindow inherits Window {
|
||||
|
||||
for r in root.repos: Rectangle {
|
||||
height: rcard.preferred-height;
|
||||
// Below the card, so the card's own buttons get their clicks.
|
||||
TouchArea {
|
||||
clicked => {
|
||||
root.open-repo(r.path);
|
||||
}
|
||||
}
|
||||
|
||||
rcard := Card {
|
||||
HorizontalLayout {
|
||||
spacing: 12px;
|
||||
@@ -553,15 +577,20 @@ export component MainWindow inherits Window {
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TouchArea {
|
||||
clicked => {
|
||||
root.open-repo(r.path);
|
||||
if root.launchers.length > 0: VerticalLayout {
|
||||
alignment: center;
|
||||
Button {
|
||||
text: "Open";
|
||||
accessible-label: "Open in " + root.launchers[0].label;
|
||||
clicked => {
|
||||
root.open-in(r.path, root.launchers[0].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -650,6 +679,22 @@ export component MainWindow inherits Window {
|
||||
text: w.plan;
|
||||
}
|
||||
|
||||
if w.path != "" && root.launchers.length > 0: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
alignment: start;
|
||||
Muted {
|
||||
text: "Open in";
|
||||
vertical-alignment: center;
|
||||
}
|
||||
|
||||
for l in root.launchers: Button {
|
||||
text: l.label;
|
||||
clicked => {
|
||||
root.open-in(w.path, l.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if w.state == "diverged": diverged := VerticalLayout {
|
||||
spacing: 8px;
|
||||
alignment: start;
|
||||
@@ -831,6 +876,14 @@ export component MainWindow inherits Window {
|
||||
text: "Public repository";
|
||||
}
|
||||
|
||||
Muted {
|
||||
text: "Afterwards";
|
||||
}
|
||||
|
||||
new-open := ComboBox {
|
||||
model: root.open-choices;
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: start;
|
||||
Button {
|
||||
@@ -838,7 +891,7 @@ export component MainWindow inherits Window {
|
||||
primary: true;
|
||||
enabled: !root.busy && new-name.text != "";
|
||||
clicked => {
|
||||
root.create-repo(new-group.current-value, new-name.text, new-public.checked);
|
||||
root.create-repo(new-group.current-value, new-name.text, new-public.checked, new-open.current-value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1009,6 +1062,250 @@ export component MainWindow inherits Window {
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Add or change a provider";
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
Card {
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
horizontal-stretch: 1;
|
||||
Muted {
|
||||
text: "Id";
|
||||
}
|
||||
|
||||
prov-id := LineEdit {
|
||||
placeholder-text: "gitea, gh, work-forge…";
|
||||
accessible-label: "Provider id";
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
min-width: 150px;
|
||||
horizontal-stretch: 0;
|
||||
Muted {
|
||||
text: "Kind";
|
||||
}
|
||||
|
||||
prov-kind := ComboBox {
|
||||
model: ["gitea", "forgejo", "github"];
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
min-width: 130px;
|
||||
horizontal-stretch: 0;
|
||||
Muted {
|
||||
text: "Git over";
|
||||
}
|
||||
|
||||
prov-proto := ComboBox {
|
||||
model: ["https", "ssh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if prov-kind.current-value != "github": VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "URL";
|
||||
}
|
||||
|
||||
prov-url := LineEdit {
|
||||
placeholder-text: "https://git.example.com";
|
||||
accessible-label: "Provider URL";
|
||||
edited(t) => {
|
||||
root.prov-url-text = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
alignment: start;
|
||||
prov-replace := CheckBox {
|
||||
text: "Replace an existing provider with this id";
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Save provider";
|
||||
primary: true;
|
||||
enabled: !root.busy && prov-id.text != "" && (prov-kind.current-value == "github" || root.prov-url-text != "");
|
||||
clicked => {
|
||||
root.add-provider(prov-id.text, prov-kind.current-value, prov-kind.current-value == "github" ? "" : root.prov-url-text, prov-proto.current-value, prov-replace.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Muted {
|
||||
text: "Then sign in to it below (a token from `tea`/`gh` is used when present).";
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Add or change a namespace";
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
Card {
|
||||
Muted {
|
||||
text: "A namespace is a directory under the workspace root whose repos live on one forge, optionally mirrored to another.";
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "Name";
|
||||
}
|
||||
|
||||
grp-name := LineEdit {
|
||||
placeholder-text: "work, personal, clients…";
|
||||
accessible-label: "Namespace name";
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
width: 170px;
|
||||
Muted {
|
||||
text: "Snapshots";
|
||||
}
|
||||
|
||||
grp-snap := ComboBox {
|
||||
model: ["default", "private-only", "all", "none"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "Primary (repos are created here)";
|
||||
}
|
||||
|
||||
grp-primary := ComboBox {
|
||||
model: root.providers;
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "Owner there (empty: your account)";
|
||||
}
|
||||
|
||||
grp-owner := LineEdit {
|
||||
placeholder-text: "account or organisation";
|
||||
accessible-label: "Owner on the primary provider";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "Mirror to";
|
||||
}
|
||||
|
||||
grp-mirror := ComboBox {
|
||||
model: root.mirror-choices;
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
Muted {
|
||||
text: "Owner on the mirror";
|
||||
}
|
||||
|
||||
grp-mowner := LineEdit {
|
||||
enabled: grp-mirror.current-index > 0;
|
||||
placeholder-text: "account or organisation";
|
||||
accessible-label: "Owner on the mirror provider";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
alignment: start;
|
||||
grp-replace := CheckBox {
|
||||
text: "Replace an existing namespace with this name";
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Save namespace";
|
||||
primary: true;
|
||||
enabled: !root.busy && grp-name.text != "";
|
||||
clicked => {
|
||||
root.add-group(grp-name.text, grp-primary.current-value, grp-mirror.current-index > 0 ? grp-mirror.current-value : "", grp-owner.text, grp-mirror.current-index > 0 ? grp-mowner.text : "", grp-snap.current-value, grp-replace.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Muted {
|
||||
text: "Public repos can take a different route (`grove group add --public-primary`); that is CLI only. The daemon picks up changes after `systemctl --user restart groved`.";
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Remove";
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
Card {
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
rm-group := ComboBox {
|
||||
model: root.groups;
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Remove namespace";
|
||||
enabled: !root.busy && root.groups.length > 0;
|
||||
clicked => {
|
||||
root.remove-group(rm-group.current-value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
rm-prov := ComboBox {
|
||||
model: root.providers;
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Remove provider";
|
||||
enabled: !root.busy && root.providers.length > 0;
|
||||
clicked => {
|
||||
root.remove-provider(rm-prov.current-value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Muted {
|
||||
text: "Removing a namespace only edits config.toml: its directory and repos stay on disk and stop syncing. A provider still used by a namespace cannot be removed. The previous config is kept as config.toml.bak.";
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Sign in to a provider";
|
||||
font-size: 16px;
|
||||
|
||||
Reference in new issue
Block a user