Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add limit-count plugin #1739

Merged
merged 16 commits into from
Apr 15, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ context('Create and delete consumer with limit-count plugin form', () => {
redis_host: '127.0.0.1',
redis_password: 'redis_password',
redis_cluster_name: 'redis_cluster_name',
redis_cluster_nodes_0: "redis.cluster1",
redis_cluster_nodes_1: "redis.cluster1",
redis_cluster_nodes_0: "127.0.0.1:5000",
redis_cluster_nodes_1: "127.0.0.1:5000",
}

it('should create consumer with limit-count form', function () {
Expand Down
10 changes: 5 additions & 5 deletions web/src/components/Plugin/UI/limit-count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const RedisForm: React.FC = () => {
label="redis_host"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emmm would better have i18n for those fields, for users may not know what's it

name="redis_host"
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_host.tooltip' })}
required
rules={[{ required: true, message: 'Please input redis_host' }]}
>
<Input />
</Form.Item>
Expand All @@ -70,7 +70,7 @@ const RedisForm: React.FC = () => {
label="redis_password"
name="redis_password"
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_password.tooltip' })}
required
rules={[{ required: true, message: 'Please input redis_password' }]}
>
<Input />
</Form.Item>
Expand Down Expand Up @@ -100,7 +100,7 @@ const RedisClusterForm: React.FC<Props> = () => {
label="redis_cluster_name"
name="redis_cluster_name"
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_cluster_name.tooltip' })}
required
rules={[{ required: true, message: 'Please input redis_cluster_name' }]}
>
<Input />
</Form.Item>
Expand Down Expand Up @@ -169,15 +169,15 @@ const LimitCount: React.FC<Props> = ({ form }) => {
label="count"
name="count"
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.count.tooltip' })}
required
rules={[{ required: true, message: 'Please input count' }]}
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
>
<InputNumber min={1} />
</Form.Item>
<Form.Item
label="time_window"
name="time_window"
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.time_window.tooltip' })}
required
rules={[{ required: true, message: 'Please input time_window' }]}
>
<InputNumber min={1} />
</Form.Item>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
'component.step.select.pluginTemplate.select.option': 'Custom',
'component.plugin.pluginTemplate.tip1': '1. When a route already have plugins field configured, the plugins in the plugin template will be merged into it.',
'component.plugin.pluginTemplate.tip2': '2. The same plugin in the plugin template will override one in the plugins',

'component.plugin.form': 'Form',
'component.plugin.format-codes.disable': 'Format JSON or YAML data',
'component.plugin.editor': 'Plugin Editor',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
'component.step.select.pluginTemplate.select.option': '手动配置',
'component.plugin.pluginTemplate.tip1': '1. 若路由已配置插件,则插件模板数据将与已配置的插件数据合并。',
'component.plugin.pluginTemplate.tip2': '2. 插件模板相同的插件会覆盖掉原有的插件。',

'component.plugin.form': '表单',
'component.plugin.format-codes.disable': '用于格式化 JSON 或 YAML 内容',
'component.plugin.editor': '插件配置',
Expand Down