You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/21 06:57:11 UTC

[GitHub] [apisix-dashboard] LiteSun opened a new pull request #1089: Feat service

LiteSun opened a new pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [ ] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   
   - Related issues
   
   ___
   ### Bugfix
   - Description
   
   - How to fix?
   
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547135045



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;
+        if (serviceId) {
+            fetchItem(serviceId).then(({ data }) => {
+                if (data.upstream_id && data.upstream_id !== '') {

Review comment:
       em, `data.upstream_id` maybe `undefined`, will make it a little clearer for the developer?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (63b3b14) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/46bf1ef9cfe4f4c659752176424151bb4fc4952f?el=desc) (46bf1ef) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.06%   41.06%           
   =======================================
     Files          28       28           
     Lines        1773     1773           
   =======================================
     Hits          728      728           
     Misses        939      939           
     Partials      106      106           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [46bf1ef...63b3b14](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548776324



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+  const { formatMessage } = useIntl();
+  const [form] = Form.useForm();
+  const [upstreamForm] = Form.useForm();
+  const upstreamRef = useRef<any>();
+  const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+  const STEP_HEADER = [
+    formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+    formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+    formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+  ]
+
+  const [stepHeader] = useState(STEP_HEADER);
+  const [step, setStep] = useState(1);
+
+  useEffect(() => {
+    const { serviceId } = (props as any).match.params;
+    if (serviceId) {
+      fetchItem(serviceId).then(({ data }) => {
+        if (data.upstream_id && data.upstream_id !== '') {
+          upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+        }
+        if (data.upstream) {
+          upstreamForm.setFieldsValue(data.upstream);
+        }
+        form.setFieldsValue(omit(data, ['upstream_id', 'upstream', 'plugins']));
+        setPlugins(data.plugins || {});
+      });
+    }
+  }, []);
+
+  const onSubmit = () => {
+    const data = {
+      ...form.getFieldsValue(),
+      plugins,
+    };
+
+    const upstreamFormData = upstreamForm.getFieldsValue();
+    if (upstreamFormData.upstream_id === '') {
+      data.upstream = omit(upstreamFormData, ['upstream_id']);
+    } else {
+      data.upstream_id = upstreamFormData.upstream_id;
+    }
+
+    const { serviceId } = (props as any).match.params;
+    (serviceId ? update(serviceId, data) : create(data))
+      .then(() => {
+        notification.success({
+          message: `${serviceId
+            ? formatMessage({ id: 'component.global.edit' })
+            : formatMessage({ id: 'component.global.create' })
+            } ${formatMessage({ id: 'menu.service' })} ${formatMessage({
+              id: 'component.status.success',
+            })}`,
+        });
+        history.push('/service/list');
+      })
+      .catch(() => {
+        setStep(3);
+      });
+  };
+
+  const onStepChange = (nextStep: number) => {
+    if (step === 1 && nextStep === 2) {
+      form.validateFields().then(() => {
+        upstreamForm.validateFields().then(() => {
+          setStep(nextStep);
+        })
+      })
+      return;
+    }
+    if (nextStep === 4) {
+      onSubmit();
+      return;
+    };
+    setStep(nextStep);
+  }
+
+  return (<>
+    <PageHeaderWrapper
+      title={`${(props as any).match.params.rid
+        ? formatMessage({ id: 'component.global.edit' })
+        : formatMessage({ id: 'component.global.create' })
+        } ${formatMessage({ id: 'menu.service' })}`}
+    >
+      <Card bordered={false}>
+        <Steps current={step - 1} style={{ marginBottom: "25px" }}>
+          {stepHeader.map((item) => (
+            <Step title={item} key={item} />
+          ))}
+        </Steps>
+        {step === 1 && <Step1
+          form={form}
+          upstreamForm={upstreamForm}
+          upstreamRef={upstreamRef}
+        />}
+        {step === 2 && (
+          <PluginPage initialData={plugins} onChange={setPlugins} schemaType="route" />

Review comment:
       you mean `plugin orchestration` right?  We currently don't add plugin orchestration.
   refer to https://github.com/apache/apisix/blob/560a2fe3ab49821f7eb90e21450839019893fe42/doc/zh-cn/admin-api.md#service




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547101572



##########
File path: web/src/helpers.tsx
##########
@@ -51,6 +51,11 @@ export const getMenuData = (): MenuDataItem[] => {
       path: '/consumer/list',
       icon: <IconFont name="iconconsumer" />,
     },
+    {
+      name: 'service',
+      path: '/service/list',
+      icon: <IconFont name="iconconsumer" />,

Review comment:
       how about https://www.iconfont.cn/search/index?q=service-list




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548758154



##########
File path: web/src/pages/Service/components/Step1.tsx
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useEffect, useState } from 'react';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+import UpstreamForm from '@/components/Upstream';
+import { fetchUpstreamList } from '../service';
+
+const FORM_LAYOUT = {
+  labelCol: {
+    span: 3,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const Step1: React.FC<ServiceModule.Step1PassProps> = ({
+  form,
+  upstreamForm,
+  upstreamRef,
+  disabled,
+}) => {
+  const { formatMessage } = useIntl();
+  const [list, setList] = useState<UpstreamModule.RequestBody[]>([]);
+  useEffect(() => {
+    fetchUpstreamList().then(({ data }) => setList(data));
+  }, []);
+
+  return <>
+    <Form {...FORM_LAYOUT} form={form}>
+      <Form.Item
+        name="name"
+        label={formatMessage({ id: 'component.global.name' })}

Review comment:
       just make sure that name field does not need to be a required field ,right?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547094023



##########
File path: web/src/helpers.tsx
##########
@@ -51,6 +51,11 @@ export const getMenuData = (): MenuDataItem[] => {
       path: '/consumer/list',
       icon: <IconFont name="iconconsumer" />,
     },
+    {
+      name: 'service',
+      path: '/service/list',
+      icon: <IconFont name="iconconsumer" />,

Review comment:
       oh yes, please select an icon here[1], then I will help to generate a new icon file.
   
   [1] https://www.iconfont.cn/




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548449078



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       If we use`None`, How to distinguish if the service name is None ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548447197



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >
           {serviceList.map(item => {
-            return <Select.Option value={item.id}>
+            return <Select.Option value={item.id} key={item.id}>
               {item.name}
             </Select.Option>
           })}
         </Select>
       </Form.Item>
-    </PanelSection>
+    </PanelSection >

Review comment:
       🤷‍♂️




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548775448



##########
File path: web/src/pages/Route/locales/zh-CN.ts
##########
@@ -40,6 +40,7 @@ export default {
   'page.route.published': '已发布',
   'page.route.unpublished': '未发布',
   'page.route.onlineDebug': '在线调试',
+  'page.route.service': '服务',

Review comment:
       > it would be better to reuse `menu.service` instread of redefine a new key
   
   If menu.service but the fields are not changed there will be a problem. so I think they should be independent 🤔




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547109401



##########
File path: web/src/helpers.tsx
##########
@@ -51,6 +51,11 @@ export const getMenuData = (): MenuDataItem[] => {
       path: '/consumer/list',
       icon: <IconFont name="iconconsumer" />,
     },
+    {
+      name: 'service',
+      path: '/service/list',
+      icon: <IconFont name="iconconsumer" />,

Review comment:
       fine, if there doesn't have a more proper icon, we could use it. I will file a new PR to do this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (4cddac6) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/6fa6a16559a1c1d0e90de4a3277a3db6e73cb9fc?el=desc) (6fa6a16) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   42.12%   42.12%           
   =======================================
     Files          29       29           
     Lines        1816     1816           
   =======================================
     Hits          765      765           
     Misses        943      943           
     Partials      108      108           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [6fa6a16...4cddac6](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (6a91c20) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/e786ef63e71ca8085de6b43b69601ed20d0f2b65?el=desc) (e786ef6) will **increase** coverage by `1.72%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   39.33%   41.06%   +1.72%     
   ==========================================
     Files          27       28       +1     
     Lines        1673     1773     +100     
   ==========================================
   + Hits          658      728      +70     
   - Misses        915      939      +24     
   - Partials      100      106       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/handler/label/label.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvbGFiZWwvbGFiZWwuZ28=) | `70.00% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [e786ef6...6a91c20](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548775448



##########
File path: web/src/pages/Route/locales/zh-CN.ts
##########
@@ -40,6 +40,7 @@ export default {
   'page.route.published': '已发布',
   'page.route.unpublished': '未发布',
   'page.route.onlineDebug': '在线调试',
+  'page.route.service': '服务',

Review comment:
       > it would be better to reuse `menu.service` instread of redefine a new key
   
   If menu.serice but the fields are not changed there will be a problem. so I think they should be independent 🤔




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548447052



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       ```tsx
   <Option>None</Option>
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548768802



##########
File path: web/src/pages/Service/components/Step1.tsx
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useEffect, useState } from 'react';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+import UpstreamForm from '@/components/Upstream';
+import { fetchUpstreamList } from '../service';
+
+const FORM_LAYOUT = {
+  labelCol: {
+    span: 3,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const Step1: React.FC<ServiceModule.Step1PassProps> = ({
+  form,
+  upstreamForm,
+  upstreamRef,
+  disabled,
+}) => {
+  const { formatMessage } = useIntl();
+  const [list, setList] = useState<UpstreamModule.RequestBody[]>([]);
+  useEffect(() => {
+    fetchUpstreamList().then(({ data }) => setList(data));
+  }, []);
+
+  return <>
+    <Form {...FORM_LAYOUT} form={form}>
+      <Form.Item
+        name="name"
+        label={formatMessage({ id: 'component.global.name' })}

Review comment:
       https://github.com/apache/apisix/blob/master/doc/admin-api.md#service
   
   yep, optional




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (0cebe35) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/1fa884a1fb6944c799cd7d9fb3ef943df52b820b?el=desc) (1fa884a) will **increase** coverage by `0.05%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   41.00%   41.06%   +0.05%     
   ==========================================
     Files          28       28              
     Lines        1773     1773              
   ==========================================
   + Hits          727      728       +1     
   + Misses        940      939       -1     
     Partials      106      106              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [1fa884a...0cebe35](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547087958



##########
File path: web/src/helpers.tsx
##########
@@ -51,6 +51,11 @@ export const getMenuData = (): MenuDataItem[] => {
       path: '/consumer/list',
       icon: <IconFont name="iconconsumer" />,
     },
+    {
+      name: 'service',
+      path: '/service/list',
+      icon: <IconFont name="iconconsumer" />,

Review comment:
       do we need to add a new icon for service?

##########
File path: web/src/pages/Service/locales/zh-CN.ts
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+    'page.route.service.desc': '描述',

Review comment:
       ```suggestion
       'page.service.desc': '描述',
   ```

##########
File path: web/src/pages/Service/locales/en-US.ts
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+    'page.route.service.desc': 'Desc',

Review comment:
       ```suggestion
       'page.service.desc': 'Desc',
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547091085



##########
File path: web/src/pages/Service/locales/en-US.ts
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+    'page.route.service.desc': 'Desc',

Review comment:
       ```suggestion
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (48ac69e) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/aca192c4f352aa7bcc9b88ac52da9ff3cc498271?el=desc) (aca192c) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.06%   41.06%           
   =======================================
     Files          28       28           
     Lines        1773     1773           
   =======================================
     Hits          728      728           
     Misses        939      939           
     Partials      106      106           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [aca192c...48ac69e](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548441932



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}

Review comment:
       1. `=` is used to set value 🤣🤣
   2. xx means
   3. TODO

##########
File path: web/src/pages/Route/service.ts
##########
@@ -104,4 +104,5 @@ export const fetchServiceList = () =>
   request('/services').then(({ data }) => ({
     data: data.rows,
     total: data.total_size,
-  }));
\ No newline at end of file
+  }));
+  

Review comment:
       ![image](https://user-images.githubusercontent.com/2106987/103073859-55026a80-4603-11eb-808d-89c6a984f63d.png)
   

##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       Why use `null` here?

##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >
           {serviceList.map(item => {
-            return <Select.Option value={item.id}>
+            return <Select.Option value={item.id} key={item.id}>
               {item.name}
             </Select.Option>
           })}
         </Select>
       </Form.Item>
-    </PanelSection>
+    </PanelSection >

Review comment:
       ![image](https://user-images.githubusercontent.com/2106987/103073875-5cc20f00-4603-11eb-9230-d13c53489efc.png)
   
   what's this?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (caeb4e4) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/6fa6a16559a1c1d0e90de4a3277a3db6e73cb9fc?el=desc) (6fa6a16) will **decrease** coverage by `0.18%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   - Coverage   42.12%   41.94%   -0.19%     
   ==========================================
     Files          29       29              
     Lines        1816     1824       +8     
   ==========================================
     Hits          765      765              
   - Misses        943      951       +8     
     Partials      108      108              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/filter/schema.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ZpbHRlci9zY2hlbWEuZ28=) | `0.00% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [6fa6a16...caeb4e4](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (4a81f61) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/1fa884a1fb6944c799cd7d9fb3ef943df52b820b?el=desc) (1fa884a) will **increase** coverage by `0.05%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   41.00%   41.06%   +0.05%     
   ==========================================
     Files          28       28              
     Lines        1773     1773              
   ==========================================
   + Hits          727      728       +1     
   + Misses        940      939       -1     
     Partials      106      106              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [1fa884a...4a81f61](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan merged pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548761995



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+  const { formatMessage } = useIntl();
+  const [form] = Form.useForm();
+  const [upstreamForm] = Form.useForm();
+  const upstreamRef = useRef<any>();
+  const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+  const STEP_HEADER = [
+    formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+    formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+    formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+  ]
+
+  const [stepHeader] = useState(STEP_HEADER);
+  const [step, setStep] = useState(1);
+
+  useEffect(() => {
+    const { serviceId } = (props as any).match.params;
+    if (serviceId) {
+      fetchItem(serviceId).then(({ data }) => {
+        if (data.upstream_id && data.upstream_id !== '') {
+          upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+        }
+        if (data.upstream) {
+          upstreamForm.setFieldsValue(data.upstream);
+        }
+        form.setFieldsValue(omit(data, ['upstream_id', 'upstream', 'plugins']));
+        setPlugins(data.plugins || {});
+      });
+    }
+  }, []);
+
+  const onSubmit = () => {
+    const data = {
+      ...form.getFieldsValue(),
+      plugins,
+    };
+
+    const upstreamFormData = upstreamForm.getFieldsValue();
+    if (upstreamFormData.upstream_id === '') {
+      data.upstream = omit(upstreamFormData, ['upstream_id']);
+    } else {
+      data.upstream_id = upstreamFormData.upstream_id;
+    }
+
+    const { serviceId } = (props as any).match.params;
+    (serviceId ? update(serviceId, data) : create(data))
+      .then(() => {
+        notification.success({
+          message: `${serviceId
+            ? formatMessage({ id: 'component.global.edit' })
+            : formatMessage({ id: 'component.global.create' })
+            } ${formatMessage({ id: 'menu.service' })} ${formatMessage({
+              id: 'component.status.success',
+            })}`,
+        });
+        history.push('/service/list');
+      })
+      .catch(() => {
+        setStep(3);
+      });
+  };
+
+  const onStepChange = (nextStep: number) => {
+    if (step === 1 && nextStep === 2) {
+      form.validateFields().then(() => {
+        upstreamForm.validateFields().then(() => {
+          setStep(nextStep);
+        })
+      })
+      return;
+    }
+    if (nextStep === 4) {
+      onSubmit();
+      return;
+    };
+    setStep(nextStep);
+  }
+
+  return (<>
+    <PageHeaderWrapper
+      title={`${(props as any).match.params.rid
+        ? formatMessage({ id: 'component.global.edit' })
+        : formatMessage({ id: 'component.global.create' })
+        } ${formatMessage({ id: 'menu.service' })}`}
+    >
+      <Card bordered={false}>
+        <Steps current={step - 1} style={{ marginBottom: "25px" }}>
+          {stepHeader.map((item) => (
+            <Step title={item} key={item} />
+          ))}
+        </Steps>
+        {step === 1 && <Step1
+          form={form}
+          upstreamForm={upstreamForm}
+          upstreamRef={upstreamRef}
+        />}
+        {step === 2 && (
+          <PluginPage initialData={plugins} onChange={setPlugins} schemaType="route" />

Review comment:
       just make sure we do not need to add `plugin pipeline` in service module,right?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548442725



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -376,6 +383,19 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
           return null;
         }}
       </Form.Item>
+      <Form.Item
+        label={formatMessage({ id: 'page.route.service' })}
+        name='service_id'
+      >
+        <Select disabled={disabled}>
+          <Select.Option value=''>{}</Select.Option>

Review comment:
       should have an issue to track.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (a7d355d) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/46bf1ef9cfe4f4c659752176424151bb4fc4952f?el=desc) (46bf1ef) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.06%   41.06%           
   =======================================
     Files          28       28           
     Lines        1773     1773           
   =======================================
     Hits          728      728           
     Misses        939      939           
     Partials      106      106           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [46bf1ef...a7d355d](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548759893



##########
File path: web/src/pages/Service/components/Step1.tsx
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useEffect, useState } from 'react';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+import UpstreamForm from '@/components/Upstream';

Review comment:
       It would be better to init upstream default value just like `Upstream Module` does

##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+  const { formatMessage } = useIntl();
+  const [form] = Form.useForm();
+  const [upstreamForm] = Form.useForm();
+  const upstreamRef = useRef<any>();
+  const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+  const STEP_HEADER = [
+    formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+    formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+    formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+  ]
+
+  const [stepHeader] = useState(STEP_HEADER);
+  const [step, setStep] = useState(1);
+
+  useEffect(() => {
+    const { serviceId } = (props as any).match.params;
+    if (serviceId) {
+      fetchItem(serviceId).then(({ data }) => {
+        if (data.upstream_id && data.upstream_id !== '') {
+          upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+        }
+        if (data.upstream) {
+          upstreamForm.setFieldsValue(data.upstream);
+        }
+        form.setFieldsValue(omit(data, ['upstream_id', 'upstream', 'plugins']));
+        setPlugins(data.plugins || {});
+      });
+    }
+  }, []);
+
+  const onSubmit = () => {
+    const data = {
+      ...form.getFieldsValue(),
+      plugins,
+    };
+
+    const upstreamFormData = upstreamForm.getFieldsValue();
+    if (upstreamFormData.upstream_id === '') {
+      data.upstream = omit(upstreamFormData, ['upstream_id']);
+    } else {
+      data.upstream_id = upstreamFormData.upstream_id;
+    }
+
+    const { serviceId } = (props as any).match.params;
+    (serviceId ? update(serviceId, data) : create(data))
+      .then(() => {
+        notification.success({
+          message: `${serviceId
+            ? formatMessage({ id: 'component.global.edit' })
+            : formatMessage({ id: 'component.global.create' })
+            } ${formatMessage({ id: 'menu.service' })} ${formatMessage({
+              id: 'component.status.success',
+            })}`,
+        });
+        history.push('/service/list');
+      })
+      .catch(() => {
+        setStep(3);
+      });
+  };
+
+  const onStepChange = (nextStep: number) => {
+    if (step === 1 && nextStep === 2) {
+      form.validateFields().then(() => {
+        upstreamForm.validateFields().then(() => {
+          setStep(nextStep);
+        })
+      })
+      return;
+    }
+    if (nextStep === 4) {
+      onSubmit();
+      return;
+    };
+    setStep(nextStep);
+  }
+
+  return (<>
+    <PageHeaderWrapper
+      title={`${(props as any).match.params.rid
+        ? formatMessage({ id: 'component.global.edit' })
+        : formatMessage({ id: 'component.global.create' })
+        } ${formatMessage({ id: 'menu.service' })}`}
+    >
+      <Card bordered={false}>
+        <Steps current={step - 1} style={{ marginBottom: "25px" }}>
+          {stepHeader.map((item) => (
+            <Step title={item} key={item} />
+          ))}
+        </Steps>
+        {step === 1 && <Step1
+          form={form}
+          upstreamForm={upstreamForm}
+          upstreamRef={upstreamRef}
+        />}
+        {step === 2 && (
+          <PluginPage initialData={plugins} onChange={setPlugins} schemaType="route" />

Review comment:
       just make sure we do need to add `plugin pipeline` in service module,right?

##########
File path: web/src/pages/Route/locales/zh-CN.ts
##########
@@ -40,6 +40,7 @@ export default {
   'page.route.published': '已发布',
   'page.route.unpublished': '未发布',
   'page.route.onlineDebug': '在线调试',
+  'page.route.service': '服务',

Review comment:
       it would be better to reuse `menu.service` instread of redefine a new key




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (9d108b5) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/97c53973ffc84e488add40ac3fe139ba3dc43ba7?el=desc) (97c5397) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.06%   41.06%           
   =======================================
     Files          28       28           
     Lines        1773     1773           
   =======================================
     Hits          728      728           
     Misses        939      939           
     Partials      106      106           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [97c5397...9d108b5](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547135750



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;
+        if (serviceId) {
+            fetchItem(serviceId).then(({ data }) => {
+                if (data.upstream_id && data.upstream_id !== '') {
+                    upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+                }
+                if (data.upstream) {
+                    upstreamForm.setFieldsValue(data.upstream);
+                }
+                form.setFieldsValue(omit(data, ['upstream_id', 'upstream']));

Review comment:
       good catch!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548364908



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -376,6 +383,19 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
           return null;
         }}
       </Form.Item>
+      <Form.Item
+        label={formatMessage({ id: 'page.route.service' })}
+        name='service_id'
+      >
+        <Select disabled={disabled}>
+          <Select.Option value=''>{}</Select.Option>
+          {serviceList.map(item => {
+            return <Select.Option value={item.id}>

Review comment:
       key

##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -376,6 +383,19 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
           return null;
         }}
       </Form.Item>
+      <Form.Item
+        label={formatMessage({ id: 'page.route.service' })}
+        name='service_id'
+      >
+        <Select disabled={disabled}>
+          <Select.Option value=''>{}</Select.Option>

Review comment:
       ![image](https://user-images.githubusercontent.com/2106987/103057401-54091300-45da-11eb-9fd4-df929f1f7a61.png)
   

##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -376,6 +383,19 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
           return null;
         }}
       </Form.Item>
+      <Form.Item
+        label={formatMessage({ id: 'page.route.service' })}
+        name='service_id'
+      >
+        <Select disabled={disabled}>
+          <Select.Option value=''>{}</Select.Option>

Review comment:
       how about using a global default value for the selector?  e.g `DEFAULT_SELECT_VALUE`
   
   Then we could omit those fields using a global filter.

##########
File path: web/src/pages/Route/service.ts
##########
@@ -99,3 +99,9 @@ export const debugRoute = (data: RouteModule.debugRequest) => {
     data,
   });
 };
+
+export const fetchServiceList = () =>
+  request('/services').then(({ data }) => ({
+    data: data.rows,
+    total: data.total_size,
+  }));

Review comment:
       new line please

##########
File path: web/src/pages/Route/transform.ts
##########
@@ -150,6 +152,7 @@ export const transformRouteData = (data: RouteModule.Body) => {
     status,
     upstream,
     upstream_id,
+    service_id,

Review comment:
       should have a default empty string value, or maybe crashed due to undefined.length

##########
File path: web/src/pages/Route/transform.ts
##########
@@ -83,6 +83,7 @@ export const transformStepData = ({
       'redirectURI',
       'ret_code',
       'redirectOption',
+      form1Data.service_id.length === 0 ? 'service_id' : '',

Review comment:
       trick, because default_service_id is empty string




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (4745035) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/46bf1ef9cfe4f4c659752176424151bb4fc4952f?el=desc) (46bf1ef) will **increase** coverage by `0.34%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   41.06%   41.40%   +0.34%     
   ==========================================
     Files          28       28              
     Lines        1773     1785      +12     
   ==========================================
   + Hits          728      739      +11     
   - Misses        939      940       +1     
     Partials      106      106              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/handler/plugin/plugin.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvcGx1Z2luL3BsdWdpbi5nbw==) | `70.00% <0.00%> (+14.44%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [46bf1ef...4745035](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548813728



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+  const { formatMessage } = useIntl();
+  const [form] = Form.useForm();
+  const [upstreamForm] = Form.useForm();
+  const upstreamRef = useRef<any>();
+  const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+  const STEP_HEADER = [
+    formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+    formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+    formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+  ]
+
+  const [stepHeader] = useState(STEP_HEADER);
+  const [step, setStep] = useState(1);
+
+  useEffect(() => {
+    const { serviceId } = (props as any).match.params;
+    if (serviceId) {
+      fetchItem(serviceId).then(({ data }) => {
+        if (data.upstream_id && data.upstream_id !== '') {
+          upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+        }
+        if (data.upstream) {
+          upstreamForm.setFieldsValue(data.upstream);
+        }
+        form.setFieldsValue(omit(data, ['upstream_id', 'upstream', 'plugins']));
+        setPlugins(data.plugins || {});
+      });
+    }
+  }, []);
+
+  const onSubmit = () => {
+    const data = {
+      ...form.getFieldsValue(),
+      plugins,
+    };
+
+    const upstreamFormData = upstreamForm.getFieldsValue();
+    if (upstreamFormData.upstream_id === '') {
+      data.upstream = omit(upstreamFormData, ['upstream_id']);
+    } else {
+      data.upstream_id = upstreamFormData.upstream_id;
+    }
+
+    const { serviceId } = (props as any).match.params;
+    (serviceId ? update(serviceId, data) : create(data))
+      .then(() => {
+        notification.success({
+          message: `${serviceId
+            ? formatMessage({ id: 'component.global.edit' })
+            : formatMessage({ id: 'component.global.create' })
+            } ${formatMessage({ id: 'menu.service' })} ${formatMessage({
+              id: 'component.status.success',
+            })}`,
+        });
+        history.push('/service/list');
+      })
+      .catch(() => {
+        setStep(3);
+      });
+  };
+
+  const onStepChange = (nextStep: number) => {
+    if (step === 1 && nextStep === 2) {
+      form.validateFields().then(() => {
+        upstreamForm.validateFields().then(() => {
+          setStep(nextStep);
+        })
+      })
+      return;
+    }
+    if (nextStep === 4) {
+      onSubmit();
+      return;
+    };
+    setStep(nextStep);
+  }
+
+  return (<>
+    <PageHeaderWrapper
+      title={`${(props as any).match.params.rid
+        ? formatMessage({ id: 'component.global.edit' })
+        : formatMessage({ id: 'component.global.create' })
+        } ${formatMessage({ id: 'menu.service' })}`}
+    >
+      <Card bordered={false}>
+        <Steps current={step - 1} style={{ marginBottom: "25px" }}>
+          {stepHeader.map((item) => (
+            <Step title={item} key={item} />
+          ))}
+        </Steps>
+        {step === 1 && <Step1
+          form={form}
+          upstreamForm={upstreamForm}
+          upstreamRef={upstreamRef}
+        />}
+        {step === 2 && (
+          <PluginPage initialData={plugins} onChange={setPlugins} schemaType="route" />

Review comment:
       got it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547095561



##########
File path: web/src/pages/Service/List.tsx
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useRef } from 'react';
+import { history, useIntl } from 'umi';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
+import { PlusOutlined } from '@ant-design/icons';
+import { Button, notification, Popconfirm, Space } from 'antd';
+
+import { fetchList, remove } from './service';
+
+const Page: React.FC = () => {
+  const ref = useRef<ActionType>();
+  const { formatMessage } = useIntl();
+
+  const columns: ProColumns<ServiceModule.ResponseBody>[] = [
+    {
+      title: 'ID',
+      dataIndex: 'id',
+      hideInSearch: true
+    },
+    {
+      title: formatMessage({ id: 'component.global.name' }),
+      dataIndex: 'name',
+    },
+    {
+      title: formatMessage({ id: 'page.route.service.desc' }),

Review comment:
       ```suggestion
         title: formatMessage({ id: 'component.global.description' }),
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548793531



##########
File path: web/src/pages/Service/components/Step1.tsx
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useEffect, useState } from 'react';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+import UpstreamForm from '@/components/Upstream';

Review comment:
       updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (b614b9a) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/1fa884a1fb6944c799cd7d9fb3ef943df52b820b?el=desc) (1fa884a) will **increase** coverage by `0.05%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   41.00%   41.06%   +0.05%     
   ==========================================
     Files          28       28              
     Lines        1773     1773              
   ==========================================
   + Hits          727      728       +1     
   + Misses        940      939       -1     
     Partials      106      106              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [1fa884a...6bdfc10](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548444031



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >
           {serviceList.map(item => {
-            return <Select.Option value={item.id}>
+            return <Select.Option value={item.id} key={item.id}>
               {item.name}
             </Select.Option>
           })}
         </Select>
       </Form.Item>
-    </PanelSection>
+    </PanelSection >

Review comment:
       maybe vscode auto format tools did this, let me recheck




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548451146



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       1. Too wired to use `None` as Service name in prod;
   2. `Select service (optional)`: https://github.com/apache/apisix-dashboard/blob/master/web/src/components/Upstream/UpstreamForm.tsx#L578




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (1d53577) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/d2b577298d4b86ea120fda718e21478cd94e82eb?el=desc) (d2b5772) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.40%   41.40%           
   =======================================
     Files          28       28           
     Lines        1785     1785           
   =======================================
     Hits          739      739           
     Misses        940      940           
     Partials      106      106           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [d2b5772...1d53577](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548446261



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       `Select.option` need children property and if `{}` and `{null}` is not ok, Which way do you recommend? 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io commented on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (1e50509) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/e786ef63e71ca8085de6b43b69601ed20d0f2b65?el=desc) (e786ef6) will **increase** coverage by `1.72%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   39.33%   41.06%   +1.72%     
   ==========================================
     Files          27       28       +1     
     Lines        1673     1773     +100     
   ==========================================
   + Hits          658      728      +70     
   - Misses        915      939      +24     
   - Partials      100      106       +6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/handler/label/label.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvbGFiZWwvbGFiZWwuZ28=) | `70.00% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [e786ef6...1e50509](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547095850



##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;

Review comment:
       4 spaces?

##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;
+        if (serviceId) {
+            fetchItem(serviceId).then(({ data }) => {
+                if (data.upstream_id && data.upstream_id !== '') {

Review comment:
       `"" === falsy`

##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;
+        if (serviceId) {
+            fetchItem(serviceId).then(({ data }) => {
+                if (data.upstream_id && data.upstream_id !== '') {
+                    upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+                }
+                if (data.upstream) {
+                    upstreamForm.setFieldsValue(data.upstream);
+                }
+                form.setFieldsValue(omit(data, ['upstream_id', 'upstream']));
+                setPlugins(data.plugins || {});
+            });
+        }
+    }, []);
+
+    const onSubmit = () => {
+        const data = {
+            ...form.getFieldsValue(),
+            plugins,
+        };
+
+        const upstreamFormData = upstreamForm.getFieldsValue();
+        if (upstreamFormData.upstream_id === '') {
+            data.upstream = omit(upstreamFormData, ['upstream_id']);
+        } else {
+            data.upstream_id = upstreamFormData.upstream_id;
+        }
+
+        const { serviceId } = (props as any).match.params;
+        (serviceId ? update(serviceId, data) : create(data))
+            .then(() => {
+                notification.success({
+                    message: `${serviceId
+                        ? formatMessage({ id: 'component.global.edit' })
+                        : formatMessage({ id: 'component.global.create' })
+                        } ${formatMessage({ id: 'menu.service' })} ${formatMessage({
+                            id: 'component.status.success',
+                        })}`,
+                });
+                history.push('/service/list');
+            })
+            .catch(() => {
+                setStep(3);
+            });
+    };
+
+    const onStepChange = (nextStep: number) => {
+        if (nextStep === 2) {

Review comment:
       page 3 -> page 2?

##########
File path: web/src/pages/Service/Create.tsx
##########
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useState, useRef, useEffect } from 'react'
+import { useIntl, history } from 'umi';
+import { Card, Steps, Form, notification } from 'antd';
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
+import { omit } from 'lodash';
+
+import ActionBar from '@/components/ActionBar';
+import PluginPage from '@/components/Plugin';
+import Preview from './components/Preview';
+import Step1 from "./components/Step1";
+import { create, update, fetchItem } from './service';
+
+const { Step } = Steps;
+
+const Page: React.FC = (props) => {
+    const { formatMessage } = useIntl();
+    const [form] = Form.useForm();
+    const [upstreamForm] = Form.useForm();
+    const upstreamRef = useRef<any>();
+    const [plugins, setPlugins] = useState<PluginComponent.Data>({});
+
+    const STEP_HEADER = [
+        formatMessage({ id: 'page.service.steps.stepTitle.basicInformation' }),
+        formatMessage({ id: 'page.service.steps.stepTitle.pluginConfig' }),
+        formatMessage({ id: 'component.global.steps.stepTitle.preview' }),
+    ]
+
+    const [stepHeader] = useState(STEP_HEADER);
+    const [step, setStep] = useState(1);
+
+    useEffect(() => {
+        const { serviceId } = (props as any).match.params;
+        if (serviceId) {
+            fetchItem(serviceId).then(({ data }) => {
+                if (data.upstream_id && data.upstream_id !== '') {
+                    upstreamForm.setFieldsValue({ upstream_id: data.upstream_id });
+                }
+                if (data.upstream) {
+                    upstreamForm.setFieldsValue(data.upstream);
+                }
+                form.setFieldsValue(omit(data, ['upstream_id', 'upstream']));

Review comment:
       and plugins?

##########
File path: web/src/pages/Service/components/Step1.tsx
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React, { useEffect, useState } from 'react';
+import { Form, Input } from 'antd';
+import { useIntl } from 'umi';
+
+import UpstreamForm from '@/components/Upstream';
+import { fetchUpstreamList } from '../service';
+
+const FORM_LAYOUT = {
+    labelCol: {
+        span: 3,
+    },
+    wrapperCol: {
+        span: 8,
+    },
+};
+
+const Step1: React.FC<ServiceModule.Step1PassProps> = ({
+    form,
+    upstreamForm,
+    upstreamRef,
+    disabled,
+}) => {
+    const { formatMessage } = useIntl();
+    const [list, setList] = useState<UpstreamModule.RequestBody[]>([]);
+    useEffect(() => {
+        fetchUpstreamList().then(({ data }) => setList(data));
+    }, []);
+
+    return <>
+        <Form {...FORM_LAYOUT} form={form}>
+            <Form.Item
+                name="name"
+                label={formatMessage({ id: 'component.global.name' })}
+            >
+                <Input disabled={disabled} />
+            </Form.Item>
+            <Form.Item
+                name="desc"
+                label={formatMessage({ id: 'component.global.description' })}
+            >
+                <Input.TextArea disabled={disabled} />
+            </Form.Item>
+        </Form>
+        <UpstreamForm
+            ref={upstreamRef}

Review comment:
       🤔 optional ref, may have a fallback value inside the component.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] LiteSun commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
LiteSun commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r548449078



##########
File path: web/src/pages/Route/components/Step1/RequestConfigView.tsx
##########
@@ -388,15 +388,16 @@ const RequestConfigView: React.FC<RouteModule.Step1PassProps> = ({
         name='service_id'
       >
         <Select disabled={disabled}>
-          <Select.Option value=''>{}</Select.Option>
+          {/* NOTE value = '' mean no service_id select, need to find a better way */}
+          <Select.Option value='' key={Math.random().toString(36).substring(7)} >{null}</Select.Option >

Review comment:
       if we use`None`, How to distinguish if the service name is None ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#discussion_r547090202



##########
File path: web/src/pages/Service/locales/zh-CN.ts
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+    'page.route.service.desc': '描述',

Review comment:
       ```suggestion
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (6bdfc10) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/1fa884a1fb6944c799cd7d9fb3ef943df52b820b?el=desc) (1fa884a) will **increase** coverage by `0.05%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1089      +/-   ##
   ==========================================
   + Coverage   41.00%   41.06%   +0.05%     
   ==========================================
     Files          28       28              
     Lines        1773     1773              
   ==========================================
   + Hits          727      728       +1     
   + Misses        940      939       -1     
     Partials      106      106              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `79.22% <0.00%> (+0.64%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [1fa884a...6bdfc10](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1089: feat(FE): add service module

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1089:
URL: https://github.com/apache/apisix-dashboard/pull/1089#issuecomment-748893636


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=h1) Report
   > Merging [#1089](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=desc) (31e8bf9) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/b3819c5ae939c9c0b0e55958718c9292eb895555?el=desc) (b3819c5) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/1089/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P)](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #1089   +/-   ##
   =======================================
     Coverage   41.72%   41.72%           
   =======================================
     Files          29       29           
     Lines        1819     1819           
   =======================================
     Hits          759      759           
     Misses        951      951           
     Partials      109      109           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=footer). Last update [b3819c5...31e8bf9](https://codecov.io/gh/apache/apisix-dashboard/pull/1089?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org