This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git


The following commit(s) were added to refs/heads/next by this push:
     new 038bc75  feat: added SSLModule (#209)
038bc75 is described below

commit 038bc75ed76a9dda3e8ea2ade81e1489fa727c0a
Author: 琚致远 <[email protected]>
AuthorDate: Fri May 22 14:54:04 2020 +0800

    feat: added SSLModule (#209)
    
    * feat: added SSLModule
    
    * feat: split routes
    
    * feat: update CurrentUser
    
    * feat: update SSL
---
 config/config.ts          | 52 +++--------------------------------------------
 config/routes.ts          | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 src/pages/ssl/List.tsx    |  9 ++++----
 src/pages/ssl/service.ts  |  6 +++---
 src/pages/ssl/typing.d.ts | 12 ++++++-----
 src/services/user.ts      |  3 +--
 6 files changed, 70 insertions(+), 63 deletions(-)

diff --git a/config/config.ts b/config/config.ts
index 8247273..5380df3 100644
--- a/config/config.ts
+++ b/config/config.ts
@@ -1,6 +1,8 @@
 import { defineConfig } from 'umi';
+
 import defaultSettings from './defaultSettings';
 import proxy from './proxy';
+import routes from './routes';
 
 const { REACT_APP_ENV } = process.env;
 
@@ -21,6 +23,7 @@ export default defineConfig({
   targets: {
     ie: 11,
   },
+  routes,
   layout: {
     name: 'APISIX Dashboard',
     locale: true,
@@ -28,55 +31,6 @@ export default defineConfig({
   },
   base: '/dashboard/',
   publicPath: '/',
-  routes: [
-    {
-      path: '/user',
-      layout: false,
-      routes: [
-        {
-          name: 'login',
-          path: '/user/login',
-          component: './user/login',
-        },
-      ],
-    },
-    {
-      path: '/',
-      redirect: '/settings',
-    },
-    {
-      name: 'settings',
-      path: '/settings',
-      icon: 'setting',
-      component: './Settings',
-    },
-    {
-      name: 'ssl',
-      path: '/ssl',
-      icon: 'BarsOutlined',
-      routes: [
-        {
-          path: '/ssl',
-          redirect: '/ssl/list',
-        },
-        {
-          path: '/ssl/list',
-          name: 'list',
-          component: './ssl/List',
-          hideInMenu: true,
-        },
-        {
-          name: 'create',
-          path: '/ssl/create',
-          component: './ssl/Create',
-          hideInMenu: true,
-        },
-      ],
-    },
-    {
-      component: './404',
-    },
-  ],
   define: {
     REACT_APP_ENV: REACT_APP_ENV || false,
     ADMIN_API_SCHEMA: 'http',
diff --git a/config/routes.ts b/config/routes.ts
new file mode 100644
index 0000000..d8a6406
--- /dev/null
+++ b/config/routes.ts
@@ -0,0 +1,51 @@
+const routes = [
+  {
+    path: '/user',
+    layout: false,
+    routes: [
+      {
+        name: 'login',
+        path: '/user/login',
+        component: './user/login',
+      },
+    ],
+  },
+  {
+    path: '/',
+    redirect: '/settings',
+  },
+  {
+    name: 'settings',
+    path: '/settings',
+    icon: 'setting',
+    component: './Settings',
+  },
+  {
+    name: 'ssl',
+    path: '/ssl',
+    icon: 'BarsOutlined',
+    routes: [
+      {
+        path: '/ssl',
+        redirect: '/ssl/list',
+      },
+      {
+        path: '/ssl/list',
+        name: 'list',
+        component: './ssl/List',
+        hideInMenu: true,
+      },
+      {
+        name: 'create',
+        path: '/ssl/create',
+        component: './ssl/Create',
+        hideInMenu: true,
+      },
+    ],
+  },
+  {
+    component: './404',
+  },
+];
+
+export default routes;
diff --git a/src/pages/ssl/List.tsx b/src/pages/ssl/List.tsx
index 5815860..5a21d64 100644
--- a/src/pages/ssl/List.tsx
+++ b/src/pages/ssl/List.tsx
@@ -4,7 +4,8 @@ import ProTable, { ProColumns, ActionType } from 
'@ant-design/pro-table';
 import { Button, Modal, notification, Switch } from 'antd';
 import { history, useIntl } from 'umi';
 import { PlusOutlined } from '@ant-design/icons';
-import { fetchList as fetchSSLList, remove as removeSSL } from 
'@/pages/ssl/service';
+
+import { fetchList as fetchSSLList, remove as removeSSL } from './service';
 import { ListItem } from '@/transforms/global';
 
 interface SearchParamsProps {
@@ -15,7 +16,7 @@ interface SearchParamsProps {
 
 const List: React.FC = () => {
   const tableRef = useRef<ActionType>();
-  const [list, setList] = useState<ListItem<SSL>[]>([]);
+  const [list, setList] = useState<ListItem<SSLModule.SSL>[]>([]);
   const { formatMessage } = useIntl();
   const onRemove = (key: string) => {
     Modal.confirm({
@@ -40,7 +41,7 @@ const List: React.FC = () => {
     });
   };
 
-  const columns: ProColumns<ListItem<SSL>>[] = [
+  const columns: ProColumns<ListItem<SSLModule.SSL>>[] = [
     {
       title: 'ID',
       dataIndex: 'displayKey',
@@ -97,7 +98,7 @@ const List: React.FC = () => {
 
   return (
     <PageHeaderWrapper>
-      <ProTable<ListItem<SSL>>
+      <ProTable<ListItem<SSLModule.SSL>>
         request={(params) => fetchPageSSLList(params)}
         search
         columns={columns}
diff --git a/src/pages/ssl/service.ts b/src/pages/ssl/service.ts
index d4c4ca7..922d2b2 100644
--- a/src/pages/ssl/service.ts
+++ b/src/pages/ssl/service.ts
@@ -2,17 +2,17 @@ import { request } from 'umi';
 import { transformFetchListData, transformFetchItemData } from 
'@/transforms/global';
 
 export const fetchList = () =>
-  request('/api/ssl').then((data) => transformFetchListData<SSL>(data));
+  request('/api/ssl').then((data) => 
transformFetchListData<SSLModule.SSL>(data));
 
 export const fetchItem = (key: string) =>
-  request(`/api/ssl/${key}`).then((data) => transformFetchItemData<SSL>(data));
+  request(`/api/ssl/${key}`).then((data) => 
transformFetchItemData<SSLModule.SSL>(data));
 
 export const remove = (key: string) =>
   request(`/api/ssl/${key}`, {
     method: 'DELETE',
   });
 
-export const create = (data: SSL) =>
+export const create = (data: SSLModule.SSL) =>
   request('/api/ssl', {
     method: 'POST',
     data,
diff --git a/src/pages/ssl/typing.d.ts b/src/pages/ssl/typing.d.ts
index 0a66d55..4799329 100644
--- a/src/pages/ssl/typing.d.ts
+++ b/src/pages/ssl/typing.d.ts
@@ -1,5 +1,7 @@
-type SSL = {
-  sni: string[];
-  cert: string;
-  key: string;
-};
+declare namespace SSLModule {
+  export type SSL = {
+    sni: string[];
+    cert: string;
+    key: string;
+  };
+}
diff --git a/src/services/user.ts b/src/services/user.ts
index 3189a54..2734525 100644
--- a/src/services/user.ts
+++ b/src/services/user.ts
@@ -4,8 +4,7 @@ export async function query() {
   return request<API.CurrentUser[]>('/api/users');
 }
 
-export async function queryCurrent() {
-  // return request<API.CurrentUser>('/api/currentUser');
+export async function queryCurrent(): Promise<API.CurrentUser> {
   return Promise.resolve({
     name: 'APISIX User',
     avatar:

Reply via email to