Skip to content

Commit

Permalink
Merge pull request #134 from Tauffer-Consulting/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vinicvaz authored Oct 31, 2023
2 parents f1ce82f + 48fd524 commit eb62a84
Show file tree
Hide file tree
Showing 33 changed files with 845 additions and 424 deletions.
2 changes: 1 addition & 1 deletion docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ services:
- DOMINO_DB_HOST=domino_postgres
- DOMINO_DB_PORT=5432
- DOMINO_DB_NAME=postgres
- DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION=0.4.2
- DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION=0.4.3
- DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN=${DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN}
- DOMINO_GITHUB_ACCESS_TOKEN_WORKFLOWS=${DOMINO_GITHUB_ACCESS_TOKEN_WORKFLOWS}
- DOMINO_GITHUB_WORKFLOWS_REPOSITORY=${DOMINO_GITHUB_WORKFLOWS_REPOSITORY}
Expand Down
31 changes: 24 additions & 7 deletions frontend/src/components/CodeEditorInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import {
useFormContext,
} from "react-hook-form";

const CodeEditorItem = React.forwardRef<HTMLTextAreaElement>(
({ ...register }, ref) => (
interface Props {
language?: string;
placeholder?: string;
}

const CodeEditorItem = React.forwardRef<HTMLTextAreaElement, Props>(
({ language = "python", placeholder, ...register }, ref) => (
<CodeEditor
language="python"
placeholder="Enter Python code."
language={language}
placeholder={placeholder ?? ""}
padding={15}
style={{
fontSize: 12,
Expand All @@ -33,18 +38,30 @@ const CodeEditorItem = React.forwardRef<HTMLTextAreaElement>(

CodeEditorItem.displayName = "CodeEditorItem";

interface Props<T> {
interface CodeEditorInputProps<T> {
name: Path<T>;
language?: string;
placeholder?: string;
}

function CodeEditorInput<T extends FieldValues>({ name }: Props<T>) {
function CodeEditorInput<T extends FieldValues>({
name,
language,
placeholder,
}: CodeEditorInputProps<T>) {
const { control } = useFormContext();

return (
<Controller
name={name}
control={control}
render={({ field }) => <CodeEditorItem {...field} />}
render={({ field }) => (
<CodeEditorItem
language={language}
placeholder={placeholder}
{...field}
/>
)}
/>
);
}
Expand Down
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 @@ -155,10 +155,40 @@ const PieceFormItem: React.FC<PieceFormItemProps> = ({
"type" in schema &&
"widget" in schema &&
schema.type === "string" &&
schema.widget === "codeeditor"
(schema.widget === "codeeditor" || schema.widget === "codeeditor-python")
) {
inputElement = (
<CodeEditorInput<IWorkflowPieceData> name={`inputs.${itemKey}.value`} />
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="python"
placeholder="Enter Python code."
/>
);
} else if (
"type" in schema &&
"widget" in schema &&
schema.type === "string" &&
schema.widget === "codeeditor-json"
) {
inputElement = (
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="json"
placeholder="Enter JSON code."
/>
);
} else if (
"type" in schema &&
"widget" in schema &&
schema.type === "string" &&
schema.widget === "codeeditor-sql"
) {
inputElement = (
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="sql"
placeholder="Enter SQL code."
/>
);
} else if (
"type" in schema &&
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 eb62a84

Please sign in to comment.