From bd9635fc1221b7720e32b046c3be9d81429500f2 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Wed, 16 Mar 2016 06:46:44 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BA=D0=B8=D0=B4=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D1=81=D1=82=D0=B5=D0=B9=D1=82=D0=B0=20=D0=B2=20title?= =?UTF-8?q?=20=D0=B8=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/auth/finish/Finish.jsx | 60 ++++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/components/auth/finish/Finish.jsx b/src/components/auth/finish/Finish.jsx index 9163c48..7f7b7a1 100644 --- a/src/components/auth/finish/Finish.jsx +++ b/src/components/auth/finish/Finish.jsx @@ -3,6 +3,7 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { FormattedMessage as Message } from 'react-intl'; import classNames from 'classnames'; +import Helmet from 'react-helmet'; import buttons from 'components/ui/buttons.scss'; @@ -23,36 +24,20 @@ class Finish extends Component { isCopySupported: document.queryCommandSupported && document.queryCommandSupported('copy') }; - handleCopyClick = (event) => { - event.preventDefault(); - // http://stackoverflow.com/a/987376/5184751 - - try { - const selection = window.getSelection(); - const range = document.createRange(); - range.selectNodeContents(this.code); - selection.removeAllRanges(); - selection.addRange(range); - - const successful = document.execCommand('copy'); - selection.removeAllRanges(); - - // TODO: было бы ещё неплохо сделать какую-то анимацию, вроде "Скопировано", - // ибо сейчас после клика как-то неубедительно, скопировалось оно или нет - console.log('Copying text command was ' + (successful ? 'successful' : 'unsuccessful')); - } catch (err) {} - }; - - setCode = (el) => { - this.code = el; - }; - render() { - const {appName, code, displayCode, success} = this.props; + const {appName, code, state, displayCode, success} = this.props; const {isCopySupported} = this.state; + const authData = JSON.stringify({ + auth_code: code, + state: state + }); + + history.pushState(null, null, `#${authData}`); return (
+ + {success ? (
@@ -102,11 +87,36 @@ class Finish extends Component {
); } + + handleCopyClick = (event) => { + event.preventDefault(); + // http://stackoverflow.com/a/987376/5184751 + + try { + const selection = window.getSelection(); + const range = document.createRange(); + range.selectNodeContents(this.code); + selection.removeAllRanges(); + selection.addRange(range); + + const successful = document.execCommand('copy'); + selection.removeAllRanges(); + + // TODO: было бы ещё неплохо сделать какую-то анимацию, вроде "Скопировано", + // ибо сейчас после клика как-то неубедительно, скопировалось оно или нет + console.log('Copying text command was ' + (successful ? 'successful' : 'unsuccessful')); + } catch (err) {} + }; + + setCode = (el) => { + this.code = el; + }; } export default connect(({auth}) => ({ appName: auth.client.name, code: auth.oauth.code, displayCode: auth.oauth.displayCode, + state: auth.oauth.state, success: auth.oauth.success }))(Finish);