From 80a61ad66fe302fa8967926ad777ed363870e70f Mon Sep 17 00:00:00 2001 From: Nathan Vieira Marcelino Date: Thu, 2 Nov 2023 16:01:49 -0300 Subject: [PATCH 1/8] refactor: dont export settings from workflow --- .../components/WorkflowEditor.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx b/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx index 407edd04..3651da5c 100644 --- a/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx +++ b/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx @@ -227,7 +227,13 @@ export const WorkflowsEditorComponent: React.FC = () => { toast.error("Workflow must have at least one piece to be exported."); return; } - exportToJson(payload, payload.workflowSettingsData?.config?.name); + const name = payload.workflowSettingsData?.config?.name; + + const exportedJson: any = { ...payload }; + + delete exportedJson.workflowSettingsData; + + exportToJson(exportedJson, name); }, []); const fileInputRef = useRef(null); @@ -445,7 +451,7 @@ export const WorkflowsEditorComponent: React.FC = () => { startIcon={} onClick={handleSaveWorkflow} > - Save + Create @@ -509,11 +515,9 @@ export const WorkflowsEditorComponent: React.FC = () => { "aria-labelledby": "import-button", }} > - - Import from file - + from file - Import from examples + from examples gallery { @@ -521,7 +525,7 @@ export const WorkflowsEditorComponent: React.FC = () => { }} disabled > - Import from workflows + from my workflows Date: Fri, 3 Nov 2023 14:33:24 -0300 Subject: [PATCH 2/8] refactor: rename worflows to my workflows --- frontend/src/components/Breadcrumbs/index.tsx | 21 ++++++++++++++++--- .../PrivateLayout/header/drawerMenu.tsx | 6 +++--- .../WorkflowPanel/RunNode/index.tsx | 2 +- .../src/components/WorkflowPanel/types.ts | 2 +- .../src/context/workspaces/repositories.tsx | 2 +- .../{workflows => myWorkflows}/api/index.ts | 0 .../api/piece/getPieceRepositories.request.ts | 0 .../api/piece/getPieceRepositoryPieces.ts | 0 .../getPiecesRepositoriesReleases.request.ts | 0 .../api/piece/index.ts | 0 .../api/piece/piece.interface.ts | 0 .../deletePieceRepository.request.ts | 0 .../getPieceRepositorySecrets.request.ts | 0 .../api/repository/index.ts | 0 .../patchPieceRepositorySecret.request.ts | 0 .../repository/pieceRepository.interface.ts | 0 .../api/runs/getWorkflowRunTaskLogs.ts | 0 .../api/runs/getWorkflowRunTaskResult.ts | 0 .../api/runs/getWorkflowRunTasks.ts | 2 +- .../api/runs/getWorkflowRuns.ts | 2 +- .../api/runs/index.ts | 0 .../api/workflow/deleteWorkflowId.ts | 2 +- .../api/workflow/getWorkflow.ts | 2 +- .../api/workflow/getWorkflowId.ts | 2 +- .../api/workflow/index.ts | 0 .../api/workflow/postWorkflow.ts | 2 +- .../api/workflow/postWorkflowRunId.ts | 2 +- .../CustomTabMenu/CustomTabMenu.tsx | 0 .../CustomTabMenu/CustomTabPanel.tsx | 0 .../CustomTabMenu/TaskDetail.tsx | 4 ++-- .../WorkflowDetail/CustomTabMenu/TaskLogs.tsx | 0 .../CustomTabMenu/TaskResult.tsx | 0 .../WorkflowDetail/CustomTabMenu/index.ts | 0 .../WorkflowDetail/States/index.tsx | 2 +- .../WorkflowDetail/WorkflowRunDetail.tsx | 2 +- .../WorkflowRunTableFooter/index.tsx | 0 .../WorkflowDetail/WorkflowRunsTable.tsx | 4 ++-- .../components/WorkflowDetail/index.tsx | 4 ++-- .../components/WorkflowsList/Actions.tsx | 2 +- .../WorkflowsList/ConfirmDeleteModal.tsx | 0 .../components/WorkflowsList/Status.tsx | 0 .../WorkflowsList/WorkflowsListSkeleton.tsx | 0 .../components/WorkflowsList/index.tsx | 4 ++-- .../constants/index.ts | 0 .../{workflows => myWorkflows}/index.ts | 0 .../pages/WorkflowDetailPage.tsx | 0 .../pages/WorkflowsPage.tsx | 0 .../{workflows => myWorkflows}/pages/index.ts | 0 .../{workflows => myWorkflows}/types/index.ts | 0 .../{workflows => myWorkflows}/types/runs.ts | 0 .../types/workflow.ts | 0 .../context/reactWorkflowPersistence.tsx | 2 +- .../context/types/workflowPieceData.ts | 2 +- .../context/workflowsEditor.tsx | 4 ++-- .../workspaceSettings/RepositoriesCard.tsx | 2 +- .../workspaceSettings/SecretsCard.tsx | 2 +- .../workspaceSettings/StorageSecretsCard.tsx | 2 +- .../workspaces/context/workspaceSettings.tsx | 2 +- frontend/src/routes/index.tsx | 8 +++---- 59 files changed, 54 insertions(+), 39 deletions(-) rename frontend/src/features/{workflows => myWorkflows}/api/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/piece/getPieceRepositories.request.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/piece/getPieceRepositoryPieces.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/piece/getPiecesRepositoriesReleases.request.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/piece/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/piece/piece.interface.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/repository/deletePieceRepository.request.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/repository/getPieceRepositorySecrets.request.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/repository/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/repository/patchPieceRepositorySecret.request.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/repository/pieceRepository.interface.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/runs/getWorkflowRunTaskLogs.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/runs/getWorkflowRunTaskResult.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/runs/getWorkflowRunTasks.ts (98%) rename frontend/src/features/{workflows => myWorkflows}/api/runs/getWorkflowRuns.ts (98%) rename frontend/src/features/{workflows => myWorkflows}/api/runs/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/deleteWorkflowId.ts (97%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/getWorkflow.ts (93%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/getWorkflowId.ts (93%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/postWorkflow.ts (91%) rename frontend/src/features/{workflows => myWorkflows}/api/workflow/postWorkflowRunId.ts (97%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/CustomTabMenu.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/CustomTabPanel.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx (97%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/TaskLogs.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/TaskResult.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/CustomTabMenu/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/States/index.tsx (95%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/WorkflowRunDetail.tsx (98%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/WorkflowRunTableFooter/index.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/WorkflowRunsTable.tsx (97%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowDetail/index.tsx (98%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowsList/Actions.tsx (97%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowsList/ConfirmDeleteModal.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowsList/Status.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowsList/WorkflowsListSkeleton.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/components/WorkflowsList/index.tsx (98%) rename frontend/src/features/{workflows => myWorkflows}/constants/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/pages/WorkflowDetailPage.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/pages/WorkflowsPage.tsx (100%) rename frontend/src/features/{workflows => myWorkflows}/pages/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/types/index.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/types/runs.ts (100%) rename frontend/src/features/{workflows => myWorkflows}/types/workflow.ts (100%) diff --git a/frontend/src/components/Breadcrumbs/index.tsx b/frontend/src/components/Breadcrumbs/index.tsx index 53556f9d..09d201ef 100644 --- a/frontend/src/components/Breadcrumbs/index.tsx +++ b/frontend/src/components/Breadcrumbs/index.tsx @@ -8,6 +8,21 @@ export const Breadcrumbs: React.FC = () => { const location = useLocation(); const pathnames = location.pathname.split("/").filter((x) => x); + const formatBreadcrumbLabel = (value: string) => { + // Remove dashes and other special characters and add spaces + const formattedValue = value + .replace(/[-_]+/g, " ") + .replace(/([a-z])([A-Z])/g, "$1 $2"); + + // Capitalize the first letter of each word + const words = formattedValue.split(" "); + const capitalizedWords = words.map((word) => { + return word.charAt(0).toUpperCase() + word.slice(1); + }); + + return capitalizedWords.join(" "); + }; + return ( { {pathnames.map((value, index) => { const last = index === pathnames.length - 1; const to = `/${pathnames.slice(0, index + 1).join("/")}`; - const capitalizedValue = value.charAt(0).toUpperCase() + value.slice(1); + const formattedValue = formatBreadcrumbLabel(value); return last ? ( { userSelect: "none", }} > - {capitalizedValue} + {formattedValue} ) : ( { }} > - {capitalizedValue} + {formattedValue} ); diff --git a/frontend/src/components/PrivateLayout/header/drawerMenu.tsx b/frontend/src/components/PrivateLayout/header/drawerMenu.tsx index b9c6dfe1..b55b3989 100644 --- a/frontend/src/components/PrivateLayout/header/drawerMenu.tsx +++ b/frontend/src/components/PrivateLayout/header/drawerMenu.tsx @@ -107,12 +107,12 @@ export const DrawerMenu: FC = ({ isOpen, handleClose }) => { { - if (workspace?.id) navigate("/workflows"); + if (workspace?.id) navigate("/my-workflows"); }} icon={} - label={"Workflows"} + label={"My Workflows"} isMenuOpen={isOpen} disabled={!workspace?.id} /> diff --git a/frontend/src/components/WorkflowPanel/RunNode/index.tsx b/frontend/src/components/WorkflowPanel/RunNode/index.tsx index d3f844a4..2a4354a5 100644 --- a/frontend/src/components/WorkflowPanel/RunNode/index.tsx +++ b/frontend/src/components/WorkflowPanel/RunNode/index.tsx @@ -1,7 +1,7 @@ /* eslint-disable no-prototype-builtins */ import { Icon } from "@iconify/react"; import { Paper, Typography } from "@mui/material"; -import { taskState } from "features/workflows/types"; +import { taskState } from "features/myWorkflows/types"; import theme from "providers/theme.config"; import React, { type CSSProperties, memo, useCallback, useMemo } from "react"; import { Position, Handle } from "reactflow"; diff --git a/frontend/src/components/WorkflowPanel/types.ts b/frontend/src/components/WorkflowPanel/types.ts index 8eeacd2c..18c286a9 100644 --- a/frontend/src/components/WorkflowPanel/types.ts +++ b/frontend/src/components/WorkflowPanel/types.ts @@ -1,4 +1,4 @@ -import { type taskState } from "features/workflows/types"; +import { type taskState } from "features/myWorkflows/types"; import { type CSSProperties } from "react"; import { type Node, type NodeProps } from "reactflow"; diff --git a/frontend/src/context/workspaces/repositories.tsx b/frontend/src/context/workspaces/repositories.tsx index cb089eaa..bc99e8de 100644 --- a/frontend/src/context/workspaces/repositories.tsx +++ b/frontend/src/context/workspaces/repositories.tsx @@ -2,7 +2,7 @@ import { type IGetRepoPiecesResponseInterface, useAuthenticatedGetPieceRepositories, useFetchAuthenticatedGetRepoIdPieces, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import { toast } from "react-toastify"; import localForage from "services/config/localForage.config"; diff --git a/frontend/src/features/workflows/api/index.ts b/frontend/src/features/myWorkflows/api/index.ts similarity index 100% rename from frontend/src/features/workflows/api/index.ts rename to frontend/src/features/myWorkflows/api/index.ts diff --git a/frontend/src/features/workflows/api/piece/getPieceRepositories.request.ts b/frontend/src/features/myWorkflows/api/piece/getPieceRepositories.request.ts similarity index 100% rename from frontend/src/features/workflows/api/piece/getPieceRepositories.request.ts rename to frontend/src/features/myWorkflows/api/piece/getPieceRepositories.request.ts diff --git a/frontend/src/features/workflows/api/piece/getPieceRepositoryPieces.ts b/frontend/src/features/myWorkflows/api/piece/getPieceRepositoryPieces.ts similarity index 100% rename from frontend/src/features/workflows/api/piece/getPieceRepositoryPieces.ts rename to frontend/src/features/myWorkflows/api/piece/getPieceRepositoryPieces.ts diff --git a/frontend/src/features/workflows/api/piece/getPiecesRepositoriesReleases.request.ts b/frontend/src/features/myWorkflows/api/piece/getPiecesRepositoriesReleases.request.ts similarity index 100% rename from frontend/src/features/workflows/api/piece/getPiecesRepositoriesReleases.request.ts rename to frontend/src/features/myWorkflows/api/piece/getPiecesRepositoriesReleases.request.ts diff --git a/frontend/src/features/workflows/api/piece/index.ts b/frontend/src/features/myWorkflows/api/piece/index.ts similarity index 100% rename from frontend/src/features/workflows/api/piece/index.ts rename to frontend/src/features/myWorkflows/api/piece/index.ts diff --git a/frontend/src/features/workflows/api/piece/piece.interface.ts b/frontend/src/features/myWorkflows/api/piece/piece.interface.ts similarity index 100% rename from frontend/src/features/workflows/api/piece/piece.interface.ts rename to frontend/src/features/myWorkflows/api/piece/piece.interface.ts diff --git a/frontend/src/features/workflows/api/repository/deletePieceRepository.request.ts b/frontend/src/features/myWorkflows/api/repository/deletePieceRepository.request.ts similarity index 100% rename from frontend/src/features/workflows/api/repository/deletePieceRepository.request.ts rename to frontend/src/features/myWorkflows/api/repository/deletePieceRepository.request.ts diff --git a/frontend/src/features/workflows/api/repository/getPieceRepositorySecrets.request.ts b/frontend/src/features/myWorkflows/api/repository/getPieceRepositorySecrets.request.ts similarity index 100% rename from frontend/src/features/workflows/api/repository/getPieceRepositorySecrets.request.ts rename to frontend/src/features/myWorkflows/api/repository/getPieceRepositorySecrets.request.ts diff --git a/frontend/src/features/workflows/api/repository/index.ts b/frontend/src/features/myWorkflows/api/repository/index.ts similarity index 100% rename from frontend/src/features/workflows/api/repository/index.ts rename to frontend/src/features/myWorkflows/api/repository/index.ts diff --git a/frontend/src/features/workflows/api/repository/patchPieceRepositorySecret.request.ts b/frontend/src/features/myWorkflows/api/repository/patchPieceRepositorySecret.request.ts similarity index 100% rename from frontend/src/features/workflows/api/repository/patchPieceRepositorySecret.request.ts rename to frontend/src/features/myWorkflows/api/repository/patchPieceRepositorySecret.request.ts diff --git a/frontend/src/features/workflows/api/repository/pieceRepository.interface.ts b/frontend/src/features/myWorkflows/api/repository/pieceRepository.interface.ts similarity index 100% rename from frontend/src/features/workflows/api/repository/pieceRepository.interface.ts rename to frontend/src/features/myWorkflows/api/repository/pieceRepository.interface.ts diff --git a/frontend/src/features/workflows/api/runs/getWorkflowRunTaskLogs.ts b/frontend/src/features/myWorkflows/api/runs/getWorkflowRunTaskLogs.ts similarity index 100% rename from frontend/src/features/workflows/api/runs/getWorkflowRunTaskLogs.ts rename to frontend/src/features/myWorkflows/api/runs/getWorkflowRunTaskLogs.ts diff --git a/frontend/src/features/workflows/api/runs/getWorkflowRunTaskResult.ts b/frontend/src/features/myWorkflows/api/runs/getWorkflowRunTaskResult.ts similarity index 100% rename from frontend/src/features/workflows/api/runs/getWorkflowRunTaskResult.ts rename to frontend/src/features/myWorkflows/api/runs/getWorkflowRunTaskResult.ts diff --git a/frontend/src/features/workflows/api/runs/getWorkflowRunTasks.ts b/frontend/src/features/myWorkflows/api/runs/getWorkflowRunTasks.ts similarity index 98% rename from frontend/src/features/workflows/api/runs/getWorkflowRunTasks.ts rename to frontend/src/features/myWorkflows/api/runs/getWorkflowRunTasks.ts index 63d82f19..7ca82299 100644 --- a/frontend/src/features/workflows/api/runs/getWorkflowRunTasks.ts +++ b/frontend/src/features/myWorkflows/api/runs/getWorkflowRunTasks.ts @@ -1,6 +1,6 @@ import { type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IGetWorkflowRunTasksResponseInterface } from "features/workflows/types/runs"; +import { type IGetWorkflowRunTasksResponseInterface } from "features/myWorkflows/types/runs"; import { dominoApiClient } from "services/clients/domino.client"; export interface IGetWorkflowRunTasksParams { diff --git a/frontend/src/features/workflows/api/runs/getWorkflowRuns.ts b/frontend/src/features/myWorkflows/api/runs/getWorkflowRuns.ts similarity index 98% rename from frontend/src/features/workflows/api/runs/getWorkflowRuns.ts rename to frontend/src/features/myWorkflows/api/runs/getWorkflowRuns.ts index c20e0c8a..ce71d34e 100644 --- a/frontend/src/features/workflows/api/runs/getWorkflowRuns.ts +++ b/frontend/src/features/myWorkflows/api/runs/getWorkflowRuns.ts @@ -1,6 +1,6 @@ import { type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IGetWorkflowRunsResponseInterface } from "features/workflows/types/runs"; +import { type IGetWorkflowRunsResponseInterface } from "features/myWorkflows/types/runs"; import { dominoApiClient } from "services/clients/domino.client"; import useSWR from "swr"; diff --git a/frontend/src/features/workflows/api/runs/index.ts b/frontend/src/features/myWorkflows/api/runs/index.ts similarity index 100% rename from frontend/src/features/workflows/api/runs/index.ts rename to frontend/src/features/myWorkflows/api/runs/index.ts diff --git a/frontend/src/features/workflows/api/workflow/deleteWorkflowId.ts b/frontend/src/features/myWorkflows/api/workflow/deleteWorkflowId.ts similarity index 97% rename from frontend/src/features/workflows/api/workflow/deleteWorkflowId.ts rename to frontend/src/features/myWorkflows/api/workflow/deleteWorkflowId.ts index a3521b4c..1a9294d7 100644 --- a/frontend/src/features/workflows/api/workflow/deleteWorkflowId.ts +++ b/frontend/src/features/myWorkflows/api/workflow/deleteWorkflowId.ts @@ -1,6 +1,6 @@ import { AxiosError, type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IDeleteWorkflowIdResponseInterface } from "features/workflows/types/workflow"; +import { type IDeleteWorkflowIdResponseInterface } from "features/myWorkflows/types/workflow"; import { toast } from "react-toastify"; import { dominoApiClient } from "services/clients/domino.client"; diff --git a/frontend/src/features/workflows/api/workflow/getWorkflow.ts b/frontend/src/features/myWorkflows/api/workflow/getWorkflow.ts similarity index 93% rename from frontend/src/features/workflows/api/workflow/getWorkflow.ts rename to frontend/src/features/myWorkflows/api/workflow/getWorkflow.ts index 15af1751..f4f9fe5b 100644 --- a/frontend/src/features/workflows/api/workflow/getWorkflow.ts +++ b/frontend/src/features/myWorkflows/api/workflow/getWorkflow.ts @@ -1,6 +1,6 @@ import { type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IGetWorkflowResponseInterface } from "features/workflows/types/workflow"; +import { type IGetWorkflowResponseInterface } from "features/myWorkflows/types/workflow"; import { dominoApiClient } from "services/clients/domino.client"; import useSWR from "swr"; diff --git a/frontend/src/features/workflows/api/workflow/getWorkflowId.ts b/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts similarity index 93% rename from frontend/src/features/workflows/api/workflow/getWorkflowId.ts rename to frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts index 728e21ce..5e46c8c3 100644 --- a/frontend/src/features/workflows/api/workflow/getWorkflowId.ts +++ b/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts @@ -1,6 +1,6 @@ import { type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IGetWorkflowIdResponseInterface } from "features/workflows/types/workflow"; +import { type IGetWorkflowIdResponseInterface } from "features/myWorkflows/types/workflow"; import { dominoApiClient } from "services/clients/domino.client"; import useSWR from "swr"; diff --git a/frontend/src/features/workflows/api/workflow/index.ts b/frontend/src/features/myWorkflows/api/workflow/index.ts similarity index 100% rename from frontend/src/features/workflows/api/workflow/index.ts rename to frontend/src/features/myWorkflows/api/workflow/index.ts diff --git a/frontend/src/features/workflows/api/workflow/postWorkflow.ts b/frontend/src/features/myWorkflows/api/workflow/postWorkflow.ts similarity index 91% rename from frontend/src/features/workflows/api/workflow/postWorkflow.ts rename to frontend/src/features/myWorkflows/api/workflow/postWorkflow.ts index 8be5ac62..1c1bd23d 100644 --- a/frontend/src/features/workflows/api/workflow/postWorkflow.ts +++ b/frontend/src/features/myWorkflows/api/workflow/postWorkflow.ts @@ -1,6 +1,6 @@ import { type AxiosResponse } from "axios"; import { type CreateWorkflowRequest } from "features/workflowEditor/context/types"; -import { type IPostWorkflowResponseInterface } from "features/workflows/types"; +import { type IPostWorkflowResponseInterface } from "features/myWorkflows/types"; import { dominoApiClient } from "services/clients/domino.client"; export interface IPostWorkflowParams extends CreateWorkflowRequest { diff --git a/frontend/src/features/workflows/api/workflow/postWorkflowRunId.ts b/frontend/src/features/myWorkflows/api/workflow/postWorkflowRunId.ts similarity index 97% rename from frontend/src/features/workflows/api/workflow/postWorkflowRunId.ts rename to frontend/src/features/myWorkflows/api/workflow/postWorkflowRunId.ts index e322a05b..a3d37088 100644 --- a/frontend/src/features/workflows/api/workflow/postWorkflowRunId.ts +++ b/frontend/src/features/myWorkflows/api/workflow/postWorkflowRunId.ts @@ -1,7 +1,7 @@ // TODO move to /runs import { AxiosError, type AxiosResponse } from "axios"; import { useWorkspaces } from "context/workspaces"; -import { type IPostWorkflowRunIdResponseInterface } from "features/workflows/types/workflow"; +import { type IPostWorkflowRunIdResponseInterface } from "features/myWorkflows/types/workflow"; import { toast } from "react-toastify"; import { dominoApiClient } from "services/clients/domino.client"; diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/CustomTabMenu.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/CustomTabMenu.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/CustomTabMenu.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/CustomTabMenu.tsx diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/CustomTabPanel.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/CustomTabPanel.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/CustomTabPanel.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/CustomTabPanel.tsx diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx similarity index 97% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx index fe3f4a54..83a30e8b 100644 --- a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskDetail.tsx @@ -9,8 +9,8 @@ import { Container, } from "@mui/material"; import { intervalToDuration } from "date-fns"; -import { taskStatesColorMap } from "features/workflows/constants"; -import { type IWorkflowRunTasks } from "features/workflows/types/runs"; +import { taskStatesColorMap } from "features/myWorkflows/constants"; +import { type IWorkflowRunTasks } from "features/myWorkflows/types/runs"; import { useMemo } from "react"; interface IWorkflowRunTasksExtended extends IWorkflowRunTasks { diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskLogs.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskLogs.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskLogs.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskLogs.tsx diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskResult.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskResult.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/TaskResult.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/TaskResult.tsx diff --git a/frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/index.ts b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/index.ts similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/index.ts rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/index.ts diff --git a/frontend/src/features/workflows/components/WorkflowDetail/States/index.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/States/index.tsx similarity index 95% rename from frontend/src/features/workflows/components/WorkflowDetail/States/index.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/States/index.tsx index 4ce0ca74..e7569853 100644 --- a/frontend/src/features/workflows/components/WorkflowDetail/States/index.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowDetail/States/index.tsx @@ -1,5 +1,5 @@ import { Chip } from "@mui/material"; -import { type IWorkflowRuns } from "features/workflows/types"; +import { type IWorkflowRuns } from "features/myWorkflows/types"; import theme from "providers/theme.config"; import React from "react"; diff --git a/frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunDetail.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunDetail.tsx similarity index 98% rename from frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunDetail.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunDetail.tsx index 89d90264..3549f6dd 100644 --- a/frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunDetail.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunDetail.tsx @@ -3,7 +3,7 @@ import { NoDataOverlay } from "components/NoDataOverlay"; import { useAuthenticatedGetWorkflowRunTaskLogs, useAuthenticatedGetWorkflowRunTaskResult, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import React, { useCallback, useMemo, useState } from "react"; import { useInterval } from "utils"; diff --git a/frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunTableFooter/index.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunTableFooter/index.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunTableFooter/index.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunTableFooter/index.tsx diff --git a/frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunsTable.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunsTable.tsx similarity index 97% rename from frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunsTable.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunsTable.tsx index 9d27593c..fd65ab83 100644 --- a/frontend/src/features/workflows/components/WorkflowDetail/WorkflowRunsTable.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowDetail/WorkflowRunsTable.tsx @@ -1,8 +1,8 @@ import { Card, Grid, Skeleton } from "@mui/material"; import { DataGrid, type GridColDef } from "@mui/x-data-grid"; import { NoDataOverlay } from "components/NoDataOverlay"; -import { useAuthenticatedGetWorkflowRuns } from "features/workflows/api"; -import { type IWorkflowRuns } from "features/workflows/types"; +import { useAuthenticatedGetWorkflowRuns } from "features/myWorkflows/api"; +import { type IWorkflowRuns } from "features/myWorkflows/types"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import { useInterval } from "utils"; diff --git a/frontend/src/features/workflows/components/WorkflowDetail/index.tsx b/frontend/src/features/myWorkflows/components/WorkflowDetail/index.tsx similarity index 98% rename from frontend/src/features/workflows/components/WorkflowDetail/index.tsx rename to frontend/src/features/myWorkflows/components/WorkflowDetail/index.tsx index 340fb6cc..8409e4ac 100644 --- a/frontend/src/features/workflows/components/WorkflowDetail/index.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowDetail/index.tsx @@ -11,11 +11,11 @@ import { useAuthenticatedGetWorkflowId, useAuthenticatedGetWorkflowRunTasks, useAuthenticatedPostWorkflowRunId, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import { type IWorkflowRuns, type IWorkflowRunTasks, -} from "features/workflows/types"; +} from "features/myWorkflows/types"; import React, { useCallback, useRef, useState } from "react"; import { useParams } from "react-router-dom"; import { type NodeMouseHandler } from "reactflow"; diff --git a/frontend/src/features/workflows/components/WorkflowsList/Actions.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/Actions.tsx similarity index 97% rename from frontend/src/features/workflows/components/WorkflowsList/Actions.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/Actions.tsx index 883e01b4..491633fa 100644 --- a/frontend/src/features/workflows/components/WorkflowsList/Actions.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowsList/Actions.tsx @@ -4,7 +4,7 @@ import PlayCircleOutlineIcon from "@mui/icons-material/PlayCircleOutline"; import { IconButton } from "@mui/material"; import { type CommonProps } from "@mui/material/OverridableComponent"; import { Modal, type ModalRef } from "components/Modal"; -import { type IWorkflow } from "features/workflows/types"; +import { type IWorkflow } from "features/myWorkflows/types"; import theme from "providers/theme.config"; import React, { useRef, useState } from "react"; diff --git a/frontend/src/features/workflows/components/WorkflowsList/ConfirmDeleteModal.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/ConfirmDeleteModal.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowsList/ConfirmDeleteModal.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/ConfirmDeleteModal.tsx diff --git a/frontend/src/features/workflows/components/WorkflowsList/Status.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/Status.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowsList/Status.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/Status.tsx diff --git a/frontend/src/features/workflows/components/WorkflowsList/WorkflowsListSkeleton.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/WorkflowsListSkeleton.tsx similarity index 100% rename from frontend/src/features/workflows/components/WorkflowsList/WorkflowsListSkeleton.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/WorkflowsListSkeleton.tsx diff --git a/frontend/src/features/workflows/components/WorkflowsList/index.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx similarity index 98% rename from frontend/src/features/workflows/components/WorkflowsList/index.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx index 50fa55f9..ace6aad7 100644 --- a/frontend/src/features/workflows/components/WorkflowsList/index.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx @@ -10,8 +10,8 @@ import { useAuthenticatedDeleteWorkflowId, useAuthenticatedGetWorkflows, useAuthenticatedPostWorkflowRunId, -} from "features/workflows/api"; -import { type IWorkflow } from "features/workflows/types"; +} from "features/myWorkflows/api"; +import { type IWorkflow } from "features/myWorkflows/types"; import React, { useCallback, useMemo } from "react"; import { useNavigate } from "react-router-dom"; import { useInterval } from "utils"; diff --git a/frontend/src/features/workflows/constants/index.ts b/frontend/src/features/myWorkflows/constants/index.ts similarity index 100% rename from frontend/src/features/workflows/constants/index.ts rename to frontend/src/features/myWorkflows/constants/index.ts diff --git a/frontend/src/features/workflows/index.ts b/frontend/src/features/myWorkflows/index.ts similarity index 100% rename from frontend/src/features/workflows/index.ts rename to frontend/src/features/myWorkflows/index.ts diff --git a/frontend/src/features/workflows/pages/WorkflowDetailPage.tsx b/frontend/src/features/myWorkflows/pages/WorkflowDetailPage.tsx similarity index 100% rename from frontend/src/features/workflows/pages/WorkflowDetailPage.tsx rename to frontend/src/features/myWorkflows/pages/WorkflowDetailPage.tsx diff --git a/frontend/src/features/workflows/pages/WorkflowsPage.tsx b/frontend/src/features/myWorkflows/pages/WorkflowsPage.tsx similarity index 100% rename from frontend/src/features/workflows/pages/WorkflowsPage.tsx rename to frontend/src/features/myWorkflows/pages/WorkflowsPage.tsx diff --git a/frontend/src/features/workflows/pages/index.ts b/frontend/src/features/myWorkflows/pages/index.ts similarity index 100% rename from frontend/src/features/workflows/pages/index.ts rename to frontend/src/features/myWorkflows/pages/index.ts diff --git a/frontend/src/features/workflows/types/index.ts b/frontend/src/features/myWorkflows/types/index.ts similarity index 100% rename from frontend/src/features/workflows/types/index.ts rename to frontend/src/features/myWorkflows/types/index.ts diff --git a/frontend/src/features/workflows/types/runs.ts b/frontend/src/features/myWorkflows/types/runs.ts similarity index 100% rename from frontend/src/features/workflows/types/runs.ts rename to frontend/src/features/myWorkflows/types/runs.ts diff --git a/frontend/src/features/workflows/types/workflow.ts b/frontend/src/features/myWorkflows/types/workflow.ts similarity index 100% rename from frontend/src/features/workflows/types/workflow.ts rename to frontend/src/features/myWorkflows/types/workflow.ts diff --git a/frontend/src/features/workflowEditor/context/reactWorkflowPersistence.tsx b/frontend/src/features/workflowEditor/context/reactWorkflowPersistence.tsx index 3f12d1ba..3557d7e1 100644 --- a/frontend/src/features/workflowEditor/context/reactWorkflowPersistence.tsx +++ b/frontend/src/features/workflowEditor/context/reactWorkflowPersistence.tsx @@ -1,4 +1,4 @@ -import { type IWorkflowElement } from "features/workflows/types"; +import { type IWorkflowElement } from "features/myWorkflows/types"; import React, { useCallback } from "react"; import { type Node, type Edge } from "reactflow"; import localForage from "services/config/localForage.config"; diff --git a/frontend/src/features/workflowEditor/context/types/workflowPieceData.ts b/frontend/src/features/workflowEditor/context/types/workflowPieceData.ts index 014f4089..7a5b7516 100644 --- a/frontend/src/features/workflowEditor/context/types/workflowPieceData.ts +++ b/frontend/src/features/workflowEditor/context/types/workflowPieceData.ts @@ -1,4 +1,4 @@ -import { type IWorkflowElement } from "features/workflows/types"; +import { type IWorkflowElement } from "features/myWorkflows/types"; import { type Edge } from "reactflow"; import { type IContainerResourceFormData } from "./containerResources"; diff --git a/frontend/src/features/workflowEditor/context/workflowsEditor.tsx b/frontend/src/features/workflowEditor/context/workflowsEditor.tsx index acb9394c..0794727a 100644 --- a/frontend/src/features/workflowEditor/context/workflowsEditor.tsx +++ b/frontend/src/features/workflowEditor/context/workflowsEditor.tsx @@ -2,11 +2,11 @@ import { useWorkspaces } from "context/workspaces"; import { type IPostWorkflowParams, useAuthenticatedPostWorkflow, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import { type IWorkflowElement, type IPostWorkflowResponseInterface, -} from "features/workflows/types"; +} from "features/myWorkflows/types"; import React, { type FC, useCallback } from "react"; import { type Edge } from "reactflow"; import { createCustomContext, generateTaskName } from "utils"; diff --git a/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx b/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx index 3a4b26bc..d448a113 100644 --- a/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx +++ b/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx @@ -29,7 +29,7 @@ import { } from "@mui/material"; import TextField from "@mui/material/TextField"; import { repositorySource } from "context/workspaces/types"; -import { type IPieceRepositoryMetadata } from "features/workflows/api"; +import { type IPieceRepositoryMetadata } from "features/myWorkflows/api"; import { type FC, type ReactNode, useCallback, useMemo, useState } from "react"; import { toast } from "react-toastify"; diff --git a/frontend/src/features/workspaces/components/workspaceSettings/SecretsCard.tsx b/frontend/src/features/workspaces/components/workspaceSettings/SecretsCard.tsx index 815cfde0..15c84cbd 100644 --- a/frontend/src/features/workspaces/components/workspaceSettings/SecretsCard.tsx +++ b/frontend/src/features/workspaces/components/workspaceSettings/SecretsCard.tsx @@ -17,7 +17,7 @@ import { import { useAuthenticatedGetRepositorySecrets, useAuthenticatedPatchRepositorySecret, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import { useState, useImperativeHandle, diff --git a/frontend/src/features/workspaces/components/workspaceSettings/StorageSecretsCard.tsx b/frontend/src/features/workspaces/components/workspaceSettings/StorageSecretsCard.tsx index 9c168b4c..beb3248e 100644 --- a/frontend/src/features/workspaces/components/workspaceSettings/StorageSecretsCard.tsx +++ b/frontend/src/features/workspaces/components/workspaceSettings/StorageSecretsCard.tsx @@ -18,7 +18,7 @@ import { import { useAuthenticatedGetRepositorySecrets, useAuthenticatedPatchRepositorySecret, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import { useState, useCallback, useMemo, useEffect } from "react"; import { useForm } from "react-hook-form"; import { toast } from "react-toastify"; diff --git a/frontend/src/features/workspaces/context/workspaceSettings.tsx b/frontend/src/features/workspaces/context/workspaceSettings.tsx index ed6dd756..900ab5af 100644 --- a/frontend/src/features/workspaces/context/workspaceSettings.tsx +++ b/frontend/src/features/workspaces/context/workspaceSettings.tsx @@ -14,7 +14,7 @@ import { useAuthenticatedDeleteRepository, useAuthenticatedGetPieceRepositories, useAuthenticatedGetPieceRepositoriesReleases, -} from "features/workflows/api"; +} from "features/myWorkflows/api"; import { type FC, useCallback, useState } from "react"; import { toast } from "react-toastify"; import { createCustomContext } from "utils"; diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx index 6b99b755..c52d1ba8 100644 --- a/frontend/src/routes/index.tsx +++ b/frontend/src/routes/index.tsx @@ -23,11 +23,11 @@ const { WorkflowsEditorPage } = lazyImport( "WorkflowsEditorPage", ); const { WorkflowsPage } = lazyImport( - async () => await import("features/workflows/pages"), + async () => await import("features/myWorkflows/pages"), "WorkflowsPage", ); const { WorkflowDetailPage } = lazyImport( - async () => await import("features/workflows/pages"), + async () => await import("features/myWorkflows/pages"), "WorkflowDetailPage", ); @@ -79,12 +79,12 @@ export const ApplicationRoutes: FC = () => ( /> } /> } From 77c3f9eff966bfa3e96effc58d7d046bc266e575 Mon Sep 17 00:00:00 2001 From: Nathan Vieira Marcelino Date: Tue, 7 Nov 2023 20:13:12 -0300 Subject: [PATCH 3/8] feat: import from my workflows --- .../myWorkflows/api/workflow/getWorkflowId.ts | 36 ++--- .../components/WorkflowsList/index.tsx | 2 +- .../MyWorkflowsGalleryModal/index.tsx | 124 ++++++++++++++++++ .../components/WorkflowEditor.tsx | 11 +- .../WorkflowExamplesGalleryModal/index.tsx | 2 +- .../context/workflowsEditor.tsx | 6 + .../workflowEditor/utils/importWorkflow.ts | 70 +++++++++- .../utils/workflows/simple_log_workflow.json | 2 +- .../utils/workflows/youtube_workflow.json | 2 +- frontend/src/utils/index.ts | 1 + frontend/src/utils/isEmpty.ts | 3 + rest/schemas/requests/workflow.py | 1 + rest/schemas/responses/workflow.py | 4 +- rest/services/workflow_service.py | 3 +- 14 files changed, 232 insertions(+), 35 deletions(-) create mode 100644 frontend/src/features/workflowEditor/components/MyWorkflowsGalleryModal/index.tsx create mode 100644 frontend/src/utils/isEmpty.ts diff --git a/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts b/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts index 5e46c8c3..c734f8e3 100644 --- a/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts +++ b/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts @@ -5,11 +5,11 @@ import { dominoApiClient } from "services/clients/domino.client"; import useSWR from "swr"; interface IGetWorkflowIdParams { - id: string; + id?: string; } -const getWorkflowUrl = (workspaceId: string, id: string) => - `/workspaces/${workspaceId}/workflows/${id}`; +const getWorkflowUrl = (workspaceId: string, id?: string) => + id ? `/workspaces/${workspaceId}/workflows/${id}` : null; /** * Get workflow by id using GET /workflow @@ -18,11 +18,13 @@ const getWorkflowUrl = (workspaceId: string, id: string) => const getWorkflowId: ( workspaceId: string, params: IGetWorkflowIdParams, -) => Promise> = async ( - workspaceId, - params, -) => { - return await dominoApiClient.get(getWorkflowUrl(workspaceId, params.id)); +) => Promise< + AxiosResponse | undefined +> = async (workspaceId, params) => { + const url = getWorkflowUrl(workspaceId, params.id); + if (url) { + return await dominoApiClient.get(url); + } }; /** @@ -30,7 +32,7 @@ const getWorkflowId: ( * @param params `{ workspaceId: number, id: string }` * @returns workflow fetcher fn */ -export const useAuthenticatedGetWorkflowId = ({ id }: { id: string }) => { +export const useAuthenticatedGetWorkflowId = ({ id }: IGetWorkflowIdParams) => { const { workspace } = useWorkspaces(); if (!workspace) @@ -40,15 +42,13 @@ export const useAuthenticatedGetWorkflowId = ({ id }: { id: string }) => { // todo add swr ? const fetcher = async (params: IGetWorkflowIdParams) => { - return await getWorkflowId(workspace.id, params).then((data) => data.data); + return await getWorkflowId(workspace.id, params).then((data) => data?.data); }; - return useSWR( - getWorkflowUrl(workspace.id, id), - async () => await fetcher({ id }), - { - revalidateOnFocus: false, - revalidateOnReconnect: false, - }, - ); + const key = getWorkflowUrl(workspace.id, id); + + return useSWR(key, async () => await fetcher({ id }), { + revalidateOnFocus: false, + revalidateOnReconnect: false, + }); }; diff --git a/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx b/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx index ace6aad7..bf8e3460 100644 --- a/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx +++ b/frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx @@ -159,7 +159,7 @@ export const WorkflowList: React.FC = () => { event.target.classList.contains(".action-button"); if (!isActionButtonClick) { if (params.row.status !== "failed" && params.row.status !== "creating") - navigate(`/workflows/${params.id}`); + navigate(`/my-workflows/${params.id}`); } }, [navigate], diff --git a/frontend/src/features/workflowEditor/components/MyWorkflowsGalleryModal/index.tsx b/frontend/src/features/workflowEditor/components/MyWorkflowsGalleryModal/index.tsx new file mode 100644 index 00000000..efb52154 --- /dev/null +++ b/frontend/src/features/workflowEditor/components/MyWorkflowsGalleryModal/index.tsx @@ -0,0 +1,124 @@ +import CheckCircleIcon from "@mui/icons-material/CheckCircle"; +import { + Card, + CardActionArea, + CardContent, + Container, + Divider, + Grid, + Typography, +} from "@mui/material"; +import Pagination from "@mui/material/Pagination"; +import Stack from "@mui/material/Stack"; +import { Modal, type ModalRef } from "components/Modal"; +import { + useAuthenticatedGetWorkflowId, + useAuthenticatedGetWorkflows, +} from "features/myWorkflows"; +import { type IWorkflow } from "features/myWorkflows/types"; +import theme from "providers/theme.config"; +import { forwardRef, type ForwardedRef, useState, useMemo } from "react"; + +interface MyWorkflowGalleryModalRef extends ModalRef {} + +interface MyWorkflowGalleryModalProps { + confirmFn: (json: any) => void; +} + +const MyWorkflowExamplesGalleryModal = forwardRef( + ( + props: MyWorkflowGalleryModalProps, + ref: ForwardedRef, + ) => { + const [page, setPage] = useState(0); + const [selected, setSelected] = useState(null); + + const { data: workflows } = useAuthenticatedGetWorkflows(page, 9); + + const { data: workflow } = useAuthenticatedGetWorkflowId({ + id: selected !== null ? String(selected) : undefined, + }); + + const cardsContents = useMemo( + () => workflows?.data ?? [], + [workflows], + ); + + return ( + + + {cardsContents.map((card, index) => ( + + + { + setSelected((s) => (s === card.id ? null : card.id)); + }} + > + + {selected === card.id && ( + + )} + {card.name} + + + + + ))} + + + + + + { + setPage(p - 1); + }} + /> + + + + + } + cancelFn={() => { + setSelected(null); + }} + confirmFn={() => { + props.confirmFn(workflow?.schema ?? {}); + }} + ref={ref} + /> + ); + }, +); +MyWorkflowExamplesGalleryModal.displayName = "MyWorkflowExamplesGalleryModal"; +export { MyWorkflowExamplesGalleryModal }; diff --git a/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx b/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx index 3651da5c..4cef7217 100644 --- a/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx +++ b/frontend/src/features/workflowEditor/components/WorkflowEditor.tsx @@ -33,6 +33,7 @@ import { } from "../utils/importWorkflow"; import { PermanentDrawerRightWorkflows } from "./DrawerMenu"; +import { MyWorkflowExamplesGalleryModal } from "./MyWorkflowsGalleryModal"; import SidebarPieceForm from "./SidebarForm"; import { ContainerResourceFormSchema } from "./SidebarForm/ContainerResourceForm"; import { createInputsSchemaValidation } from "./SidebarForm/PieceForm/validation"; @@ -85,6 +86,7 @@ export const WorkflowsEditorComponent: React.FC = () => { const incompatiblePiecesModalRef = useRef(null); const workflowsGalleryModalRef = useRef(null); + const myWorkflowsGalleryModalRef = useRef(null); const [incompatiblesPieces, setIncompatiblesPieces] = useState([]); const { workspace } = useWorkspaces(); @@ -521,9 +523,8 @@ export const WorkflowsEditorComponent: React.FC = () => { { - setAnchorEl(null); + myWorkflowsGalleryModalRef.current?.open(); }} - disabled > from my workflows @@ -534,6 +535,12 @@ export const WorkflowsEditorComponent: React.FC = () => { void handleImportedJson(json); }} /> + { + void handleImportedJson(json); + }} + />