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 diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index 9c7ed27fe..a5110babe 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -12,6 +12,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"); @@ -19,14 +20,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)); diff --git a/ui/js/actions/user.js b/ui/js/actions/user.js index 799bc8cbc..dad5e7624 100644 --- a/ui/js/actions/user.js +++ b/ui/js/actions/user.js @@ -178,3 +178,14 @@ export function doUserIdentityVerify(stripeToken) { }); }; } + +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/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index 0d4dbbd6b..ad135a3cd 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?"); } diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index c24515308..904ea9a5f 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -103,6 +103,7 @@ export const USER_IDENTITY_VERIFY_FAILURE = "USER_IDENTITY_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 c3d4086a3..c4ea548b2 100644 --- a/ui/js/page/help/index.js +++ b/ui/js/page/help/index.js @@ -1,15 +1,18 @@ import React from "react"; import { doNavigate } from "actions/app"; import { connect } from "react-redux"; +import { doFetchAccessToken } from "actions/user"; +import { selectAccessToken, selectUser } from "selectors/user"; import HelpPage from "./view"; -import { selectUser } from "selectors/user"; const select = state => ({ user: selectUser(state), + accessToken: selectAccessToken(state), }); const perform = dispatch => ({ navigate: (path, params) => dispatch(doNavigate(path, params)), + fetchAccessToken: () => dispatch(doFetchAccessToken()), }); export default connect(select, perform)(HelpPage); diff --git a/ui/js/page/help/view.jsx b/ui/js/page/help/view.jsx index 0d2d42378..f56d058e8 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")}

@@ -163,6 +173,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 4f78d3dc2..56720b2f7 100644 --- a/ui/js/reducers/user.js +++ b/ui/js/reducers/user.js @@ -142,6 +142,14 @@ reducers[types.USER_IDENTITY_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 55108d335..68554d825 100644 --- a/ui/js/selectors/user.js +++ b/ui/js/selectors/user.js @@ -68,3 +68,8 @@ export const selectUserIsVerificationCandidate = createSelector( selectUser, user => user && (!user.has_verified_email || !user.is_identity_verified) ); + +export const selectAccessToken = createSelector( + _selectState, + state => state.accessToken +);