Skip to content

Commit

Permalink
Merge pull request #125 from Tauffer-Consulting/feature/sharable-work…
Browse files Browse the repository at this point in the history
…flows

Feature/sharable workflows
  • Loading branch information
luiztauffer authored Oct 28, 2023
2 parents be887dc + 3116618 commit 031b35e
Show file tree
Hide file tree
Showing 14 changed files with 468 additions and 188 deletions.
81 changes: 81 additions & 0 deletions frontend/src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
Grid,
} from "@mui/material";
import React, { useCallback, useImperativeHandle, useState } from "react";

interface Props {
title: string;
content?: string | React.ReactNode;

confirmFn?: () => void;
cancelFn?: () => void;
}

export interface ModalRef {
open: () => void;
close: () => void;
}

export const Modal = React.forwardRef<ModalRef, Props>(
({ cancelFn, confirmFn, title, content }, ref) => {
const [isOpen, setIsOpen] = useState(false);

const open = () => {
setIsOpen(true);
};

const handleClose = useCallback(() => {
if (cancelFn) {
cancelFn();
}

setIsOpen(false);
}, []);

const handleConfirm = useCallback(() => {
if (confirmFn) {
confirmFn();
}

setIsOpen(false);
}, []);

useImperativeHandle(ref, () => ({
open,
close: handleClose,
}));

return (
<Dialog open={isOpen} onClose={handleClose}>
<DialogTitle>{title}</DialogTitle>
<DialogContent>
<DialogContentText>{content}</DialogContentText>
</DialogContent>
<DialogActions>
<Grid container justifyContent="center" spacing={4}>
{cancelFn && (
<Grid item>
<Button onClick={handleClose} variant="contained">
Cancel
</Button>
</Grid>
)}
<Grid item>
<Button onClick={handleConfirm} variant="contained">
OK
</Button>
</Grid>
</Grid>
</DialogActions>
</Dialog>
);
},
);

Modal.displayName = "Modal";
43 changes: 0 additions & 43 deletions frontend/src/components/NewFeatureDialog/index.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/components/WorkflowPanel/DefaultNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const CustomNode = memo<DefaultNodeProps>(({ id, data, selected }) => {
...data.style.nodeStyle,
display: "flex",
flexDirection: "row",
justifyContent: "center",
justifyContent: "space-evenly",
alignItems: "center",

position: "relative",
Expand All @@ -88,7 +88,7 @@ export const CustomNode = memo<DefaultNodeProps>(({ id, data, selected }) => {
backgroundColor: theme.palette.error.light,
color: theme.palette.error.contrastText,
}),
};
} satisfies CSSProperties;
}, [data, selected]);

const { sourcePosition, targetPosition } = useMemo(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/WorkflowPanel/RunNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const RunNode = memo<RunNodeProps>(({ id, data, selected }) => {
...data.style.nodeStyle,
display: "flex",
flexDirection: "row",
justifyContent: "center",
justifyContent: "space-evenly",
alignItems: "center",
textAlign: "center",
position: "relative",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SidebarPieceForm: React.FC<ISidebarPieceFormProps> = (props) => {
const { schema, formId, open, onClose, title } = props;

const {
setForageWorkflowPiecesData,
setForageWorkflowPiecesDataById,
fetchForageWorkflowPiecesDataById,
setForageWorkflowPiecesOutputSchema,
clearDownstreamDataById,
Expand Down Expand Up @@ -141,10 +141,10 @@ const SidebarPieceForm: React.FC<ISidebarPieceFormProps> = (props) => {

const saveData = useCallback(async () => {
if (formId && open) {
await setForageWorkflowPiecesData(formId, data as IWorkflowPieceData);
await setForageWorkflowPiecesDataById(formId, data as IWorkflowPieceData);
await updateOutputSchema();
}
}, [formId, open, setForageWorkflowPiecesData, data, updateOutputSchema]);
}, [formId, open, setForageWorkflowPiecesDataById, data, updateOutputSchema]);

// load forage
useEffect(() => {
Expand Down
Loading

0 comments on commit 031b35e

Please sign in to comment.