TypeScript
fix(mobile): collapse pull request repository errors (#21389)
maria043c9c316959
diff --git a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsxindex 70adb062397..e0b97485551 100644--- a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx@@ -27,6 +27,7 @@ import { useProjects } from "../../state/entities";import { environmentServerConfigsAtom } from "../../state/server";import { PullRequestListRow } from "./PullRequestListRow";import { PullRequestListFilters } from "./PullRequestListFilters";+import { PullRequestCardRow } from "./PullRequestControls";import { usePullRequestList } from "./usePullRequestList";import { usePullRequestListControls } from "./usePullRequestListControls";import { usePullRequestListActions } from "./usePullRequestListActions";@@ -57,6 +58,29 @@ function PullRequestScrollView(props: ScrollViewProps) {);}+function PullRequestListErrors(props: { readonly messages: readonly string[] }) {+ const [expanded, setExpanded] = useState(false);+ const title = `${props.messages.length} ${props.messages.length === 1 ? "error" : "errors"} loading pull requests`;+ return (+ <View>+ <PullRequestCardRow+ title={title}+ icon="exclamationmark.triangle"+ compact+ last+ expanded={expanded}+ accessibilityLabel={`${title}. ${expanded ? "Hide" : "Show"} details`}+ onPress={() => setExpanded((value) => !value)}+ />+ {expanded ? (+ <Text selectable className="px-4 pb-3 text-sm text-foreground-muted">+ {props.messages.join("\n")}+ </Text>+ ) : null}+ </View>+ );+}+export function PullRequestsScreen(props: {readonly sidebar?: boolean;@@ -295,14 +319,13 @@ export function PullRequestsScreen(projects={projects}/>{result.data?.errors.length ? (- <Text className="px-4 py-3 text-sm text-foreground-muted">- {result.data.errors- .map(- (error) =>- `${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`,- )- .join("\n")}- </Text>+ <PullRequestListErrors+ key={JSON.stringify(targets)}+ messages={result.data.errors.map(+ (error) =>+ `${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`,+ )}+ />) : null}</>}