Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Platform, View } from "react-native";
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
import { AppText as Text } from "../../components/ui/AppText";
import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
import { pullRequestLayerParams } from "./pullRequestStack";
import { pullRequestStatus } from "./pullRequestStatus";
import type { PullRequestParams } from "./usePullRequestDiff";
import type { PullRequestStackState } from "./usePullRequestStack";
Expand Down Expand Up @@ -66,7 +67,7 @@ export function PullRequestStackCard(props: {
selected
? undefined
: () => {
const params = { ...props.params, number: layer.number };
const params = pullRequestLayerParams(props.params, layer.number);
if (Platform.OS === "android")
selectAndroidWorkspace({ name: "PullRequest", params });
else navigation.dispatch(StackActions.push("PullRequest", params));
Expand Down
21 changes: 21 additions & 0 deletions apps/mobile/src/features/pull-requests/pullRequestStack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sourceControlClients } from "@t3tools/client-runtime/source-control-cli
import { ProjectId, type PullRequestStack, type ThreadPullRequestLink } from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";
import {
pullRequestLayerParams,
pullRequestStackMerge,
savedPullRequestStack,
singlePullRequestMergeAllowed,
Expand Down Expand Up @@ -124,6 +125,26 @@ describe("mobile stack merge scope", () => {
});
});

describe("mobile stack layer navigation", () => {
it("opens another layer without the summary of the layer it came from", () => {
const route = {
environmentId: "environment",
projectId: "project",
repository: "acme/web",
host: "github.com",
number: 2,
initialSummary: { number: 2, url: "https://github.com/acme/web/pull/2" },
};
expect(pullRequestLayerParams(route, 3)).toEqual({
environmentId: "environment",
projectId: "project",
repository: "acme/web",
host: "github.com",
number: 3,
});
});
});

describe("mobile saved stack navigation", () => {
it("keeps all saved layers and enriches titles without carrying action revisions", () => {
const saved = savedPullRequestStack([link], reference);
Expand Down
9 changes: 9 additions & 0 deletions apps/mobile/src/features/pull-requests/pullRequestStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ export function savedPullRequestStack(
};
}

/** The list summary describes the layer it was opened from, so another layer's route drops it. */
export function pullRequestLayerParams<Params extends { readonly initialSummary?: unknown }>(
params: Params,
number: number,
) {
const { initialSummary: _, ...layer } = params;
return { ...layer, number };
}

export function singlePullRequestMergeAllowed(input: {
readonly supportsStackActions: boolean;
readonly hasStack: boolean;
Expand Down
Loading