Handle review changes
This commit is contained in:
parent
691edf3508
commit
dc6f436409
@ -1,7 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { useForm, Controller, SubmitHandler } from 'react-hook-form';
|
import { useForm, Controller, SubmitHandler } from 'react-hook-form';
|
||||||
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
|
import { useNavigate, useOutletContext, useParams } from 'react-router-dom';
|
||||||
import { toast as reactHotToast } from 'react-hot-toast';
|
|
||||||
import { RequestError } from 'octokit';
|
import { RequestError } from 'octokit';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
@ -45,9 +44,7 @@ const CreateRepo = () => {
|
|||||||
const [owner, repo] = template.repoFullName.split('/');
|
const [owner, repo] = template.repoFullName.split('/');
|
||||||
|
|
||||||
// TODO: Handle this functionality in backend
|
// TODO: Handle this functionality in backend
|
||||||
let gitRepo;
|
const gitRepo = await octokit?.rest.repos.createUsingTemplate({
|
||||||
try {
|
|
||||||
gitRepo = await octokit?.rest.repos.createUsingTemplate({
|
|
||||||
template_owner: owner,
|
template_owner: owner,
|
||||||
template_repo: repo,
|
template_repo: repo,
|
||||||
owner: data.account,
|
owner: data.account,
|
||||||
@ -55,24 +52,8 @@ const CreateRepo = () => {
|
|||||||
include_all_branches: false,
|
include_all_branches: false,
|
||||||
private: data.isPrivate,
|
private: data.isPrivate,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
if (
|
|
||||||
!(
|
|
||||||
error instanceof RequestError &&
|
|
||||||
error.message.includes(REPO_EXIST_ERROR)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
toast({
|
if (!gitRepo) {
|
||||||
id: 'repo-exist-error',
|
|
||||||
title: 'Could not create: repository already exists',
|
|
||||||
variant: 'error',
|
|
||||||
onDismiss: dismiss,
|
|
||||||
});
|
|
||||||
|
|
||||||
setIsLoading(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,18 +65,31 @@ const CreateRepo = () => {
|
|||||||
template: 'webapp',
|
template: 'webapp',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Boolean(addProject)) {
|
navigate(`deploy?projectId=${addProject.id}&templateId=${template.id}`);
|
||||||
setIsLoading(true);
|
|
||||||
navigate(
|
|
||||||
`deploy?projectId=${addProject.id}&templateId=${template.id}`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
reactHotToast.error('Error deploying project');
|
|
||||||
|
if (
|
||||||
|
err instanceof RequestError &&
|
||||||
|
err.message.includes(REPO_EXIST_ERROR)
|
||||||
|
) {
|
||||||
|
toast({
|
||||||
|
id: 'repo-exist-error',
|
||||||
|
title: 'Could not create: repository already exists',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(err);
|
||||||
|
toast({
|
||||||
|
id: 'error-deploying-project',
|
||||||
|
title: 'Error deploying project',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[octokit],
|
[octokit],
|
||||||
|
Loading…
Reference in New Issue
Block a user