Skip to content

Commit 043c9c3

Browse files
authored
fix(mobile): collapse pull request repository errors (pingdotgg#21389)
1 parent 327f3fc commit 043c9c3

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { useProjects } from "../../state/entities";
2727
import { environmentServerConfigsAtom } from "../../state/server";
2828
import { PullRequestListRow } from "./PullRequestListRow";
2929
import { PullRequestListFilters } from "./PullRequestListFilters";
30+
import { PullRequestCardRow } from "./PullRequestControls";
3031
import { usePullRequestList } from "./usePullRequestList";
3132
import { usePullRequestListControls } from "./usePullRequestListControls";
3233
import { usePullRequestListActions } from "./usePullRequestListActions";
@@ -57,6 +58,29 @@ function PullRequestScrollView(props: ScrollViewProps) {
5758
);
5859
}
5960

61+
function PullRequestListErrors(props: { readonly messages: readonly string[] }) {
62+
const [expanded, setExpanded] = useState(false);
63+
const title = `${props.messages.length} ${props.messages.length === 1 ? "error" : "errors"} loading pull requests`;
64+
return (
65+
<View>
66+
<PullRequestCardRow
67+
title={title}
68+
icon="exclamationmark.triangle"
69+
compact
70+
last
71+
expanded={expanded}
72+
accessibilityLabel={`${title}. ${expanded ? "Hide" : "Show"} details`}
73+
onPress={() => setExpanded((value) => !value)}
74+
/>
75+
{expanded ? (
76+
<Text selectable className="px-4 pb-3 text-sm text-foreground-muted">
77+
{props.messages.join("\n")}
78+
</Text>
79+
) : null}
80+
</View>
81+
);
82+
}
83+
6084
export function PullRequestsScreen(
6185
props: {
6286
readonly sidebar?: boolean;
@@ -295,14 +319,13 @@ export function PullRequestsScreen(
295319
projects={projects}
296320
/>
297321
{result.data?.errors.length ? (
298-
<Text className="px-4 py-3 text-sm text-foreground-muted">
299-
{result.data.errors
300-
.map(
301-
(error) =>
302-
`${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`,
303-
)
304-
.join("\n")}
305-
</Text>
322+
<PullRequestListErrors
323+
key={JSON.stringify(targets)}
324+
messages={result.data.errors.map(
325+
(error) =>
326+
`${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`,
327+
)}
328+
/>
306329
) : null}
307330
</>
308331
}

0 commit comments

Comments
 (0)