Skip to content

Commit 8c25a71

Browse files
committed
undo alert changes
1 parent 93d6147 commit 8c25a71

File tree

6 files changed

+32
-48
lines changed

6 files changed

+32
-48
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,9 +1621,8 @@ export function useEngineNotificationChannels(engineId: string) {
16211621
}
16221622

16231623
export interface CreateNotificationChannelInput {
1624-
deploymentId: string;
16251624
subscriptionRoutes: string[];
1626-
type: "slack" | "email" | "webhook";
1625+
type: "slack" | "email"; // TODO: Add others when implemented.
16271626
value: string;
16281627
}
16291628

apps/dashboard/src/components/engine/alerts/EngineAlertDialogForm.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ import {
2929
} from "@/components/ui/select";
3030
import {
3131
type EngineAlertRule,
32-
type EngineInstance,
3332
EngineNotificationChannelTypeConfig,
3433
} from "@3rdweb-sdk/react/hooks/useEngine";
3534
import { zodResolver } from "@hookform/resolvers/zod";
3635
import { useForm } from "react-hook-form";
3736
import { z } from "zod";
3837

3938
const alertFormSchema = z.object({
40-
deploymentId: z.string(),
4139
subscriptionRoutes: z.array(z.string()),
4240
type: z.enum(
4341
Object.keys(EngineNotificationChannelTypeConfig) as [
@@ -50,7 +48,6 @@ const alertFormSchema = z.object({
5048
type EngineAlertFormValues = z.infer<typeof alertFormSchema>;
5149

5250
export function EngineAlertDialogForm(props: {
53-
instance: EngineInstance;
5451
alertRules: EngineAlertRule[];
5552
title: string;
5653
values: EngineAlertFormValues | null;
@@ -65,7 +62,6 @@ export function EngineAlertDialogForm(props: {
6562
const form = useForm<z.infer<typeof alertFormSchema>>({
6663
resolver: zodResolver(alertFormSchema),
6764
defaultValues: {
68-
deploymentId: props.instance.deploymentId,
6965
subscriptionRoutes: ["alert.*"],
7066
type: "slack",
7167
},

apps/dashboard/src/components/engine/alerts/ManageEngineAlerts.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { ToolTipLabel } from "@/components/ui/tooltip";
2222
import {
2323
type CreateNotificationChannelInput,
2424
type EngineAlertRule,
25-
type EngineInstance,
2625
type EngineNotificationChannel,
2726
useEngineCreateNotificationChannel,
2827
useEngineDeleteNotificationChannel,
@@ -44,19 +43,19 @@ type CreateAlertMutation = UseMutationResult<
4443
>;
4544

4645
export function ManageEngineAlertsSection(props: {
47-
instance: EngineInstance;
4846
alertRules: EngineAlertRule[];
4947
alertRulesIsLoading: boolean;
48+
engineId: string;
5049
}) {
5150
const notificationChannelsQuery = useEngineNotificationChannels(
52-
props.instance.id,
51+
props.engineId,
5352
);
5453
const deleteAlertMutation = useEngineDeleteNotificationChannel(
55-
props.instance.id,
54+
props.engineId,
5655
);
5756

5857
const createAlertMutation = useEngineCreateNotificationChannel(
59-
props.instance.id,
58+
props.engineId,
6059
);
6160

6261
// not passing the mutation to avoid multiple rows sharing the same mutation state, we create the new mutation for each row instead in each component instead
@@ -66,8 +65,8 @@ export function ManageEngineAlertsSection(props: {
6665

6766
return (
6867
<ManageEngineAlertsSectionUI
69-
instance={props.instance}
7068
alertRules={props.alertRules}
69+
engineId={props.engineId}
7170
notificationChannels={notificationChannelsQuery.data ?? []}
7271
isLoading={
7372
notificationChannelsQuery.isLoading || props.alertRulesIsLoading
@@ -82,17 +81,16 @@ export function ManageEngineAlertsSection(props: {
8281
}
8382

8483
export function ManageEngineAlertsSectionUI(props: {
85-
instance: EngineInstance;
8684
alertRules: EngineAlertRule[];
85+
engineId: string;
8786
notificationChannels: EngineNotificationChannel[];
8887
isLoading: boolean;
8988
onAlertsUpdated: () => void;
9089
createAlertMutation: CreateAlertMutation;
9190
deleteAlert: (notificationChannelId: string) => Promise<void>;
9291
}) {
9392
const {
94-
instance,
95-
alertRules,
93+
engineId,
9694
notificationChannels,
9795
isLoading,
9896
onAlertsUpdated,
@@ -113,8 +111,8 @@ export function ManageEngineAlertsSectionUI(props: {
113111
</div>
114112

115113
<CreateAlertButton
116-
instance={instance}
117-
alertRules={alertRules}
114+
engineId={engineId}
115+
alertRules={props.alertRules}
118116
onSuccess={onAlertsUpdated}
119117
createAlertMutation={createAlertMutation}
120118
/>
@@ -224,7 +222,7 @@ function EngineAlertsTableUI(props: {
224222
}
225223

226224
function CreateAlertButton(props: {
227-
instance: EngineInstance;
225+
engineId: string;
228226
alertRules: EngineAlertRule[];
229227
onSuccess: () => void;
230228
createAlertMutation: CreateAlertMutation;
@@ -254,7 +252,6 @@ function CreateAlertButton(props: {
254252
</ToolTipLabel>
255253

256254
<EngineAlertDialogForm
257-
instance={props.instance}
258255
alertRules={props.alertRules}
259256
open={isModalOpen}
260257
onOpenChange={setIsModalOpen}

apps/dashboard/src/components/engine/alerts/RecentEngineAlerts.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@ import {
1414
import {
1515
type EngineAlert,
1616
type EngineAlertRule,
17-
type EngineInstance,
1817
useEngineAlerts,
1918
} from "@3rdweb-sdk/react/hooks/useEngine";
2019
import { formatDistance } from "date-fns";
2120
import { useMemo } from "react";
2221

2322
export function RecentEngineAlertsSection(props: {
24-
instance: EngineInstance;
2523
alertRules: EngineAlertRule[];
2624
alertRulesIsLoading: boolean;
25+
engineId: string;
2726
}) {
2827
// TODO - pagination
2928
// required : return the total number of alerts in response from API
30-
const alertsQuery = useEngineAlerts(props.instance.id, 100, 0);
29+
const alertsQuery = useEngineAlerts(props.engineId, 100, 0);
3130
const alerts = alertsQuery.data ?? [];
3231

3332
return (

apps/dashboard/src/components/engine/configuration/engine-wallet-config.tsx

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
useEngineWalletConfig,
77
} from "@3rdweb-sdk/react/hooks/useEngine";
88
import { Flex } from "@chakra-ui/react";
9+
import { EngineBackendWalletOptions } from "lib/engine";
910
import { CircleAlertIcon } from "lucide-react";
11+
import Link from "next/link";
1012
import { useState } from "react";
1113
import {} from "react-icons/md";
1214
import { Heading, Text } from "tw-components";
@@ -23,27 +25,12 @@ export const EngineWalletConfig: React.FC<EngineWalletConfigProps> = ({
2325
}) => {
2426
const { data: walletConfig } = useEngineWalletConfig(instance.url);
2527

26-
const tabOptions: {
27-
key: EngineBackendWalletType;
28-
name: string;
29-
content: React.ReactNode;
30-
}[] = [
31-
{
32-
key: "local",
33-
name: "Local",
34-
content: <LocalConfig />,
35-
},
36-
{
37-
key: "aws-kms",
38-
name: "AWS KMS",
39-
content: <KmsAwsConfig instance={instance} />,
40-
},
41-
{
42-
key: "gcp-kms",
43-
name: "Google Cloud KMS",
44-
content: <KmsGcpConfig instance={instance} />,
45-
},
46-
] as const;
28+
const tabContent: Record<EngineBackendWalletType, React.ReactNode> = {
29+
local: <LocalConfig />,
30+
"aws-kms": <KmsAwsConfig instance={instance} />,
31+
"gcp-kms": <KmsGcpConfig instance={instance} />,
32+
} as const;
33+
4734
const [activeTab, setActiveTab] = useState<EngineBackendWalletType>("local");
4835

4936
const isAwsKmsConfigured = !!walletConfig?.awsAccessKeyId;
@@ -54,13 +41,19 @@ export const EngineWalletConfig: React.FC<EngineWalletConfigProps> = ({
5441
<Flex flexDir="column" gap={2}>
5542
<Heading size="title.md">Backend Wallets</Heading>
5643
<Text>
57-
Create backend wallets on the <strong>Overview</strong> tab. To use
58-
other wallet types, configure them first.
44+
Create backend wallets on the{" "}
45+
<Link
46+
href={`/dashboard/engine/${instance.id}`}
47+
className="text-link-foreground hover:text-foreground"
48+
>
49+
Overview
50+
</Link>{" "}
51+
tab. To use other wallet types, configure them below.
5952
</Text>
6053
</Flex>
6154

6255
<TabButtons
63-
tabs={tabOptions.map(({ key, name }) => ({
56+
tabs={EngineBackendWalletOptions.map(({ key, name }) => ({
6457
key,
6558
name,
6659
isActive: activeTab === key,
@@ -79,7 +72,7 @@ export const EngineWalletConfig: React.FC<EngineWalletConfigProps> = ({
7972
tabClassName="font-medium !text-sm"
8073
/>
8174

82-
{tabOptions.find((opt) => opt.key === activeTab)?.content}
75+
{tabContent[activeTab]}
8376
</Flex>
8477
);
8578
};

apps/dashboard/src/components/engine/configuration/kms-gcp-config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const KmsGcpConfig: React.FC<KmsGcpConfigProps> = ({ instance }) => {
8989
category="engine"
9090
className="text-link-foreground hover:text-foreground"
9191
>
92-
learn more about using GCP KMS wallets
92+
learn more about using Google Cloud KMS wallets
9393
</TrackedLinkTW>
9494
.
9595
</p>

0 commit comments

Comments
 (0)