AuthView.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const LoaderView = require('./Loader')
  2. const { h, Component } = require('preact')
  3. class AuthBlock extends Component {
  4. componentDidMount () {
  5. setTimeout(() => {
  6. if (!this.connectButton) return
  7. this.connectButton.focus({ preventScroll: true })
  8. }, 150)
  9. }
  10. render () {
  11. return <div class="uppy-Provider-auth">
  12. <div class="uppy-Provider-authIcon">{this.props.pluginIcon()}</div>
  13. <h1 class="uppy-Provider-authTitle">Please authenticate with <span class="uppy-Provider-authTitleName">{this.props.pluginName}</span><br /> to select files</h1>
  14. <button
  15. type="button"
  16. class="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn"
  17. onclick={this.props.handleAuth}
  18. ref={(el) => { this.connectButton = el }}
  19. >
  20. Connect to {this.props.pluginName}
  21. </button>
  22. {this.props.demo &&
  23. <button class="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Provider-authBtn" onclick={this.props.handleDemoAuth}>Proceed with Demo Account</button>
  24. }
  25. </div>
  26. }
  27. }
  28. class AuthView extends Component {
  29. componentDidMount () {
  30. this.props.checkAuth()
  31. }
  32. render () {
  33. if (this.props.checkAuthInProgress) {
  34. return <LoaderView />
  35. }
  36. return <AuthBlock {...this.props} />
  37. }
  38. }
  39. module.exports = AuthView