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(Route): added priority field #1006

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}>
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
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