diff --git a/packages/backend/src/graphql/graphql-schema.ts b/packages/backend/src/graphql/graphql-schema.ts index 4f714b24..5b911151 100644 --- a/packages/backend/src/graphql/graphql-schema.ts +++ b/packages/backend/src/graphql/graphql-schema.ts @@ -7,7 +7,7 @@ const queryType = new GraphQLObjectType({ name: 'Query', fields: { getApps: { - type: GraphQLList(GraphQLString), + type: GraphQLList(appType), args: { name: { type: GraphQLString } }, diff --git a/packages/backend/src/graphql/types/app.ts b/packages/backend/src/graphql/types/app.ts index 3669c807..26699be9 100644 --- a/packages/backend/src/graphql/types/app.ts +++ b/packages/backend/src/graphql/types/app.ts @@ -7,6 +7,7 @@ const appType = new GraphQLObjectType({ name: { type: GraphQLString }, iconUrl: { type: GraphQLString }, docUrl: { type: GraphQLString }, + primaryColor: { type: GraphQLString }, fields: { type: GraphQLList(fieldType) } } }); diff --git a/packages/backend/src/models/app.ts b/packages/backend/src/models/app.ts index 2705556a..d5654697 100644 --- a/packages/backend/src/models/app.ts +++ b/packages/backend/src/models/app.ts @@ -1,12 +1,15 @@ import fs from 'fs'; class App { - static folderPath = __dirname + '/../apps' + static folderPath = __dirname + '/../apps'; static list = fs.readdirSync(this.folderPath); - static findAll(name?: string): string[] { - if(!name) return this.list; - return this.list.filter((app) => app.includes(name.toLowerCase())); + static findAll(name?: string): object[] { + if(!name) return this.list.map((name) => this.findOneByName(name)); + + return this.list + .filter((app) => app.includes(name.toLowerCase())) + .map((name) => this.findOneByName(name)); } static findOneByName(name: string): object { diff --git a/packages/web/package.json b/packages/web/package.json index b29b032a..243a27b6 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -19,6 +19,7 @@ "graphql": "^15.6.0", "react": "^17.0.2", "react-dom": "^17.0.2", + "react-hook-form": "^7.17.2", "react-intl": "^5.20.12", "react-router-dom": "^5.3.0", "react-scripts": "4.0.3", diff --git a/packages/web/src/components/AddAppConnection/index.tsx b/packages/web/src/components/AddAppConnection/index.tsx index d76580a4..d8f5bb91 100644 --- a/packages/web/src/components/AddAppConnection/index.tsx +++ b/packages/web/src/components/AddAppConnection/index.tsx @@ -2,13 +2,16 @@ import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import Dialog from '@mui/material/Dialog'; +import type { App } from 'types/app'; type AddAppConnectionProps = { onClose: (value: string) => void; + application: App; }; export default function AddAppConnection(props: AddAppConnectionProps){ - const { onClose } = props; + const { application, onClose } = props; + const { name } = application; return ( @@ -16,7 +19,7 @@ export default function AddAppConnection(props: AddAppConnectionProps){ - Here comes the "add connection" dialog + Add a connection to {name} diff --git a/packages/web/src/components/AppIcon/index.tsx b/packages/web/src/components/AppIcon/index.tsx index 46e5c7a3..feb19ac9 100644 --- a/packages/web/src/components/AppIcon/index.tsx +++ b/packages/web/src/components/AppIcon/index.tsx @@ -7,9 +7,9 @@ type AppIconProps = { }; export default function AppIcon(props: AppIconProps) { - const { color = '#00adef', name, url } = props; + const { color, name, url } = props; return ( - + ); }; diff --git a/packages/web/src/components/AppRow/index.tsx b/packages/web/src/components/AppRow/index.tsx index 09727638..92e5e260 100644 --- a/packages/web/src/components/AppRow/index.tsx +++ b/packages/web/src/components/AppRow/index.tsx @@ -1,36 +1,32 @@ import { Link } from 'react-router-dom'; import Card from '@mui/material/Card'; import Box from '@mui/material/Box'; -import Avatar from '@mui/material/Avatar'; import CardActionArea from '@mui/material/CardActionArea'; import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import useFormatMessage from 'hooks/useFormatMessage'; +import AppIcon from 'components/AppIcon'; +import * as URLS from 'config/urls'; +import type { App } from 'types/app'; import { CardContent, Typography, DesktopOnlyBreakline } from './style'; type AppRowProps = { - icon?: React.ReactNode; - name: string; - connectionNumber?: number; - flowNumber?: number; - to: string; + application: App; } const countTranslation = (value: React.ReactNode) => (<>{value}); function AppRow(props: AppRowProps) { const formatMessage = useFormatMessage(); - const { name, to } = props; + const { name, primaryColor, iconUrl } = props.application; return ( - + - - {name[0].toUpperCase()} - + diff --git a/packages/web/src/components/TextField/index.tsx b/packages/web/src/components/TextField/index.tsx new file mode 100644 index 00000000..36bd484a --- /dev/null +++ b/packages/web/src/components/TextField/index.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { Controller, Control, FieldValues } from "react-hook-form"; +import MuiTextField from "@mui/material/TextField"; + +type TextFieldProps = { + control: Control; + name: string; +} + +export default function TextField({ control, name }: TextFieldProps) { + return ( + } + /> + ); +}; diff --git a/packages/web/src/graphql/queries/get-app.ts b/packages/web/src/graphql/queries/get-app.ts index eb7f24a9..2999b2cf 100644 --- a/packages/web/src/graphql/queries/get-app.ts +++ b/packages/web/src/graphql/queries/get-app.ts @@ -6,6 +6,7 @@ export const GET_APP = gql` name iconUrl docUrl + primaryColor fields { key label diff --git a/packages/web/src/graphql/queries/get-apps.ts b/packages/web/src/graphql/queries/get-apps.ts index 236aa78c..d8f4f7eb 100644 --- a/packages/web/src/graphql/queries/get-apps.ts +++ b/packages/web/src/graphql/queries/get-apps.ts @@ -2,6 +2,22 @@ import { gql } from '@apollo/client'; export const GET_APPS = gql` query GetApps($name: String) { - getApps(name: $name) + getApps(name: $name) { + name + iconUrl + docUrl + primaryColor + fields { + key + label + type + required + readOnly + placeholder + description + docUrl + clickToCopy + } + } } `; \ No newline at end of file diff --git a/packages/web/src/pages/Application/index.tsx b/packages/web/src/pages/Application/index.tsx index 55d88ded..7b374997 100644 --- a/packages/web/src/pages/Application/index.tsx +++ b/packages/web/src/pages/Application/index.tsx @@ -38,7 +38,7 @@ export default function Application() { - + @@ -95,7 +95,7 @@ export default function Application() { - + ); diff --git a/packages/web/src/pages/Applications/index.tsx b/packages/web/src/pages/Applications/index.tsx index 492732d3..1bb5e1dc 100644 --- a/packages/web/src/pages/Applications/index.tsx +++ b/packages/web/src/pages/Applications/index.tsx @@ -8,8 +8,8 @@ import PageTitle from 'components/PageTitle'; import AppRow from 'components/AppRow'; import SearchInput from 'components/SearchInput'; import * as URLS from 'config/urls'; - import { GET_APPS } from 'graphql/queries/get-apps'; +import type { App } from 'types/app'; export default function Applications() { const [appName, setAppName] = useState(null); @@ -32,8 +32,8 @@ export default function Applications() { - {data?.getApps?.map((name: string) => ( - + {data?.getApps?.map((app: App) => ( + ))} diff --git a/packages/web/src/types/app.ts b/packages/web/src/types/app.ts new file mode 100644 index 00000000..98655e1a --- /dev/null +++ b/packages/web/src/types/app.ts @@ -0,0 +1,21 @@ +type AppFields = { + key: string; + label: string; + type: string; + required: boolean, + readOnly: boolean, + placeholder: string; + description: string; + docUrl: string; + clickToCopy: boolean, +}; + +type App = { + name: string; + iconUrl: string; + docUrl: string; + primaryColor: string; + fields: AppFields; +}; + +export type { App, AppFields }; diff --git a/yarn.lock b/yarn.lock index 500e8ff2..2ab38478 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12953,6 +12953,11 @@ react-error-overlay@^6.0.9: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a" integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew== +react-hook-form@^7.17.2: + version "7.17.2" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.17.2.tgz#235f15bb65c13e7a1198d33f2db24bcc9e27b303" + integrity sha512-oBaHwlYnbpzSFdNrs43QpcM+K2A0kUeNjV86ECYkCimlR1Ctl+tz4oQQd9plfGYkO7PJGLVMOVpUtL5EHjAcYQ== + react-intl@^5.20.12: version "5.20.12" resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-5.20.12.tgz#1a4969d15c381378cae35912fa2ec7010e27b4f7"