From 7c4bbfabd7962d049d296133705c4cf690a209cb Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sun, 4 Jan 2026 16:36:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`workflo?= =?UTF-8?q?w-ui-fixes`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @TejaBudumuru3. * https://github.com/Dev-Pross/BuildFlow/pull/48#issuecomment-3708231042 The following files were modified: * `apps/http-backend/src/index.ts` * `apps/web/app/components/nodes/CreateWorkFlow.tsx` * `apps/web/app/components/nodes/GoogleSheetFormClient.tsx` * `apps/web/app/components/nodes/actions.ts` * `apps/web/app/components/ui/app-sidebar.tsx` --- apps/http-backend/src/index.ts | 9 +++++++-- apps/web/app/components/nodes/CreateWorkFlow.tsx | 13 ++++++++++++- .../components/nodes/GoogleSheetFormClient.tsx | 12 +++++++++++- apps/web/app/components/nodes/actions.ts | 15 ++++++++++++++- apps/web/app/components/ui/app-sidebar.tsx | 7 +++++++ 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/apps/http-backend/src/index.ts b/apps/http-backend/src/index.ts index 7fc1d35..e28526c 100644 --- a/apps/http-backend/src/index.ts +++ b/apps/http-backend/src/index.ts @@ -39,7 +39,12 @@ app.use("/user" , userRouter) app.use('/node', sheetRouter) app.use('/google', googleAuth) const PORT= 3002 -async function startServer() { +/** + * Initialize runtime and start the HTTP server. + * + * Registers all nodes, starts the token scheduler, and begins listening on the configured port. + */ + async function startServer() { await NodeRegistry.registerAll() tokenScheduler.start(); app.listen(PORT, () => { @@ -48,4 +53,4 @@ async function startServer() { } - startServer() + startServer() \ No newline at end of file diff --git a/apps/web/app/components/nodes/CreateWorkFlow.tsx b/apps/web/app/components/nodes/CreateWorkFlow.tsx index 7eb41bf..e9fea62 100644 --- a/apps/web/app/components/nodes/CreateWorkFlow.tsx +++ b/apps/web/app/components/nodes/CreateWorkFlow.tsx @@ -137,6 +137,12 @@ export const CreateWorkFlow = () => { dispatch(workflowActions.setWorkflowStatus(newWorkflow.isEmpty)) } } + /** + * Fetches workflow data for the current `workflowId` and updates Redux workflow state when successful. + * + * If `workflowId` is not set, the function returns without performing any action. On successful fetch, + * it dispatches actions to mark the workflow as non-empty, populate workflow nodes, and set the workflow trigger. + */ async function getWorkflowData(){ if(!workflowId) return const workflow = await getworkflowData(workflowId) @@ -158,6 +164,11 @@ export const CreateWorkFlow = () => { return; // Keep the current placeholder state } + /** + * Build node and edge lists from Redux workflow data and replace the local React Flow state. + * + * Constructs a sequence of nodes from `existingTrigger` and `existingNodes`, positions them horizontally with a constant gap, appends a trailing placeholder node, and creates edges that connect each node to the next. Node IDs follow the conventions `trigger~{id}` for the trigger and `action~{id}~{index}` for actions. Finally, updates the component state by calling `setNodes` and `setEdges`. + */ function loadWorkflow(){ const START_X = 100; const GAP = 250; @@ -357,4 +368,4 @@ export const CreateWorkFlow = () => { ); }; -export default CreateWorkFlow; +export default CreateWorkFlow; \ No newline at end of file diff --git a/apps/web/app/components/nodes/GoogleSheetFormClient.tsx b/apps/web/app/components/nodes/GoogleSheetFormClient.tsx index 4e29a97..131f809 100644 --- a/apps/web/app/components/nodes/GoogleSheetFormClient.tsx +++ b/apps/web/app/components/nodes/GoogleSheetFormClient.tsx @@ -28,6 +28,16 @@ interface GoogleSheetFormClientProps { }; } +/** + * Renders a Google Sheets configuration form for selecting a credential, spreadsheet, sheet, operation, and range, and for saving or updating the node configuration. + * + * @param type - Credential type used to load available Google credentials + * @param nodeType - Node type string containing the node kind and node id separated by `~` + * @param avlNode - Optional external node identifier (accepted for API compatibility) + * @param position - Position index of the node within the workflow + * @param initialData - Optional initial configuration used to pre-populate the form; may include `credentialId`, `spreadSheetId`, `sheetName`, `operation`, and `range` + * @returns The rendered JSX element for the form + */ export function GoogleSheetFormClient({ type, nodeType, avlNode, position, initialData }: GoogleSheetFormClientProps) { const [selectedCredential, setSelectedCredential] = useState(initialData?.credentialId || ''); const [documents, setDocuments] = useState>([]); @@ -418,4 +428,4 @@ export function GoogleSheetFormClient({ type, nodeType, avlNode, position, initi ); -} +} \ No newline at end of file diff --git a/apps/web/app/components/nodes/actions.ts b/apps/web/app/components/nodes/actions.ts index 9bd6cb4..aa42bd8 100644 --- a/apps/web/app/components/nodes/actions.ts +++ b/apps/web/app/components/nodes/actions.ts @@ -1,4 +1,3 @@ - import { createNode, createTrigger, updateNode, updateTrigger } from '@/app/workflow/lib/config'; interface SaveConfigFormData { @@ -26,6 +25,14 @@ interface updateConfigData{ id: string } +/** + * Create a node or trigger from the provided Google Sheets configuration and return the backend result. + * + * Builds a config object from the supplied form data, calls the trigger creation path when `formData.type === 'trigger'`, or the node creation path otherwise, and returns the service response. + * + * @param formData - Form values containing type, credentialId, spreadsheetId, sheetName, operation, range, name, node_Trigger, workflowId, and optional position + * @returns `{ success: boolean, data: any }` where `success` indicates operation outcome and `data` contains the created entity or backend payload + */ export async function handleSaveConfig(formData: SaveConfigFormData) { // const executor = new GoogleSheetsNodeExecutor(); const context = { @@ -73,6 +80,12 @@ export async function handleSaveConfig(formData: SaveConfigFormData) { // }; } +/** + * Updates an existing node or trigger configuration using the provided form data. + * + * @param formData - Payload containing `id`, `type` ('trigger' or other), and updated config fields: `credentialId`, `spreadsheetId`, `sheetName`, `operation`, and `range` + * @returns An object with `success` indicating whether the update succeeded and `data` containing the updated resource payload + */ export async function handleUpdateConfig(formData: updateConfigData){ const data = { id: formData.id, diff --git a/apps/web/app/components/ui/app-sidebar.tsx b/apps/web/app/components/ui/app-sidebar.tsx index 9f1043f..dad84b3 100644 --- a/apps/web/app/components/ui/app-sidebar.tsx +++ b/apps/web/app/components/ui/app-sidebar.tsx @@ -34,6 +34,13 @@ import { toast } from 'sonner' import { signOut } from 'next-auth/react' import { useRouter } from 'next/navigation' +/** + * Render the application's sidebar with workflow and credential management controls and the user menu. + * + * Loads workflows and credentials, updates Redux with selected workflow and fetched workflow data, provides actions to create a new workflow and sign out, and exposes UI for selecting workflows and credentials. + * + * @returns The sidebar JSX element containing the create-workflow button, workflow and credential lists, and the user dropdown menu. + */ export function AppSidebar() { const user = useAppSelector((s)=> s.user)