diff options
Diffstat (limited to 'webapp/components/admin_console/saml_settings.jsx')
-rw-r--r-- | webapp/components/admin_console/saml_settings.jsx | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/webapp/components/admin_console/saml_settings.jsx b/webapp/components/admin_console/saml_settings.jsx index a02ab4a8a..4c0c0c8fd 100644 --- a/webapp/components/admin_console/saml_settings.jsx +++ b/webapp/components/admin_console/saml_settings.jsx @@ -14,7 +14,7 @@ import SettingsGroup from './settings_group.jsx'; import * as Utils from 'utils/utils.jsx'; -import {samlCertificateStatus, uploadCertificateFile, removeCertificateFile} from 'actions/admin_actions.jsx'; +import * as AdminActions from 'actions/admin_actions.jsx'; export default class SamlSettings extends AdminSettings { constructor(props) { @@ -74,7 +74,7 @@ export default class SamlSettings extends AdminSettings { } componentWillMount() { - samlCertificateStatus( + AdminActions.samlCertificateStatus( (data) => { const files = {}; if (!data.IdpCertificateFile) { @@ -94,38 +94,50 @@ export default class SamlSettings extends AdminSettings { } uploadCertificate(id, file, callback) { - uploadCertificateFile( - file, - () => { - const fileName = file.name; - this.handleChange(id, fileName); - this.setState({[id]: fileName, [`${id}Error`]: null}); - if (callback && typeof callback === 'function') { - callback(); - } - }, - (error) => { - if (callback && typeof callback === 'function') { - callback(error.message); - } + const complete = () => { + const fileName = file.name; + this.handleChange(id, fileName); + this.setState({[id]: fileName, [`${id}Error`]: null}); + if (callback && typeof callback === 'function') { + callback(); } - ); + }; + + function fail(error) { + if (callback && typeof callback === 'function') { + callback(error.message); + } + } + + if (id === 'idpCertificateFile') { + AdminActions.uploadIdpSamlCertificate(file, complete, fail); + } else if (id === 'publicCertificateFile') { + AdminActions.uploadPublicSamlCertificate(file, complete, fail); + } else if (id === 'privateKeyFile') { + AdminActions.uploadPrivateSamlCertificate(file, complete, fail); + } } removeCertificate(id, callback) { - removeCertificateFile( - this.state[id], - () => { - this.handleChange(id, ''); - this.setState({[id]: null, [`${id}Error`]: null}); - }, - (error) => { - if (callback && typeof callback === 'function') { - callback(); - } - this.setState({[id]: null, [`${id}Error`]: error.message}); + const complete = () => { + this.handleChange(id, ''); + this.setState({[id]: null, [`${id}Error`]: null}); + }; + + const fail = (error) => { + if (callback && typeof callback === 'function') { + callback(); } - ); + this.setState({[id]: null, [`${id}Error`]: error.message}); + }; + + if (id === 'idpCertificateFile') { + AdminActions.removeIdpSamlCertificate(complete, fail); + } else if (id === 'publicCertificateFile') { + AdminActions.removePublicSamlCertificate(complete, fail); + } else if (id === 'privateKeyFile') { + AdminActions.removePrivateSamlCertificate(complete, fail); + } } renderTitle() { |