mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(app): hide header Git actions for non-Git workspaces
This commit is contained in:
@@ -161,10 +161,7 @@ test.describe("Project with no workspaces persists", () => {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await workspaceRow.click();
|
||||
await expect(page.getByTestId("changes-primary-cta")).toHaveAttribute(
|
||||
"aria-label",
|
||||
"Archive workspace",
|
||||
);
|
||||
await expect(page.getByTestId("changes-primary-cta")).toHaveCount(0);
|
||||
|
||||
await archiveWorkspaceFromSidebar(page, workspace.workspaceId);
|
||||
|
||||
|
||||
@@ -353,14 +353,18 @@ describe("git-actions-policy", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("offers archive workspace regardless of its backing", () => {
|
||||
it("hides Git actions for a non-Git workspace", () => {
|
||||
const directory = buildGitActions(createInput({ isGit: false }));
|
||||
|
||||
expect(directory).toEqual({ primary: null, secondary: [], menu: [] });
|
||||
});
|
||||
|
||||
it("offers archive workspace for Git checkouts and worktrees", () => {
|
||||
const localCheckout = buildGitActions(createInput({ hasUncommittedChanges: true }));
|
||||
const worktree = buildGitActions(
|
||||
createInput({ hasUncommittedChanges: true, isPaseoOwnedWorktree: true }),
|
||||
);
|
||||
|
||||
expect(directory.primary?.id).toBe("archive-workspace");
|
||||
expect(localCheckout.secondary.some((action) => action.id === "archive-workspace")).toBe(true);
|
||||
expect(worktree.secondary.some((action) => action.id === "archive-workspace")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -189,6 +189,10 @@ export function narrowPullRequestState(state: string | null | undefined): "open"
|
||||
}
|
||||
|
||||
export function buildGitActions(input: BuildGitActionsInput): GitActions {
|
||||
if (!input.isGit) {
|
||||
return { primary: null, secondary: [], menu: [] };
|
||||
}
|
||||
|
||||
const allActions = new Map<GitActionId, GitAction>();
|
||||
|
||||
allActions.set("commit", {
|
||||
@@ -293,8 +297,8 @@ export function buildGitActions(input: BuildGitActionsInput): GitActions {
|
||||
const primaryActionId = getPrimaryActionId(input);
|
||||
const primary = primaryActionId ? (allActions.get(primaryActionId) ?? null) : null;
|
||||
|
||||
const secondaryIds = input.isGit ? [...REMOTE_ACTION_IDS] : [];
|
||||
if (input.isGit && !input.isOnBaseBranch) {
|
||||
const secondaryIds = [...REMOTE_ACTION_IDS];
|
||||
if (!input.isOnBaseBranch) {
|
||||
secondaryIds.push(...getFeatureActionIds(input));
|
||||
}
|
||||
secondaryIds.push("archive-workspace");
|
||||
|
||||
Reference in New Issue
Block a user