Catch reserved keywords and display modal

pull/5370/head
ioedeveloper 4 years ago
parent f351487107
commit cb3f39ba0a
  1. 16
      libs/remix-ui/file-explorer/src/lib/file-explorer.tsx

@ -584,8 +584,23 @@ export const FileExplorer = (props: FileExplorerProps) => {
modal('Validation Error', 'Special characters are not allowed', 'OK', () => {})
} else {
if (state.focusEdit.isNew) {
if ((content === props.name) || (content.indexOf('gist-') === 0)) {
removeInputField(parentFolder)(dispatch)
modal('Reserved Keyword', `File name contains remix reserved keywords. '${content}'`, {
label: 'Close',
fn: () => {}
}, null)
} else {
state.focusEdit.type === 'file' ? createNewFile(joinPath(parentFolder, content)) : createNewFolder(joinPath(parentFolder, content))
removeInputField(parentFolder)(dispatch)
}
} else {
if ((content === props.name) || (content.indexOf('gist-') === 0)) {
editRef.current.textContent = state.focusEdit.lastEdit
modal('Reserved Keyword', `File name contains remix reserved keywords. '${content}'`, {
label: 'Close',
fn: () => {}
}, null)
} else {
const oldPath: string = state.focusEdit.element
const oldName = extractNameFromKey(oldPath)
@ -594,6 +609,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
editRef.current.textContent = extractNameFromKey(oldPath)
renamePath(oldPath, newPath)
}
}
setState(prevState => {
return { ...prevState, focusEdit: { element: null, isNew: false, type: '', lastEdit: '' } }
})

Loading…
Cancel
Save