Skip to content

Commit e55735d

Browse files
committed
refactor: Clean up imports and formatting across multiple components for improved readability
1 parent 2deb3ae commit e55735d

13 files changed

Lines changed: 104 additions & 99 deletions

File tree

apps/api/src/nodes/cloudflare-node-registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { WhisperLargeV3TurboNode } from "./audio/whisper-large-v3-turbo-node";
1919
import { WhisperNode } from "./audio/whisper-node";
2020
import { WhisperTinyEnNode } from "./audio/whisper-tiny-en-node";
2121
import { BaseNodeRegistry } from "./base-node-registry";
22+
import { BlobNode } from "./blob/blob-node";
2223
import { CloudflareBrowserContentNode } from "./browser/cloudflare-browser-content-node";
2324
import { CloudflareBrowserJsonNode } from "./browser/cloudflare-browser-json-node";
2425
import { CloudflareBrowserLinksNode } from "./browser/cloudflare-browser-links-node";
@@ -38,7 +39,6 @@ import { ListGuildChannelsDiscordNode } from "./discord/list-guild-channels-disc
3839
import { ListUserGuildsDiscordNode } from "./discord/list-user-guilds-discord-node";
3940
import { SendDMDiscordNode } from "./discord/send-dm-discord-node";
4041
import { SendMessageDiscordNode } from "./discord/send-message-discord-node";
41-
import { BlobNode } from "./blob/blob-node";
4242
import { DocumentNode } from "./document/document-node";
4343
import { ToMarkdownNode } from "./document/to-markdown-node";
4444
import { ParseEmailNode } from "./email/parse-email-node";

apps/api/src/nodes/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
// Types for workflows
2-
import {
3-
GeoJSON,
4-
Node,
5-
NodeExecution,
6-
NodeType,
7-
} from "@dafthunk/types";
2+
import { GeoJSON, Node, NodeExecution, NodeType } from "@dafthunk/types";
83

94
import { BaseToolRegistry } from "./base-tool-registry";
105
import { ToolReference } from "./tool-types";

apps/web/src/components/ui/calendar.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as React from "react"
21
import {
32
ChevronDownIcon,
43
ChevronLeftIcon,
54
ChevronRightIcon,
6-
} from "lucide-react"
7-
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
5+
} from "lucide-react";
6+
import * as React from "react";
7+
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker";
88

9-
import { cn } from "@/utils/utils"
10-
import { Button, buttonVariants } from "@/components/ui/button"
9+
import { Button, buttonVariants } from "@/components/ui/button";
10+
import { cn } from "@/utils/utils";
1111

1212
function Calendar({
1313
className,
@@ -19,9 +19,9 @@ function Calendar({
1919
components,
2020
...props
2121
}: React.ComponentProps<typeof DayPicker> & {
22-
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
22+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
2323
}) {
24-
const defaultClassNames = getDefaultClassNames()
24+
const defaultClassNames = getDefaultClassNames();
2525

2626
return (
2727
<DayPicker
@@ -131,13 +131,13 @@ function Calendar({
131131
className={cn(className)}
132132
{...props}
133133
/>
134-
)
134+
);
135135
},
136136
Chevron: ({ className, orientation, ...props }) => {
137137
if (orientation === "left") {
138138
return (
139139
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
140-
)
140+
);
141141
}
142142

143143
if (orientation === "right") {
@@ -146,12 +146,12 @@ function Calendar({
146146
className={cn("size-4", className)}
147147
{...props}
148148
/>
149-
)
149+
);
150150
}
151151

152152
return (
153153
<ChevronDownIcon className={cn("size-4", className)} {...props} />
154-
)
154+
);
155155
},
156156
DayButton: CalendarDayButton,
157157
WeekNumber: ({ children, ...props }) => {
@@ -161,13 +161,13 @@ function Calendar({
161161
{children}
162162
</div>
163163
</td>
164-
)
164+
);
165165
},
166166
...components,
167167
}}
168168
{...props}
169169
/>
170-
)
170+
);
171171
}
172172

