Skip to content

Commit

Permalink
Merge pull request #123 from Tauffer-Consulting/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vinicvaz authored Oct 25, 2023
2 parents 4bcd89a + 37c6d5d commit f1ce82f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 21 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.3.14
- DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION=0.4.2
- 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
2 changes: 1 addition & 1 deletion frontend/src/components/DatetimeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function DatetimeInput<T extends FieldValues>({
format="DD/MM/YYYY HH:mm"
value={dayjs(value)}
onChange={(e) => {
onChange(dayjs(e).toISOString() as any);
e?.isValid() ? onChange(e.toISOString()) : onChange(null);
}}
{...rest}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const CustomNode = memo<DefaultNodeProps>(({ id, data, selected }) => {
style: {
width: "20px",
height: "20px",
margin: "5px",
...data.style.iconStyle,
},
};
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/WorkflowPanel/RunNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ const RunNode = memo<RunNodeProps>(({ id, data, selected }) => {
flexDirection: "row",
justifyContent: "center",
alignItems: "center",

textAlign: "center",
position: "relative",
padding: 1,
width: 150,
height: 70,
lineHeight: "60px",
Expand Down Expand Up @@ -126,6 +127,7 @@ const RunNode = memo<RunNodeProps>(({ id, data, selected }) => {
style: {
width: "20px",
height: "20px",
margin: "5px",
...data.style.iconStyle,
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import localforage from "localforage";
import React, {
type ReactNode,
useCallback,
Expand All @@ -9,6 +8,7 @@ import React, {
} from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import localForage from "services/config/localForage.config";
import { createCustomContext } from "utils";

import { postAuthLogin, postAuthRegister } from "./api";
Expand Down Expand Up @@ -54,7 +54,7 @@ export const AuthenticationProvider: React.FC<{ children: ReactNode }> = ({

const logout = useCallback(() => {
localStorage.clear();
void localforage.clear();
void localForage.clear();
isLogged.current = false;
setStore((store) => ({
...store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const PieceFormItem: React.FC<PieceFormItemProps> = ({
alignItems="flex-start"
sx={{ paddingTop: "10px" }}
>
<Grid item xs={12}>
<Grid item xs={10}>
{inputElement}
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const validationObject = () => {
});
};

function getValidationValueBySchemaType(schema: any) {
function getValidationValueBySchemaType(schema: any, required: boolean) {
let inputSchema;

if (schema.type === "number" && !schema.format) {
Expand All @@ -74,7 +74,7 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.number().typeError("Must must be a number").required();
return yup.number().typeError("Must must be a number").required(); // number is always required
}),
});
} else if (schema.type === "integer" && !schema.format) {
Expand All @@ -88,7 +88,7 @@ function getValidationValueBySchemaType(schema: any) {
.number()
.integer()
.typeError("Must must be a number")
.required();
.required(); // number is always required
}),
});
} else if (schema.type === "boolean" && !schema.format) {
Expand All @@ -98,7 +98,7 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.boolean().required();
return yup.boolean().required(); // boolean is always required
}),
});
} else if (schema.type === "string" && schema.format === "date") {
Expand All @@ -108,7 +108,7 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.string().required();
return yup.date().required(); // date is always required
}),
});
} else if (schema.type === "string" && schema?.format === "time") {
Expand All @@ -118,7 +118,13 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.string().required();
return yup
.string()
.required("Time is required")
.test("valid-datetime", "Invalid time format", (value) => {
const timeRegex = /^\d{2}:\d{2}(:\d{2})?$/;
return timeRegex.test(value);
}); // Time is always required
}),
});
} else if (schema.type === "string" && schema?.format === "date-time") {
Expand All @@ -128,7 +134,14 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.string().required();
return yup
.string()
.required("Datetime is required") // Change the error message as needed
.test("valid-datetime", "Invalid datetime format", (value) => {
const dateTimeRegex =
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(?:\.\d{1,3})?)?Z?$/;
return dateTimeRegex.test(value);
}); // Datetime is always required
}),
});
} else if (schema.type === "string" && schema?.widget === "codeeditor") {
Expand All @@ -138,7 +151,7 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.string();
return required ? yup.string().required() : yup.string();
}),
});
} else if (schema.type === "string" && !schema.format) {
Expand All @@ -148,7 +161,7 @@ function getValidationValueBySchemaType(schema: any) {
if (fromUpstream) {
return yup.mixed().notRequired();
}
return yup.string().required();
return required ? yup.string().required() : yup.string();
}),
});
} else if (schema.type === "object") {
Expand All @@ -165,6 +178,8 @@ export function createInputsSchemaValidation(schema: any) {
return yup.mixed().notRequired();
}

const requiredFields = schema?.required || [];

const validationSchema = Object.entries(schema.properties).reduce(
(acc, cur: [string, any]) => {
const [key, subSchema] = cur;
Expand All @@ -176,14 +191,16 @@ export function createInputsSchemaValidation(schema: any) {
const subItemSchemaName = subSchema.items.$ref.split("/").pop();
subItemSchema = schema.definitions?.[subItemSchemaName];
}
const required = true; // for arrays, we always require the value
inputSchema = yup.object({
...defaultValidation,
value: yup
.array()
.of(getValidationValueBySchemaType(subItemSchema) as any),
.of(getValidationValueBySchemaType(subItemSchema, required) as any),
});
} else {
inputSchema = getValidationValueBySchemaType(subSchema);
const required = requiredFields.includes(key);
inputSchema = getValidationValueBySchemaType(subSchema, required);
}

return { ...acc, [key]: inputSchema };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ const SidebarPieceForm: React.FC<ISidebarPieceFormProps> = (props) => {
</Typography>

<Grid container>
<div style={{ display: "flex", flexDirection: "column" }}>
<div
style={{
display: "flex",
flexDirection: "column",
maxWidth: "100%",
}}
>
<Grid container spacing={2} sx={{ marginBottom: "20px" }}>
<Grid item xs={10}>
<Typography
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/features/workflowEditor/utils/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export const extractDefaultValues = (
output[key] = value.default;
} else if ("properties" in value) {
output[key] = extractDefaultValues(value as any, output[key]);
} else {
output[key] = "";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const TaskResult = (props: ITaskResultProps) => {
if (!base64_content || !file_type) {
return <Typography variant="h2">No content</Typography>;
}

switch (file_type) {
case "txt":
return <pre style={style}>{window.atob(base64_content)}</pre>;
Expand Down Expand Up @@ -61,7 +60,12 @@ export const TaskResult = (props: ITaskResultProps) => {
</object>
);
case "md":
return <ReactMarkdown>{window.atob(base64_content)}</ReactMarkdown>;
return (
<div style={{ overflow: "auto" }} className="markdown-container">
<ReactMarkdown>{window.atob(base64_content)}</ReactMarkdown>;
</div>
);

case "pdf":
return (
<div style={{ width: "100%", ...style }}>
Expand Down
2 changes: 1 addition & 1 deletion rest/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Settings(BaseSettings):

# Default domino pieces repository
DOMINO_DEFAULT_PIECES_REPOSITORY = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY', "Tauffer-Consulting/default_domino_pieces")
DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION', "0.3.14")
DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_VERSION', "0.4.2")
DOMINO_DEFAULT_PIECES_REPOSITORY_SOURCE = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_SOURCE', "github")
DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN: EmptyStrToNone = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_TOKEN', "")
DOMINO_DEFAULT_PIECES_REPOSITORY_URL: str = os.environ.get('DOMINO_DEFAULT_PIECES_REPOSITORY_URL', 'https://github.com/Tauffer-Consulting/default_domino_pieces')
Expand Down

0 comments on commit f1ce82f

Please sign in to comment.