-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSearchRepositoryDropdown.tsx
46 lines (40 loc) · 1.42 KB
/
SearchRepositoryDropdown.tsx
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
import { Icon, List, Image } from "@raycast/api";
import { useViewer } from "../hooks/useViewer";
export default function SearchRepositoryDropdown(props: { onFilterChange: (filter: string) => void }) {
const viewer = useViewer();
return (
<List.Dropdown tooltip="Filter Repositories" onChange={props.onFilterChange} storeValue>
<List.Dropdown.Section>
<List.Dropdown.Item title={"All Repositories"} value={""} />
{viewer ? (
<List.Dropdown.Item
title={"My Repositories"}
value={`user:${viewer.login} ${viewer.organizations?.nodes?.map((org) => `org:${org?.login}`).join(" ")}`}
/>
) : null}
</List.Dropdown.Section>
<List.Dropdown.Section>
{viewer ? (
<List.Dropdown.Item
icon={{ source: viewer.avatarUrl ?? Icon.PersonCircle, mask: Image.Mask.Circle }}
title={viewer.login}
value={`user:${viewer.login}`}
/>
) : null}
{viewer?.organizations?.nodes?.map((org) => {
if (!org) {
return null;
}
return (
<List.Dropdown.Item
icon={{ source: org.avatarUrl ?? Icon.PersonCircle, mask: Image.Mask.Circle }}
key={org.login}
title={org.login}
value={`org:${org.login}`}
/>
);
})}
</List.Dropdown.Section>
</List.Dropdown>
);
}