Commit c3e56831 authored by ioedeveloper's avatar ioedeveloper

Catch reserved keywords and display modal

parent 1ee1462f
...@@ -584,8 +584,23 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -584,8 +584,23 @@ export const FileExplorer = (props: FileExplorerProps) => {
modal('Validation Error', 'Special characters are not allowed', 'OK', () => {}) modal('Validation Error', 'Special characters are not allowed', 'OK', () => {})
} else { } else {
if (state.focusEdit.isNew) { 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)) state.focusEdit.type === 'file' ? createNewFile(joinPath(parentFolder, content)) : createNewFolder(joinPath(parentFolder, content))
removeInputField(parentFolder)(dispatch) 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 { } else {
const oldPath: string = state.focusEdit.element const oldPath: string = state.focusEdit.element
const oldName = extractNameFromKey(oldPath) const oldName = extractNameFromKey(oldPath)
...@@ -594,6 +609,7 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -594,6 +609,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
editRef.current.textContent = extractNameFromKey(oldPath) editRef.current.textContent = extractNameFromKey(oldPath)
renamePath(oldPath, newPath) renamePath(oldPath, newPath)
} }
}
setState(prevState => { setState(prevState => {
return { ...prevState, focusEdit: { element: null, isNew: false, type: '', lastEdit: '' } } return { ...prevState, focusEdit: { element: null, isNew: false, type: '', lastEdit: '' } }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment