Skip to content

Commit 95ae892

Browse files
committed
Drop the dirty-state Save tracking from ConfigureErrorAlerts
Revert the formChangeTick / isDirty / stableStringify block — Save is back to disabled-while-submitting only.
1 parent 86b12ec commit 95ae892

1 file changed

Lines changed: 2 additions & 34 deletions

File tree

apps/webapp/app/components/errors/ConfigureErrorAlerts.tsx

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
} from "@heroicons/react/20/solid";
1010
import { useFetcher, useNavigate } from "@remix-run/react";
1111
import { SlackIcon } from "@trigger.dev/companyicons";
12-
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
13-
import stableStringify from "json-stable-stringify";
12+
import { Fragment, useEffect, useRef, useState } from "react";
1413
import { z } from "zod";
1514
import { Button, LinkButton } from "~/components/primitives/Buttons";
1615
import { Callout, variantClasses } from "~/components/primitives/Callout";
@@ -105,35 +104,6 @@ export function ConfigureErrorAlerts({
105104
existingWebhooks.length > 0 ? [...existingWebhooks.map((w) => w.url), ""] : [""]
106105
);
107106

108-
const [formChangeTick, setFormChangeTick] = useState(0);
109-
const bumpFormChange = () => setFormChangeTick((n) => n + 1);
110-
111-
const isDirty = useMemo(() => {
112-
const initialSlackValue = existingSlackChannel
113-
? `${existingSlackChannel.channelId}/${existingSlackChannel.channelName}`
114-
: "";
115-
if ((selectedSlackChannelValue ?? "") !== initialSlackValue) return true;
116-
const currentEmails = emailFieldValues.current.filter((v) => v !== "");
117-
if (
118-
stableStringify(currentEmails) !==
119-
stableStringify(existingEmails.map((e) => e.email))
120-
)
121-
return true;
122-
const currentWebhooks = webhookFieldValues.current.filter((v) => v !== "");
123-
if (
124-
stableStringify(currentWebhooks) !==
125-
stableStringify(existingWebhooks.map((w) => w.url))
126-
)
127-
return true;
128-
return false;
129-
}, [
130-
selectedSlackChannelValue,
131-
existingSlackChannel,
132-
existingEmails,
133-
existingWebhooks,
134-
formChangeTick,
135-
]);
136-
137107
const [form, { emails, webhooks, slackChannel, slackIntegrationId }] = useForm({
138108
id: "configure-error-alerts",
139109
onValidate({ formData }) {
@@ -195,7 +165,6 @@ export function ConfigureErrorAlerts({
195165
icon={EnvelopeIcon}
196166
onChange={(e) => {
197167
emailFieldValues.current[index] = e.target.value;
198-
bumpFormChange();
199168
if (
200169
emailFields.length === emailFieldValues.current.length &&
201170
emailFieldValues.current.every((v) => v !== "")
@@ -358,7 +327,6 @@ export function ConfigureErrorAlerts({
358327
icon={GlobeAltIcon}
359328
onChange={(e) => {
360329
webhookFieldValues.current[index] = e.target.value;
361-
bumpFormChange();
362330
if (
363331
webhookFields.length === webhookFieldValues.current.length &&
364332
webhookFieldValues.current.every((v) => v !== "")
@@ -385,7 +353,7 @@ export function ConfigureErrorAlerts({
385353
<Button
386354
variant="primary/medium"
387355
type="submit"
388-
disabled={!isDirty || isSubmitting}
356+
disabled={isSubmitting}
389357
isLoading={isSubmitting}
390358
>
391359
{isSubmitting ? "Saving…" : "Save"}

0 commit comments

Comments
 (0)