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 52% rename from frontend/src/features/workflows/api/workflow/getWorkflowId.ts rename to frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts index 728e21ce..c734f8e3 100644 --- a/frontend/src/features/workflows/api/workflow/getWorkflowId.ts +++ b/frontend/src/features/myWorkflows/api/workflow/getWorkflowId.ts @@ -1,15 +1,15 @@ 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"; 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/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/CustomTabMenu/styles.css b/frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/styles.css similarity index 100% rename from frontend/src/features/workflows/components/WorkflowDetail/CustomTabMenu/styles.css rename to frontend/src/features/myWorkflows/components/WorkflowDetail/CustomTabMenu/styles.css 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 20498e5c..2e651aa9 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 97% rename from frontend/src/features/workflows/components/WorkflowsList/index.tsx rename to frontend/src/features/myWorkflows/components/WorkflowsList/index.tsx index 50fa55f9..bf8e3460 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"; @@ -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/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/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 9e2bf0e8..15ce9e0a 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(); @@ -227,7 +229,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); @@ -449,7 +457,7 @@ export const WorkflowsEditorComponent: React.FC = () => { startIcon={} onClick={handleSaveWorkflow} > - Save + Create @@ -513,19 +521,16 @@ export const WorkflowsEditorComponent: React.FC = () => { "aria-labelledby": "import-button", }} > - - Import from file - + from file - Import from examples + from examples gallery { - setAnchorEl(null); + myWorkflowsGalleryModalRef.current?.open(); }} - disabled > - Import from workflows + from my workflows { void handleImportedJson(json); }} /> + { + void handleImportedJson(json); + }} + />