Skip to content

Commit f57ad4e

Browse files
authored
fix: historical comments issues (#1786)
1 parent 3ed0b07 commit f57ad4e

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

web/src/components/Plugin/UI/api-breaker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const ApiBreaker: React.FC<Props> = ({ form }) => {
6767
initialValue={300}
6868
tooltip={formatMessage({ id: 'component.pluginForm.api-breaker.max_breaker_sec.tooltip' })}
6969
>
70-
<InputNumber min={60} />
70+
<InputNumber min={3} />
7171
</Form.Item>
7272

7373
<Form.List name={['unhealthy', 'http_statuses']}>

web/src/components/Plugin/UI/cors.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ const Cors: React.FC<Props> = ({ form }) => {
5757
<Select
5858
mode="multiple"
5959
optionLabelProp="label"
60-
onChange={(value) => {
61-
((value as string[]).join(","));
62-
if ((value as string[]).includes('*')) {
60+
onChange={(value: string[]) => {
61+
if (value.includes('*')) {
6362
form.setFieldsValue({
6463
allow_methods: ['*'],
6564
});
@@ -80,7 +79,6 @@ const Cors: React.FC<Props> = ({ form }) => {
8079
<Form
8180
form={form}
8281
{...FORM_ITEM_LAYOUT}
83-
initialValues={{ allow_origins_by_regex: [''] }}
8482
>
8583
<Form.Item
8684
extra={formatMessage({ id: 'component.pluginForm.cors.allow_origins.extra' })}
@@ -127,7 +125,7 @@ const Cors: React.FC<Props> = ({ form }) => {
127125
<Switch />
128126
</Form.Item>
129127

130-
<Form.List name={['allow_origins_by_regex']}>
128+
<Form.List name='allow_origins_by_regex' initialValue={['']}>
131129
{(fields, { add, remove }) => {
132130
return (
133131
<div>

web/src/components/Plugin/UI/limit-count.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ const RedisForm: React.FC = () => {
6464
<Input />
6565
</Form.Item>
6666
<Form.Item
67+
initialValue={6379}
6768
label="redis_port"
6869
name="redis_port"
6970
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_port.tooltip' })}
7071
>
71-
<InputNumber min={1} />
72+
<InputNumber min={1} max={65535} />
7273
</Form.Item>
7374
<Form.Item
7475
label="redis_password"
@@ -80,23 +81,25 @@ const RedisForm: React.FC = () => {
8081
<Input />
8182
</Form.Item>
8283
<Form.Item
84+
initialValue={0}
8385
label="redis_database"
8486
name="redis_database"
8587
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_database.tooltip' })}
8688
>
8789
<InputNumber min={0} />
8890
</Form.Item>
8991
<Form.Item
92+
initialValue={1000}
9093
label="redis_timeout"
9194
name="redis_timeout"
9295
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_timeout.tooltip' })}
9396
>
94-
<InputNumber />
97+
<InputNumber min={1} />
9598
</Form.Item>
9699
</>)
97100
}
98101

99-
const RedisClusterForm: React.FC<Props> = () => {
102+
const RedisClusterForm: React.FC = () => {
100103
const { formatMessage } = useIntl();
101104

102105
return (
@@ -109,7 +112,7 @@ const RedisClusterForm: React.FC<Props> = () => {
109112
>
110113
<Input />
111114
</Form.Item>
112-
<Form.List name="redis_cluster_nodes">
115+
<Form.List name="redis_cluster_nodes" initialValue={['', '']}>
113116
{(fields, { add, remove }) => {
114117
return (
115118
<div>
@@ -159,6 +162,21 @@ const RedisClusterForm: React.FC<Props> = () => {
159162
);
160163
}}
161164
</Form.List>
165+
<Form.Item
166+
label="redis_password"
167+
name="redis_password"
168+
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_password.tooltip' })}
169+
>
170+
<Input />
171+
</Form.Item>
172+
<Form.Item
173+
initialValue={1000}
174+
label="redis_timeout"
175+
name="redis_timeout"
176+
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_timeout.tooltip' })}
177+
>
178+
<InputNumber min={1} />
179+
</Form.Item>
162180
</>)
163181
}
164182

@@ -170,7 +188,6 @@ const LimitCount: React.FC<Props> = ({ form }) => {
170188
<Form
171189
form={form}
172190
{...FORM_ITEM_LAYOUT}
173-
initialValues={{ key: 'remote_addr', redis_cluster_nodes: ['', ''], policy, redis_port: 6379, redis_database: 0, redis_timeout: 1000 }}
174191
>
175192
<Form.Item
176193
label="count"
@@ -191,6 +208,7 @@ const LimitCount: React.FC<Props> = ({ form }) => {
191208
<InputNumber min={1} />
192209
</Form.Item>
193210
<Form.Item
211+
initialValue='remote_addr'
194212
label="key"
195213
name="key"
196214
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.key.tooltip' })}
@@ -200,19 +218,21 @@ const LimitCount: React.FC<Props> = ({ form }) => {
200218
</Select>
201219
</Form.Item>
202220
<Form.Item
221+
initialValue={503}
203222
label="rejected_code"
204223
name="rejected_code"
205224
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.rejected_code.tooltip' })}
206225
>
207226
<InputNumber min={200} max={599} />
208227
</Form.Item>
209228
<Form.Item
229+
initialValue={policy}
210230
label="policy"
211231
name="policy"
212232
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.policy.tooltip' })}
213233
>
214234
<Select onChange={(e: PolicyProps) => { setPoicy(e) }}>
215-
{["local", "redis", "redis-cluster"].map(item => (<Select.Option value={item}>{item}</Select.Option>))}
235+
{["local", "redis", "redis-cluster"].map(item => (<Select.Option value={item} key={item}>{item}</Select.Option>))}
216236
</Select>
217237
</Form.Item>
218238
<Form.Item shouldUpdate={(prev, next) => prev.policy !== next.policy} style={{ display: 'none' }}>
@@ -221,7 +241,7 @@ const LimitCount: React.FC<Props> = ({ form }) => {
221241
}}
222242
</Form.Item>
223243
{Boolean(policy === 'redis') && <RedisForm />}
224-
{Boolean(policy === 'redis-cluster') && <RedisClusterForm form={form} />}
244+
{Boolean(policy === 'redis-cluster') && <RedisClusterForm />}
225245
</Form>
226246
);
227247
}

web/src/components/Plugin/locales/en-US.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
'component.pluginForm.cors.allow_origins.extra': 'For example: https://somehost.com:8081',
3636
'component.pluginForm.cors.allow_methods.tooltip': 'Which Method is allowed to enable CORS, such as: GET, POST etc. Multiple method use , to split. When allow_credential is false, you can use * to indicate allow all any method. You also can allow any method forcefully using ** even already enable allow_credential, but it will bring some security risks.',
3737
'component.pluginForm.cors.allow_headers.tooltip': 'Which headers are allowed to set in request when access cross-origin resource. Multiple value use , to split. When allow_credential is false, you can use * to indicate allow all request headers. You also can allow any header forcefully using ** even already enable allow_credential, but it will bring some security risks.',
38-
'component.pluginForm.cors.expose_headers.tooltip': ' Which headers are allowed to set in response when access cross-origin resource. Multiple value use , to split.',
38+
'component.pluginForm.cors.expose_headers.tooltip': 'Which headers are allowed to set in response when access cross-origin resource. Multiple value use , to split.',
3939
'component.pluginForm.cors.max_age.tooltip': 'Maximum number of seconds the results can be cached.. Within this time range, the browser will reuse the last check result. -1 means no cache. Please note that the maximum value is depended on browser, please refer to MDN for details.',
4040
'component.pluginForm.cors.allow_credential.tooltip': 'If you set this option to true, you can not use \'*\' for other options.',
4141
'component.pluginForm.cors.allow_origins_by_regex.tooltip': 'Use regex expressions to match which origin is allowed to enable CORS, for example, [".*.test.com"] can use to match all subdomain of test.com.',
@@ -54,7 +54,7 @@ export default {
5454

5555
// proxy-mirror
5656
'component.pluginForm.proxy-mirror.host.tooltip': 'Specify a mirror service address, e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)',
57-
'component.pluginForm.proxy-mirror.host.extra': 'e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)',
57+
'component.pluginForm.proxy-mirror.host.extra': 'e.g. http://127.0.0.1:9797',
5858
'component.pluginForm.proxy-mirror.host.ruletip': 'address needs to contain schema: http or https, not URI part',
5959

6060
// limit-conn

web/src/components/Plugin/locales/zh-CN.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default {
5454

5555
// proxy-mirror
5656
'component.pluginForm.proxy-mirror.host.tooltip': '指定镜像服务地址,例如:http://127.0.0.1:9797(地址中需要包含 schema :http或https,不能包含 URI 部分)',
57-
'component.pluginForm.proxy-mirror.host.extra': '例如:http://127.0.0.1:9797(地址中需要包含 schema:http或https,不能包含 URI 部分)',
57+
'component.pluginForm.proxy-mirror.host.extra': '例如:http://127.0.0.1:9797',
5858
'component.pluginForm.proxy-mirror.host.ruletip': '地址中需要包含 schema :http或https,不能包含 URI 部分',
5959

6060
// limit-conn

0 commit comments

Comments
 (0)