From cc071dddcf883867d4424a937cbdb51116353474 Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Mon, 18 Dec 2023 16:58:17 +0530 Subject: [PATCH] Implement layout for creating new project with template (#6) * Create layout for create project with template * Handle create project with tempalte form * Refactor pages folder according to routes * Add navigation to create project with template page --------- Co-authored-by: neeraj --- packages/frontend/src/App.tsx | 2 +- .../frontend/src/components/CreateRepo.tsx | 99 +++++++++++++++++++ .../frontend/src/components/Deployments.tsx | 6 +- packages/frontend/src/components/Dropdown.tsx | 10 +- .../frontend/src/components/TemplateCard.tsx | 13 ++- .../frontend/src/pages/projects/Create.tsx | 32 +++--- .../src/pages/projects/create/Template.tsx | 26 +++++ .../src/pages/projects/create/index.tsx | 25 +++++ .../src/pages/projects/create/routes.tsx | 15 +++ .../frontend/src/pages/projects/routes.tsx | 2 + packages/frontend/src/pages/routes.tsx | 2 +- 11 files changed, 199 insertions(+), 33 deletions(-) create mode 100644 packages/frontend/src/components/CreateRepo.tsx create mode 100644 packages/frontend/src/pages/projects/create/Template.tsx create mode 100644 packages/frontend/src/pages/projects/create/index.tsx create mode 100644 packages/frontend/src/pages/projects/create/routes.tsx diff --git a/packages/frontend/src/App.tsx b/packages/frontend/src/App.tsx index 76a24baa..0efb68b0 100644 --- a/packages/frontend/src/App.tsx +++ b/packages/frontend/src/App.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { createBrowserRouter, RouterProvider } from 'react-router-dom'; -import Home from './pages'; +import Home from './pages/index'; import { homeRoutes } from './pages/routes'; const router = createBrowserRouter([ diff --git a/packages/frontend/src/components/CreateRepo.tsx b/packages/frontend/src/components/CreateRepo.tsx new file mode 100644 index 00000000..80740b1c --- /dev/null +++ b/packages/frontend/src/components/CreateRepo.tsx @@ -0,0 +1,99 @@ +import React from 'react'; +import { useForm, Controller } from 'react-hook-form'; + +import Dropdown from './Dropdown'; + +const USER_OPTIONS = [ + { value: 'saugatyadav1', label: 'saugatyadav1' }, + { value: 'brad102', label: 'brad102' }, + { value: 'erin20', label: 'erin20' }, +]; + +const CreateRepo = () => { + const { register, handleSubmit, control } = useForm({ + defaultValues: { + framework: 'reactNative', + repoName: '', + isPrivate: false, + account: { value: 'saugatyadav1', label: 'saugatyadav1' }, + }, + }); + + return ( +
{})}> +
+

Create a repository

+

+ The project will be cloned into this repository +

