From d09fe55caccec93bb64bb344a59085212a794db2 Mon Sep 17 00:00:00 2001 From: Geoff Cramer Date: Fri, 17 Jul 2026 10:02:58 -0400 Subject: [PATCH] Make workspace Batch ID editable (#533) * :sparkles: Make workspace Batch ID editable * cleanup --- components/repositories/RevokeCredential.tsx | 11 +++++++- components/workspace/ModToolForm.tsx | 28 +++++++++++--------- components/workspace/PanelActionForm.tsx | 9 ++++++- lib/batchId.ts | 4 +++ 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/components/repositories/RevokeCredential.tsx b/components/repositories/RevokeCredential.tsx index cdfc8ba..5cd5541 100644 --- a/components/repositories/RevokeCredential.tsx +++ b/components/repositories/RevokeCredential.tsx @@ -19,7 +19,7 @@ import { ToolsOzoneCommunicationDefs } from '@atproto/api' import { MOD_EVENTS } from '@/mod-event/constants' import { compileTemplateContent } from '@/email/helpers' import { executeBatchedOperation, pluralize } from '@/lib/util' -import { getBatchId, regenerateBatchId } from '@/lib/batchId' +import { getBatchId, regenerateBatchId, setBatchId } from '@/lib/batchId' import { ActionPanelNames, hydrateModToolInfo, @@ -200,6 +200,12 @@ function useRevokeCredentialsState() { toast.success('Batch ID updated') } + const handleBatchIdChange = (batchId: string) => { + // Persist edits so other consumers of the stored batch id stay in sync + setBatchId(batchId) + setCurrentBatchId(batchId) + } + return { isRevokeModalOpen, setIsRevokeModalOpen, @@ -210,6 +216,7 @@ function useRevokeCredentialsState() { externalUrl, setExternalUrl, handleRegenerateBatchId, + handleBatchIdChange, } } @@ -244,6 +251,7 @@ export const RevokeCredentialsForm = ({ externalUrl, setExternalUrl, handleRegenerateBatchId, + handleBatchIdChange, } = useRevokeCredentialsState() const templateName = emailTemplate?.name @@ -344,6 +352,7 @@ export const RevokeCredentialsForm = ({ setExternalUrl={setExternalUrl} currentBatchId={currentBatchId} handleRegenerateBatchId={handleRegenerateBatchId} + onBatchIdChange={handleBatchIdChange} /> )} diff --git a/components/workspace/ModToolForm.tsx b/components/workspace/ModToolForm.tsx index 5b6550a..c0f00d9 100644 --- a/components/workspace/ModToolForm.tsx +++ b/components/workspace/ModToolForm.tsx @@ -6,11 +6,13 @@ import { WORKSPACE_FORM_ID } from './constants' export const ModToolForm = ({ currentBatchId, handleRegenerateBatchId, + onBatchIdChange, externalUrl, setExternalUrl, }: { currentBatchId: string handleRegenerateBatchId: () => void + onBatchIdChange?: (batchId: string) => void externalUrl?: string setExternalUrl?: (url: string) => void }) => { @@ -31,20 +33,20 @@ export const ModToolForm = ({ -
-
-
- - Batch ID: - - - {currentBatchId} - -
-
+
+ +
+ onBatchIdChange?.(e.target.value)} + placeholder="Batch identifier" + autoComplete="off" + /> @@ -57,7 +59,7 @@ export const ModToolForm = ({
-
+
) diff --git a/components/workspace/PanelActionForm.tsx b/components/workspace/PanelActionForm.tsx index 3a95c49..66fc5a8 100644 --- a/components/workspace/PanelActionForm.tsx +++ b/components/workspace/PanelActionForm.tsx @@ -9,7 +9,7 @@ import { WORKSPACE_FORM_ID } from './constants' import { EmailComposer } from 'components/email/Composer' import { EmailComposerData } from 'components/email/helpers' import { ActionPolicySelector } from '@/reports/ModerationForm/ActionPolicySelector' -import { getBatchId, regenerateBatchId } from '@/lib/batchId' +import { getBatchId, regenerateBatchId, setBatchId } from '@/lib/batchId' import { useState } from 'react' import { toast } from 'react-toastify' import { ModToolForm } from './ModToolForm' @@ -33,6 +33,12 @@ export const WorkspacePanelActionForm = ({ setCurrentBatchId(newBatchId) toast.success('Workspace Batch ID updated') } + const handleBatchIdChange = (batchId: string) => { + // Persist edits so event submission picks up the user-provided value + setBatchId(batchId) + setCurrentBatchId(batchId) + } + const isAckEvent = modEventType === MOD_EVENTS.ACKNOWLEDGE const isEmailEvent = modEventType === MOD_EVENTS.EMAIL const isTakedownEvent = modEventType === MOD_EVENTS.TAKEDOWN @@ -213,6 +219,7 @@ export const WorkspacePanelActionForm = ({
diff --git a/lib/batchId.ts b/lib/batchId.ts index 32928ce..b743db9 100644 --- a/lib/batchId.ts +++ b/lib/batchId.ts @@ -18,6 +18,10 @@ export const getBatchId = (): string => { return batchId } +export const setBatchId = (batchId: string): void => { + localStorage.setItem(BATCH_ID_KEY, batchId) +} + export const regenerateBatchId = (): string => { const newBatchId = generateBatchId() localStorage.setItem(BATCH_ID_KEY, newBatchId) -- knotmirror 0.0.1