proxy: hide builtin proxies

This commit is contained in:
Haishan 2018-10-21 19:59:38 +08:00
parent 4febd4feb5
commit 7f81b3baec
4 changed files with 20 additions and 2 deletions

View file

@ -48,6 +48,7 @@
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"reselect": "^4.0.0",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {

View file

@ -13,11 +13,11 @@ const th = cx(s0.row, s0.th, 'border-bottom');
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { getProxies, fetchProxies, requestDelayAll } from 'd/proxies';
import { getUserProxies, fetchProxies, requestDelayAll } from 'd/proxies';
function mapStateToProps(s) {
return {
proxies: getProxies(s)
proxies: getUserProxies(s)
};
}

View file

@ -1,9 +1,21 @@
'use strict';
import { createSelector } from 'reselect';
import * as proxiesAPI from 'a/proxies';
const ProxyTypeBuiltin = ['DIRECT', 'GLOBAL', 'REJECT'];
export const getProxies = s => s.proxies.proxies;
export const getDelay = s => s.proxies.delay;
export const getUserProxies = createSelector(getProxies, proxies => {
let o = {};
for (const prop in proxies) {
if (ProxyTypeBuiltin.indexOf(prop) < 0) {
o[prop] = proxies[prop];
}
}
return o;
});
const CompletedFetchProxies = 'proxies/CompletedFetchProxies';
const OptimisticSwitchProxy = 'proxies/OptimisticSwitchProxy';

View file

@ -6952,6 +6952,11 @@ require-uncached@^1.0.3:
caller-path "^0.1.0"
resolve-from "^1.0.0"
reselect@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"