diff --git a/package.json b/package.json index a0a1dc02..e777aec4 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "scripts": { "start": "lerna run --stream --scope=@*/{web,backend} dev", - "start:web": "lerna run --stream --scope @*/web start", + "start:web": "lerna run --stream --scope @*/web dev", "start:backend": "lerna run --stream --scope @*/backend dev" }, "workspaces": [ diff --git a/packages/web/src/components/AddNewAppConnection/index.tsx b/packages/web/src/components/AddNewAppConnection/index.tsx new file mode 100644 index 00000000..40b20c6f --- /dev/null +++ b/packages/web/src/components/AddNewAppConnection/index.tsx @@ -0,0 +1,66 @@ +import { useCallback, useState } from 'react'; +import { useQuery } from '@apollo/client'; +import { Link } from 'react-router-dom'; +import DialogTitle from '@mui/material/DialogTitle'; +import DialogContent from '@mui/material/DialogContent'; +import Dialog from '@mui/material/Dialog'; +import TextField from '@mui/material/TextField'; +import SearchIcon from '@mui/icons-material/Search'; +import InputAdornment from '@mui/material/InputAdornment'; +import List from '@mui/material/List'; +import ListItem from '@mui/material/ListItem'; +import ListItemButton from '@mui/material/ListItemButton'; +import ListItemIcon from '@mui/material/ListItemIcon'; +import ListItemText from '@mui/material/ListItemText'; + +import * as URLS from 'config/urls'; +import AppIcon from 'components/AppIcon'; +import type { App } from 'types/app'; +import { GET_APPS } from 'graphql/queries/get-apps'; +import useFormatMessage from 'hooks/useFormatMessage'; + +type AddNewAppConnectionProps = { + onClose: () => void; +}; + +export default function AddNewAppConnection(props: AddNewAppConnectionProps){ + const { onClose } = props; + const formatMessage = useFormatMessage(); + const [appName, setAppName] = useState(null); + const { data } = useQuery(GET_APPS, { variables: {name: appName } }); + + return ( + + {formatMessage('apps.addNewAppConnection')} + + + setAppName(event.target.value)} + InputProps={{ + startAdornment: ( + + + + ), + }} + /> + + + {data?.getApps?.map((app: App) => ( + + + + + + + + + ))} + + + + ); +}; diff --git a/packages/web/src/components/AppRow/index.tsx b/packages/web/src/components/AppRow/index.tsx index 92e5e260..cbc5a75b 100644 --- a/packages/web/src/components/AppRow/index.tsx +++ b/packages/web/src/components/AppRow/index.tsx @@ -14,7 +14,7 @@ type AppRowProps = { application: App; } -const countTranslation = (value: React.ReactNode) => (<>{value}); +const countTranslation = (value: React.ReactNode) => (<>{value}
); function AppRow(props: AppRowProps) { const formatMessage = useFormatMessage(); diff --git a/packages/web/src/components/AppRow/style.ts b/packages/web/src/components/AppRow/style.ts index 84f3612c..89ee3a3b 100644 --- a/packages/web/src/components/AppRow/style.ts +++ b/packages/web/src/components/AppRow/style.ts @@ -20,7 +20,7 @@ export const Typography = styled(MuiTypography)(({ theme }) => ({ })); export const DesktopOnlyBreakline = styled('br')(({ theme }) => ({ - [theme.breakpoints.down('md')]: { + [theme.breakpoints.down('sm')]: { display: 'none', } })); diff --git a/packages/web/src/config/urls.ts b/packages/web/src/config/urls.ts index ad1c585f..0e937dfe 100644 --- a/packages/web/src/config/urls.ts +++ b/packages/web/src/config/urls.ts @@ -10,3 +10,5 @@ export const APP_ADD_CONNECTION = (appSlug: string) => `/app/${appSlug}/connecti export const APP_ADD_CONNECTION_PATTERN = '/app/:slug/connections/add'; export const APP_FLOWS = (appSlug: string) => `/app/${appSlug}/flows`; export const APP_FLOWS_PATTERN = '/app/:slug/flows'; + +export const NEW_APP_CONNECTION = '/apps/new'; \ No newline at end of file diff --git a/packages/web/src/graphql/cache.ts b/packages/web/src/graphql/cache.ts new file mode 100644 index 00000000..f834f1fa --- /dev/null +++ b/packages/web/src/graphql/cache.ts @@ -0,0 +1,11 @@ +import { InMemoryCache } from '@apollo/client'; + +const cache = new InMemoryCache({ + typePolicies: { + App: { + keyFields: ['key'] + } + } +}); + +export default cache; diff --git a/packages/web/src/graphql/client.ts b/packages/web/src/graphql/client.ts index a4d3ad03..bb0b0d71 100644 --- a/packages/web/src/graphql/client.ts +++ b/packages/web/src/graphql/client.ts @@ -1,7 +1,7 @@ -import { ApolloClient, InMemoryCache } from '@apollo/client'; +import { ApolloClient } from '@apollo/client'; +import cache from './cache'; import appConfig from 'config/app'; -const cache = new InMemoryCache(); const client = new ApolloClient({ uri: appConfig.graphqlUrl, cache diff --git a/packages/web/src/graphql/queries/get-apps.ts b/packages/web/src/graphql/queries/get-apps.ts index d8f4f7eb..54106964 100644 --- a/packages/web/src/graphql/queries/get-apps.ts +++ b/packages/web/src/graphql/queries/get-apps.ts @@ -3,6 +3,7 @@ import { gql } from '@apollo/client'; export const GET_APPS = gql` query GetApps($name: String) { getApps(name: $name) { + key name iconUrl docUrl diff --git a/packages/web/src/locales/en.json b/packages/web/src/locales/en.json index cb830a71..03b6bb96 100644 --- a/packages/web/src/locales/en.json +++ b/packages/web/src/locales/en.json @@ -11,5 +11,9 @@ "app.addConnection": "Add connection", "app.settings": "Settings", "app.connections": "Connections", - "app.flows": "Flows" + "app.flows": "Flows", + "apps.title": "Apps", + "apps.addConnection": "Add connection", + "apps.addNewAppConnection": "Add a new app connection", + "apps.searchApp": "Search for app" } \ No newline at end of file diff --git a/packages/web/src/pages/Applications/index.tsx b/packages/web/src/pages/Applications/index.tsx index 1bb5e1dc..d8e302bf 100644 --- a/packages/web/src/pages/Applications/index.tsx +++ b/packages/web/src/pages/Applications/index.tsx @@ -1,17 +1,23 @@ import { useCallback, useState } from 'react'; +import { Link, Route, useHistory } from 'react-router-dom'; import { useQuery } from '@apollo/client'; import Box from '@mui/material/Box'; import Grid from '@mui/material/Grid'; +import Button from '@mui/material/Button'; import Container from 'components/Container'; +import AddNewAppConnection from 'components/AddNewAppConnection'; import PageTitle from 'components/PageTitle'; import AppRow from 'components/AppRow'; import SearchInput from 'components/SearchInput'; -import * as URLS from 'config/urls'; +import useFormatMessage from 'hooks/useFormatMessage' import { GET_APPS } from 'graphql/queries/get-apps'; +import * as URLS from 'config/urls'; import type { App } from 'types/app'; export default function Applications() { + const history = useHistory(); + const formatMessage = useFormatMessage(); const [appName, setAppName] = useState(null); const { data } = useQuery(GET_APPS, { variables: {name: appName } }); @@ -19,22 +25,45 @@ export default function Applications() { setAppName(event.target.value); }, []); + const goToApps = useCallback(() => { + history.push(URLS.APPS); + }, [history]); + return ( - - - Applications + + + {formatMessage('apps.title')} - - + + + + + + + + {data?.getApps?.map((app: App) => ( ))} + + + + ); diff --git a/packages/web/src/routes.tsx b/packages/web/src/routes.tsx index 0f9d0022..f822da4e 100644 --- a/packages/web/src/routes.tsx +++ b/packages/web/src/routes.tsx @@ -16,7 +16,7 @@ export default ( - +