Skip to content

Commit

Permalink
feat: added priority (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
juzhiyuan authored Dec 10, 2020
1 parent 0010423 commit 39239eb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion web/src/components/Plugin/CodeMirrorDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ const CodeMirrorDrawer: React.FC<Props> = ({
onClick={() => {
window.open(`https://github.com/apache/apisix/blob/master/doc/plugins/${name}.md`);
}}
key={1}
>
Document
</Button>,
<Button type="primary" onClick={formatCodes}>
<Button type="primary" onClick={formatCodes} key={2}>
Format
</Button>,
]}
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ const PluginPage: React.FC<Props> = ({
title={[
item.avatar && (
<Avatar
key={1}
icon={item.avatar}
className="plugin-avatar"
style={{
marginRight: 5,
}}
/>
),
<span>{item.name}</span>,
<span key={2}>{item.name}</span>,
]}
style={{ height: 66 }}
extra={[
Expand Down
14 changes: 13 additions & 1 deletion web/src/pages/Route/components/Step1/RequestConfigView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';
import Form from 'antd/es/form';
import { Checkbox, Button, Input, Select, Row, Col } from 'antd';
import { Checkbox, Button, Input, Select, Row, Col, InputNumber } from 'antd';
import { PlusOutlined, MinusCircleOutlined } from '@ant-design/icons';
import { useIntl } from 'umi';
import { PanelSection } from '@api7-dashboard/ui';
Expand Down Expand Up @@ -267,6 +267,18 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
>
<Checkbox.Group options={HTTP_METHOD_OPTION_LIST} disabled={disabled} />
</Form.Item>
<Form.Item
label={formatMessage({ id: 'page.route.form.itemLabel.priority' })}
name="priority"
>
<InputNumber
placeholder={`Please input ${formatMessage({
id: 'page.route.form.itemLabel.priority',
})}`}
style={{ width: '60%' }}
disabled={disabled}
/>
</Form.Item>
<Form.Item
label={formatMessage({ id: 'page.route.form.itemLabel.redirect' })}
name="redirectOption"
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/Route/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default {
'page.route.panelSection.title.requestConfigBasicDefine': 'Request Basic Define',
'page.route.protocol': 'Protocol',
'page.route.form.itemLabel.httpMethod': 'HTTP Method',
'page.route.form.itemLabel.priority': 'Priority',
'page.route.form.itemLabel.redirect': 'Redirect',
'page.route.select.option.enableHttps': 'Enable HTTPS',
'page.route.select.option.configCustom': 'Custom',
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/Route/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
'page.route.form.itemRulesPatternMessage.apiNameRule':
'最大长度100,仅支持字母、数字、- 和 _,且只能以字母开头',
'page.route.form.itemLabel.httpMethod': 'HTTP 方法',
'page.route.form.itemLabel.priority': '优先级',
'page.route.form.itemLabel.redirect': '重定向',
'page.route.form.itemLabel.redirectCustom': '自定义重定向',
'page.route.form.itemLabel.rewriteType': '请求路径',
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/Route/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const transformRouteData = (data: RouteModule.Body) => {
status,
upstream,
upstream_id,
priority = 0,
} = data;
const form1Data: Partial<RouteModule.Form1Data> = {
name,
Expand All @@ -154,6 +155,7 @@ export const transformRouteData = (data: RouteModule.Body) => {
uris: uris || (uri && [uri]) || [],
remote_addrs: remote_addrs || [''],
methods,
priority,
};

const redirect = data.plugins?.redirect || {};
Expand Down

0 comments on commit 39239eb

Please sign in to comment.