From 12f81c63ce931234d0ada353fb255d3b166f7980 Mon Sep 17 00:00:00 2001 From: Ary Date: Sat, 10 Feb 2024 06:30:33 -0700 Subject: [PATCH] Project Manager: Quick Start (#762) --- apps/client/src/common/api/ontimeApi.ts | 19 +- .../panel/project-panel/ProjectCreateForm.tsx | 136 +++++++++++++ .../panel/project-panel/ProjectForm.tsx | 2 +- .../panel/project-panel/ProjectList.tsx | 24 +-- .../project-panel/ProjectPanel.module.scss | 12 ++ apps/client/src/features/editors/Editor.tsx | 5 - apps/client/src/features/menu/MenuBar.tsx | 14 -- .../modals/quick-start/QuickStart.tsx | 183 ------------------ .../src/controllers/ontimeController.ts | 54 +++--- apps/server/src/routes/ontimeRouter.ts | 7 +- .../src/utils/generateUniqueFilename.ts | 26 +++ 11 files changed, 219 insertions(+), 263 deletions(-) create mode 100644 apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx delete mode 100644 apps/client/src/features/modals/quick-start/QuickStart.tsx create mode 100644 apps/server/src/utils/generateUniqueFilename.ts diff --git a/apps/client/src/common/api/ontimeApi.ts b/apps/client/src/common/api/ontimeApi.ts index f7d8c06e6..c90cb3b15 100644 --- a/apps/client/src/common/api/ontimeApi.ts +++ b/apps/client/src/common/api/ontimeApi.ts @@ -247,13 +247,6 @@ export async function getLatestVersion(): Promise { }; } -/** - * @description HTTP POST request to create a new project file with given project data - */ -export async function postNew(initialData: Partial) { - return axios.post(`${ontimeURL}/new`, initialData); -} - /** * @description HTTP request to get the list of available project files */ @@ -382,11 +375,15 @@ export async function deleteProject(filename: string): Promise /** * @description HTTP request to create a project file */ -export async function createProject(filename: string): Promise { +export async function createProject( + project: Partial< + ProjectData & { + filename: string; + } + >, +): Promise { const url = `${ontimeURL}/project`; const decodedUrl = decodeURIComponent(url); - const res = await axios.post(decodedUrl, { - filename, - }); + const res = await axios.post(decodedUrl, project); return res.data; } diff --git a/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx new file mode 100644 index 000000000..6e3e6cd0a --- /dev/null +++ b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx @@ -0,0 +1,136 @@ +import { useEffect } from 'react'; +import { useForm } from 'react-hook-form'; +import { Button, Input, Textarea } from '@chakra-ui/react'; + +import style from './ProjectPanel.module.scss'; + +export type ProjectCreateFormValues = { + title?: string; + description?: string; + publicInfo?: string; + publicUrl?: string; + backstageInfo?: string; + backstageUrl?: string; +}; + +interface ProjectCreateFormProps { + onCancel: () => void; + onSubmit: (values: ProjectCreateFormValues) => Promise; + submitError: string | null; +} + +export default function ProjectCreateForm({ onSubmit, onCancel, submitError }: ProjectCreateFormProps) { + const { + handleSubmit, + register, + formState: { isSubmitting, isValid }, + setFocus, + } = useForm({ + defaultValues: { title: '' }, + values: { title: '' }, + resetOptions: { + keepDirtyValues: true, + }, + }); + + useEffect(() => { + setFocus('title'); + }, [setFocus]); + + return ( +
+
+ +
+
+ +
+
+