Skip to content

Commit 1d0c516

Browse files
feat(mobile): pull request menu can copy or share the link
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3ff5b3c commit 1d0c516

4 files changed

Lines changed: 50 additions & 8 deletions

File tree

‎apps/mobile/src/components/ui/AppSymbol.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import IconPlus from "@tabler/icons-react-native/IconPlus";
103103
import IconQrcode from "@tabler/icons-react-native/IconQrcode";
104104
import IconRefresh from "@tabler/icons-react-native/IconRefresh";
105105
import IconSearch from "@tabler/icons-react-native/IconSearch";
106+
import IconShare from "@tabler/icons-react-native/IconShare";
106107
import IconServer from "@tabler/icons-react-native/IconServer";
107108
import IconSettings from "@tabler/icons-react-native/IconSettings";
108109
import IconSparkles from "@tabler/icons-react-native/IconSparkles";
@@ -244,6 +245,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
244245
"sidebar.left": IconLayoutSidebar,
245246
"sidebar.right": IconLayoutSidebarRight,
246247
"slider.horizontal.3": IconAdjustmentsHorizontal,
248+
"square.and.arrow.up": IconShare,
247249
"square.and.pencil": IconEdit,
248250
"square.on.square": IconCopy,
249251
"square.grid.2x2": IconApps,

‎apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { useAtomRefresh } from "@effect/atom-react";
4848
import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
4949
import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
5050
import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
51+
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
5152
import { pullRequestStatus } from "./pullRequestStatus";
5253
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5354
import {
@@ -427,6 +428,18 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
427428
icon: "arrow.up.right" as const,
428429
onPress: () => void Linking.openURL(pr.url),
429430
},
431+
{
432+
accessibilityLabel: "Copy link",
433+
icon: "link" as const,
434+
overflowOnly: true,
435+
onPress: () => copyPullRequestLink(pr),
436+
},
437+
{
438+
accessibilityLabel: "Share…",
439+
icon: "square.and.arrow.up" as const,
440+
overflowOnly: true,
441+
onPress: () => sharePullRequestLink(pr),
442+
},
430443
]
431444
: []),
432445
...(showsDeleteBranch
@@ -478,6 +491,19 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
478491
<Toolbar.Label>{openOnProviderLabel(pr.provider)}</Toolbar.Label>
479492
</Toolbar.MenuAction>
480493
) : null}
494+
{pr ? (
495+
<Toolbar.MenuAction icon="link" onPress={() => copyPullRequestLink(pr)}>
496+
<Toolbar.Label>Copy link</Toolbar.Label>
497+
</Toolbar.MenuAction>
498+
) : null}
499+
{pr ? (
500+
<Toolbar.MenuAction
501+
icon="square.and.arrow.up"
502+
onPress={() => sharePullRequestLink(pr)}
503+
>
504+
<Toolbar.Label>Share…</Toolbar.Label>
505+
</Toolbar.MenuAction>
506+
) : null}
481507
{showsDeleteBranch ? (
482508
<Toolbar.MenuAction
483509
icon={PR_ACTION_ICONS["delete-branch"]}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Platform, Share } from "react-native";
2+
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
3+
4+
interface PullRequestLink {
5+
readonly url: string;
6+
readonly title: string;
7+
}
8+
9+
export function copyPullRequestLink(pr: PullRequestLink) {
10+
copyTextWithHaptic(pr.url, { target: "pull request link" });
11+
}
12+
13+
export function sharePullRequestLink(pr: PullRequestLink) {
14+
// Android ignores `url`; iOS turns a `message` URL into plain text instead of a link preview.
15+
void Share.share(
16+
Platform.OS === "ios" ? { url: pr.url, title: pr.title } : { message: pr.url, title: pr.title },
17+
);
18+
}

‎apps/mobile/src/features/pull-requests/usePullRequestListActions.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { RegistryContext, useAtomValue } from "@effect/atom-react";
33
import { useNavigation } from "@react-navigation/native";
44
import { executeAtomQuery, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
55
import type { EnvironmentId, PullRequestAction } from "@t3tools/contracts";
6-
import * as Clipboard from "expo-clipboard";
76
import { Atom } from "effect/reactivity";
87
import { use, useCallback, useMemo, useRef, useState } from "react";
9-
import { Linking, Platform, Share } from "react-native";
8+
import { Linking, Platform } from "react-native";
109
import type { MenuProps } from "../../components/ui/Menu.types";
1110
import { composerPullRequests } from "../../state/pull-requests";
1211
import { useAtomCommand } from "../../state/use-atom-command";
@@ -16,6 +15,7 @@ import {
1615
PR_ACTION_LABELS,
1716
} from "./pullRequestActions";
1817
import { scopedPullRequestListKey, type EnvironmentPullRequestListEntry } from "./pullRequestList";
18+
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
1919
import { pullRequestTarget } from "./usePullRequestDiff";
2020
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
2121

@@ -122,19 +122,15 @@ export function usePullRequestListActions(
122122
return;
123123
}
124124
if (action === "copy") {
125-
void Clipboard.setStringAsync(entry.url);
125+
copyPullRequestLink(entry);
126126
return;
127127
}
128128
if (action === "provider") {
129129
void Linking.openURL(entry.url);
130130
return;
131131
}
132132
if (action === "share") {
133-
void Share.share(
134-
Platform.OS === "ios"
135-
? { url: entry.url, title: entry.title }
136-
: { message: entry.url, title: entry.title },
137-
);
133+
sharePullRequestLink(entry);
138134
return;
139135
}
140136
const supported = (["close", "reopen", "ready", "draft"] as const).find(

0 commit comments

Comments
 (0)