-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathOrganizationSettingsSideMenu.tsx
More file actions
177 lines (174 loc) · 6.1 KB
/
OrganizationSettingsSideMenu.tsx
File metadata and controls
177 lines (174 loc) · 6.1 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
165
166
167
168
169
170
171
172
173
174
175
176
177
import {
BellAlertIcon,
ChartBarIcon,
Cog8ToothIcon,
CreditCardIcon,
PuzzlePieceIcon,
UserGroupIcon,
} from "@heroicons/react/20/solid";
import { ArrowLeftIcon } from "@heroicons/react/24/solid";
import { useFeatures } from "~/hooks/useFeatures";
import { type MatchedOrganization } from "~/hooks/useOrganizations";
import { cn } from "~/utils/cn";
import {
organizationSettingsPath,
organizationTeamPath,
organizationVercelIntegrationPath,
rootPath,
v3BillingAlertsPath,
v3BillingPath,
v3UsagePath,
} from "~/utils/pathBuilder";
import { LinkButton } from "../primitives/Buttons";
import { HelpAndFeedback } from "./HelpAndFeedbackPopover";
import { SideMenuHeader } from "./SideMenuHeader";
import { SideMenuItem } from "./SideMenuItem";
import { useCurrentPlan } from "~/routes/_app.orgs.$organizationSlug/route";
import { Paragraph } from "../primitives/Paragraph";
import { Badge } from "../primitives/Badge";
import { useHasAdminAccess } from "~/hooks/useUser";
import { AskAI } from "../AskAI";
export type BuildInfo = {
appVersion: string | undefined;
packageVersion: string;
buildTimestampSeconds: string | undefined;
gitSha: string | undefined;
gitRefName: string | undefined;
};
export function OrganizationSettingsSideMenu({
organization,
buildInfo,
}: {
organization: MatchedOrganization;
buildInfo: BuildInfo;
}) {
const { isManagedCloud } = useFeatures();
const currentPlan = useCurrentPlan();
const isAdmin = useHasAdminAccess();
const showBuildInfo = isAdmin || !isManagedCloud;
return (
<div
className={cn(
"grid h-full grid-rows-[2.5rem_auto_2.5rem] overflow-hidden border-r border-grid-bright bg-background-bright transition"
)}
>
<div className={cn("flex items-center justify-between p-1 transition")}>
<LinkButton
variant="minimal/medium"
LeadingIcon={ArrowLeftIcon}
to={rootPath()}
fullWidth
textAlignLeft
>
<span className="text-text-bright">Back to app</span>
</LinkButton>
</div>
<div className="mb-6 flex grow flex-col gap-4 overflow-y-auto px-1 pt-2 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600">
<div className="flex flex-col">
<div className="mb-1">
<SideMenuHeader title="Organization" />
</div>
{isManagedCloud && (
<>
<SideMenuItem
name="Usage"
icon={ChartBarIcon}
activeIconColor="text-indigo-500"
to={v3UsagePath(organization)}
data-action="usage"
/>
<SideMenuItem
name="Billing"
icon={CreditCardIcon}
activeIconColor="text-emerald-500"
to={v3BillingPath(organization)}
data-action="billing"
badge={
currentPlan?.v3Subscription?.isPaying ? (
<Badge variant="extra-small">{currentPlan?.v3Subscription?.plan?.title}</Badge>
) : undefined
}
/>
<SideMenuItem
name="Billing alerts"
icon={BellAlertIcon}
activeIconColor="text-rose-500"
to={v3BillingAlertsPath(organization)}
data-action="billing-alerts"
/>
</>
)}
<SideMenuItem
name="Team"
icon={UserGroupIcon}
activeIconColor="text-amber-500"
to={organizationTeamPath(organization)}
data-action="team"
/>
<SideMenuItem
name="Settings"
icon={Cog8ToothIcon}
activeIconColor="text-orgSettings"
to={organizationSettingsPath(organization)}
data-action="settings"
/>
<SideMenuItem
name="Integrations"
icon={PuzzlePieceIcon}
activeIconColor="text-blue-500"
to={organizationVercelIntegrationPath(organization)}
data-action="integrations"
/>
</div>
<div className="flex flex-col gap-1">
<SideMenuHeader title="App version" />
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
{buildInfo.appVersion || `v${buildInfo.packageVersion}`}
</Paragraph>
</div>
{showBuildInfo && buildInfo.buildTimestampSeconds && (
<div className="flex flex-col gap-1">
<SideMenuHeader title="Build timestamp" />
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
{new Date(Number(buildInfo.buildTimestampSeconds) * 1000).toISOString()}
</Paragraph>
</div>
)}
{showBuildInfo && buildInfo.gitRefName && (
<div className="flex flex-col gap-1">
<SideMenuHeader title="Git ref" />
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
<a
href={`https://github.com/triggerdotdev/trigger.dev/tree/${buildInfo.gitRefName}`}
target="_blank"
rel="noopener noreferrer"
className="transition hover:text-text-bright"
>
{buildInfo.gitRefName}
</a>
</Paragraph>
</div>
)}
{showBuildInfo && buildInfo.gitSha && (
<div className="flex flex-col gap-1">
<SideMenuHeader title="Git sha" />
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
<a
href={`https://github.com/triggerdotdev/trigger.dev/commit/${buildInfo.gitSha}`}
target="_blank"
rel="noopener noreferrer"
className="transition hover:text-text-bright"
>
{buildInfo.gitSha.slice(0, 9)}
</a>
</Paragraph>
</div>
)}
</div>
<div className="flex w-full items-center justify-between border-t border-grid-bright p-1">
<HelpAndFeedback />
<AskAI />
</div>
</div>
);
}