Set project name for repository organization and name (#57)

* Remove unused methods from backend utils

* Set project name from repo organization and name when creating project

* Rename success and project components according to routes
This commit is contained in:
2024-02-06 16:18:29 +05:30
committed by GitHub
parent afd522654c
commit c0cee2c57f
11 changed files with 22 additions and 92 deletions
@@ -8,7 +8,7 @@ import HorizontalLine from '../../components/HorizontalLine';
import ProjectTabs from '../../components/projects/project/ProjectTabs';
import { useGQLClient } from '../../context/GQLClientContext';
const Project = () => {
const Id = () => {
const { id } = useParams();
const navigate = useNavigate();
const client = useGQLClient();
@@ -64,4 +64,4 @@ const Project = () => {
);
};
export default Project;
export default Id;
@@ -39,16 +39,14 @@ const Import = () => {
const { addProject } = await client.addProject({
// TODO: Implement form for setting project name
name: gitRepo.name,
name: `${gitRepo.owner!.login}-${gitRepo.name}`,
// TODO: Get organization id from context or URL
organizationId: String(1),
prodBranch: gitRepo.default_branch ?? 'main',
repository: gitRepo.full_name,
});
if (addProject) {
navigate('/projects/create/success');
}
navigate(`/projects/create/success/${addProject.id}`);
}, [client, gitRepo]);
return (
@@ -3,7 +3,7 @@ import React from 'react';
import NewProject from './index';
import CreateWithTemplate from './Template';
import { templateRoutes } from './template/routes';
import Success from './Success';
import Id from './success/Id';
import Import from './Import';
export const createProjectRoutes = [
@@ -17,8 +17,8 @@ export const createProjectRoutes = [
children: templateRoutes,
},
{
path: 'success',
element: <Success />,
path: 'success/:id',
element: <Id />,
},
{
path: 'import',
@@ -1,10 +1,10 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link, useParams } from 'react-router-dom';
import { Button } from '@material-tailwind/react';
// TODO: Use dynamic route params for fetching project created details
const Success = () => {
const Id = () => {
const { id } = useParams();
return (
<div className="flex justify-center">
<div className="w-1/2">
@@ -57,7 +57,7 @@ const Success = () => {
</Link>
</div>
<div>
<Link to="/projects/1">
<Link to={`/projects/${id}`}>
<Button className="rounded-full" variant="gradient" color="blue">
View project
</Button>
@@ -69,4 +69,4 @@ const Success = () => {
);
};
export default Success;
export default Id;
@@ -1,7 +1,7 @@
import React from 'react';
import CreateProject from './Create';
import Project from './Project';
import Id from './Id';
import AddDomain from './id/domain/add';
import { createProjectRoutes } from './create/routes';
import { addDomainRoutes } from './id/domain/add/routes';
@@ -22,6 +22,6 @@ export const projectsRoutesWithoutSearch = [
export const projectsRoutesWithSearch = [
{
path: ':id',
element: <Project />,
element: <Id />,
},
];