error and auth fixes

This commit is contained in:
Jeremy Kauffman 2017-05-24 17:53:03 -04:00
parent 6e414c93ce
commit 0c41cbb823
9 changed files with 22 additions and 14 deletions

View file

@ -208,12 +208,13 @@ export function doCheckUpgradeAvailable() {
export function doAlertError(errorList) {
return function(dispatch, getState) {
const state = getState()
console.log('do alert error')
console.log(errorList)
dispatch({
type: types.OPEN_MODAL,
data: {
modal: 'error',
error: errorList
extraContent: errorList
}
})
}

View file

@ -6,6 +6,7 @@ import {
} from 'selectors/app'
import {
doCheckUpgradeAvailable,
doAlertError,
} from 'actions/app'
import {
doUpdateBalance,
@ -17,6 +18,7 @@ const select = (state) => ({
})
const perform = (dispatch) => ({
alertError: (errorList) => dispatch(doAlertError(errorList)),
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
updateBalance: (balance) => dispatch(doUpdateBalance(balance))
})

View file

@ -178,7 +178,7 @@ const ErrorStage = (props) => {
return <section>
<p>An error was encountered that we cannot continue from.</p>
<p>At least we're earning the name beta.</p>
{ this.props.errorText ? <p>Message: {props.errorText}</p> : '' }
{ props.errorText ? <p>Message: {props.errorText}</p> : '' }
<Link button="alt" label="Try Reload" onClick={() => { window.location.reload() } } />
</section>
}

View file

@ -4,7 +4,7 @@ import {
} from 'react-redux'
import {
selectCurrentModal,
selectError,
selectModalExtraContent,
} from 'selectors/app'
import {
doCloseModal,
@ -13,7 +13,7 @@ import ErrorModal from './view'
const select = (state) => ({
modal: selectCurrentModal(state),
error: selectError(state),
error: selectModalExtraContent(state),
})
const perform = (dispatch) => ({

View file

@ -9,10 +9,12 @@ class ErrorModal extends React.Component {
const {
modal,
closeModal,
error,
error
} = this.props
const _error_key_labels = {
const errorObj = typeof error === "string" ? { error: error } : error
const error_key_labels = {
connectionString: 'API connection string',
method: 'Method',
params: 'Parameters',
@ -20,13 +22,15 @@ class ErrorModal extends React.Component {
message: 'Error message',
data: 'Error data',
}
const errorInfo = <ul className="error-modal__error-list"></ul>
const errorInfoList = []
for (let key of Object.keys(error)) {
let val = typeof error[key] == 'string' ? error[key] : JSON.stringify(error[key]);
let label = this._error_key_labels[key];
let label = error_key_labels[key];
errorInfoList.push(<li key={key}><strong>{label}</strong>: <code>{val}</code></li>);
}
const errorInfo = <ul className="error-modal__error-list">{errorInfoList}</ul>
return(
<ExpandableModal

View file

@ -110,6 +110,7 @@ lbryio.authenticate = function() {
lbry.status().then((response) => {
let installation_id = response.installation_id;
installation_id = installation_id.substring(0, installation_id.length) + "X"
function setCurrentUser() {
lbryio.call('user', 'me').then((data) => {

View file

@ -70,14 +70,14 @@ reducers[types.UPDATE_VERSION] = function(state, action) {
reducers[types.OPEN_MODAL] = function(state, action) {
return Object.assign({}, state, {
modal: action.data.modal,
extraContent: action.data.errorList
modalExtraContent: action.data.extraContent
})
}
reducers[types.CLOSE_MODAL] = function(state, action) {
return Object.assign({}, state, {
modal: undefined,
extraContent: undefined
modalExtraContent: undefined
})
}

View file

@ -180,9 +180,9 @@ export const selectUpgradeDownloadItem = createSelector(
(state) => state.downloadItem
)
export const selectError = createSelector(
export const selectModalExtraContent = createSelector(
_selectState,
(state) => state.error
(state) => state.modalExtraContent
)
export const selectDaemonReady = createSelector(

View file

@ -1,6 +1,6 @@
@import "../global";
.modal-overlay {
.modal-overlay, .error-modal-overlay {
position: fixed;
display: flex;
justify-content: center;