mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 02:07:26 +03:00
Installed redux-actions dependency and used it for selectedServer reducer
This commit is contained in:
parent
2ba86767fe
commit
724c804971
3 changed files with 62 additions and 14 deletions
|
@ -53,6 +53,7 @@
|
||||||
"react-tagsinput": "^3.19.0",
|
"react-tagsinput": "^3.19.0",
|
||||||
"reactstrap": "^6.0.1",
|
"reactstrap": "^6.0.1",
|
||||||
"redux": "^4.0.0",
|
"redux": "^4.0.0",
|
||||||
|
"redux-actions": "^2.6.5",
|
||||||
"redux-thunk": "^2.3.0",
|
"redux-thunk": "^2.3.0",
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
|
import { createAction, handleActions } from 'redux-actions';
|
||||||
import { resetShortUrlParams } from '../../short-urls/reducers/shortUrlsListParams';
|
import { resetShortUrlParams } from '../../short-urls/reducers/shortUrlsListParams';
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements, newline-after-var */
|
/* eslint-disable padding-line-between-statements */
|
||||||
export const SELECT_SERVER = 'shlink/selectedServer/SELECT_SERVER';
|
export const SELECT_SERVER = 'shlink/selectedServer/SELECT_SERVER';
|
||||||
export const RESET_SELECTED_SERVER = 'shlink/selectedServer/RESET_SELECTED_SERVER';
|
export const RESET_SELECTED_SERVER = 'shlink/selectedServer/RESET_SELECTED_SERVER';
|
||||||
/* eslint-enable padding-line-between-statements, newline-after-var */
|
/* eslint-enable padding-line-between-statements */
|
||||||
|
|
||||||
const defaultState = null;
|
const defaultState = null;
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export const resetSelectedServer = createAction(RESET_SELECTED_SERVER);
|
||||||
switch (action.type) {
|
|
||||||
case SELECT_SERVER:
|
|
||||||
return action.selectedServer;
|
|
||||||
case RESET_SELECTED_SERVER:
|
|
||||||
return defaultState;
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const resetSelectedServer = () => ({ type: RESET_SELECTED_SERVER });
|
|
||||||
|
|
||||||
export const selectServer = (serversService) => (serverId) => (dispatch) => {
|
export const selectServer = (serversService) => (serverId) => (dispatch) => {
|
||||||
dispatch(resetShortUrlParams());
|
dispatch(resetShortUrlParams());
|
||||||
|
@ -30,3 +20,10 @@ export const selectServer = (serversService) => (serverId) => (dispatch) => {
|
||||||
selectedServer,
|
selectedServer,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const reducer = handleActions({
|
||||||
|
[RESET_SELECTED_SERVER]: () => defaultState,
|
||||||
|
[SELECT_SERVER]: (state, { selectedServer }) => selectedServer,
|
||||||
|
}, defaultState);
|
||||||
|
|
||||||
|
export default reducer;
|
||||||
|
|
50
yarn.lock
50
yarn.lock
|
@ -5663,6 +5663,11 @@ jsx-ast-utils@^2.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
array-includes "^3.0.3"
|
array-includes "^3.0.3"
|
||||||
|
|
||||||
|
just-curry-it@^3.1.0:
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/just-curry-it/-/just-curry-it-3.1.0.tgz#ab59daed308a58b847ada166edd0a2d40766fbc5"
|
||||||
|
integrity sha512-mjzgSOFzlrurlURaHVjnQodyPNvrHrf1TbQP2XU9NSqBtHQPuHZ+Eb6TAJP7ASeJN9h9K0KXoRTs8u6ouHBKvg==
|
||||||
|
|
||||||
just-extend@^4.0.2:
|
just-extend@^4.0.2:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.0.2.tgz#f3f47f7dfca0f989c55410a7ebc8854b07108afc"
|
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.0.2.tgz#f3f47f7dfca0f989c55410a7ebc8854b07108afc"
|
||||||
|
@ -7612,6 +7617,11 @@ postcss-reduce-initial@^4.0.2:
|
||||||
postcss-reduce-transforms@^4.0.1:
|
postcss-reduce-transforms@^4.0.1:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/postcss-reduce-transforms/-/postcss-reduce-transforms-4.0.1.tgz#8600d5553bdd3ad640f43bff81eb52f8760d4561"
|
resolved "https://registry.yarnpkg.com/postcss-reduce-transforms/-/postcss-reduce-transforms-4.0.1.tgz#8600d5553bdd3ad640f43bff81eb52f8760d4561"
|
||||||
|
dependencies:
|
||||||
|
cssnano-util-get-match "^4.0.0"
|
||||||
|
has "^1.0.0"
|
||||||
|
postcss "^7.0.0"
|
||||||
|
postcss-value-parser "^3.0.0"
|
||||||
|
|
||||||
postcss-replace-overflow-wrap@^3.0.0:
|
postcss-replace-overflow-wrap@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
|
@ -8325,6 +8335,22 @@ redent@^2.0.0:
|
||||||
indent-string "^3.0.0"
|
indent-string "^3.0.0"
|
||||||
strip-indent "^2.0.0"
|
strip-indent "^2.0.0"
|
||||||
|
|
||||||
|
reduce-reducers@^0.4.3:
|
||||||
|
version "0.4.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/reduce-reducers/-/reduce-reducers-0.4.3.tgz#8e052618801cd8fc2714b4915adaa8937eb6d66c"
|
||||||
|
integrity sha512-+CNMnI8QhgVMtAt54uQs3kUxC3Sybpa7Y63HR14uGLgI9/QR5ggHvpxwhGGe3wmx5V91YwqQIblN9k5lspAmGw==
|
||||||
|
|
||||||
|
redux-actions@^2.6.5:
|
||||||
|
version "2.6.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/redux-actions/-/redux-actions-2.6.5.tgz#bdca548768ee99832a63910c276def85e821a27e"
|
||||||
|
integrity sha512-pFhEcWFTYNk7DhQgxMGnbsB1H2glqhQJRQrtPb96kD3hWiZRzXHwwmFPswg6V2MjraXRXWNmuP9P84tvdLAJmw==
|
||||||
|
dependencies:
|
||||||
|
invariant "^2.2.4"
|
||||||
|
just-curry-it "^3.1.0"
|
||||||
|
loose-envify "^1.4.0"
|
||||||
|
reduce-reducers "^0.4.3"
|
||||||
|
to-camel-case "^1.0.0"
|
||||||
|
|
||||||
redux-thunk@^2.3.0:
|
redux-thunk@^2.3.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"
|
||||||
|
@ -8936,6 +8962,11 @@ shebang-regex@^1.0.0:
|
||||||
shell-quote@1.6.1:
|
shell-quote@1.6.1:
|
||||||
version "1.6.1"
|
version "1.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"
|
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"
|
||||||
|
dependencies:
|
||||||
|
array-filter "~0.0.0"
|
||||||
|
array-map "~0.0.0"
|
||||||
|
array-reduce "~0.0.0"
|
||||||
|
jsonify "~0.0.0"
|
||||||
|
|
||||||
shellwords@^0.1.1:
|
shellwords@^0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
|
@ -9676,6 +9707,13 @@ to-arraybuffer@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
|
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
|
||||||
|
|
||||||
|
to-camel-case@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/to-camel-case/-/to-camel-case-1.0.0.tgz#1a56054b2f9d696298ce66a60897322b6f423e46"
|
||||||
|
integrity sha1-GlYFSy+daWKYzmamCJcyK29CPkY=
|
||||||
|
dependencies:
|
||||||
|
to-space-case "^1.0.0"
|
||||||
|
|
||||||
to-fast-properties@^1.0.3:
|
to-fast-properties@^1.0.3:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
|
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
|
||||||
|
@ -9684,6 +9722,11 @@ to-fast-properties@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
|
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
|
||||||
|
|
||||||
|
to-no-case@^1.0.0:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/to-no-case/-/to-no-case-1.0.2.tgz#c722907164ef6b178132c8e69930212d1b4aa16a"
|
||||||
|
integrity sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo=
|
||||||
|
|
||||||
to-object-path@^0.3.0:
|
to-object-path@^0.3.0:
|
||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
|
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
|
||||||
|
@ -9706,6 +9749,13 @@ to-regex@^3.0.1, to-regex@^3.0.2:
|
||||||
regex-not "^1.0.2"
|
regex-not "^1.0.2"
|
||||||
safe-regex "^1.1.0"
|
safe-regex "^1.1.0"
|
||||||
|
|
||||||
|
to-space-case@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/to-space-case/-/to-space-case-1.0.0.tgz#b052daafb1b2b29dc770cea0163e5ec0ebc9fc17"
|
||||||
|
integrity sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=
|
||||||
|
dependencies:
|
||||||
|
to-no-case "^1.0.0"
|
||||||
|
|
||||||
toggle-selection@^1.0.3:
|
toggle-selection@^1.0.3:
|
||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
|
resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
|
||||||
|
|
Loading…
Reference in a new issue