Repository navigation
Expand file tree
/
Copy pathWorkspaceFilePreviewError.tsx
More file actions
53 lines (49 loc) · 1.82 KB
/
Copy pathWorkspaceFilePreviewError.tsx
File metadata and controls
53 lines (49 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { EnvironmentId } from "@t3tools/contracts";
import { View } from "react-native";
import { EmptyState } from "../../components/ui/EmptyState";
import { environmentCatalog } from "../../connection/catalog";
import type { AssetUrlFailureReason } from "../../state/asset-url-state";
import { useAtomCommand } from "../../state/use-atom-command";
import { useEnvironmentPresentation } from "../../state/presentation";
import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
export function WorkspaceFilePreviewError(props: {
readonly environmentId: EnvironmentId | null;
readonly reason: AssetUrlFailureReason;
readonly onRetry: () => void;
}) {
const { environmentId, onRetry } = props;
const environment = useEnvironmentPresentation(environmentId);
const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, "environment retry");
const retryConnection = () => {
if (environmentId !== null) void retryEnvironment(environmentId);
onRetry();
};
if (props.reason === "disconnected") {
return (
<View className="flex-1 bg-sheet">
<EnvironmentConnectionNotice
environmentLabel={environment.presentation?.entry.target.label ?? "Environment"}
connection={
environment.presentation?.connection ?? {
phase: "available",
error: null,
traceId: null,
}
}
resourceName="preview"
onRetry={retryConnection}
/>
</View>
);
}
return (
<View className="flex-1 items-center justify-center bg-sheet px-6">
<EmptyState
title="Preview unavailable"
detail="This file may be missing, unsupported, or unavailable on this environment."
actionLabel="Try again"
onAction={props.onRetry}
/>
</View>
);
}