Fix 500 exception when editing a file (#96)

jobatzil/rename
Tan Nhu 2022-11-29 02:48:37 -08:00 committed by GitHub
parent 505d72049b
commit a90fc1c59e
2 changed files with 6 additions and 2 deletions

View File

@ -52,6 +52,7 @@ interface CommitModalButtonProps extends Omit<ButtonProps, 'onClick' | 'onSubmit
commitTitlePlaceHolder: string
oldResourcePath?: string
payload?: string
sha?: string
onSuccess: (data: RepoCommitFilesResponse, newBranch?: string) => void
}
@ -63,6 +64,7 @@ export const CommitModalButton: React.FC<CommitModalButtonProps> = ({
commitTitlePlaceHolder,
oldResourcePath,
payload = '',
sha,
onSuccess,
...props
}) => {
@ -82,7 +84,8 @@ export const CommitModalButton: React.FC<CommitModalButtonProps> = ({
{
action: commitAction,
path: oldResourcePath || resourcePath,
payload: `${oldResourcePath ? `file://${resourcePath}\n` : ''}${payload}`
payload: `${oldResourcePath ? `file://${resourcePath}\n` : ''}${payload}`,
sha
// encoding: 'base64',
// payload: window.btoa(payload || '')
}

View File

@ -179,9 +179,10 @@ function Editor({
oldResourcePath={commitAction === GitCommitAction.MOVE ? resourcePath : undefined}
resourcePath={fileResourcePath}
payload={content}
sha={resourceContent.sha}
onSuccess={(_data, newBranch) => {
history.replace(
routes.toCODERepositoryFileEdit({
routes.toCODERepository({
repoPath: repoMetadata.path as string,
resourcePath: fileResourcePath,
gitRef: newBranch || gitRef