Updating stuff with states in slack import
Этот коммит содержится в:
@@ -12,7 +12,7 @@ export default class SettingsUpload extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
clientError: this.props.clientError,
|
clientError: this.props.clientError,
|
||||||
serverError: this.props.serverError,
|
serverError: this.props.serverError,
|
||||||
importClass: ' disabled'
|
fileSelected: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export default class SettingsUpload extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
clientError: this.props.clientError,
|
clientError: this.props.clientError,
|
||||||
serverError: this.props.serverError,
|
serverError: this.props.serverError,
|
||||||
importClass: ' disabled'
|
fileSelected: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export default class SettingsUpload extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
clientError: '',
|
clientError: '',
|
||||||
serverError: '',
|
serverError: '',
|
||||||
importClass: ' disabled'
|
fileSelected: ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,15 +44,13 @@ export default class SettingsUpload extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFileSelect(e) {
|
onFileSelect(e) {
|
||||||
this.setState({
|
|
||||||
importClass: ''
|
|
||||||
});
|
|
||||||
var filename = $(e.target).val();
|
var filename = $(e.target).val();
|
||||||
if (filename.substring(3, 11) === 'fakepath') {
|
if (filename.substring(3, 11) === 'fakepath') {
|
||||||
filename = filename.substring(12);
|
filename = filename.substring(12);
|
||||||
}
|
}
|
||||||
$(e.target).closest('li').find('.file-status').addClass('hide');
|
this.setState({
|
||||||
$(e.target).closest('li').find('.file-name').removeClass('hide').html(filename);
|
fileSelected: filename
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -68,9 +66,47 @@ export default class SettingsUpload extends React.Component {
|
|||||||
<div className='file-status'>{this.state.serverError}</div>
|
<div className='file-status'>{this.state.serverError}</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var importClass = '';
|
var fileSelected = (
|
||||||
if (this.state.importClass) {
|
<div>
|
||||||
importClass = ' disabled';
|
<span className='btn btn-sm btn-primary btn-file sel-btn'>
|
||||||
|
{'Select file'}
|
||||||
|
<input
|
||||||
|
ref='uploadinput'
|
||||||
|
accept={this.props.fileTypesAccepted}
|
||||||
|
type='file'
|
||||||
|
onChange={this.onFileSelect}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<a
|
||||||
|
className={'btn btn-sm btn-primary disabled'}
|
||||||
|
onClick={this.doSubmit}
|
||||||
|
>
|
||||||
|
{'Import'}
|
||||||
|
</a>
|
||||||
|
<div className='file-status file-name hidden'></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
if (this.state.fileSelected) {
|
||||||
|
fileSelected = (
|
||||||
|
<div>
|
||||||
|
<span className='btn btn-sm btn-primary btn-file sel-btn'>
|
||||||
|
{'Select file'}
|
||||||
|
<input
|
||||||
|
ref='uploadinput'
|
||||||
|
accept={this.props.fileTypesAccepted}
|
||||||
|
type='file'
|
||||||
|
onChange={this.onFileSelect}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<a
|
||||||
|
className={'btn btn-sm btn-primary'}
|
||||||
|
onClick={this.doSubmit}
|
||||||
|
>
|
||||||
|
{'Import'}
|
||||||
|
</a>
|
||||||
|
<div className='file-status file-name'>{this.state.fileSelected}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ul className='section-max'>
|
<ul className='section-max'>
|
||||||
@@ -79,22 +115,7 @@ export default class SettingsUpload extends React.Component {
|
|||||||
<li className='col-sm-offset-3 col-sm-9'>
|
<li className='col-sm-offset-3 col-sm-9'>
|
||||||
<ul className='setting-list'>
|
<ul className='setting-list'>
|
||||||
<li className='setting-list-item'>
|
<li className='setting-list-item'>
|
||||||
<span className='btn btn-sm btn-primary btn-file sel-btn'>
|
{fileSelected}
|
||||||
{'Select file'}
|
|
||||||
<input
|
|
||||||
ref='uploadinput'
|
|
||||||
accept={this.props.fileTypesAccepted}
|
|
||||||
type='file'
|
|
||||||
onChange={this.onFileSelect}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
<a
|
|
||||||
className={'btn btn-sm btn-primary' + importClass}
|
|
||||||
onClick={this.doSubmit}
|
|
||||||
>
|
|
||||||
{'Import'}
|
|
||||||
</a>
|
|
||||||
<div className='file-status file-name hide'></div>
|
|
||||||
{serverError}
|
{serverError}
|
||||||
{clientError}
|
{clientError}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user