Skip to content

Commit 54017cb

Browse files
authored
feat: always show alerts tab and lock email alerts when keys are missing (#1478)
1 parent 39ef733 commit 54017cb

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ function V3ProjectSideMenu({
459459
project: SideMenuProject;
460460
organization: MatchedOrganization;
461461
}) {
462-
const { alertsEnabled } = useFeatures();
463-
464462
return (
465463
<>
466464
<SideMenuHeader title={"Project"} />
@@ -520,15 +518,13 @@ function V3ProjectSideMenu({
520518
to={v3DeploymentsPath(organization, project)}
521519
data-action="deployments"
522520
/>
523-
{alertsEnabled && (
524-
<SideMenuItem
525-
name="Alerts"
526-
icon={BellAlertIcon}
527-
activeIconColor="text-red-500"
528-
to={v3ProjectAlertsPath(organization, project)}
529-
data-action="alerts"
530-
/>
531-
)}
521+
<SideMenuItem
522+
name="Alerts"
523+
icon={BellAlertIcon}
524+
activeIconColor="text-red-500"
525+
to={v3ProjectAlertsPath(organization, project)}
526+
data-action="alerts"
527+
/>
532528
<SideMenuItem
533529
name="Concurrency limits"
534530
icon={RectangleStackIcon}

apps/webapp/app/features.server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { requestUrl } from "./utils/requestUrl.server";
44
export type TriggerFeatures = {
55
isManagedCloud: boolean;
66
v3Enabled: boolean;
7-
alertsEnabled: boolean;
87
};
98

109
function isManagedCloud(host: string): boolean {
@@ -20,7 +19,6 @@ function featuresForHost(host: string): TriggerFeatures {
2019
return {
2120
isManagedCloud: isManagedCloud(host),
2221
v3Enabled: env.V3_ENABLED === "true",
23-
alertsEnabled: env.ALERT_FROM_EMAIL !== undefined && env.ALERT_RESEND_API_KEY !== undefined,
2422
};
2523
}
2624

apps/webapp/app/hooks/useFeatures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import type { TriggerFeatures } from "~/features.server";
55
export function useFeatures(): TriggerFeatures {
66
const routeMatch = useTypedRouteLoaderData<typeof loader>("root");
77

8-
return routeMatch?.features ?? { isManagedCloud: false, v3Enabled: false, alertsEnabled: false };
8+
return routeMatch?.features ?? { isManagedCloud: false, v3Enabled: false };
99
}

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.alerts.new/route.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Label } from "~/components/primitives/Label";
2323
import SegmentedControl from "~/components/primitives/SegmentedControl";
2424
import { Select, SelectItem } from "~/components/primitives/Select";
2525
import { InfoIconTooltip } from "~/components/primitives/Tooltip";
26+
import { env } from "~/env.server";
2627
import { useOrganization } from "~/hooks/useOrganizations";
2728
import { useProject } from "~/hooks/useProject";
2829
import { redirectWithSuccessMessage } from "~/models/message.server";
@@ -150,9 +151,13 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
150151
const url = new URL(request.url);
151152
const option = url.searchParams.get("option");
152153

154+
const emailAlertsEnabled =
155+
env.ALERT_FROM_EMAIL !== undefined && env.ALERT_RESEND_API_KEY !== undefined;
156+
153157
return typedjson({
154158
...results,
155159
option: option === "slack" ? ("SLACK" as const) : undefined,
160+
emailAlertsEnabled,
156161
});
157162
}
158163

@@ -200,7 +205,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
200205

201206
export default function Page() {
202207
const [isOpen, setIsOpen] = useState(false);
203-
const { slack, option } = useTypedLoaderData<typeof loader>();
208+
const { slack, option, emailAlertsEnabled } = useTypedLoaderData<typeof loader>();
204209
const lastSubmission = useActionData();
205210
const navigation = useNavigation();
206211
const navigate = useNavigate();
@@ -271,16 +276,23 @@ export default function Page() {
271276
</InputGroup>
272277

273278
{currentAlertChannel === "EMAIL" ? (
274-
<InputGroup fullWidth>
275-
<Label>Email</Label>
276-
<Input
277-
{...conform.input(channelValue)}
278-
placeholder="email@youremail.com"
279-
type="email"
280-
autoFocus
281-
/>
282-
<FormError id={channelValue.errorId}>{channelValue.error}</FormError>
283-
</InputGroup>
279+
emailAlertsEnabled ? (
280+
<InputGroup fullWidth>
281+
<Label>Email</Label>
282+
<Input
283+
{...conform.input(channelValue)}
284+
placeholder="email@youremail.com"
285+
type="email"
286+
autoFocus
287+
/>
288+
<FormError id={channelValue.errorId}>{channelValue.error}</FormError>
289+
</InputGroup>
290+
) : (
291+
<Callout variant="warning">
292+
Email integration is not available. Please contact your organization
293+
administrator.
294+
</Callout>
295+
)
284296
) : currentAlertChannel === "SLACK" ? (
285297
<InputGroup fullWidth>
286298
{slack.status === "READY" ? (

0 commit comments

Comments
 (0)