Skip to content

Commit 5021d52

Browse files
committed
feat(web): add cron trigger saving functionality to DeploymentDetailPage with enhanced error handling
1 parent 1b03f75 commit 5021d52

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

apps/web/src/pages/workflows/deployment-detail-page.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ import {
3737
} from "@/components/ui/dropdown-menu";
3838
import { ExecutionFormDialog } from "@/components/workflow/execution-form-dialog";
3939
import { HttpIntegrationDialog } from "@/components/workflow/http-integration-dialog";
40-
import { SetCronDialog } from "@/components/workflow/set-cron-dialog";
40+
import {
41+
type CronFormData,
42+
SetCronDialog,
43+
} from "@/components/workflow/set-cron-dialog";
4144
import {
4245
ActionButton,
4346
DeployButton,
@@ -51,6 +54,7 @@ import {
5154
useDeploymentHistory,
5255
} from "@/services/deployment-service";
5356
import {
57+
upsertCronTrigger,
5458
useCronTrigger,
5559
useWorkflow,
5660
useWorkflowExecution,
@@ -168,7 +172,7 @@ export function DeploymentDetailPage() {
168172
const [expandedHistory, setExpandedHistory] = useState(false);
169173
const [isIntegrationDialogOpen, setIsIntegrationDialogOpen] = useState(false);
170174

171-
const { cronTrigger } = useCronTrigger(workflowId!);
175+
const { cronTrigger, mutateCronTrigger } = useCronTrigger(workflowId!);
172176

173177
const {
174178
workflow: workflowSummary,
@@ -256,6 +260,24 @@ export function DeploymentDetailPage() {
256260
);
257261
};
258262

263+
const handleSaveCron = async (data: CronFormData) => {
264+
if (!workflowId || !orgHandle) return;
265+
try {
266+
const updatedCron = await upsertCronTrigger(workflowId, orgHandle, {
267+
cronExpression: data.cronExpression,
268+
active: data.active,
269+
versionAlias: data.versionAlias,
270+
versionNumber: data.versionNumber,
271+
});
272+
mutateCronTrigger(updatedCron);
273+
toast.success("Cron schedule saved successfully.");
274+
setIsIntegrationDialogOpen(false);
275+
} catch (error) {
276+
console.error("Failed to save cron schedule:", error);
277+
toast.error("Failed to save cron schedule. Please try again.");
278+
}
279+
};
280+
259281
const displayDeployments = expandedHistory
260282
? deployments || []
261283
: deployments.slice(0, 3) || [];
@@ -470,8 +492,7 @@ export function DeploymentDetailPage() {
470492
<SetCronDialog
471493
isOpen={isIntegrationDialogOpen}
472494
onClose={() => setIsIntegrationDialogOpen(false)}
473-
// TODO: Add submit handler
474-
onSubmit={() => {}}
495+
onSubmit={handleSaveCron}
475496
initialData={{
476497
cronExpression: cronTrigger?.cronExpression || "",
477498
active:

0 commit comments

Comments
 (0)