Skip to content

Commit 1774faf

Browse files
committed
feat: 添加对自定义仓库操作的支持(end),更新命令面板以包含用户定义的操作
1 parent 37f9dd1 commit 1774faf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/ViewModels/RepositoryCommandPalette.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@ public RepositoryCommandPalette(Launcher launcher, Repository repo)
141141
}));
142142

143143
_cmds.Sort((l, r) => l.Label.CompareTo(r.Label));
144+
145+
// repository custom actions (defined in preferences or repo settings)
146+
foreach (var (action, ctxLabel) in _repo.GetCustomActions(Models.CustomActionScope.Repository))
147+
{
148+
// construct a human readable label; global actions are marked
149+
var label = ctxLabel.Name;
150+
if (ctxLabel.IsGlobal)
151+
label += " (GLOBAL)";
152+
153+
// keywords include action name and a generic 'custom' term to make filtering easier
154+
_cmds.Add(new(label, action.Name + " custom", "Settings", async () =>
155+
{
156+
var repo = _repo;
157+
_launcher.CancelCommandPalette();
158+
await repo.ExecCustomActionAsync(action, null);
159+
}));
160+
}
144161
_visibleCmds = _cmds;
145162
_selectedCmd = _cmds[0];
146163
}

0 commit comments

Comments
 (0)