diff --git a/src/GitServerClient.js b/src/GitServerClient.js index e8c342a..32f4ca7 100644 --- a/src/GitServerClient.js +++ b/src/GitServerClient.js @@ -42,13 +42,13 @@ const getMembershipForUser = async ({ owner, username }) => { return await callCWRCGitWithToken(`${baseUrl}/orgs/${owner}/memberships/${username}`); }; -const createRepo = async ({ repo, description, isPrivate }) => { +const createRepo = async ({ owner, repo, description, isPrivate }) => { let url = `${baseUrl}/user/repos`; if (isGitLab) url = `${baseUrl}/projects?name=${repo}`; return await callCWRCGitWithToken(url, { method: 'POST', - body: JSON.stringify({ repo, isPrivate, description }), + body: JSON.stringify({ owner, repo, isPrivate, description }), }); }; diff --git a/src/components/save/CreateRepoModal.js b/src/components/save/CreateRepoModal.js index 753d78d..3994ae0 100644 --- a/src/components/save/CreateRepoModal.js +++ b/src/components/save/CreateRepoModal.js @@ -37,7 +37,7 @@ const CreateRepoModal = ({ cancel, complete, owner, ownerType, repo }) => { if (ownerType === 'User') { newRepo = await cwrcGit - .createRepo({ repo, repoDesc, isPrivate }) + .createRepo({ owner, repo, repoDesc, isPrivate }) .catch((error) => displayError(error)); } else if (ownerType === 'Organization') { newRepo = await cwrcGit diff --git a/src/components/save/FileModal.js b/src/components/save/FileModal.js index 278c45a..681af54 100644 --- a/src/components/save/FileModal.js +++ b/src/components/save/FileModal.js @@ -95,7 +95,7 @@ const FileModal = ({ // if request from fork action, check file on forked repo if (fromFork) owner = username; - await cwrcGit + const response = await cwrcGit .saveDoc({ repo: `${owner}/${repo}`, path, @@ -103,13 +103,12 @@ const FileModal = ({ branch, message: commitMessage, }) + // eslint-disable-next-line no-unused-vars .catch((error) => { - if (error.status === 404) { - error.statusText = t('save:error.repoNoPermission'); - } - return displayError(error); + displayError(t('save:error.repoNoPermission')); }); + if (!response) return; complete(); };