Skip to content

Commit

Permalink
Merge pull request #242 from Tauffer-Consulting/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vinicvaz authored Feb 23, 2024
2 parents 91839d1 + fe8e95f commit 60d1f72
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 121 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pieces_repository_test/*
airflow/*
domino_data/*

.vscode/*

**/**.pyc
**/**.swn
**/**.swl
Expand Down Expand Up @@ -186,10 +184,6 @@ pip-selfcheck.json

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v0.9.1

### Fixes
- [x] Fix Domino k8s Operator to allow handle old pieces without shared storage usage info.
- [x] Fix errors messages on some inputs.
- [x] Fix import incompatible JSONs should not add anything to the workflow.
- [x] Fix new entries of object arrays.

### Docs
- [x] Added how to debug in frontend docs.

# v0.9.0

### Features
Expand Down
51 changes: 51 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,54 @@ DOCKER_BUILDKIT=1 docker build -f ./Dockerfile.prod -t domino-frontend .
```

### [Project Structure](./docs/project-structure.md)


### Debug

#### VSCode:

Create a `.vscode` folder in the root project and add a `launch.json` file in it:

```json
{
"version": "0.2.0",
"configurations": [
// Google Chrome configuration
{
"type": "chrome",
"request": "launch",
"name": "Chrome Debug",
"userDataDir": false,
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend/src",
"enableContentValidation": false,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"pathMapping": {"url": "/src/", "path": "${webRoot}/"}
},
// Microsoft Edge configuration
{
"type": "msedge",
"request": "launch",
"name": "Edge Debug",
"userDataDir": false,
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend/src",
"enableContentValidation": false,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"pathMapping": {"url": "/src/", "path": "${webRoot}/"}
},
]
}
```
2 changes: 2 additions & 0 deletions frontend/src/@types/piece/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ declare global {
type Property = import("./schema").Property;
type SimpleProperty = import("./schema").SimpleProperty;
type ArrayProperty = import("./schema").ArrayProperty;
type AnyOfArray = import("./schema").AnyOfArray;
type AnyOf = import("./schema").AnyOf;
type AnyOfProperty = import("./schema").AnyOfProperty;

type StringProperty = import("./schema").StringProperty;
Expand Down
20 changes: 12 additions & 8 deletions frontend/src/@types/piece/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ export interface Reference {
$ref: `#/$defs/${string}`;
}

