#8: Add tooltips to settings [partial]

This commit is contained in:
2019-08-30 16:51:49 -05:00
parent 42515a08c3
commit 7e6e3cbc49
6 changed files with 116 additions and 6 deletions

View File

@@ -13,6 +13,14 @@ export const clearError = () => {
};
};
export const CLEAR_INFO = 'error/clearInfo';
export const clearInfo = () => {
return {
type: CLEAR_INFO,
payload: null,
};
};
export const dismissError = () => {
return (dispatch, getState) => {
dispatch(clearError());
@@ -27,6 +35,12 @@ export const dismissError = () => {
};
};
export const dismissInfo = () => {
return dispatch => {
dispatch(clearInfo());
};
};
export const notifyError = (msg, critical, callback) => {
return dispatch => {
ErrorActions = [callback, ...ErrorActions];
@@ -36,6 +50,14 @@ export const notifyError = (msg, critical, callback) => {
};
};
export const notifyInfo = (title, msg) => {
return dispatch => {
title = title ? title.toString() : 'Information';
msg = msg ? msg.toString() : '';
dispatch(setInfo(title, msg));
};
};
export const SET_ERROR_INFO = 'error/setErrorInfo';
export const setErrorInfo = (msg, critical) => {
return {
@@ -45,4 +67,16 @@ export const setErrorInfo = (msg, critical) => {
critical
}
}
};
export const SET_INFO = 'error/setInfo';
export const setInfo = (title, msg) => {
return {
type: SET_INFO,
payload: {
title,
msg
}
}
};

View File

@@ -1,13 +1,17 @@
import {createReducer} from 'redux-starter-kit';
import {
CLEAR_ERROR,
SET_ERROR_INFO
CLEAR_INFO,
SET_ERROR_INFO,
SET_INFO
} from '../actions/error_actions';
export const errorReducer = createReducer({
DisplayError: false,
DisplayInfo: false,
ErrorCritical: false,
ErrorStack: [],
InfoStack: [],
}, {
[CLEAR_ERROR]: state => {
const errorStack = (state.ErrorStack.length > 0) ? state.ErrorStack.slice(1) : [];
@@ -17,6 +21,14 @@ export const errorReducer = createReducer({
ErrorStack: errorStack,
}
},
[CLEAR_INFO]: state => {
const infoStack = (state.InfoStack.length > 0) ? state.InfoStack.slice(1) : [];
return {
...state,
DisplayInfo: (infoStack.length > 0),
InfoStack: infoStack,
}
},
[SET_ERROR_INFO]: (state, action) => {
const errorStack = [action.payload.msg, ...state.ErrorStack];
return {
@@ -25,5 +37,16 @@ export const errorReducer = createReducer({
ErrorCritical: state.ErrorCritical || action.payload.critical,
ErrorStack: errorStack,
}
},
[SET_INFO]: (state, action) => {
const infoStack = [{
title: action.payload.title,
message: action.payload.msg
}, ...state.InfoStack];
return {
...state,
DisplayInfo: true,
InfoStack: infoStack,
}
}
});