+
+
+
Framework
+
+ + +
+
+
+
Git account
+
+ ( + + )} + /> +
+
+
+
Name the repo
+
+ +
+
+
+ +
+
+ +
+
+ ); +}; + +export default CreateRepo; diff --git a/packages/frontend/src/components/Deployments.tsx b/packages/frontend/src/components/Deployments.tsx index d45cfe21..308f5b63 100644 --- a/packages/frontend/src/components/Deployments.tsx +++ b/packages/frontend/src/components/Deployments.tsx @@ -4,7 +4,7 @@ import deploymentDetails from '../assets/deployments.json'; import DeployDetailsCard from './DeploymentDetailsCard'; import Dropdown from './Dropdown'; -const statusOptions = [ +const STATUS_OPTIONS = [ { value: 'production', label: 'Production' }, { value: 'preview', label: 'Preview' }, ]; @@ -30,8 +30,8 @@ const Deployments = () => {
{}} + options={STATUS_OPTIONS} + onChange={() => {}} />
diff --git a/packages/frontend/src/components/Dropdown.tsx b/packages/frontend/src/components/Dropdown.tsx index 6cf44f3d..aa24cafa 100644 --- a/packages/frontend/src/components/Dropdown.tsx +++ b/packages/frontend/src/components/Dropdown.tsx @@ -11,19 +11,21 @@ interface Option { } interface DropdownProps { - placeholder: string; options: Option[]; - handler: (arg: ReactDropdownOption) => void; + onChange: (arg: ReactDropdownOption) => void; + placeholder?: string; + value?: Option; } -const Dropdown = ({ placeholder, options, handler }: DropdownProps) => { +const Dropdown = ({ placeholder, options, onChange, value }: DropdownProps) => { return ( ); }; diff --git a/packages/frontend/src/components/TemplateCard.tsx b/packages/frontend/src/components/TemplateCard.tsx index 1c9b567f..30feaec5 100644 --- a/packages/frontend/src/components/TemplateCard.tsx +++ b/packages/frontend/src/components/TemplateCard.tsx @@ -1,5 +1,7 @@ import React from 'react'; +import { Link } from 'react-router-dom'; + interface TemplateDetails { framework: string; icon: string; @@ -10,9 +12,14 @@ interface TemplateCardProps { const TemplateCard: React.FC = ({ framework }) => { return ( -
- {framework.icon} - {framework.framework} +
+
+ {framework.icon} + {framework.framework} +
+ + +
); }; diff --git a/packages/frontend/src/pages/projects/Create.tsx b/packages/frontend/src/pages/projects/Create.tsx index 204cbc02..18758ad4 100644 --- a/packages/frontend/src/pages/projects/Create.tsx +++ b/packages/frontend/src/pages/projects/Create.tsx @@ -1,14 +1,8 @@ import React from 'react'; -import { Link } from 'react-router-dom'; - -import templateDetails from '../../assets/templates.json'; -import TemplateCard from '../../components/TemplateCard'; -import RepositoryList from '../../components/RepositoryList'; -import ConnectAccount from '../../components/ConnectAccount'; - -const IS_GIT_AUTH = true; +import { Outlet, useNavigate } from 'react-router-dom'; const CreateProject = () => { + const navigate = useNavigate(); return (
@@ -16,22 +10,18 @@ const CreateProject = () => {

Create new project

- - - +

-
Start with template
-
- {templateDetails.map((framework, key) => { - return ; - })} -
-
Import a repository
- {IS_GIT_AUTH ? : } +
); }; diff --git a/packages/frontend/src/pages/projects/create/Template.tsx b/packages/frontend/src/pages/projects/create/Template.tsx new file mode 100644 index 00000000..efde9fec --- /dev/null +++ b/packages/frontend/src/pages/projects/create/Template.tsx @@ -0,0 +1,26 @@ +import React from 'react'; + +import CreateRepo from '../../../components/CreateRepo'; + +const CreateWithTemplate = () => { + return ( +
+
+
^
+
React native
+
^snowball-tools/react-native-starter
+
+
+
+
1 Create repository
+
2 Deploy
+
+
+ +
+
+
+ ); +}; + +export default CreateWithTemplate; diff --git a/packages/frontend/src/pages/projects/create/index.tsx b/packages/frontend/src/pages/projects/create/index.tsx new file mode 100644 index 00000000..524c70fb --- /dev/null +++ b/packages/frontend/src/pages/projects/create/index.tsx @@ -0,0 +1,25 @@ +import React from 'react'; + +import templateDetails from '../../../assets/templates.json'; +import TemplateCard from '../../../components/TemplateCard'; +import RepositoryList from '../../../components/RepositoryList'; +import ConnectAccount from '../../../components/ConnectAccount'; + +const IS_GIT_AUTH = true; + +const NewProject = () => { + return ( + <> +
Start with template
+
+ {templateDetails.map((framework, key) => { + return ; + })} +
+
Import a repository
+ {IS_GIT_AUTH ? : } + + ); +}; + +export default NewProject; diff --git a/packages/frontend/src/pages/projects/create/routes.tsx b/packages/frontend/src/pages/projects/create/routes.tsx new file mode 100644 index 00000000..d8e1d2b7 --- /dev/null +++ b/packages/frontend/src/pages/projects/create/routes.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +import NewProject from './index'; +import CreateWithTemplate from './Template'; + +export const createProjectRoutes = [ + { + index: true, + element: , + }, + { + path: 'template', + element: , + }, +]; diff --git a/packages/frontend/src/pages/projects/routes.tsx b/packages/frontend/src/pages/projects/routes.tsx index f988e0b7..9d450f10 100644 --- a/packages/frontend/src/pages/projects/routes.tsx +++ b/packages/frontend/src/pages/projects/routes.tsx @@ -2,6 +2,7 @@ import React from 'react'; import CreateProject from './Create'; import Project from './Project'; +import { createProjectRoutes } from './create/routes'; export const projectsRoutes = [ { @@ -11,5 +12,6 @@ export const projectsRoutes = [ { path: 'create', element: , + children: createProjectRoutes, }, ]; diff --git a/packages/frontend/src/pages/routes.tsx b/packages/frontend/src/pages/routes.tsx index 1f82c111..756b362e 100644 --- a/packages/frontend/src/pages/routes.tsx +++ b/packages/frontend/src/pages/routes.tsx @@ -6,7 +6,7 @@ import { projectsRoutes } from './projects/routes'; export const homeRoutes = [ { - path: '/', + index: true, element: , }, {