Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 0a03615988 feat(vcs): Deployment submenu in the changes tree's context menu
The Commit tool window's changes tree had no Deployment entries, so uploading changed
files meant finding them again in the Project view. Its context menu now takes other
features' groups through a new "changes" menu slot; Deployment contributes its submenu
there (Upload to, Download from, Sync with, Delete from Server, ...) for the selected
files that are still on disk.
2026-11-17 01:10:30 +08:00
4 змінених файлів з 45 додано та 3 видалено

No files matched your search

+1 -1
Переглянути файл
@@ -87,7 +87,7 @@ export function activate(): () => void {
registerOverlay({ id: "deployment.dialogs", component: DeploymentDialogs }),
registerMenuGroup({
id: "deployment",
menus: ["projectView", "editor", "editorTab"],
menus: ["projectView", "editor", "editorTab", "changes"],
order: 60,
items: (_menu, { paths }) => deploymentMenu(paths),
prepare: async (_menu, { paths }) => {
+14 -2
Переглянути файл
@@ -44,7 +44,13 @@ import {
type TreeHandle,
T,
} from "@/ui";
import { editorService, maybeEditorService, type EditorInput, useMenuSlotItems } from "@/workbench/contributions";
import {
editorService,
maybeEditorService,
menuGroupItems,
type EditorInput,
useMenuSlotItems,
} from "@/workbench/contributions";
import { evaluateWhen, useContextKeys } from "@/platform/context";
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
import {
@@ -293,9 +299,11 @@ export function listMenu(id: string, active: boolean, files: readonly FileStatus
/** Paths Delete… applies to: only when every selected file is unversioned (versioned ones are rolled back). */
/** The selected files that still exist in the working tree (Delete… removes them from disk). */
/** Whether the change leaves the file in the working tree. */
const onDisk = (f: FileStatus) => f.unstaged !== "deleted" && !(f.staged === "deleted" && !f.unstaged);
export function deletableFiles(nodes: ChangeNode[]): string[] {
const files = filesOf(nodes);
const onDisk = (f: FileStatus) => f.unstaged !== "deleted" && !(f.staged === "deleted" && !f.unstaged);
return files.length && files.every(onDisk) ? files.map((f) => f.path) : [];
}
@@ -428,6 +436,10 @@ export function nodeMenu(
{ kind: "action", action: "vcs.localHistory", arg: first?.path },
{ kind: "action", action: "vcs.annotate", arg: first?.path },
{ kind: "separator" },
// Other features' groups (Deployment) for the files that exist.
...menuGroupItems("changes", {
paths: files.filter(onDisk).map((f) => stripSlash(f.path)),
}),
{ label: "Copy Path", icon: "copy", run: () => copyChangePaths(nodes, "absolute") },
{ label: "Copy File Name", icon: "copy", run: () => copyChangePaths(nodes, "name") },
);
+29
Переглянути файл
@@ -0,0 +1,29 @@
import { afterEach, expect, it, vi } from "vitest";
import type { FileStatus } from "@/bindings";
import type { MenuItem } from "@/ui";
import { registerMenuGroup } from "@/workbench/contributions";
import type { ChangeNode } from "../changes";
const { nodeMenu } = await import("../CommitView");
const file = (rel: string, unstaged: FileStatus["unstaged"], staged: FileStatus["staged"] = null): ChangeNode => {
const f: FileStatus = { path: `/p/${rel}`, relPath: rel, staged, unstaged, renamedFrom: null };
return { key: f.path, type: "file", label: rel, group: "changes", files: [f], path: f.path };
};
let dispose: () => void = () => {};
afterEach(() => dispose());
it("adds other features' groups for the changed files still on disk", () => {
const items = vi.fn((_menu: string, { paths }: { paths: string[] }): MenuItem[] =>
paths.length ? [{ id: "deployment", label: "Deployment", submenu: [] }] : [],
);
dispose = registerMenuGroup({ id: "deployment", menus: ["changes"], items });
const labels = (menu: MenuItem[]) => menu.flatMap((i) => (i.kind !== "separator" && "label" in i ? [i.label] : []));
const menu = nodeMenu([file("a.txt", "modified"), file("gone.txt", "deleted"), file("new.txt", "untracked")], ["/p"]);
expect(items).toHaveBeenLastCalledWith("changes", { paths: ["/p/a.txt", "/p/new.txt"] });
expect(labels(menu)).toContain("Deployment");
expect(labels(nodeMenu([file("gone.txt", "deleted")], ["/p"]))).not.toContain("Deployment");
});
+1
Переглянути файл
@@ -1273,6 +1273,7 @@ export type ContextMenuId =
| "editor"
| "projectView"
| "editorTab"
| "changes"
| "problems"
| "searchResults"
| "editorGutter"