import {render} from 'react-dom';
import React from 'react';
import AuthDialog from '@jetbrains/ring-ui/components/auth-dialog/auth-dialog';
import Button from '@jetbrains/ring-ui/components/button/button';
import youtrackLogo from '!file-loader?publicPath=../../!@jetbrains/logos/youtrack/youtrack.svg';
class AuthDialogDemo extends React.Component {
state = {
confirm: {
show: true,
onConfirm: () => {},
onReject: () => {}
}
};
componentDidMount() {
this.showAuthDialog();
}
hideAuthDialog = () => {
this.setState({confirm: {show: false}});
}
showAuthDialog = () => {
return new Promise((resolve, reject) => {
this.setState({
confirm: {
show: true,
errorMessage: 'Authorization is required',
serviceName: 'YouTrack',
onConfirm: () => this.hideAuthDialog() || resolve(),
onCancel: () => this.hideAuthDialog() || reject()
}
});
}).
then(() => console.info('Confirmed')).
catch(() => console.warn('Rejected'));
}
render() {
return (
);
}
}
render(, document.getElementById('auth-dialog'));