type AnyOf = DefaultPropertyAttrs & {
anyOf: Array<{
type: "null" | "number" | "integer" | "string" | "boolean";
widget?: `codeeditor-${string}` | "textarea";
format?: "date" | "time" | "date-time";
}>;
export type AnyOf = DefaultPropertyAttrs & {
anyOf: Array<
{
type: "null" | "number" | "integer" | "string" | "boolean";
widget?: `codeeditor-${string}` | "textarea";
format?: "date" | "time" | "date-time";
} & DefaultPropertyAttrs
>;
default?: any;
};

export type AnyOfArray = DefaultPropertyAttrs & {
anyOf: Array<{ items: AnyOf["anyOf"]; type: "array" } | { type: "null" }>;
anyOf: Array<
{ items: AnyOf["anyOf"] | Reference; type: "array" } | { type: "null" }
>;
default?: any[];
};

Expand All @@ -126,7 +130,7 @@ export type SimpleDefinition =
export interface EnumDefinition {
title: string;
description: string;
type: "string";
type: "string" | "number" | "integer";
enum: string[];
}

Expand Down
61 changes: 49 additions & 12 deletions frontend/src/components/DatetimeInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FormHelperText } from "@mui/material";
import {
DatePicker,
DateTimePicker,
Expand All @@ -14,28 +15,34 @@ import {
type Path,
useFormContext,
} from "react-hook-form";
import { fetchFromObject } from "utils";

interface Props<T> {
label: string;
name: Path<T>;
type?: "time" | "date" | "date-time";
defaultValue?: Date;
defaultValue?: string | null;
}

function DatetimeInput<T extends FieldValues>({
label,
name,
type = "date",
defaultValue = new Date(),
defaultValue = null,
}: Props<T>) {
const { control } = useFormContext();
const {
control,
formState: { errors },
} = useFormContext();

const error = fetchFromObject(errors, name);

switch (type) {
case "date-time": {
const defaultDateTime = dayjs(
defaultValue ?? new Date(),
"YYYY-MM-DD HH:mm",
);
const defaultDateTime =
typeof defaultValue === "string"
? dayjs(new Date(defaultValue), "YYYY-MM-DD HH:mm")
: defaultValue;

return (
<Controller
Expand All @@ -49,10 +56,18 @@ function DatetimeInput<T extends FieldValues>({
label={label}
ampm={false}
format="DD/MM/YYYY HH:mm"
value={dayjs(value)}
value={value ? dayjs(value) : null}
onChange={(e) => {
e?.isValid() ? onChange(e.toISOString()) : onChange(null);
}}
slotProps={{
textField: {
error: !!error,
helperText: (
<FormHelperText error>{error?.message}</FormHelperText>
),
},
}}
{...rest}
/>
</DemoContainer>
Expand All @@ -62,7 +77,10 @@ function DatetimeInput<T extends FieldValues>({
);
}
case "time": {
const defaultTime = dayjs(defaultValue ?? new Date(), "HH:mm");
const defaultTime =
typeof defaultValue === "string"
? dayjs(defaultValue, "HH:mm")
: defaultValue;

return (
<Controller
Expand All @@ -77,12 +95,20 @@ function DatetimeInput<T extends FieldValues>({
label={label}
format="HH:mm"
sx={{ width: "100%" }}
value={dayjs(value as string, "HH:mm")}
value={value ? dayjs(value as string, "HH:mm") : null}
onChange={(e) => {
e?.isValid()
? onChange(dayjs(e).format("HH:mm") as any)
: onChange(null);
}}
slotProps={{
textField: {
error: !!error,
helperText: (
<FormHelperText error>{error?.message}</FormHelperText>
),
},
}}
{...rest}
/>
</DemoContainer>
Expand All @@ -94,7 +120,10 @@ function DatetimeInput<T extends FieldValues>({
case "date":
default:
// eslint-disable-next-line no-case-declarations
const defaultDate = dayjs(defaultValue ?? new Date(), "YYYY-MM-DD");
const defaultDate =
typeof defaultValue === "string"
? dayjs(defaultValue, "YYYY-MM-DD")
: defaultValue;

return (
<Controller
Expand All @@ -109,12 +138,20 @@ function DatetimeInput<T extends FieldValues>({
views={["day", "month", "year"]}
format="DD/MM/YYYY"
sx={{ width: "100%" }}
value={dayjs(value as string)}
value={value ? dayjs(value as string) : null}
onChange={(e) => {
e?.isValid()
? onChange(dayjs(e).format("YYYY-MM-DD") as any)
: onChange(null);
}}
slotProps={{
textField: {
error: !!error,
helperText: (
<FormHelperText error>{error?.message}</FormHelperText>
),
},
}}
{...rest}
/>
</LocalizationProvider>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/context/workspaces/workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const WorkspacesProvider: FC<IWorkspacesProviderProps> = ({
async (name: string) =>
await postWorkspace({ name })
.then((data) => {
toast.success(`Workflow ${name} created successfully`);
toast.success(`Workspace ${name} created successfully`);
void workspacesRefresh();
return data;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ export const TaskResult = ({
isLoading,
}: ITaskResultProps) => {
const style: CSSProperties = {
height: "100%",
width: "100%",
overflowY: "scroll",
overflowY: "auto",
overflowX: "hidden",
wordWrap: "break-word",
whiteSpace: "pre-wrap",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export const WorkflowDetail: React.FC = () => {
const fetchWorkflowTasks = useAuthenticatedGetWorkflowRunTasks();
const handleRunWorkflow = useAuthenticatedPostWorkflowRunId();

const triggerRun = () => {
if (workflow?.id) {
void handleRunWorkflow({ id: String(workflow.id) });
setInterval(() => {
setAutoUpdate(true);
}, 1500);
}
};

const refreshDetails = useCallback(() => {
void workflowRunDetailRef.current?.refreshTaskLogs();
void workflowRunDetailRef.current?.refreshTaskResults();
Expand Down Expand Up @@ -208,12 +217,7 @@ export const WorkflowDetail: React.FC = () => {
{/* WorkflowRunsTable */}
<Grid item xs={12} sx={{ paddingLeft: "1rem" }}>
<WorkflowRunsTable
triggerRun={() => {
if (workflow?.id) {
void handleRunWorkflow({ id: String(workflow.id) });
setAutoUpdate(true);
}
}}
triggerRun={triggerRun}
refresh={refresh}
selectedRun={selectedRun}
ref={workflowRunsTableRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const ButtonsMenu: React.FC<Props> = ({

setIncompatiblesPieces(differences);
incompatiblePiecesModalRef.current?.open();
return;
}

handleImported(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export const ContainerResourceFormSchema: yup.ObjectSchema<IContainerResourceFor
min: yup
.number()
.integer()
.typeError("Must must be a number")
.transform((value) => (isNaN(value) ? undefined : value))
.max(maxAcceptedCpu)
.min(minAcceptedCpu)
.required(),
max: yup
.number()
.integer()
.typeError("Must be a number")
.transform((value) => (isNaN(value) ? undefined : value))
.max(maxAcceptedCpu)
.when("min", ([min], schema) => schema.min(min))
.required(),
Expand Down
Loading

0 comments on commit 60d1f72

Please sign in to comment.