1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-29 09:40:10 +02:00

add rename file support and validate duplicate file names

This commit is contained in:
Kushagra Gour
2018-10-08 16:28:17 +05:30
parent 556e507a83
commit 770f25a6ee
4 changed files with 129 additions and 31 deletions

View File

@@ -490,7 +490,9 @@ export default class App extends Component {
isKeyboardShortcutsModalOpen: !this.state.isKeyboardShortcutsModalOpen
});
trackEvent('ui', 'showKeyboardShortcutsShortcut');
} else if (event.keyCode === 27) {
} else if (event.keyCode === 27 && event.target.tagName !== 'INPUT') {
// We might be listening on keydown for some input inside the app. In that case
// we don't want this to trigger which in turn focuses back the last editor.
this.closeSavedItemsPane();
}
});
@@ -1202,6 +1204,19 @@ export default class App extends Component {
}
});
}
renameFileHandler(oldFileName, newFileName) {
this.setState({
currentItem: {
...this.state.currentItem,
files: this.state.currentItem.files.map(file => {
if (file.name === oldFileName) {
return { ...file, name: newFileName };
}
return file;
})
}
});
}
render() {
return (
@@ -1236,6 +1251,7 @@ export default class App extends Component {
onSplitUpdate={this.splitUpdateHandler.bind(this)}
onAddFile={this.addFileHandler.bind(this)}
onRemoveFile={this.removeFileHandler.bind(this)}
onRenameFile={this.renameFileHandler.bind(this)}
/>
) : (
<ContentWrap