-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
165 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
frontend/src/features/workflowEditor/components/MyWorkflowsGalleryModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MyWorkflowGalleryModalRef>, | ||
) => { | ||
const [page, setPage] = useState(0); | ||
const [selected, setSelected] = useState<number | null>(null); | ||
|
||
const { data: workflows } = useAuthenticatedGetWorkflows(page, 9); | ||
|
||
const { data: workflow } = useAuthenticatedGetWorkflowId({ | ||
id: selected !== null ? String(selected) : undefined, | ||
}); | ||
|
||
const cardsContents = useMemo<IWorkflow[]>( | ||
() => workflows?.data ?? [], | ||
[workflows], | ||
); | ||
|
||
return ( | ||
<Modal | ||
title="Example Workflows Gallery" | ||
maxWidth={"md"} | ||
fullWidth={true} | ||
content={ | ||
<Container> | ||
<Grid container justifyContent="center"> | ||
{cardsContents.map((card, index) => ( | ||
<Grid item key={index} xs={12} sm={4} md={4}> | ||
<Card | ||
elevation={4} | ||
sx={{ | ||
height: "200px", | ||
backgroundColor: theme.palette.grey[100], | ||
}} | ||
> | ||
<CardActionArea | ||
sx={{ height: "100%" }} | ||
onClick={() => { | ||
setSelected((s) => (s === card.id ? null : card.id)); | ||
}} | ||
> | ||
<CardContent | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
height: "100%", | ||
}} | ||
> | ||
{selected === card.id && ( | ||
<CheckCircleIcon | ||
sx={{ | ||
position: "absolute", | ||
top: 10, | ||
right: 10, | ||
color: theme.palette.success.light, | ||
borderRadius: "50%", | ||
}} | ||
/> | ||
)} | ||
<Typography variant="h3">{card.name}</Typography> | ||
</CardContent> | ||
</CardActionArea> | ||
</Card> | ||
</Grid> | ||
))} | ||
<Grid item xs={12}> | ||
<Divider sx={{ height: 20 }} /> | ||
</Grid> | ||
<Grid xs={12} item> | ||
<Stack spacing={2} alignItems="center"> | ||
<Pagination | ||
count={workflows?.metadata?.last_page} | ||
onChange={(_, p) => { | ||
setPage(p - 1); | ||
}} | ||
/> | ||
</Stack> | ||
</Grid> | ||
</Grid> | ||
</Container> | ||
} | ||
cancelFn={() => { | ||
setSelected(null); | ||
}} | ||
confirmFn={() => { | ||
props.confirmFn(workflow?.schema ?? {}); | ||
}} | ||
ref={ref} | ||
/> | ||
); | ||
}, | ||
); | ||
MyWorkflowExamplesGalleryModal.displayName = "MyWorkflowExamplesGalleryModal"; | ||
export { MyWorkflowExamplesGalleryModal }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
frontend/src/features/workflowEditor/components/WorkflowExamplesGalleryModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters