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

View File

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