PLT-3624 quick fix remove SAML certificates without saving (#3555)

Этот коммит содержится в:
enahum
2016-07-12 16:10:04 -04:00
коммит произвёл Harrison Healey
родитель caef414abe
Коммит ab52700aaa
3 изменённых файлов: 12 добавлений и 17 удалений

Просмотреть файл

@@ -18,7 +18,8 @@ export default class FileUploadSetting extends Setting {
uploadingText: React.PropTypes.node, uploadingText: React.PropTypes.node,
onSubmit: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired,
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
fileType: React.PropTypes.string.isRequired fileType: React.PropTypes.string.isRequired,
error: React.PropTypes.string
}; };
} }
@@ -29,7 +30,8 @@ export default class FileUploadSetting extends Setting {
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.state = { this.state = {
fileName: null fileName: null,
serverError: props.error
}; };
} }

Просмотреть файл

@@ -23,28 +23,18 @@ export default class RemoveFileSetting extends Setting {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleRemove = this.handleRemove.bind(this); this.handleRemove = this.handleRemove.bind(this);
this.state = {
serverError: null
};
} }
handleRemove(e) { handleRemove(e) {
e.preventDefault(); e.preventDefault();
$(this.refs.remove_button).button('loading'); $(this.refs.remove_button).button('loading');
this.props.onSubmit(this.props.id, (error) => { this.props.onSubmit(this.props.id, () => {
$(this.refs.remove_button).button('reset'); $(this.refs.remove_button).button('reset');
this.setState({serverError: error});
}); });
} }
render() { render() {
let serverError;
if (this.state.serverError) {
serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
}
return ( return (
<Setting <Setting
label={this.props.label} label={this.props.label}
@@ -64,7 +54,6 @@ export default class RemoveFileSetting extends Setting {
> >
{this.props.removeButtonText} {this.props.removeButtonText}
</button> </button>
{serverError}
</div> </div>
</Setting> </Setting>
); );

Просмотреть файл

@@ -76,7 +76,7 @@ export default class SamlSettings extends AdminSettings {
() => { () => {
const fileName = file.name; const fileName = file.name;
this.handleChange(id, fileName); this.handleChange(id, fileName);
this.setState({[id]: fileName}); this.setState({[id]: fileName, [`${id}Error`]: null});
if (callback && typeof callback === 'function') { if (callback && typeof callback === 'function') {
callback(); callback();
} }
@@ -94,12 +94,13 @@ export default class SamlSettings extends AdminSettings {
this.state[id], this.state[id],
() => { () => {
this.handleChange(id, ''); this.handleChange(id, '');
this.setState({[id]: null}); this.setState({[id]: null, [`${id}Error`]: null});
}, },
(error) => { (error) => {
if (callback && typeof callback === 'function') { if (callback && typeof callback === 'function') {
callback(error.message); callback();
} }
this.setState({[id]: null, [`${id}Error`]: error.message});
} }
); );
} }
@@ -168,6 +169,7 @@ export default class SamlSettings extends AdminSettings {
disabled={!this.state.enable} disabled={!this.state.enable}
fileType='.crt,.cer' fileType='.crt,.cer'
onSubmit={this.uploadCertificate} onSubmit={this.uploadCertificate}
error={this.state.idpCertificateFileError}
/> />
); );
} }
@@ -215,6 +217,7 @@ export default class SamlSettings extends AdminSettings {
disabled={!this.state.enable || !this.state.encrypt} disabled={!this.state.enable || !this.state.encrypt}
fileType='.key' fileType='.key'
onSubmit={this.uploadCertificate} onSubmit={this.uploadCertificate}
error={this.state.privateKeyFileError}
/> />
); );
} }
@@ -262,6 +265,7 @@ export default class SamlSettings extends AdminSettings {
disabled={!this.state.enable || !this.state.encrypt} disabled={!this.state.enable || !this.state.encrypt}
fileType='.crt,.cer' fileType='.crt,.cer'
onSubmit={this.uploadCertificate} onSubmit={this.uploadCertificate}
error={this.state.publicCertificateFileError}
/> />
); );
} }