Skip to content

Commit 2ff0637

Browse files
committed
add env variable for precise config
1 parent d71124a commit 2ff0637

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

redisinsight/ui/src/config/default.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ export const defaultConfig = {
8484
'RI_DATABASE_OVERVIEW_MINIMUM_REFRESH_INTERVAL',
8585
1,
8686
),
87+
rejsonMonacoEditorMaxThreshold: intEnv(
88+
'RI_REJSON_MONACO_EDITOR_MAX_THRESHOLD',
89+
10_000,
90+
),
8791
},
8892
features: {
8993
envDependent: {

redisinsight/ui/src/slices/browser/keys.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'
22
import { cloneDeep, remove, get, isUndefined } from 'lodash'
33
import axios, { AxiosError, CancelTokenSource } from 'axios'
44
import { apiService, localStorageService } from 'uiSrc/services'
5+
import { getConfig } from 'uiSrc/config'
56
import {
67
ApiEndpoints,
78
BrowserStorageItem,
@@ -61,12 +62,7 @@ import {
6162
refreshZsetMembersAction,
6263
} from './zset'
6364
import { fetchSetMembers, refreshSetMembersAction } from './set'
64-
import {
65-
fetchReJSON,
66-
JSON_LENGTH_TO_FORCE_RETRIEVE,
67-
setEditorType,
68-
setIsWithinThreshold,
69-
} from './rejson'
65+
import { fetchReJSON, setEditorType, setIsWithinThreshold } from './rejson'
7066
import {
7167
setHashInitialState,
7268
fetchHashFields,
@@ -108,6 +104,8 @@ import { AppDispatch, RootState } from '../store'
108104
import { StreamViewType } from '../interfaces/stream'
109105
import { EditorType, RedisResponseBuffer, RedisString } from '../interfaces'
110106

107+
const riConfig = getConfig()
108+
111109
const defaultViewFormat = KeyValueFormat.Unicode
112110

113111
export const initialState: KeysStore = {
@@ -813,7 +811,9 @@ export function fetchKeyInfo(
813811
dispatch<any>(fetchReJSON(key, '$', data.length, resetData))
814812
dispatch<any>(setEditorType(EditorType.Default))
815813
dispatch<any>(
816-
setIsWithinThreshold(data.size <= JSON_LENGTH_TO_FORCE_RETRIEVE),
814+
setIsWithinThreshold(
815+
data.size <= riConfig.browser.rejsonMonacoEditorMaxThreshold,
816+
),
817817
)
818818
}
819819
if (data.type === KeyTypes.Stream) {

redisinsight/ui/src/slices/tests/browser/keys.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { cloneDeep } from 'lodash'
22
import { AxiosError } from 'axios'
33
import { configureStore } from '@reduxjs/toolkit'
4+
import { getConfig } from 'uiSrc/config'
45
import {
56
BrowserColumns,
67
KeyTypes,
@@ -32,7 +33,6 @@ import {
3233
import { MOCK_TIMESTAMP } from 'uiSrc/mocks/data/dateNow'
3334
import { rootReducer } from 'uiSrc/slices/store'
3435
import {
35-
JSON_LENGTH_TO_FORCE_RETRIEVE,
3636
setEditorType,
3737
setIsWithinThreshold,
3838
} from 'uiSrc/slices/browser/rejson'
@@ -111,6 +111,9 @@ import reducer, {
111111
refreshKey,
112112
} from '../../browser/keys'
113113

114+
const riConfig = getConfig()
115+
const REJSON_THRESHOLD = riConfig.browser.rejsonMonacoEditorMaxThreshold
116+
114117
jest.mock('uiSrc/services', () => ({
115118
...jest.requireActual('uiSrc/services'),
116119
}))
@@ -1409,8 +1412,8 @@ describe('keys slice', () => {
14091412
name: stringToBuffer('rejson'),
14101413
type: KeyTypes.ReJSON,
14111414
ttl: -1,
1412-
size: JSON_LENGTH_TO_FORCE_RETRIEVE,
1413-
length: JSON_LENGTH_TO_FORCE_RETRIEVE + 100, // just to make sure this isn't used instead of size
1415+
size: REJSON_THRESHOLD,
1416+
length: REJSON_THRESHOLD + 100, // just to make sure this isn't used instead of size
14141417
}
14151418
const responsePayload = { data, status: 200 }
14161419

@@ -1433,8 +1436,8 @@ describe('keys slice', () => {
14331436
name: stringToBuffer('rejson'),
14341437
type: KeyTypes.ReJSON,
14351438
ttl: -1,
1436-
size: JSON_LENGTH_TO_FORCE_RETRIEVE + 1,
1437-
length: JSON_LENGTH_TO_FORCE_RETRIEVE, // just to make sure this isn't used instead of size
1439+
size: REJSON_THRESHOLD + 1,
1440+
length: REJSON_THRESHOLD, // just to make sure this isn't used instead of size
14381441
}
14391442
const responsePayload = { data, status: 200 }
14401443

0 commit comments

Comments
 (0)