import {Component} from 'react'; import {browserHistory} from 'react-router'; import {Client} from 'sentry/api'; import Form from 'sentry/components/deprecatedforms/form'; import TextField from 'sentry/components/deprecatedforms/textField'; import {t, tct} from 'sentry/locale'; import {AuthConfig} from 'sentry/types'; type Props = { api: Client; authConfig: AuthConfig; }; type State = { errorMessage: string | null; }; class SsoForm extends Component { state: State = { errorMessage: null, }; handleSubmit: Form['props']['onSubmit'] = async (data, onSuccess, onError) => { const {api} = this.props; try { const response = await api.requestPromise('/auth/sso-locate/', { method: 'POST', data, }); onSuccess(data); browserHistory.push({pathname: response.nextUri}); } catch (e) { if (!e.responseJSON) { onError(e); return; } const message = e.responseJSON.detail; this.setState({errorMessage: message}); onError(e); } }; render() { const {serverHostname} = this.props.authConfig; const {errorMessage} = this.state; return (
acme, example: , })} /> ); } } type SlugExampleProps = { hostname: string; slug: string; }; const SlugExample = ({hostname, slug}: SlugExampleProps) => ( {hostname}/{slug} ); export default SsoForm;