Update Import project flow to configure deployment
This commit is contained in:
parent
f374fa69ff
commit
9d8d2199e2
@ -67,7 +67,7 @@ export class Project {
|
|||||||
@Column('varchar')
|
@Column('varchar')
|
||||||
icon!: string;
|
icon!: string;
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
@Column({ type: 'simple-array', nullable: true })
|
||||||
baseDomains!: string[] | null;
|
baseDomains!: string[] | null;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
|
@ -299,6 +299,7 @@ export class Service {
|
|||||||
auctionId: Not(IsNull()),
|
auctionId: Not(IsNull()),
|
||||||
},
|
},
|
||||||
relations: ['deployments'],
|
relations: ['deployments'],
|
||||||
|
withDeleted: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Should only check on the first deployment
|
// Should only check on the first deployment
|
||||||
|
@ -26,7 +26,7 @@ const Configure = () => {
|
|||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const templateId = searchParams.get('templateId');
|
const templateId = searchParams.get('templateId');
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { templateOwner, templateRepo, owner, name, isPrivate, orgSlug } = location.state || {};
|
const { templateOwner, templateRepo, owner, name, isPrivate, orgSlug, repository } = location.state || {};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast, dismiss } = useToast();
|
const { toast, dismiss } = useToast();
|
||||||
@ -47,14 +47,6 @@ const Configure = () => {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const projectData: any = {
|
|
||||||
templateOwner,
|
|
||||||
templateRepo,
|
|
||||||
owner,
|
|
||||||
name,
|
|
||||||
isPrivate
|
|
||||||
};
|
|
||||||
|
|
||||||
let lrn: string | undefined;
|
let lrn: string | undefined;
|
||||||
let auctionData: AuctionData | undefined;
|
let auctionData: AuctionData | undefined;
|
||||||
|
|
||||||
@ -63,10 +55,20 @@ const Configure = () => {
|
|||||||
} else if (data.option === 'Auction') {
|
} else if (data.option === 'Auction') {
|
||||||
auctionData = {
|
auctionData = {
|
||||||
numProviders: Number(data.numProviders!),
|
numProviders: Number(data.numProviders!),
|
||||||
maxPrice: (data.maxPrice!).toString()
|
maxPrice: (data.maxPrice!).toString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (templateId) {
|
||||||
|
// Template-based project creation
|
||||||
|
const projectData: any = {
|
||||||
|
templateOwner,
|
||||||
|
templateRepo,
|
||||||
|
owner,
|
||||||
|
name,
|
||||||
|
isPrivate,
|
||||||
|
};
|
||||||
|
|
||||||
const { addProjectFromTemplate } = await client.addProjectFromTemplate(
|
const { addProjectFromTemplate } = await client.addProjectFromTemplate(
|
||||||
orgSlug,
|
orgSlug,
|
||||||
projectData,
|
projectData,
|
||||||
@ -77,12 +79,33 @@ const Configure = () => {
|
|||||||
data.option === 'Auction'
|
data.option === 'Auction'
|
||||||
? navigate(
|
? navigate(
|
||||||
`/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}`,
|
`/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}`,
|
||||||
|
{ state: { isAuction: true } }
|
||||||
|
)
|
||||||
|
: navigate(
|
||||||
|
`/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const { addProject } = await client.addProject(
|
||||||
|
orgSlug,
|
||||||
{
|
{
|
||||||
state: {
|
name: repository.fullName,
|
||||||
isAuction: true
|
prodBranch: repository.defaultBranch,
|
||||||
|
repository: repository.fullName,
|
||||||
|
template: 'webapp',
|
||||||
|
},
|
||||||
|
lrn,
|
||||||
|
auctionData
|
||||||
|
);
|
||||||
|
|
||||||
|
data.option === 'Auction'
|
||||||
|
? navigate(
|
||||||
|
`/${orgSlug}/projects/create/success/${addProject.id}`,
|
||||||
|
{ state: { isAuction: true } }
|
||||||
|
)
|
||||||
|
: navigate(
|
||||||
|
`/${orgSlug}/projects/create/deploy?projectId=${addProject.id}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
: navigate(`/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}`);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating project:', error);
|
console.error('Error creating project:', error);
|
||||||
toast({
|
toast({
|
||||||
@ -106,7 +129,9 @@ const Configure = () => {
|
|||||||
Configure deployment
|
Configure deployment
|
||||||
</Heading>
|
</Heading>
|
||||||
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
||||||
The app can be deployed by setting the deployer LRN for a single deployment or by creating a deployer auction for multiple deployments
|
The app can be deployed by setting the deployer LRN for a single
|
||||||
|
deployment or by creating a deployer auction for multiple
|
||||||
|
deployments
|
||||||
</Heading>
|
</Heading>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -119,11 +144,14 @@ const Configure = () => {
|
|||||||
control={control}
|
control={control}
|
||||||
render={({ field: { value, onChange } }) => (
|
render={({ field: { value, onChange } }) => (
|
||||||
<Select
|
<Select
|
||||||
label='Configuration Options'
|
label="Configuration Options"
|
||||||
value={{ value: value || 'LRN', label: value === 'Auction' ? 'Create Auction' : 'Deployer LRN' } as SelectOption}
|
value={
|
||||||
onChange={(value) =>
|
{
|
||||||
onChange((value as SelectOption).value)
|
value: value || 'LRN',
|
||||||
|
label: value === 'Auction' ? 'Create Auction' : 'Deployer LRN',
|
||||||
|
} as SelectOption
|
||||||
}
|
}
|
||||||
|
onChange={(value) => onChange((value as SelectOption).value)}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'LRN', label: 'Deployer LRN' },
|
{ value: 'LRN', label: 'Deployer LRN' },
|
||||||
{ value: 'Auction', label: 'Create Auction' },
|
{ value: 'Auction', label: 'Create Auction' },
|
||||||
@ -138,7 +166,9 @@ const Configure = () => {
|
|||||||
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
||||||
The app will be deployed by the configured deployer
|
The app will be deployed by the configured deployer
|
||||||
</Heading>
|
</Heading>
|
||||||
<span className="text-sm text-elements-high-em">Enter LRN for deployer</span>
|
<span className="text-sm text-elements-high-em">
|
||||||
|
Enter LRN for deployer
|
||||||
|
</span>
|
||||||
<Controller
|
<Controller
|
||||||
name="lrn"
|
name="lrn"
|
||||||
control={control}
|
control={control}
|
||||||
@ -155,7 +185,9 @@ const Configure = () => {
|
|||||||
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
<Heading as="h5" className="text-sm font-sans text-elements-low-em">
|
||||||
Set the number of deployers and maximum price for each deployment
|
Set the number of deployers and maximum price for each deployment
|
||||||
</Heading>
|
</Heading>
|
||||||
<span className="text-sm text-elements-high-em">Number of Deployers</span>
|
<span className="text-sm text-elements-high-em">
|
||||||
|
Number of Deployers
|
||||||
|
</span>
|
||||||
<Controller
|
<Controller
|
||||||
name="numProviders"
|
name="numProviders"
|
||||||
control={control}
|
control={control}
|
||||||
@ -165,7 +197,9 @@ const Configure = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col justify-start gap-3">
|
<div className="flex flex-col justify-start gap-3">
|
||||||
<span className="text-sm text-elements-high-em">Maximum Price (alnt)</span>
|
<span className="text-sm text-elements-high-em">
|
||||||
|
Maximum Price (alnt)
|
||||||
|
</span>
|
||||||
<Controller
|
<Controller
|
||||||
name="maxPrice"
|
name="maxPrice"
|
||||||
control={control}
|
control={control}
|
||||||
|
@ -38,36 +38,19 @@ export const ProjectRepoCard: React.FC<ProjectRepoCardProps> = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
navigate(`configure`,
|
||||||
setIsLoading(true);
|
{
|
||||||
const { addProject } = await client.addProject(orgSlug, {
|
state: {
|
||||||
name: `${repository.owner?.login}-${repository.name}`,
|
repository: {
|
||||||
prodBranch: repository.default_branch as string,
|
owner: repository.owner?.login,
|
||||||
repository: repository.full_name,
|
name: repository.name,
|
||||||
// TODO: Compute template from repo
|
defaultBranch: repository.default_branch,
|
||||||
template: 'webapp',
|
fullName: repository.full_name,
|
||||||
});
|
},
|
||||||
if (addProject) {
|
orgSlug,
|
||||||
navigate(`import?projectId=${addProject.id}`);
|
},
|
||||||
} else {
|
|
||||||
toast({
|
|
||||||
id: 'failed-to-create-project',
|
|
||||||
title: 'Failed to create project',
|
|
||||||
variant: 'error',
|
|
||||||
onDismiss: dismiss,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error((error as Error).message);
|
|
||||||
toast({
|
|
||||||
id: 'failed-to-create-project',
|
|
||||||
title: 'Failed to create project',
|
|
||||||
variant: 'error',
|
|
||||||
onDismiss: dismiss,
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
}, [client, repository, orgSlug, setIsLoading, navigate, toast]);
|
}, [client, repository, orgSlug, setIsLoading, navigate, toast]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -2,7 +2,8 @@ import NewProject from './index';
|
|||||||
import CreateWithTemplate from './Template';
|
import CreateWithTemplate from './Template';
|
||||||
import { templateRoutes } from './template/routes';
|
import { templateRoutes } from './template/routes';
|
||||||
import Id from './success/Id';
|
import Id from './success/Id';
|
||||||
import Import from './Import';
|
import Configure from 'components/projects/create/Configure';
|
||||||
|
import Deploy from 'components/projects/create/Deploy';
|
||||||
|
|
||||||
export const createProjectRoutes = [
|
export const createProjectRoutes = [
|
||||||
{
|
{
|
||||||
@ -19,7 +20,11 @@ export const createProjectRoutes = [
|
|||||||
element: <Id />,
|
element: <Id />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'import',
|
path: 'configure',
|
||||||
element: <Import />,
|
element: <Configure />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'deploy',
|
||||||
|
element: <Deploy />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
2
packages/gql-client/dist/index.js
vendored
2
packages/gql-client/dist/index.js
vendored
@ -385,7 +385,7 @@ var addProjectFromTemplate = import_client2.gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
var addProject = import_client2.gql`
|
var addProject = import_client2.gql`
|
||||||
mutation ($organizationSlug: String!, $data: AddProjectInput, $lrn: String, $auctionData: AuctionData) {
|
mutation ($organizationSlug: String!, $data: AddProjectInput!, $lrn: String, $auctionData: AuctionData) {
|
||||||
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
2
packages/gql-client/dist/index.js.map
vendored
2
packages/gql-client/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
packages/gql-client/dist/index.mjs
vendored
2
packages/gql-client/dist/index.mjs
vendored
@ -357,7 +357,7 @@ var addProjectFromTemplate = gql2`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
var addProject = gql2`
|
var addProject = gql2`
|
||||||
mutation ($organizationSlug: String!, $data: AddProjectInput, $lrn: String, $auctionData: AuctionData) {
|
mutation ($organizationSlug: String!, $data: AddProjectInput!, $lrn: String, $auctionData: AuctionData) {
|
||||||
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
2
packages/gql-client/dist/index.mjs.map
vendored
2
packages/gql-client/dist/index.mjs.map
vendored
File diff suppressed because one or more lines are too long
@ -57,7 +57,7 @@ export const addProjectFromTemplate = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const addProject = gql`
|
export const addProject = gql`
|
||||||
mutation ($organizationSlug: String!, $data: AddProjectInput, $lrn: String, $auctionData: AuctionData) {
|
mutation ($organizationSlug: String!, $data: AddProjectInput!, $lrn: String, $auctionData: AuctionData) {
|
||||||
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionData: $auctionData) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user