Skip to content

Commit 6f39b74

Browse files
feat(v3): implement httpRequestTimeout
1 parent b9c5a35 commit 6f39b74

File tree

4 files changed

+83
-598
lines changed

4 files changed

+83
-598
lines changed

packages/web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
"license": "Apache-2.0",
3939
"dependencies": {
4040
"@appbaseio/analytics": "^1.1.1",
41-
"@appbaseio/reactivecore": "9.14.40",
41+
"@appbaseio/reactivecore": "9.15.1",
4242
"@appbaseio/rheostat": "^1.0.0-alpha.15",
4343
"@emotion/core": "^10.0.28",
4444
"@emotion/styled": "^10.0.27",
4545
"appbase-js": "^5.2.0",
4646
"cross-env": "^5.2.0",
4747
"dayjs": "^1.11.7",
4848
"downshift": "^1.31.2",
49-
"echarts": "^5.3.3",
49+
"echarts": "^5.3.4",
5050
"echarts-for-react": "^3.0.2",
5151
"emotion-theming": "^10.0.27",
5252
"hoist-non-react-statics": "^3.2.1",

packages/web/src/components/basic/ReactiveBase.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ReactiveBase extends Component {
7474
],
7575
() => {
7676
this.setStore(this.props);
77-
this.setState(state => ({
77+
this.setState((state) => ({
7878
key: `${state.key}-0`,
7979
}));
8080
},
@@ -104,30 +104,28 @@ class ReactiveBase extends Component {
104104
}
105105

106106
get headers() {
107-
const {
108-
enableAppbase, headers, appbaseConfig, mongodb, endpoint,
109-
} = this.props;
107+
const { enableAppbase, headers, appbaseConfig, mongodb, endpoint } = this.props;
110108
const { enableTelemetry } = appbaseConfig || {};
111109
return {
112-
...(enableAppbase
113-
&& !mongodb && {
114-
'X-Search-Client': X_SEARCH_CLIENT,
115-
...(enableTelemetry === false && { 'X-Enable-Telemetry': false }),
116-
}),
110+
...(enableAppbase &&
111+
!mongodb && {
112+
'X-Search-Client': X_SEARCH_CLIENT,
113+
...(enableTelemetry === false && { 'X-Enable-Telemetry': false }),
114+
}),
117115
...headers,
118-
...(enableAppbase
119-
&& endpoint
120-
&& endpoint.headers && {
121-
...endpoint.headers,
122-
}),
116+
...(enableAppbase &&
117+
endpoint &&
118+
endpoint.headers && {
119+
...endpoint.headers,
120+
}),
123121
};
124122
}
125123

126124
setStore = (props) => {
127125
this.type = props.type ? props.type : '*';
128126

129-
const credentials
130-
= props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
127+
const credentials =
128+
props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
131129

132130
const appbaseConfig = {
133131
...props.analyticsConfig, // TODO: remove in 4.0
@@ -157,8 +155,9 @@ class ReactiveBase extends Component {
157155
graphQLUrl: props.graphQLUrl,
158156
transformResponse: props.transformResponse,
159157
mongodb: props.mongodb,
160-
...(props.enableAppbase
161-
&& props.endpoint instanceof Object && { endpoint: props.endpoint }),
158+
...(props.enableAppbase &&
159+
props.endpoint instanceof Object && { endpoint: props.endpoint }),
160+
httpRequestTimeout: props.httpRequestTimeout * 1000,
162161
};
163162

164163
let queryParams = '';
@@ -220,12 +219,13 @@ class ReactiveBase extends Component {
220219
if (this.props.endpoint && this.props.endpoint.url) {
221220
// Remove parts between '//' and first '/' in the url
222221
analyticsInitConfig.url = this.props.endpoint.url.replace(/\/\/(.*?)\/.*/, '//$1');
223-
const headerCredentials = this.props.endpoint.headers
224-
&& this.props.endpoint.headers.Authorization;
225-
analyticsInitConfig.credentials = headerCredentials && headerCredentials.replace('Basic ', '');
222+
const headerCredentials =
223+
this.props.endpoint.headers && this.props.endpoint.headers.Authorization;
224+
analyticsInitConfig.credentials =
225+
headerCredentials && headerCredentials.replace('Basic ', '');
226226
// Decode the credentials
227-
analyticsInitConfig.credentials = analyticsInitConfig.credentials
228-
&& atob(analyticsInitConfig.credentials);
227+
analyticsInitConfig.credentials =
228+
analyticsInitConfig.credentials && atob(analyticsInitConfig.credentials);
229229
}
230230
} catch (e) {
231231
console.error('Endpoint not set correctly for analytics');
@@ -291,6 +291,7 @@ ReactiveBase.defaultProps = {
291291
as: 'div',
292292
enableAppbase: false,
293293
endpoint: null,
294+
httpRequestTimeout: 30,
294295
};
295296

296297
ReactiveBase.propTypes = {
@@ -322,6 +323,7 @@ ReactiveBase.propTypes = {
322323
mongodb: types.mongodb,
323324
preferences: types.preferences,
324325
endpoint: types.endpoint,
326+
httpRequestTimeout: types.number,
325327
};
326328

327329
export default ReactiveBase;

0 commit comments

Comments
 (0)