173173
function CalendarDayButton({
@@ -176,12 +176,12 @@ function CalendarDayButton({
176176
modifiers,
177177
...props
178178
}: React.ComponentProps<typeof DayButton>) {
179-
const defaultClassNames = getDefaultClassNames()
179+
const defaultClassNames = getDefaultClassNames();
180180

181-
const ref = React.useRef<HTMLButtonElement>(null)
181+
const ref = React.useRef<HTMLButtonElement>(null);
182182
React.useEffect(() => {
183-
if (modifiers.focused) ref.current?.focus()
184-
}, [modifiers.focused])
183+
if (modifiers.focused) ref.current?.focus();
184+
}, [modifiers.focused]);
185185

186186
return (
187187
<Button
@@ -205,7 +205,7 @@ function CalendarDayButton({
205205
)}
206206
{...props}
207207
/>
208-
)
208+
);
209209
}
210210

211-
export { Calendar, CalendarDayButton }
211+
export { Calendar, CalendarDayButton };

apps/web/src/components/ui/popover.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as React from "react"
2-
import * as PopoverPrimitive from "@radix-ui/react-popover"
1+
import * as PopoverPrimitive from "@radix-ui/react-popover";
2+
import * as React from "react";
33

4-
import { cn } from "@/utils/utils"
4+
import { cn } from "@/utils/utils";
55

6-
const Popover = PopoverPrimitive.Root
6+
const Popover = PopoverPrimitive.Root;
77

8-
const PopoverTrigger = PopoverPrimitive.Trigger
8+
const PopoverTrigger = PopoverPrimitive.Trigger;
99

10-
const PopoverAnchor = PopoverPrimitive.Anchor
10+
const PopoverAnchor = PopoverPrimitive.Anchor;
1111

1212
const PopoverContent = React.forwardRef<
1313
React.ElementRef<typeof PopoverPrimitive.Content>,
@@ -25,7 +25,7 @@ const PopoverContent = React.forwardRef<
2525
{...props}
2626
/>
2727
</PopoverPrimitive.Portal>
28-
))
29-
PopoverContent.displayName = PopoverPrimitive.Content.displayName
28+
));
29+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
3030

31-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
31+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };

apps/web/src/components/workflow/fields/blob-field.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ export function BlobField({
173173
Download
174174
</a>
175175
</div>
176-
<video src={objectUrl} controls className="w-full rounded-md border" />
176+
<video
177+
src={objectUrl}
178+
controls
179+
className="w-full rounded-md border"
180+
/>
177181
</div>
178182
);
179183
}

