Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start on select on integration #765

Merged
merged 8 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions grai-frontend/src/components/chat/WebsocketChat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ test("type", async () => {

expect(screen.getByRole("textbox")).toBeInTheDocument()

user.type(screen.getByRole("textbox"), "He")
user.type(screen.getByRole("textbox"), "H")

await waitFor(() => expect(screen.getByRole("textbox")).toHaveValue("He"))
await waitFor(() => expect(screen.getByRole("textbox")).toHaveValue("H"))

user.type(screen.getByRole("textbox"), "{enter}")

await waitFor(() => expect(screen.getByRole("textbox")).toHaveValue(""))

expect(screen.getByText("He")).toBeInTheDocument()
expect(screen.getByText("H")).toBeInTheDocument()
})

test("receive", async () => {
render(<WebsocketChat workspace={workspace} />)

await server.connected

await act(async () => server.send(JSON.stringify({ message: "He" })))
await act(async () => server.send(JSON.stringify({ message: "H" })))

await screen.findByText("He")
await screen.findByText("H")
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test("renders", async () => {
id: "1",
name: "connector 1",
metadata: null,
icon: null,
}}
onSelect={() => {}}
/>,
Expand All @@ -27,13 +28,36 @@ test("coming soon", async () => {
name: "connector 1",
metadata: null,
status: "coming_soon",
icon: null,
}}
onSelect={() => {}}
/>,
{
withRouter: true,
},
)

expect(screen.getByText(/Coming soon/i)).toBeInTheDocument()
})

test("alpha", async () => {
render(
<ConnectorCard
connector={{
id: "1",
name: "connector 1",
metadata: null,
status: "alpha",
icon: null,
}}
onSelect={() => {}}
/>,
{
withRouter: true,
},
)

expect(screen.getByText(/alpha/i)).toBeInTheDocument()
})

