This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit c348f17caeb9a99991bf12926d88ee4ffdb7cd6e
Author: 青湛 <[email protected]>
AuthorDate: Fri Mar 29 14:34:39 2024 +1300

    fix: missed project name check (#7244)
---
 config-ui/src/api/project/index.ts      |  2 ++
 config-ui/src/routes/onboard/step-1.tsx | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/config-ui/src/api/project/index.ts 
b/config-ui/src/api/project/index.ts
index dd6f786a0..fb8efe5e5 100644
--- a/config-ui/src/api/project/index.ts
+++ b/config-ui/src/api/project/index.ts
@@ -24,6 +24,8 @@ export const list = (data: Pagination): Promise<{ count: 
number; projects: IProj
 
 export const get = (name: string): Promise<IProject> => 
request(`/projects/${name}`);
 
+export const checkName = (name: string) => request(`/projects/${name}/check`);
+
 export const create = (data: Pick<IProject, 'name' | 'description' | 
'metrics'>) =>
   request('/projects', {
     method: 'post',
diff --git a/config-ui/src/routes/onboard/step-1.tsx 
b/config-ui/src/routes/onboard/step-1.tsx
index 707285d9a..6d97abcc5 100644
--- a/config-ui/src/routes/onboard/step-1.tsx
+++ b/config-ui/src/routes/onboard/step-1.tsx
@@ -55,6 +55,16 @@ export const Step1 = () => {
       return;
     }
 
+    const [, res] = await operator(() => API.project.checkName(projectName), {
+      setOperating,
+      hideToast: true,
+    });
+
+    if (res.exist) {
+      message.error(`Project name "${projectName}" already exists, please try 
another name.`);
+      return;
+    }
+
     const [success] = await operator(() => API.store.set('onboard', { step: 2, 
records, done, projectName, plugin }), {
       setOperating,
       hideToast: true,

Reply via email to