-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathGuideRow.tsx
More file actions
164 lines (159 loc) · 5.17 KB
/
Copy pathGuideRow.tsx
File metadata and controls
164 lines (159 loc) · 5.17 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import { Button } from "@telegraph/button";
import { Box, Stack } from "@telegraph/layout";
import { Tag } from "@telegraph/tag";
import { Tooltip } from "@telegraph/tooltip";
import { Text } from "@telegraph/typography";
import {
CheckCircle2,
CircleDashed,
Code2,
Eye,
LocateFixed,
UserCircle2,
} from "lucide-react";
import * as React from "react";
import { GuideHoverCard } from "./GuideHoverCard";
import {
AnnotatedGuide,
UnknownGuide,
isUnknownGuide,
} from "./useInspectGuideClientStore";
const Row = ({ children }: React.PropsWithChildren) => (
<Stack h="7" px="2" borderTop="px" justify="space-between" align="center">
{children}
</Stack>
);
type Props = {
guide: UnknownGuide | AnnotatedGuide;
orderIndex: number;
};
export const GuideRow = ({ guide, orderIndex }: Props) => {
return (
<Row>
<GuideHoverCard guide={guide}>
<Stack h="6" justify="flex-start" align="center" gap="2">
<Tag
size="0"
variant="soft"
color={guide.bypass_global_group_limit ? "blue" : "default"}
>
{orderIndex + 1}
</Tag>
<Text as="code" size="1">
{guide.key}
</Text>
</Stack>
</GuideHoverCard>
<Stack justify="flex-end">
{!isUnknownGuide(guide) && (
<>
<Stack gap="1">
<Tooltip
label={
guide.annotation.selectable.status === "returned"
? "This guide was queried and can display"
: guide.annotation.selectable.status === "queried"
? "This guide was queried but cannot display"
: guide.annotation.selectable.status === "throttled"
? "This guide was queried and can display but is throttled currently"
: "No component is present in the current location to display this guide"
}
>
<Button
px="1"
size="1"
variant="soft"
color={
guide.annotation.selectable.status === "returned"
? "green"
: guide.annotation.selectable.status === "queried"
? "gray"
: guide.annotation.selectable.status === "throttled"
? "yellow"
: "red"
}
leadingIcon={{ icon: Code2, alt: "Render" }}
/>
</Tooltip>
<Tooltip
label={
guide.annotation.activatable.status
? "This guide can be activated at the current location"
: "This guide cannot be activated at the current location"
}
>
<Button
px="1"
size="1"
variant="soft"
color={guide.annotation.activatable.status ? "green" : "red"}
leadingIcon={{ icon: LocateFixed, alt: "Target" }}
/>
</Tooltip>
</Stack>
<Stack px="2" align="center">
<Box h="3" borderLeft="px" borderColor="gray-6" />
</Stack>
</>
)}
<Stack gap="1">
{!isUnknownGuide(guide) && (
<>
<Tooltip
label={
guide.annotation.targetable.status
? "This user is being targeted"
: guide.annotation.targetable.message
}
>
<Button
px="1"
size="1"
variant="soft"
color={guide.annotation.targetable.status ? "green" : "red"}
leadingIcon={{ icon: UserCircle2, alt: "Target" }}
/>
</Tooltip>
<Tooltip
label={
guide.annotation.archived.status
? "User has already dismissed this guide"
: "User has not dismissed this guide"
}
>
<Button
px="1"
size="1"
variant="soft"
color={guide.annotation.archived.status ? "red" : "green"}
leadingIcon={{ icon: Eye, alt: "Not archived" }}
/>
</Tooltip>
</>
)}
<Tooltip
label={
isUnknownGuide(guide)
? "This guide has never been committed and published yet"
: !guide.active
? "This guide is not active"
: "This guide is active"
}
>
<Button
px="1"
size="1"
variant="soft"
color={guide.active ? "green" : "red"}
leadingIcon={
guide.active
? { icon: CheckCircle2, alt: "Active" }
: { icon: CircleDashed, alt: "Inactive" }
}
/>
</Tooltip>
</Stack>
</Stack>
</Row>
);
};