From 63daf5d282fdf417e62be2c3a8b577b7cf93157f Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Wed, 19 Jul 2017 12:35:32 +0700 Subject: [PATCH 1/4] Use toQueryString from util/query_params in app actions --- ui/js/actions/app.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index c29520720..d5014d9ad 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -13,6 +13,7 @@ import { doSearch } from "actions/search"; import { doFetchDaemonSettings } from "actions/settings"; import { doAuthenticate } from "actions/user"; import { doFileList } from "actions/file_info"; +import { toQueryString } from "util/query_params"; const { remote, ipcRenderer, shell } = require("electron"); const path = require("path"); @@ -20,14 +21,10 @@ const { download } = remote.require("electron-dl"); const fs = remote.require("fs"); const { lbrySettings: config } = require("../../../app/package.json"); -const queryStringFromParams = params => { - return Object.keys(params).map(key => `${key}=${params[key]}`).join("&"); -}; - export function doNavigate(path, params = {}) { return function(dispatch, getState) { let url = path; - if (params) url = `${url}?${queryStringFromParams(params)}`; + if (params) url = `${url}?${toQueryString(params)}`; dispatch(doChangePath(url)); From 76a99cc576605d11ce6eb8bb8b591687857553e1 Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Wed, 19 Jul 2017 13:12:01 +0700 Subject: [PATCH 2/4] Add a loading file info message. --- ui/js/component/fileActions/view.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/js/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index 53188a1f5..64fb859db 100644 --- a/ui/js/component/fileActions/view.jsx +++ b/ui/js/component/fileActions/view.jsx @@ -142,6 +142,8 @@ class FileActions extends React.PureComponent { onClick={() => openInShell(fileInfo)} /> ); + } else if (!fileInfo) { + content = ; } else { console.log("handle this case of file action props?"); } From c8990a0f797e1abc91d628d1adea6a56ac154ccd Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Fri, 21 Jul 2017 16:04:36 +0700 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3269d2934..c35165bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Web UI version numbers should always match the corresponding version of LBRY App * Added transition to card hovers to smooth animation * Support markdown makeup in claim description * Replaced free speech flag (used when image is missing) with labeled color tiles + * Added a loading message to file actions ### Changed * Publishes now uses claims rather than files From cad678417ee615bbb4891bfede6ff862ac412f42 Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Fri, 21 Jul 2017 13:23:39 +0700 Subject: [PATCH 4/4] Add access token to help page --- ui/js/actions/user.js | 11 +++++++++++ ui/js/constants/action_types.js | 1 + ui/js/page/help/index.js | 9 ++++++++- ui/js/page/help/view.jsx | 22 ++++++++++++++++++++++ ui/js/reducers/user.js | 8 ++++++++ ui/js/selectors/user.js | 5 +++++ 6 files changed, 55 insertions(+), 1 deletion(-) diff --git a/ui/js/actions/user.js b/ui/js/actions/user.js index ebfa8ed4b..a2db27c9f 100644 --- a/ui/js/actions/user.js +++ b/ui/js/actions/user.js @@ -136,3 +136,14 @@ export function doUserEmailVerify(verificationToken) { }); }; } + +export function doFetchAccessToken() { + return function(dispatch, getState) { + const success = token => + dispatch({ + type: types.FETCH_ACCESS_TOKEN_SUCCESS, + data: { token }, + }); + lbryio.getAuthToken().then(success); + }; +} diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index ff20168a4..3a3ecfbd9 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -100,6 +100,7 @@ export const USER_EMAIL_VERIFY_FAILURE = "USER_EMAIL_VERIFY_FAILURE"; export const USER_FETCH_STARTED = "USER_FETCH_STARTED"; export const USER_FETCH_SUCCESS = "USER_FETCH_SUCCESS"; export const USER_FETCH_FAILURE = "USER_FETCH_FAILURE"; +export const FETCH_ACCESS_TOKEN_SUCCESS = "FETCH_ACCESS_TOKEN_SUCCESS"; // Rewards export const FETCH_REWARDS_STARTED = "FETCH_REWARDS_STARTED"; diff --git a/ui/js/page/help/index.js b/ui/js/page/help/index.js index 31bb1ed51..f5378405e 100644 --- a/ui/js/page/help/index.js +++ b/ui/js/page/help/index.js @@ -1,10 +1,17 @@ import React from "react"; import { doNavigate } from "actions/app"; import { connect } from "react-redux"; +import { doFetchAccessToken } from "actions/user"; +import { selectAccessToken } from "selectors/user"; import HelpPage from "./view"; +const select = state => ({ + accessToken: selectAccessToken(state), +}); + const perform = dispatch => ({ navigate: (path, params) => dispatch(doNavigate(path, params)), + fetchAccessToken: () => dispatch(doFetchAccessToken()), }); -export default connect(null, perform)(HelpPage); +export default connect(select, perform)(HelpPage); diff --git a/ui/js/page/help/view.jsx b/ui/js/page/help/view.jsx index b8a59a619..a805a92d9 100644 --- a/ui/js/page/help/view.jsx +++ b/ui/js/page/help/view.jsx @@ -14,6 +14,7 @@ class HelpPage extends React.PureComponent { lbryId: null, uiVersion: null, upgradeAvailable: null, + accessTokenHidden: true, }; } @@ -36,6 +37,14 @@ class HelpPage extends React.PureComponent { lbryId: info.lbry_id, }); }); + + if (!this.props.accessToken) this.props.fetchAccessToken(); + } + + showAccessToken() { + this.setState({ + accessTokenHidden: false, + }); } render() { @@ -121,6 +130,7 @@ class HelpPage extends React.PureComponent { +

{__("About")}

@@ -155,6 +165,18 @@ class HelpPage extends React.PureComponent { {__("Installation ID")} {this.state.lbryId} + + {__("Access Token")} + + {this.state.accessTokenHidden && + } + {!this.state.accessTokenHidden && + this.props.accessToken} + + : } diff --git a/ui/js/reducers/user.js b/ui/js/reducers/user.js index 4e4ffda40..ef7602193 100644 --- a/ui/js/reducers/user.js +++ b/ui/js/reducers/user.js @@ -120,6 +120,14 @@ reducers[types.USER_EMAIL_VERIFY_FAILURE] = function(state, action) { }); }; +reducers[types.FETCH_ACCESS_TOKEN_SUCCESS] = function(state, action) { + const { token } = action.data; + + return Object.assign({}, state, { + accessToken: token, + }); +}; + export default function reducer(state = defaultState, action) { const handler = reducers[action.type]; if (handler) return handler(state, action); diff --git a/ui/js/selectors/user.js b/ui/js/selectors/user.js index d17485aa6..265e9c936 100644 --- a/ui/js/selectors/user.js +++ b/ui/js/selectors/user.js @@ -76,3 +76,8 @@ export const selectUserIsAuthRequested = createSelector( (isEmailDeclined, isPending, isVerificationCandidate, hasEmail) => !isEmailDeclined && (isPending || !hasEmail || isVerificationCandidate) ); + +export const selectAccessToken = createSelector( + _selectState, + state => state.accessToken +);