test("click", async () => {
Expand All @@ -45,6 +69,7 @@ test("click", async () => {
id: "1",
name: "connector 1",
metadata: null,
icon: null,
}}
onSelect={() => {}}
/>,
Expand All @@ -68,6 +93,7 @@ test("to", async () => {
name: "connector 1",
metadata: null,
to: "a",
icon: null,
}}
onSelect={() => {}}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {
Typography,
} from "@mui/material"
import { useNavigate } from "react-router-dom"
import ConnectorIcon from "./ConnectorIcon"

export interface Connector {
id: string
name: string
icon?: string | null | ReactNode
icon: string | null | ReactNode
status?: string
metadata: any
to?: string
Expand All @@ -31,9 +32,18 @@ const ConnectorCard: React.FC<ConnectorCardProps> = ({
}) => {
const navigate = useNavigate()

const comingSoon = connector.status === "coming_soon"

return (
<Box>
<Card variant="outlined">
<Card
variant="outlined"
sx={{
borderRadius: "20px",
border: comingSoon ? "1px solid rgba(0, 0, 0, 0.08)" : undefined,
height: "88px",
}}
>
<CardActionArea
onClick={() => {
if (connector.to) {
Expand All @@ -42,59 +52,55 @@ const ConnectorCard: React.FC<ConnectorCardProps> = ({
}
onSelect(connector)
}}
className="connector-card"
sx={{ height: "100%" }}
>
<List>
<ListItem>
<ListItemIcon sx={{ minWidth: 45 }}>
{connector.icon &&
(typeof connector.icon === "string" ? (
<img
src={connector.icon}
alt={`${connector.name} logo`}
style={{ height: 28, width: 28 }}
/>
) : (
connector.icon
))}
<ListItem sx={{ pl: "20px" }}>
<ListItemIcon sx={{ minWidth: 48 }}>
{connector.icon && <ConnectorIcon connector={connector} />}
</ListItemIcon>
<ListItemText
primary={
<Typography variant="body2">{connector.name}</Typography>
<Typography
variant="body1"
sx={{
fontWeight: 500,
color: comingSoon ? "#AFAFAF" : undefined,
}}
>
{connector.name}
</Typography>
}
/>
</ListItem>
</List>
</CardActionArea>
</Card>
{connector.status !== "general_release" && (
<Box
sx={{
position: "relative",
top: -75,
right: -155,
width: 130,
textAlign: "center",
// height: 100,
borderWidth: 1,
borderStyle: "solid",
borderColor: "divider",
borderRadius: 1,
backgroundColor: theme => theme.palette.grey[100],
}}
>
<Typography
variant="body2"
{connector.status &&
["coming_soon", "alpha"].includes(connector.status) && (
<Box
sx={{
m: 0.3,
color: theme => theme.palette.grey[500],
textTransform: "uppercase",
position: "relative",
top: -105,
right: comingSoon ? -220 : -275,
width: "fit-content",
textAlign: "center",
px: "12px",
py: "6px",
borderRadius: "100px",
background: "#f4edff",
}}
>
{connector.status?.replace("_", " ")}
</Typography>
</Box>
)}
<Typography
variant="body2"
sx={{
textTransform: "capitalize",
}}
>
{connector.status?.replace("_", " ")}
</Typography>
</Box>
)}
</Box>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { ReactNode } from "react"

export interface Connector {
icon: string | ReactNode
name: string
}

type ConnectorIconProps = {
connector: Connector
}

const ConnectorIcon: React.FC<ConnectorIconProps> = ({ connector }) => {
if (typeof connector.icon === "string")
return (
<img
src={connector.icon}
alt={`${connector.name} logo`}
style={{ height: 28, width: 28 }}
/>
)

return <>{connector.icon}</>
}

export default ConnectorIcon
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import React from "react"
import { Typography, Grid } from "@mui/material"
import { Grid } from "@mui/material"
import ConnectorCard, { Connector } from "./ConnectorCard"

type ConnectorListProps = {
title: string
connectors: Connector[]
onSelect: (connector: Connector) => void
}

const ConnectorList: React.FC<ConnectorListProps> = ({
title,
connectors,
onSelect,
}) => (
<>
<Typography variant="h6" sx={{ mt: 5, mb: 3, textTransform: "capitalize" }}>
{title}
</Typography>
<Grid container spacing={2}>
{connectors.map(connector => (
<Grid item md={3} key={connector.id}>
<ConnectorCard connector={connector} onSelect={onSelect} />
</Grid>
))}
</Grid>
</>
<Grid container spacing={2}>
{connectors.map(connector => (
<Grid item md={3} key={connector.id}>
<ConnectorCard connector={connector} onSelect={onSelect} />
</Grid>
))}
</Grid>
)

export default ConnectorList
32 changes: 18 additions & 14 deletions grai-frontend/src/components/connections/create/ConnectionFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const ConnectionFile: React.FC<ConnectionFileProps> = ({
},
})
.then(res =>
workspaceNavigate(`runs/${res.data?.uploadConnectorFile.id}`)
workspaceNavigate(`runs/${res.data?.uploadConnectorFile.id}`),
)
.then(() => enqueueSnackbar("File uploaded"))
.catch(() => {})
Expand All @@ -120,8 +120,8 @@ const ConnectionFile: React.FC<ConnectionFileProps> = ({
return (
<Form onSubmit={handleSubmit}>
<WizardSubtitle
title={`Connect to ${connector?.name}`}
icon={connector?.icon}
title="Setup connection"
subTitle="Choose a file to upload"
/>
<Grid container sx={{ mt: 5 }}>
<Grid item md={8} sx={{ pr: 3 }}>
Expand Down Expand Up @@ -154,22 +154,26 @@ const ConnectionFile: React.FC<ConnectionFileProps> = ({
onChange={file => setValues({ ...values, file })}
accept={accept}
/>
<WizardBottomBar opts={opts}>
<LoadingButton
variant="contained"
type="submit"
sx={{
minWidth: 120,
backgroundColor: "#FC6016",
boxShadow: "0px 4px 6px 0px rgba(252, 96, 22, 0.20)",
}}
disabled={!values.file}
loading={loading}
>
Finish
</LoadingButton>
</WizardBottomBar>
</Grid>
<Grid item md={4} sx={{}}>
<CreateConnectionHelp connector={connector} />
</Grid>
</Grid>
<WizardBottomBar opts={opts}>
<LoadingButton
variant="contained"
type="submit"
sx={{ minWidth: 120 }}
disabled={!values.file}
loading={loading}
>
Finish
</LoadingButton>
</WizardBottomBar>
</Form>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react"
import { Tab, Tabs } from "@mui/material"

type ConnectorCategoryTabsProps = {
categories: string[]
value: string | null
onChange: (value: string | null) => void
}

const ConnectorCategoryTabs: React.FC<ConnectorCategoryTabsProps> = ({
categories,
value,
onChange,
}) => {
return (
<Tabs value={value} onChange={(_, newValue) => onChange(newValue)}>
<Tab label="All Integrations" value={null} />
{categories.map(category => (
<Tab
label={category}
value={category}
key={category}
sx={{ textTransform: "capitalize" }}
/>
))}
</Tabs>
)
}

export default ConnectorCategoryTabs
Loading
Loading