apps/web/src/components/workflow/fields/boolean-field.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ export function BooleanField({
1717

1818
return (
1919
<div
20-
className={cn(
21-
"flex items-center justify-start gap-2 w-full",
22-
className
23-
)}
20+
className={cn("flex items-center justify-start gap-2 w-full", className)}
2421
>
2522
{!disabled && clearable && hasValue && (
2623
<ClearButton onClick={onClear} label="Clear boolean" />

apps/web/src/components/workflow/fields/date-field.tsx

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useState } from "react";
21
import { ChevronDownIcon } from "lucide-react";
2+
import { useState } from "react";
33

44
import { Button } from "@/components/ui/button";
55
import { Calendar } from "@/components/ui/calendar";
@@ -61,11 +61,12 @@ export function DateField({
6161
value,
6262
}: FieldProps) {
6363
// Value can be an ISO string or old format object { date: string, offset: number }
64-
const isoValue = typeof value === "string"
65-
? value
66-
: (value && typeof value === "object" && "date" in value)
67-
? (value as { date: string }).date
68-
: "";
64+
const isoValue =
65+
typeof value === "string"
66+
? value
67+
: value && typeof value === "object" && "date" in value
68+
? (value as { date: string }).date
69+
: "";
6970

7071
// Timezone offset is for display/editing only (not persisted)
7172
const [offset, setOffset] = useState(0);
@@ -133,7 +134,9 @@ export function DateField({
133134
const [hours, minutes, seconds] = timeStr.split(":").map(Number);
134135

135136
// Create a date in UTC with these components
136-
const utcDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
137+
const utcDate = new Date(
138+
Date.UTC(year, month, day, hours, minutes, seconds)
139+
);
137140

138141
// Adjust for the GMT offset to get the actual UTC time
139142
// If offset is -5 (GMT-5), and user selects 14:00, that's 19:00 UTC
@@ -157,29 +160,33 @@ export function DateField({
157160
const [hours, minutes, seconds = 0] = time.split(":").map(Number);
158161

159162
// Get the date part - if no date is set yet, use today's date in the GMT offset
160-
const dateInOffset = dateValue ? getOffsetTime(dateValue) : (() => {
161-
const now = new Date();
162-
const offsetMs = offset * 60 * 60 * 1000;
163-
const offsetNow = new Date(now.getTime() + offsetMs);
164-
return {
165-
year: offsetNow.getUTCFullYear(),
166-
month: offsetNow.getUTCMonth(),
167-
day: offsetNow.getUTCDate(),
168-
hours: offsetNow.getUTCHours(),
169-
minutes: offsetNow.getUTCMinutes(),
170-
seconds: offsetNow.getUTCSeconds(),
171-
};
172-
})();
163+
const dateInOffset = dateValue
164+
? getOffsetTime(dateValue)
165+
: (() => {
166+
const now = new Date();
167+
const offsetMs = offset * 60 * 60 * 1000;
168+
const offsetNow = new Date(now.getTime() + offsetMs);
169+
return {
170+
year: offsetNow.getUTCFullYear(),
171+
month: offsetNow.getUTCMonth(),
172+
day: offsetNow.getUTCDate(),
173+
hours: offsetNow.getUTCHours(),
174+
minutes: offsetNow.getUTCMinutes(),
175+
seconds: offsetNow.getUTCSeconds(),
176+
};
177+
})();
173178

174179
// Create UTC date representing the selected date/time in GMT offset
175-
const utcDate = new Date(Date.UTC(
176-
dateInOffset.year,
177-
dateInOffset.month,
178-
dateInOffset.day,
179-
hours,
180-
minutes,
181-
seconds
182-
));
180+
const utcDate = new Date(
181+
Date.UTC(
182+
dateInOffset.year,
183+
dateInOffset.month,
184+
dateInOffset.day,
185+
hours,
186+
minutes,
187+
seconds
188+
)
189+
);
183190

184191
// Convert from GMT offset to UTC
185192
const offsetMs = offset * 60 * 60 * 1000;

apps/web/src/components/workflow/widgets/blob.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ interface BlobWidgetProps extends BaseWidgetProps {
1414
value: any;
1515
}
1616

17-
function BlobWidget({
18-
value,
19-
onChange,
20-
readonly = false,
21-
}: BlobWidgetProps) {
17+
function BlobWidget({ value, onChange, readonly = false }: BlobWidgetProps) {
2218
const [error, setError] = useState<string | null>(null);
2319
const [fileName, setFileName] = useState<string | null>(() => {
2420
if (value && isObjectReference(value)) {

apps/web/src/components/workflow/workflow-builder.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,19 @@ export function WorkflowBuilder({
226226
}
227227
}, [initialWorkflowExecution, nodes, updateNodeData]);
228228

229-
const resetNodeStates = useCallback((state: NodeExecutionState = "idle") => {
230-
nodes.forEach((node) => {
231-
updateNodeExecution(node.id, {
232-
state,
233-
outputs: {},
234-
error: undefined,
229+
const resetNodeStates = useCallback(
230+
(state: NodeExecutionState = "idle") => {
231+
nodes.forEach((node) => {
232+
updateNodeExecution(node.id, {
233+
state,
234+
outputs: {},
235+
error: undefined,
236+
});
235237
});
236-
});
237-
setWorkflowErrorMessage(undefined);
238-
}, [nodes, updateNodeExecution]);
238+
setWorkflowErrorMessage(undefined);
239+
},
240+
[nodes, updateNodeExecution]
241+
);
239242

240243
const handleExecute = useCallback(() => {
241244
if (!executeWorkflow) return null;

apps/web/src/components/workflow/workflow-canvas.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ export function DeployButton({
322322
);
323323
}
324324

325-
326325
type SidebarToggleProps = {
327326
onClick: (e: React.MouseEvent) => void;
328327
isSidebarVisible: boolean;
@@ -809,7 +808,10 @@ export function WorkflowCanvas({
809808
{/* Publishing Actions Group - Deploy */}
810809
{!disabled && onDeploy && (
811810
<ActionBarGroup>
812-
<DeployButton onClick={onDeploy} disabled={nodes.length === 0} />
811+
<DeployButton
812+
onClick={onDeploy}
813+
disabled={nodes.length === 0}
814+
/>
813815
</ActionBarGroup>
814816
)}
815817

0 commit comments

Comments
 (0)