blob: 9a6266a6268dca73f18a5ff0f6618c15c0adcc3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import $ from 'jquery';
import React from 'react';
import Setting from './setting.jsx';
export default class RemoveFileSetting extends Setting {
static get propTypes() {
return {
id: React.PropTypes.string.isRequired,
label: React.PropTypes.node.isRequired,
helpText: React.PropTypes.node,
removeButtonText: React.PropTypes.node.isRequired,
removingText: React.PropTypes.node,
fileName: React.PropTypes.string.isRequired,
onSubmit: React.PropTypes.func.isRequired,
disabled: React.PropTypes.bool
};
}
constructor(props) {
super(props);
this.handleRemove = this.handleRemove.bind(this);
}
handleRemove(e) {
e.preventDefault();
$(this.refs.remove_button).button('loading');
this.props.onSubmit(this.props.id, () => {
$(this.refs.remove_button).button('reset');
});
}
render() {
return (
<Setting
label={this.props.label}
helpText={this.props.helpText}
inputId={this.props.id}
>
<div>
<div className='help-text remove-filename'>
{this.props.fileName}
</div>
<button
className='btn btn-danger'
onClick={this.handleRemove}
ref='remove_button'
disabled={this.props.disabled}
data-loading-text={`<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> ${this.props.removingText}`}
>
{this.props.removeButtonText}
</button>
</div>
</Setting>
);
}
}
|