Skip to content

Commit

Permalink
fix: frontend build
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-vm committed Nov 3, 2023
1 parent 96c001d commit a2409e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { v4 as uuidv4 } from "uuid";
import * as yup from "yup";

import { type IWorkflowPieceData, storageAccessModes } from "../context/types";
import { type DominoWorkflowForage } from "../context/workflowsEditor";
import { type GenerateWorkflowsParams } from "../context/workflowsEditor";
import { containerResourcesSchema } from "../schemas/containerResourcesSchemas";
import { extractDefaultInputValues, extractDefaultValues } from "../utils";
import {
Expand Down Expand Up @@ -233,7 +233,7 @@ export const WorkflowsEditorComponent: React.FC = () => {
const fileInputRef = useRef<HTMLInputElement>(null);

const handleImportedJson = useCallback(
async (json: DominoWorkflowForage) => {
async (json: GenerateWorkflowsParams) => {
try {
if (json) {
const differences = await validateJsonImported(json);
Expand Down
17 changes: 7 additions & 10 deletions frontend/src/features/workflowEditor/context/workflowsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "features/workflows/types";
import React, { type FC, useCallback } from "react";
import { type Edge } from "reactflow";
import { createCustomContext, generateTaskName, getIdSlice } from "utils";
import { createCustomContext, generateTaskName } from "utils";

import {
useReactWorkflowPersistence,
Expand All @@ -32,25 +32,22 @@ import {
} from "./workflowSettingsData";

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type GenerateWorkflowsParams = {
export type GenerateWorkflowsParams = {
workflowPieces: Record<string, Piece>;
workflowPiecesData: ForagePiecesData;
workflowSettingsData: IWorkflowSettings;
workflowNodes: IWorkflowElement[];
workflowEdges: Edge[];
};

export type DominoWorkflowForage = GenerateWorkflowsParams & {
workflowPieces: Record<string, Piece>;
};

interface IWorkflowsEditorContext
extends IReactWorkflowPersistenceContext,
IWorkflowSettingsContext,
IWorkflowPieceContext,
IWorkflowPiecesDataContext {
fetchWorkflowForage: () => Promise<DominoWorkflowForage>;
fetchWorkflowForage: () => Promise<GenerateWorkflowsParams>;
importWorkflowToForage: (
importedWorkflow: DominoWorkflowForage,
importedWorkflow: GenerateWorkflowsParams,
) => Promise<void>;
generateWorkflowsEditorBodyParams: (
p: GenerateWorkflowsParams,
Expand Down Expand Up @@ -119,7 +116,7 @@ const WorkflowsEditorProvider: FC<{ children?: React.ReactNode }> = ({
const workflowSettingsData = await fetchWorkflowSettingsData();
const workflowNodes = await fetchForageWorkflowNodes();
const workflowEdges = await fetchForageWorkflowEdges();
const result: DominoWorkflowForage = {
const result: GenerateWorkflowsParams = {
workflowPieces,
workflowPiecesData,
workflowSettingsData,
Expand All @@ -134,7 +131,7 @@ const WorkflowsEditorProvider: FC<{ children?: React.ReactNode }> = ({
]);

const importWorkflowToForage = useCallback(
async (dominoWorkflow: DominoWorkflowForage) => {
async (dominoWorkflow: GenerateWorkflowsParams) => {
await setForageWorkflowPieces(dominoWorkflow.workflowPieces);
await setForageWorkflowPiecesData(dominoWorkflow.workflowPiecesData);
await setWorkflowSettingsData(dominoWorkflow.workflowSettingsData);
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/features/workflowEditor/utils/importWorkflow.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import localForage from "services/config/localForage.config";
import * as yup from "yup";

import { type DominoWorkflowForage } from "../context/workflowsEditor";
import { type GenerateWorkflowsParams } from "../context/workflowsEditor";

export const importJsonWorkflow = (
e: React.ChangeEvent<HTMLInputElement>,
): Promise<DominoWorkflowForage> | null => {
): Promise<GenerateWorkflowsParams> | null => {
const file = e.target.files?.[0];

if (file) {
return new Promise<DominoWorkflowForage>((resolve, reject) => {
return new Promise<GenerateWorkflowsParams>((resolve, reject) => {
const reader = new FileReader();

reader.onload = (e) => {
try {
const jsonData = JSON.parse(
e.target?.result as string,
) as DominoWorkflowForage;
) as GenerateWorkflowsParams;

resolve(jsonData); // Resolve the promise with the JSON data
} catch (error) {
Expand Down

0 comments on commit a2409e2

Please sign in to comment.