Fix pre-filling rename dialog with file name
This commit is contained in:
@ -3,8 +3,8 @@ import { template } from 'utils';
|
||||
|
||||
export default class Dialog extends Component {
|
||||
render() {
|
||||
let { input, title, description, active, value } = this.props;
|
||||
let conditionalInput = input ? <input ref='input' defaultValue={value} /> : '';
|
||||
let { input, title, description, active } = this.props;
|
||||
let conditionalInput = input ? <input ref='input' /> : '';
|
||||
|
||||
let buttons = this.props.buttons.map((button, i) => {
|
||||
return (
|
||||
@ -41,4 +41,12 @@ export default class Dialog extends Component {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (!this.props.value) return;
|
||||
|
||||
let input = React.findDOMNode(this.refs.input);
|
||||
|
||||
input.value = this.props.value;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import { hide, hideAll } from 'actions/dialog';
|
||||
import { hide, hideAll, show } from 'actions/dialog';
|
||||
import { rename, remove, create, active } from 'actions/file';
|
||||
import { search } from 'actions/files-view';
|
||||
import store, { bind } from 'store';
|
||||
|
||||
const INVALID_NAME = 'Please enter a valid name.';
|
||||
|
||||
export default {
|
||||
createDialog: {
|
||||
title: 'Create',
|
||||
@ -15,6 +17,8 @@ export default {
|
||||
action() {
|
||||
let input = React.findDOMNode(this.refs.input);
|
||||
|
||||
if (!input.value) show('errorDialog', {description: INVALID_NAME});
|
||||
|
||||
let cwd = store.getState().get('cwd');
|
||||
let path = cwd + '/' + input.value;
|
||||
let action = create(path.replace(/^\//, ''));
|
||||
@ -29,6 +33,8 @@ export default {
|
||||
action() {
|
||||
let input = React.findDOMNode(this.refs.input);
|
||||
|
||||
if (!input.value) show('errorDialog', {description: INVALID_NAME});
|
||||
|
||||
let cwd = store.getState().get('cwd');
|
||||
let path = cwd + '/' + input.value;
|
||||
let action = create(path.replace(/^\//, ''), true);
|
||||
@ -66,6 +72,8 @@ export default {
|
||||
action() {
|
||||
let input = React.findDOMNode(this.refs.input);
|
||||
|
||||
if (!input.value) show('errorDialog', {description: INVALID_NAME});
|
||||
|
||||
let activeFile = store.getState().get('activeFile');
|
||||
this.props.dispatch(rename(activeFile, input.value))
|
||||
this.props.dispatch(hideAll());
|
||||
@ -121,6 +129,8 @@ export default {
|
||||
action() {
|
||||
let input = React.findDOMNode(this.refs.input);
|
||||
|
||||
if (!input.value) show('errorDialog', {description: INVALID_NAME});
|
||||
|
||||
let action = search(input.value);
|
||||
this.props.dispatch(action);
|
||||
this.props.dispatch(hideAll());
|
||||
|
Reference in New Issue
Block a user