36 | , mountNode);
37 | ````
38 |
--------------------------------------------------------------------------------
/src/components/Exception/index.en-US.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Exception
3 | cols: 1
4 | order: 5
5 | ---
6 |
7 | Exceptions page is used to provide feedback on specific abnormal state. Usually, it contains an explanation of the error status, and provides users with suggestions or operations, to prevent users from feeling lost and confused.
8 |
9 | ## API
10 |
11 | Property | Description | Type | Default
12 | ---------|-------------|------|--------
13 | type | type of exception, the corresponding default `title`, `desc`, `img` will be given if set, which can be overridden by explicit setting of `title`, `desc`, `img` | Enum {'403', '404', '500'} | -
14 | title | title | ReactNode | -
15 | desc | supplementary description | ReactNode | -
16 | img | the url of background image | string | -
17 | actions | suggested operations, a default 'Home' link will show if not set | ReactNode | -
18 | linkElement | to specify the element of link | string\|ReactElement | 'a'
--------------------------------------------------------------------------------
/src/layouts/BlankLayout.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 |
20 | export default (props) => ;
21 |
--------------------------------------------------------------------------------
/src/routes/System/Alert/globalData.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | export const Type = {
19 | 1: "SHENYU.SYSTEM.ALERT.EMAIL",
20 | 5: "SHENYU.SYSTEM.ALERT.DING_TALK",
21 | };
22 |
--------------------------------------------------------------------------------
/src/services/error.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import request from "../utils/request";
19 |
20 | export async function query(code) {
21 | return request(`/api/${code}`);
22 | }
23 |
--------------------------------------------------------------------------------
/src/routes/Exception/style.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | .trigger {
19 | background: 'red';
20 | :global(.ant-btn) {
21 | margin-right: 8px;
22 | margin-bottom: 12px;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/utils/emit.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const EventEmitter = require("events").EventEmitter;
19 |
20 | const emit = new EventEmitter();
21 | emit.setMaxListeners(50);
22 | export { emit };
23 |
--------------------------------------------------------------------------------
/src/routes/System/Resource/index.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | .headerSearch {
19 | display: flex;
20 | justify-content: space-between;
21 | margin-left: 1px;
22 |
23 | .search {
24 | margin-right: 10px;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/utils/locales.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import enUs from "../locales/en-US.json";
19 | import zhCn from "../locales/zh-CN.json";
20 |
21 | const locales = {
22 | "en-US": enUs,
23 | "zh-CN": zhCn,
24 | };
25 |
26 | export default locales;
27 |
--------------------------------------------------------------------------------
/src/components/Result/demo/error.md:
--------------------------------------------------------------------------------
1 | ---
2 | order: 2
3 | title: Failed
4 | ---
5 |
6 | 提交失败。
7 |
8 | ````jsx
9 | import Result from 'ant-design-pro/lib/Result';
10 | import { Button, Icon } from 'antd';
11 |
12 | const extra = (
13 |
26 | );
27 |
28 | const actions = ;
29 |
30 | ReactDOM.render(
31 |
38 | , mountNode);
39 | ````
40 |
--------------------------------------------------------------------------------
/src/services/user.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import request from "../utils/request";
19 |
20 | export async function query() {
21 | return request("/api/users");
22 | }
23 |
24 | export async function queryCurrent() {
25 | return request("/api/currentUser");
26 | }
27 |
--------------------------------------------------------------------------------
/src/layouts/PageHeaderLayout.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import '~antd/lib/style/themes/default.less';
19 |
20 | .content {
21 | margin: 24px 24px 0;
22 | }
23 |
24 | @media screen and (max-width: @screen-sm) {
25 | .content {
26 | margin: 24px 0 0;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: dashboard Deploy
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - master
8 |
9 | jobs:
10 | build_and_deploy_job:
11 | runs-on: ubuntu-latest
12 | name: Build and Deploy Job
13 | steps:
14 | -
15 | name: Checkout Code
16 | uses: actions/checkout@v2
17 | with:
18 | submodules: recursive
19 | -
20 | name: Setup Node
21 | uses: actions/setup-node@v2.4.0
22 | with:
23 | node-version: "20"
24 | -
25 | name: Setup Dependencies
26 | run: yarn install
27 | -
28 | name: Build Site
29 | run: npm run build
30 | -
31 | name: Deploy
32 | uses: peaceiris/actions-gh-pages@v3
33 | if: github.event_name == 'push' && github.ref == 'refs/heads/master'
34 | with:
35 | github_token: ${{ secrets.GITHUB_TOKEN }}
36 | user_name: 'github-actions[bot]'
37 | user_email: 'github-actions[bot]@users.noreply.github.com'
38 | publish_branch: dist
39 | publish_dir: ./dist
40 |
41 |
--------------------------------------------------------------------------------
/src/routes/Document/components/ApiContext.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /* eslint-disable no-unused-vars */
19 |
20 | import { createContext } from "react";
21 |
22 | export default createContext({
23 | apiDetail: {},
24 | apiData: {},
25 | apiMock: {},
26 | tagDetail: {},
27 | });
28 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | root = true
19 |
20 | [*]
21 | indent_style = space
22 | indent_size = 2
23 | end_of_line = lf
24 | charset = utf-8
25 | trim_trailing_whitespace = true
26 | insert_final_newline = true
27 |
28 | [*.md]
29 | trim_trailing_whitespace = false
30 |
31 | [Makefile]
32 | indent_style = tab
33 |
--------------------------------------------------------------------------------
/src/components/tsconfig.json:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | {
18 | "include": [
19 | "./src/*"
20 | ],
21 | "compilerOptions": {
22 | "strict": true,
23 | "esModuleInterop": true,
24 | "lib": [
25 | "dom",
26 | "es2015"
27 | ],
28 | "jsx": "react-jsx"
29 | }
30 | }
--------------------------------------------------------------------------------
/src/routes/Exception/403.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Link } from "dva/router";
20 | import Exception from "components/Exception";
21 |
22 | export default () => (
23 |
28 | );
29 |
--------------------------------------------------------------------------------
/src/routes/Exception/404.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Link } from "dva/router";
20 | import Exception from "components/Exception";
21 |
22 | export default () => (
23 |
28 | );
29 |
--------------------------------------------------------------------------------
/src/routes/Exception/500.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Link } from "dva/router";
20 | import Exception from "components/Exception";
21 |
22 | export default () => (
23 |
28 | );
29 |
--------------------------------------------------------------------------------
/src/theme.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
19 | module.exports = {
20 | "primary-color": "#1890ff",
21 | "card-actions-background": "#f5f8fa",
22 | "table-row-hover-bg": "lighten(@primary-color, 25%)",
23 | "form-item-margin-bottom": "12px",
24 | };
25 |
--------------------------------------------------------------------------------
/src/components/_utils/pathTools.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | // /userinfo/2144/id => ['/userinfo','/useinfo/2144,'/userindo/2144/id']
19 | export function urlToList(url) {
20 | const urllist = url.split("/").filter((i) => i);
21 | return urllist.map((urlItem, index) => {
22 | return `/${urllist.slice(0, index + 1).join("/")}`;
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/src/components/CountDown/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | export interface ICountDownProps {
20 | format?: (time: number) => void;
21 | target: Date | number;
22 | onEnd?: () => void;
23 | style?: React.CSSProperties;
24 | }
25 |
26 | export default class CountDown extends React.Component {}
27 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | {
18 | "include": [
19 | "./src/*"
20 | ],
21 | "compilerOptions": {
22 | "strict": true,
23 | "esModuleInterop": true,
24 | "experimentalDecorators": true,
25 | "lib": [
26 | "dom",
27 | "es2015"
28 | ],
29 | "jsx": "react"
30 | }
31 | }
--------------------------------------------------------------------------------
/src/models/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | // Use require.context to require reducers automatically
19 | // Ref: https://webpack.js.org/guides/dependency-management/#require-context
20 | const context = require.context("./", false, /\.js$/);
21 | export default context
22 | .keys()
23 | .filter((item) => item !== "./index.js")
24 | .map((key) => context(key));
25 |
--------------------------------------------------------------------------------
/src/routes/Result/Success.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { shallow } from "enzyme";
20 | import Success from "./Success";
21 |
22 | it("renders with Result", () => {
23 | const wrapper = shallow();
24 | expect(wrapper.find("Result").length).toBe(1);
25 | expect(wrapper.find("Result").prop("type")).toBe("success");
26 | });
27 |
--------------------------------------------------------------------------------
/src/components/Login/index.zh-CN.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Login
3 | subtitle: 登录
4 | cols: 1
5 | order: 15
6 | ---
7 |
8 | 支持多种登录方式切换,内置了几种常见的登录控件,可以灵活组合,也支持和自定义控件配合使用。
9 |
10 | ## API
11 |
12 | ### Login
13 |
14 | 参数 | 说明 | 类型 | 默认值
15 | ----|------|-----|------
16 | defaultActiveKey | 默认激活 tab 面板的 key | String | -
17 | onTabChange | 切换页签时的回调 | (key) => void | -
18 | onSubmit | 点击提交时的回调 | (err, values) => void | -
19 |
20 | ### Login.Tab
21 |
22 | 参数 | 说明 | 类型 | 默认值
23 | ----|------|-----|------
24 | key | 对应选项卡的 key | String | -
25 | tab | 选项卡头显示文字 | ReactNode | -
26 |
27 | ### Login.UserName
28 |
29 | 参数 | 说明 | 类型 | 默认值
30 | ----|------|-----|------
31 | name | 控件标记,提交数据中同样以此为 key | String | -
32 | rules | 校验规则,同 Form getFieldDecorator(id, options) 中 [option.rules 的规则](getFieldDecorator(id, options)) | object[] | -
33 |
34 | 除上述属性以外,Login.UserName 还支持 antd.Input 的所有属性,并且自带默认的基础配置,包括 `placeholder` `size` `prefix` 等,这些基础配置均可被覆盖。
35 |
36 | ### Login.Password、Login.Mobile 同 Login.UserName
37 |
38 | ### Login.Captcha
39 |
40 | 参数 | 说明 | 类型 | 默认值
41 | ----|------|-----|------
42 | onGetCaptcha | 点击获取校验码的回调 | () => void | -
43 |
44 | 除上述属性以外,Login.Captcha 支持的属性与 Login.UserName 相同。
45 |
46 | ### Login.Submit
47 |
48 | 支持 antd.Button 的所有属性。
49 |
--------------------------------------------------------------------------------
/src/components/Result/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | export interface IResultProps {
20 | type: 'success' | 'error';
21 | title: React.ReactNode;
22 | description?: React.ReactNode;
23 | extra?: React.ReactNode;
24 | actions?: React.ReactNode;
25 | style?: React.CSSProperties;
26 | }
27 |
28 | export default class Result extends React.Component {}
29 |
--------------------------------------------------------------------------------
/src/rollbar.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import Rollbar from "rollbar";
19 |
20 | // Track error by rollbar.com
21 | if (location.host === "preview.pro.ant.design") {
22 | Rollbar.init({
23 | accessToken: "033ca6d7c0eb4cc1831cf470c2649971",
24 | captureUncaught: true,
25 | captureUnhandledRejections: true,
26 | hostWhiteList: ["ant.design"],
27 | payload: {
28 | environment: "production",
29 | },
30 | });
31 | }
32 |
--------------------------------------------------------------------------------
/src/components/Exception/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | export interface IExceptionProps {
20 | type?: '403' | '404' | '500';
21 | title?: React.ReactNode;
22 | desc?: React.ReactNode;
23 | img?: string;
24 | actions?: React.ReactNode;
25 | linkElement?: React.ReactNode;
26 | style?: React.CSSProperties;
27 | }
28 |
29 | export default class Exception extends React.Component {}
30 |
--------------------------------------------------------------------------------
/src/components/GlobalFooter/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | export interface IGlobalFooterProps {
20 | links?: Array<{
21 | key?: string;
22 | title: React.ReactNode;
23 | href: string;
24 | blankTarget?: boolean;
25 | }>;
26 | copyright?: React.ReactNode;
27 | style?: React.CSSProperties;
28 | }
29 |
30 | export default class GlobalFooter extends React.Component {}
31 |
--------------------------------------------------------------------------------
/src/routes/System/Scale/globalData.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | export const ConfigType = {
19 | 0: "SHENYU.SYSTEM.SCALE.CONFIG_TYPE.SHENYU",
20 | 1: "SHENYU.SYSTEM.SCALE.CONFIG_TYPE.K8S",
21 | 2: "SHENYU.SYSTEM.SCALE.CONFIG_TYPE.OTHERS",
22 | };
23 |
24 | export const PolicyType = {
25 | 1: "SHENYU.SYSTEM.SCALE.POLICY_TYPE.MANUAL",
26 | 2: "SHENYU.SYSTEM.SCALE.POLICY_TYPE.PERIOD",
27 | 3: "SHENYU.SYSTEM.SCALE.POLICY_TYPE.DYNAMIC",
28 | };
29 |
--------------------------------------------------------------------------------
/.babelrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const path = require('path');
19 |
20 | module.exports = {
21 | plugins: [
22 | [
23 | 'module-resolver',
24 | {
25 | alias: {
26 | components: path.join(__dirname, './src/components'),
27 | },
28 | },
29 | ],
30 | [
31 | 'import',
32 | {
33 | libraryName: 'antd',
34 | style: true, // or css
35 | },
36 | ],
37 | ],
38 | };
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Apache ShenYu Dashboard
2 |
3 | 
4 | [](https://gitpod.io/#https://github.com/apache/shenyu-dashboard)
5 |
6 |
7 | ## Overview
8 | Apache ShenYu Dashboard is frontend of a management background for [Apache ShenYu](https://github.com/apache/shenyu). The API interface is in the [Apache Shenyu Admin](https://github.com/apache/shenyu/tree/master/shenyu-admin) module.
9 |
10 | ## Prerequisite
11 | - node v8.0+
12 |
13 | ## How to Build
14 |
15 | ### Configuration
16 |
17 | Modify the api url for different environment, eg: `http://192.168.1.100:8000`
18 |
19 |
20 | ### Develop Environment
21 |
22 | ```shell
23 | # install dependencies in this project root path.
24 | npm install
25 | # start
26 | npm start
27 | ```
28 |
29 | ### Production Environment
30 |
31 | ```shell
32 | # install dependencies in this project root path.
33 | npm install
34 | # build for production
35 | npm run build
36 |
37 | # copy to apache-shenyu-admin
38 | cp -rf dist/* shenyu-admin/src/main/resources/static/
39 | ```
40 |
41 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Shenyu DevContainer",
3 | "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4 | "features": {
5 | "ghcr.io/devcontainers/features/java:1": {
6 | "version": "17",
7 | "installMaven": "true",
8 | "installGradle": "false"
9 | },
10 | "ghcr.io/devcontainers/features/node:1": {
11 | "version": "20"
12 | },
13 | "ghcr.io/devcontainers/features/git-lfs:1.1.0": {}
14 | },
15 | "customizations": {
16 | "vscode": {
17 | "settings": {},
18 | // same extensions as Gitpod, should match /.gitpod.yml
19 | "extensions": [
20 | "vscjava.vscode-java-pack",
21 | "editorconfig.editorconfig",
22 | "dbaeumer.vscode-eslint",
23 | "stylelint.vscode-stylelint",
24 | "DavidAnson.vscode-markdownlint",
25 | "ms-azuretools.vscode-docker",
26 | "cweijan.vscode-database-client2",
27 | "GitHub.vscode-pull-request-github"
28 | ]
29 | }
30 | },
31 | "portsAttributes": {
32 | "8000": {
33 | "label": "Shenyu Admin",
34 | "onAutoForward": "notify"
35 | }
36 | },
37 | "postCreateCommand": "java -version"
38 | }
39 |
--------------------------------------------------------------------------------
/src/components/Authorized/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import Authorized from "./Authorized";
19 | import AuthorizedRoute from "./AuthorizedRoute";
20 | import Secured from "./Secured";
21 | import check from "./CheckPermissions.js";
22 | import renderAuthorize from "./renderAuthorize";
23 |
24 | Authorized.Secured = Secured;
25 | Authorized.AuthorizedRoute = AuthorizedRoute;
26 | Authorized.check = check;
27 |
28 | export default renderAuthorize(Authorized);
29 |
--------------------------------------------------------------------------------
/src/components/Authorized/Authorized.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import CheckPermissions from "./CheckPermissions";
20 |
21 | class Authorized extends React.Component {
22 | render() {
23 | const { children, authority, noMatch = null } = this.props;
24 | const childrenRender = typeof children === "undefined" ? null : children;
25 | return CheckPermissions(authority, childrenRender, noMatch);
26 | }
27 | }
28 |
29 | export default Authorized;
30 |
--------------------------------------------------------------------------------
/src/polyfill.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import "@babel/polyfill";
19 | import "url-polyfill";
20 | import setprototypeof from "setprototypeof";
21 |
22 | // React depends on set/map/requestAnimationFrame
23 | // https://reactjs.org/docs/javascript-environment-requirements.html
24 | // import 'core-js/es6/set';
25 | // import 'core-js/es6/map';
26 | // import 'raf/polyfill'; 只兼容到IE10不需要,况且fetch的polyfill whatwg-fetch也只兼容到IE10
27 |
28 | // https://github.com/umijs/umi/issues/413
29 | Object.setPrototypeOf = setprototypeof;
30 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: .gitpod.Dockerfile
3 |
4 | additionalRepositories:
5 | - url: https://github.com/apache/shenyu.git
6 | checkoutLocation: backend
7 |
8 | tasks:
9 |
10 | - name: Run backend
11 | before: cd ../backend/shenyu-admin
12 | command: |
13 | gp sync-await setup-backend
14 | mvn spring-boot:run
15 |
16 | - name: Run frontend
17 | command: |
18 | gp sync-await setup-frontend && gp ports await 9095
19 | npm start
20 | openMode: split-right
21 |
22 | - name: Setup backend
23 | before: cd ../backend
24 | init: |
25 | mvn clean install -DskipTests
26 | command: |
27 | gp sync-done setup-backend
28 | exit 0
29 |
30 | - name: Setup frontend
31 | init: |
32 | npm install
33 | command: |
34 | gp sync-done setup-frontend
35 | exit 0
36 | openMode: split-right
37 |
38 | vscode:
39 | extensions:
40 | - vscjava.vscode-java-pack
41 | - editorconfig.editorconfig
42 | - dbaeumer.vscode-eslint
43 | - stylelint.vscode-stylelint
44 | - DavidAnson.vscode-markdownlint
45 | - ms-azuretools.vscode-docker
46 | - cweijan.vscode-database-client2
47 | - GitHub.vscode-pull-request-github
48 |
49 | ports:
50 | - port: 9095
51 | onOpen: ignore
52 |
--------------------------------------------------------------------------------
/tests/fix_puppeteer.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Licensed to the Apache Software Foundation (ASF) under one or more
5 | # contributor license agreements. See the NOTICE file distributed with
6 | # this work for additional information regarding copyright ownership.
7 | # The ASF licenses this file to You under the Apache License, Version 2.0
8 | # (the "License"); you may not use this file except in compliance with
9 | # the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | #
19 |
20 | sudo apt-get update
21 | sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
22 | libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
23 | libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
24 | libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
25 | ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
26 |
--------------------------------------------------------------------------------
/src/layouts/PageHeaderLayout.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Link } from "dva/router";
20 | import PageHeader from "../components/PageHeader";
21 | import styles from "./PageHeaderLayout.less";
22 |
23 | export default ({ children, wrapperClassName, top, ...restProps }) => (
24 |
25 | {top}
26 |
27 | {children ?
{children}
: null}
28 |
29 | );
30 |
--------------------------------------------------------------------------------
/src/components/Exception/typeConfig.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const config = {
19 | 403: {
20 | img: "https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg",
21 | title: "403",
22 | desc: "抱歉,你无权访问该页面",
23 | },
24 | 404: {
25 | img: "https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg",
26 | title: "404",
27 | desc: "抱歉,你访问的页面不存在",
28 | },
29 | 500: {
30 | img: "https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg",
31 | title: "500",
32 | desc: "抱歉,服务器出错了",
33 | },
34 | };
35 |
36 | export default config;
37 |
--------------------------------------------------------------------------------
/src/routes/Plugin/PluginRuleHandle/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import RequestRuleHandle from "./RequestRuleHandle";
19 | import HystrixRuleHandle from "./HystrixRuleHandle";
20 | import ParamPluginRuleHandle from "./ParamPluginRuleHandle";
21 | import ResponseRuleHandle from "./ResponseRuleHandle";
22 | import GeneralContextRuleHandle from "./GeneralContextRuleHandle";
23 |
24 | export default {
25 | request: RequestRuleHandle,
26 | generalContext: GeneralContextRuleHandle,
27 | modifyResponse: ResponseRuleHandle,
28 | hystrix: HystrixRuleHandle,
29 | paramMapping: ParamPluginRuleHandle,
30 | };
31 |
--------------------------------------------------------------------------------
/src/e2e/home.e2e.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import puppeteer from "puppeteer";
19 |
20 | describe("Homepage", () => {
21 | it("it should have logo text", async () => {
22 | const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
23 | const page = await browser.newPage();
24 | await page.goto("http://localhost:8000", { waitUntil: "networkidle2" });
25 | await page.waitForSelector("h1");
26 | const text = await page.evaluate(() => document.body.innerHTML);
27 | expect(text).toContain("
Ant Design Pro
");
28 | await page.close();
29 | browser.close();
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/src/components/_utils/pathTools.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import { urlToList } from "./pathTools";
19 |
20 | describe("test urlToList", () => {
21 | it("A path", () => {
22 | expect(urlToList("/userinfo")).toEqual(["/userinfo"]);
23 | });
24 | it("Secondary path", () => {
25 | expect(urlToList("/userinfo/2144")).toEqual([
26 | "/userinfo",
27 | "/userinfo/2144",
28 | ]);
29 | });
30 | it("Three paths", () => {
31 | expect(urlToList("/userinfo/2144/addr")).toEqual([
32 | "/userinfo",
33 | "/userinfo/2144",
34 | "/userinfo/2144/addr",
35 | ]);
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/src/models/user.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import { query as queryUsers } from "../services/user";
19 |
20 | export default {
21 | namespace: "user",
22 |
23 | state: {
24 | list: [],
25 | currentUser: {},
26 | },
27 |
28 | effects: {
29 | *fetch(_, { call, put }) {
30 | const response = yield call(queryUsers);
31 | yield put({
32 | type: "save",
33 | payload: response,
34 | });
35 | },
36 | },
37 |
38 | reducers: {
39 | save(state, action) {
40 | return {
41 | ...state,
42 | list: action.payload,
43 | };
44 | },
45 | },
46 | };
47 |
--------------------------------------------------------------------------------
/src/utils/IntlUtils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import intl from "react-intl-universal";
19 | import locales from "./locales";
20 |
21 | export function initIntl(lang) {
22 | intl.init({
23 | currentLocale: lang,
24 | locales,
25 | // eslint-disable-next-line no-unused-vars
26 | warningHandler: (message) => {},
27 | });
28 | }
29 |
30 | export function getIntlContent(key, defaultValue) {
31 | return intl.get(key).defaultMessage(defaultValue);
32 | }
33 |
34 | export function getCurrentLocale(locale) {
35 | if (locale === "en-US") {
36 | return "English";
37 | } else {
38 | return "中文";
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/index.ejs:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Apache ShenYu Gateway
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/components/Login/LoginSubmit.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import classNames from "classnames";
20 | import { Button, Form } from "antd";
21 | import styles from "./index.less";
22 |
23 | const FormItem = Form.Item;
24 |
25 | const LoginSubmit = ({ className, ...rest }) => {
26 | const clsString = classNames(styles.submit, className);
27 | return (
28 |
29 |
36 |
37 | );
38 | };
39 |
40 | export default LoginSubmit;
41 |
--------------------------------------------------------------------------------
/.asf.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | github:
18 | description: Apache ShenYu Dashboard
19 | homepage: https://shenyu.apache.org/
20 | labels:
21 | - shenyu
22 | - shenyu-dashboard
23 | enabled_merge_buttons:
24 | squash: true
25 | merge: false
26 | rebase: false
27 | protected_branches:
28 | master:
29 | required_status_checks:
30 | strict: true
31 | required_pull_request_reviews:
32 | dismiss_stale_reviews: true
33 | required_approving_review_count: 1
34 | notifications:
35 | commits: notifications@shenyu.apache.org
36 | issues: notifications@shenyu.apache.org
37 | pullrequests: notifications@shenyu.apache.org
38 |
--------------------------------------------------------------------------------
/src/routes/Document/components/globalData.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | export const Method = {
19 | 0: "GET",
20 | 1: "HEAD",
21 | 2: "POST",
22 | 3: "PUT",
23 | 4: "PATCH",
24 | 5: "DELETE",
25 | 6: "OPTIONS",
26 | 7: "TRACE",
27 | };
28 |
29 | export const RPCTYPE = [
30 | "http",
31 | "dubbo",
32 | "sofa",
33 | "tars",
34 | "websocket",
35 | "springCloud",
36 | "motan",
37 | "grpc",
38 | ];
39 |
40 | export const API_SOURCE_TYPE = [
41 | "swagger",
42 | "annotation generation",
43 | "create manually",
44 | "import swagger",
45 | "import yapi",
46 | ];
47 |
48 | export const STATE_TYPE = ["unpublished", "published", "offline"];
49 |
--------------------------------------------------------------------------------
/src/components/GlobalFooter/index.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import '~antd/lib/style/themes/default.less';
19 |
20 | .globalFooter {
21 | padding: 0px 240px;
22 | margin: 0px 0 15px 0;
23 | text-align: center;
24 |
25 | .links {
26 | margin-bottom: 8px;
27 |
28 | a {
29 | color: @text-color-secondary;
30 | transition: all 0.3s;
31 |
32 | &:not(:last-child) {
33 | margin-right: 40px;
34 | }
35 |
36 | &:hover {
37 | color: @text-color;
38 | }
39 | }
40 | }
41 |
42 | .copyright {
43 | color: #ffffff;
44 | font-size: @font-size-base;
45 | }
46 |
47 | .imgStyle {
48 | height: 50px;
49 | margin: 0px 10px;
50 | }
51 | }
--------------------------------------------------------------------------------
/src/models/error.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import { routerRedux } from "dva/router";
19 | import { query } from "../services/error";
20 |
21 | export default {
22 | namespace: "error",
23 |
24 | state: {
25 | error: "",
26 | isloading: false,
27 | },
28 |
29 | effects: {
30 | *query({ payload }, { call, put }) {
31 | yield call(query, payload.code);
32 | // redirect on client when network broken
33 | yield put(routerRedux.push(`/exception/${payload.code}`));
34 | yield put({
35 | type: "trigger",
36 | payload: payload.code,
37 | });
38 | },
39 | },
40 |
41 | reducers: {
42 | trigger(state, action) {
43 | return {
44 | error: action.payload,
45 | };
46 | },
47 | },
48 | };
49 |
--------------------------------------------------------------------------------
/src/components/PageHeader/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title:
3 | en-US: PageHeader
4 | zh-CN: PageHeader
5 | subtitle: 页头
6 | cols: 1
7 | order: 11
8 | ---
9 |
10 | 页头用来声明页面的主题,包含了用户所关注的最重要的信息,使用户可以快速理解当前页面是什么以及它的功能。
11 |
12 | ## API
13 |
14 | | 参数 | 说明 | 类型 | 默认值 |
15 | |----------|------------------------------------------|-------------|-------|
16 | | title | title 区域 | ReactNode | - |
17 | | logo | logo区域 | ReactNode | - |
18 | | action | 操作区,位于 title 行的行尾 | ReactNode | - |
19 | | content | 内容区 | ReactNode | - |
20 | | extraContent | 额外内容区,位于content的右侧 | ReactNode | - |
21 | | breadcrumbList | 面包屑数据,配置了此属性时 `routes` `params` `location` `breadcrumbNameMap` 无效 | array<{title: ReactNode, href?: string}> | - |
22 | | routes | 面包屑相关属性,router 的路由栈信息 | object[] | - |
23 | | params | 面包屑相关属性,路由的参数 | object | - |
24 | | location | 面包屑相关属性,当前的路由信息 | object | - |
25 | | breadcrumbNameMap | 面包屑相关属性,路由的地址-名称映射表 | object | - |
26 | | tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - |
27 | | tabActiveKey | 当前高亮的 tab 项 | string | - |
28 | | tabDefaultActiveKey | 默认高亮的 tab 项 | string | 第一项 |
29 | | onTabChange | 切换面板的回调 | (key) => void | - |
30 | | linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - |
31 |
32 | > 面包屑的配置方式有三种,一是直接配置 `breadcrumbList`,二是结合 `react-router@2` `react-router@3`,配置 `routes` 及 `params` 实现,类似 [面包屑 Demo](https://ant.design/components/breadcrumb-cn/#components-breadcrumb-demo-router),三是结合 `react-router@4`,配置 `location` `breadcrumbNameMap`,优先级依次递减,脚手架中使用最后一种。 对于后两种用法,你也可以将 `routes` `params` 及 `location` `breadcrumbNameMap` 放到 context 中,组件会自动获取。
33 |
--------------------------------------------------------------------------------
/src/components/PageHeader/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | export interface IPageHeaderProps {
20 | title?: React.ReactNode | string;
21 | logo?: React.ReactNode | string;
22 | action?: React.ReactNode | string;
23 | content?: React.ReactNode;
24 | extraContent?: React.ReactNode;
25 | routes?: any[];
26 | params?: any;
27 | breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>;
28 | tabList?: Array<{ key: string; tab: React.ReactNode }>;
29 | tabActiveKey?: string;
30 | tabDefaultActiveKey?: string;
31 | onTabChange?: (key: string) => void;
32 | tabBarExtraContent?: React.ReactNode;
33 | linkElement?: React.ReactNode;
34 | style?: React.CSSProperties;
35 | }
36 |
37 | export default class PageHeader extends React.Component {}
38 |
--------------------------------------------------------------------------------
/src/utils/resizable.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import { Resizable } from "react-resizable";
19 | import React from "react";
20 |
21 | const ResizableTitle = (props) => {
22 | const { onResize, width, ...restProps } = props;
23 |
24 | if (!width) {
25 | return
44 |
45 | );
46 | };
47 |
48 | export const resizableComponents = {
49 | header: {
50 | cell: ResizableTitle,
51 | },
52 | };
53 |
--------------------------------------------------------------------------------
/src/components/SiderMenu/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import "rc-drawer/assets/index.css";
19 | import React from "react";
20 | import DrawerMenu from "rc-drawer";
21 | import SiderMenu from "./SiderMenu";
22 |
23 | const SiderMenuWrapper = (props) => {
24 | const { isMobile, collapsed } = props;
25 | return isMobile ? (
26 | }
30 | onHandleClick={() => {
31 | props.onCollapse(!collapsed);
32 | }}
33 | open={!collapsed}
34 | onMaskClick={() => {
35 | props.onCollapse(true);
36 | }}
37 | >
38 |
39 |
40 | ) : (
41 |
42 | );
43 | };
44 |
45 | export default SiderMenuWrapper;
46 |
--------------------------------------------------------------------------------
/src/components/Authorized/renderAuthorize.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /* eslint-disable import/no-mutable-exports */
19 | let CURRENT = "NULL";
20 | /**
21 | * use authority or getAuthority
22 | * @param {string|()=>String} currentAuthority
23 | */
24 | const renderAuthorize = (Authorized) => {
25 | return (currentAuthority) => {
26 | if (currentAuthority) {
27 | if (currentAuthority.constructor.name === "Function") {
28 | CURRENT = currentAuthority();
29 | }
30 | if (
31 | currentAuthority.constructor.name === "String" ||
32 | currentAuthority.constructor.name === "Array"
33 | ) {
34 | CURRENT = currentAuthority;
35 | }
36 | } else {
37 | CURRENT = "NULL";
38 | }
39 | return Authorized;
40 | };
41 | };
42 |
43 | export { CURRENT };
44 | export default (Authorized) => renderAuthorize(Authorized);
45 |
--------------------------------------------------------------------------------
/src/components/Login/index.en-US.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Login
3 | cols: 1
4 | order: 15
5 | ---
6 |
7 | Support multiple common ways of login with built-in controls. You can choose your own combinations and use with your custom controls.
8 |
9 | ## API
10 |
11 | ### Login
12 |
13 | Property | Description | Type | Default
14 | ----|------|-----|------
15 | defaultActiveKey | default key to activate the tab panel | String | -
16 | onTabChange | callback on changing tabs | (key) => void | -
17 | onSubmit | callback on submit | (err, values) => void | -
18 |
19 | ### Login.Tab
20 |
21 | Property | Description | Type | Default
22 | ----|------|-----|------
23 | key | key of the tab | String | -
24 | tab | displayed text of the tab | ReactNode | -
25 |
26 | ### Login.UserName
27 |
28 | Property | Description | Type | Default
29 | ----|------|-----|------
30 | name | name of the control, also the key of the submitted data | String | -
31 | rules | validation rules, same with [option.rules](getFieldDecorator(id, options)) in Form getFieldDecorator(id, options) | object[] | -
32 |
33 | Apart from the above properties, Login.Username also support all properties of antd.Input, together with the default values of basic settings, such as _placeholder_, _size_ and _prefix_. All of these default values can be over-written.
34 |
35 | ### Login.Password, Login.Mobile are the same as Login.UserName
36 |
37 | ### Login.Captcha
38 |
39 | Property | Description | Type | Default
40 | ----|------|-----|------
41 | onGetCaptcha | callback on getting a new Captcha | () => void | -
42 |
43 | Apart from the above properties, _Login.Captcha_ support the same properties with _Login.UserName_.
44 |
45 | ### Login.Submit
46 |
47 | Support all properties of _antd.Button_.
--------------------------------------------------------------------------------
/src/components/PageHeader/demo/structure.md:
--------------------------------------------------------------------------------
1 | ---
2 | order: 0
3 | title: Structure
4 | ---
5 |
6 | 基本结构,具备响应式布局功能,主要断点为 768px 和 576px,拖动窗口改变大小试试看。
7 |
8 | ````jsx
9 | import PageHeader from 'ant-design-pro/lib/PageHeader';
10 |
11 | const breadcrumbList = [{
12 | title: '面包屑',
13 | }];
14 |
15 | const tabList = [{
16 | key: '1',
17 | tab: '页签一',
18 | }, {
19 | key: '2',
20 | tab: '页签二',
21 | }, {
22 | key: '3',
23 | tab: '页签三',
24 | }];
25 |
26 | ReactDOM.render(
27 |
28 | Title
}
31 | logo={
logo
}
32 | action={
action
}
33 | content={
content
}
34 | extraContent={
extraContent
}
35 | breadcrumbList={breadcrumbList}
36 | tabList={tabList}
37 | tabActiveKey="1"
38 | />
39 |
40 | , mountNode);
41 | ````
42 |
43 |
69 |
--------------------------------------------------------------------------------
/src/routes/System/Resource/IconModal.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | .iconCard {
19 | height: 700px;
20 | overflow-y: scroll;
21 | .iconList {
22 | display: flex;
23 | justify-content: flex-start;
24 | flex-wrap: wrap;
25 | .iconContent {
26 | display:flex;
27 | justify-content: center;
28 | height: 70px;
29 | width: 100px;
30 | align-items: center;
31 | flex-direction: column;
32 | margin: 5px;
33 | cursor: pointer;
34 | border-radius: 4px;
35 | -webkit-transition: color .3s ease-in-out,background-color .3s ease-in-out;
36 | transition: color .3s ease-in-out,background-color .3s ease-in-out;
37 | }
38 | .iconContent:hover{
39 | color: white;
40 | background-color: #1890ff;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/components/_utils/utils.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | // 默认 namespaceId
19 | export const defaultNamespaceId = "649330b6-c2d7-4edc-be8e-8a54df9eb385";
20 |
21 | // 随机数字
22 | export function randomNum(m: number, n: number) {
23 | return Math.floor(Math.random() * (n - m + 1) + m);
24 | }
25 |
26 | // 随机颜色
27 | export function randomColor() {
28 | return `rgb(${randomNum(0, 255)}, ${randomNum(0, 255)}, ${randomNum(
29 | 0,
30 | 255,
31 | )})`;
32 | }
33 |
34 | export const originalCharacter = [
35 | "1",
36 | "2",
37 | "3",
38 | "4",
39 | "5",
40 | "6",
41 | "7",
42 | "8",
43 | "9",
44 | "a",
45 | "b",
46 | "c",
47 | "d",
48 | "e",
49 | "f",
50 | "g",
51 | "h",
52 | "i",
53 | "j",
54 | "k",
55 | "l",
56 | "m",
57 | "n",
58 | "p",
59 | "q",
60 | "r",
61 | "s",
62 | "t",
63 | "u",
64 | "v",
65 | "w",
66 | "x",
67 | "y",
68 | "z",
69 | ];
70 |
--------------------------------------------------------------------------------
/src/components/Authorized/AuthorizedRoute.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Route, Redirect } from "react-router-dom";
20 | import Authorized from "./Authorized";
21 |
22 | class AuthorizedRoute extends React.Component {
23 | render() {
24 | const {
25 | component: Component,
26 | render,
27 | authority,
28 | redirectPath,
29 | ...rest
30 | } = this.props;
31 | return (
32 | }
38 | />
39 | }
40 | >
41 |
44 | Component ? : render(props)
45 | }
46 | />
47 |
48 | );
49 | }
50 | }
51 |
52 | export default AuthorizedRoute;
53 |
--------------------------------------------------------------------------------
/src/components/Login/LoginTab.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | /* eslint-disable react/static-property-placement */
19 | import React, { Component } from "react";
20 | import PropTypes from "prop-types";
21 | import { Tabs } from "antd";
22 |
23 | const { TabPane } = Tabs;
24 |
25 | const generateId = (() => {
26 | let i = 0;
27 | return (prefix = "") => {
28 | i += 1;
29 | return `${prefix}${i}`;
30 | };
31 | })();
32 |
33 | export default class LoginTab extends Component {
34 | static __ANT_PRO_LOGIN_TAB = true;
35 |
36 | static contextTypes = {
37 | tabUtil: PropTypes.object,
38 | };
39 |
40 | constructor(props) {
41 | super(props);
42 | this.uniqueId = generateId("login-tab-");
43 | }
44 |
45 | componentDidMount() {
46 | const { tabUtil } = this.context;
47 | if (tabUtil) {
48 | tabUtil.addTab(this.uniqueId);
49 | }
50 | }
51 |
52 | render() {
53 | return ;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/.webpackrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const path = require("path");
19 |
20 | export default {
21 | es5ImcompatibleVersions: true,
22 | extraBabelIncludes:[
23 | "node_modules",
24 | ],
25 | entry: "./src/index.js",
26 | extraBabelPlugins: [
27 | ["import", { libraryName: "antd", libraryDirectory: "es", style: true }]
28 | ],
29 | env: {
30 | development: {
31 | extraBabelPlugins: ["dva-hmr"]
32 | }
33 | },
34 | alias: {
35 | components: path.resolve(__dirname, "src/components/")
36 | },
37 | ignoreMomentLocale: true,
38 | theme: "./src/theme.js",
39 | html: {
40 | template: "./src/index.ejs"
41 | },
42 | lessLoaderOptions: {
43 | javascriptEnabled: true
44 | },
45 | disableDynamicImport: true,
46 | publicPath: "",
47 | hash: true,
48 | proxy: {
49 | "/": {
50 | target: "http://localhost:9095",
51 | changeOrigin: true,
52 | pathRewrite: { "^/": "" }
53 | }
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/src/routes/User/Login.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import '~antd/lib/style/themes/default.less';
19 |
20 | .main {
21 | width: 368px;
22 | margin: 0 auto;
23 |
24 | @media screen and (max-width: @screen-sm) {
25 | width: 95%;
26 | }
27 |
28 | .icon {
29 | font-size: 24px;
30 | color: rgba(0, 0, 0, 0.2);
31 | margin-left: 16px;
32 | vertical-align: middle;
33 | cursor: pointer;
34 | transition: color 0.3s;
35 |
36 | &:hover {
37 | color: @primary-color;
38 | }
39 | }
40 |
41 | .other {
42 | text-align: left;
43 | margin-top: 24px;
44 | line-height: 22px;
45 |
46 | .register {
47 | float: right;
48 | }
49 | }
50 | }
51 |
52 | .verify {
53 | width: 70%;
54 | float: left;
55 | margin-right: 10px;
56 | }
57 |
58 | .codeError {
59 | color: red;
60 | font-size: 14px;
61 | }
62 |
63 |
64 | :global {
65 | .ant-input .ant-input-lg {
66 | font-size: 240px;
67 | background-color: #fff;
68 | }
69 | }
--------------------------------------------------------------------------------
/src/components/Result/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import classNames from "classnames";
20 | import { Icon } from "antd";
21 | import styles from "./index.less";
22 |
23 | export default function Result({
24 | className,
25 | type,
26 | title,
27 | description,
28 | extra,
29 | actions,
30 | ...restProps
31 | }) {
32 | const iconMap = {
33 | error: ,
34 | success: ,
35 | };
36 | const clsString = classNames(styles.result, className);
37 | return (
38 |
39 |
{iconMap[type]}
40 |
{title}
41 | {description &&
{description}
}
42 | {extra &&
{extra}
}
43 | {actions &&
{actions}
}
44 |
45 | );
46 | }
47 |
--------------------------------------------------------------------------------
/src/components/Login/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | import Button from 'antd/lib/button';
20 | export interface LoginProps {
21 | defaultActiveKey?: string;
22 | onTabChange?: (key: string) => void;
23 | style?: React.CSSProperties;
24 | onSubmit?: (error: any, values: any) => void;
25 | }
26 |
27 | export interface TabProps {
28 | key?: string;
29 | tab?: React.ReactNode;
30 | }
31 | export class Tab extends React.Component {}
32 |
33 | export interface LoginItemProps {
34 | name?: string;
35 | rules?: any[];
36 | style?: React.CSSProperties;
37 | onGetCaptcha?: () => void;
38 | placeholder?: string;
39 | }
40 |
41 | export class LoginItem extends React.Component {}
42 |
43 | export default class Login extends React.Component {
44 | static Tab: typeof Tab;
45 | static UserName: typeof LoginItem;
46 | static Password: typeof LoginItem;
47 | static Mobile: typeof LoginItem;
48 | static Captcha: typeof LoginItem;
49 | static Submit: typeof Button;
50 | }
51 |
--------------------------------------------------------------------------------
/src/router.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { routerRedux, Route, Switch } from "dva/router";
20 | import { ConfigProvider, BackTop } from "antd";
21 | import enUS from "antd/lib/locale-provider/en_US";
22 | import { getRouterData } from "./common/router";
23 | import AuthRoute from "./utils/AuthRoute";
24 |
25 | const { ConnectedRouter } = routerRedux;
26 |
27 | function RouterConfig({ history, app }) {
28 | const routerData = getRouterData(app);
29 | const UserLayout = routerData["/user"].component;
30 | const BasicLayout = routerData["/"].component;
31 |
32 | return (
33 |
34 |
35 |
36 |
37 |
42 |
43 |
44 |
45 |
46 | );
47 | }
48 |
49 | export default RouterConfig;
50 |
--------------------------------------------------------------------------------
/src/routes/Home/home.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import "~antd/lib/style/themes/default.less";
19 |
20 | .content {
21 | text-align: center;
22 | padding-top: 28px;
23 | padding-bottom: 20px;
24 | border-bottom: 1px solid #e8e8e8;
25 | margin-bottom: 24px;
26 |
27 | span {
28 | font-size: 32px;
29 | color: @primary-color;
30 | }
31 | }
32 |
33 | .processContent {
34 | margin-left: 30px;
35 | margin-right: 30px;
36 | }
37 |
38 | .contextHide {
39 | margin-bottom: 0;
40 | margin-right: 0;
41 | margin-left: 0;
42 | }
43 |
44 | .row {
45 | padding: 15px;
46 | }
47 |
48 | .logItem {
49 | padding: 15px !important;
50 | border: none;
51 | border-radius: 20px;
52 | opacity: 0.8;
53 | box-shadow: 3px 3px 10px rgba(76, 76, 76, 0.5);
54 | border-radius: 15px;
55 | }
56 |
57 | .card {
58 | box-shadow: 3px 5px 15px rgba(50, 50, 50, 0.5);
59 | background-color: rgba(255, 255, 255, 0.2);
60 | border-radius: 25px;
61 | }
62 |
63 | .logItem,
64 | .card {
65 | border-top: 1px solid rgba(255, 255, 255, 0.5);
66 | border-left: 1px solid rgba(255, 255, 255, 0.5);
67 | }
68 |
--------------------------------------------------------------------------------
/src/utils/utils.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | .textOverflow() {
19 | overflow: hidden;
20 | text-overflow: ellipsis;
21 | word-break: break-all;
22 | white-space: nowrap;
23 | }
24 |
25 | .textOverflowMulti(@line: 3, @bg: #fff) {
26 | overflow: hidden;
27 | position: relative;
28 | line-height: 1.5em;
29 | max-height: @line * 1.5em;
30 | text-align: justify;
31 | margin-right: -1em;
32 | padding-right: 1em;
33 | &:before {
34 | background: @bg;
35 | content: '...';
36 | padding: 0 1px;
37 | position: absolute;
38 | right: 14px;
39 | bottom: 0;
40 | }
41 | &:after {
42 | background: white;
43 | content: '';
44 | margin-top: 0.2em;
45 | position: absolute;
46 | right: 14px;
47 | width: 1em;
48 | height: 1em;
49 | }
50 | }
51 |
52 | // mixins for clearfix
53 | // ------------------------
54 | .clearfix() {
55 | zoom: 1;
56 | &:before,
57 | &:after {
58 | content: ' ';
59 | display: table;
60 | }
61 | &:after {
62 | clear: both;
63 | visibility: hidden;
64 | font-size: 0;
65 | height: 0;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/components/PageHeader/demo/image.md:
--------------------------------------------------------------------------------
1 | ---
2 | order: 2
3 | title: With Image
4 | ---
5 |
6 | 带图片的页头。
7 |
8 | ````jsx
9 | import PageHeader from 'ant-design-pro/lib/PageHeader';
10 |
11 | const content = (
12 |
51 | );
52 | };
53 |
54 | export default GlobalFooter;
55 |
--------------------------------------------------------------------------------
/src/components/Authorized/index.d.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import * as React from 'react';
19 | import { RouteProps } from 'react-router';
20 |
21 | type authorityFN = (currentAuthority?: string) => boolean;
22 |
23 | type authority = string | Array | authorityFN | Promise;
24 |
25 | export type IReactComponent
=
26 | | React.StatelessComponent
27 | | React.ComponentClass
28 | | React.ClassicComponentClass
;
29 |
30 | interface Secured {
31 | (authority: authority, error?: React.ReactNode): (target: T) => T;
32 | }
33 |
34 | export interface AuthorizedRouteProps extends RouteProps {
35 | authority: authority;
36 | }
37 | export class AuthorizedRoute extends React.Component {}
38 |
39 | interface check {
40 | (
41 | authority: authority,
42 | target: T,
43 | Exception: S
44 | ): T | S;
45 | }
46 |
47 | interface AuthorizedProps {
48 | authority: authority;
49 | noMatch?: React.ReactNode;
50 | }
51 |
52 | export class Authorized extends React.Component {
53 | static Secured: Secured;
54 | static AuthorizedRoute: typeof AuthorizedRoute;
55 | static check: check;
56 | }
57 |
58 | declare function renderAuthorize(currentAuthority: string): typeof Authorized;
59 |
60 | export default renderAuthorize;
61 |
--------------------------------------------------------------------------------
/src/layouts/UserLayout.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import '~antd/lib/style/themes/default.less';
19 |
20 | .container {
21 | display: flex;
22 | flex-direction: column;
23 | height: 100vh;
24 | overflow: auto;
25 | // background-image: url();
26 | background: #ffffff;
27 | }
28 |
29 | .content {
30 | padding: 32px 0;
31 | flex: 1;
32 | }
33 |
34 | @media (min-width: @screen-md-min) {
35 | .container {
36 | // background url https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg
37 | background-image: url('../assets/bg.jpg');
38 | background-repeat: no-repeat;
39 | background-position: center;
40 | background-size: cover;
41 | }
42 |
43 | .content {
44 | padding: 100px 0 0 0;
45 | }
46 | }
47 |
48 | .top {
49 | text-align: center;
50 | }
51 |
52 | .header {
53 | height: 44px;
54 | line-height: 44px;
55 |
56 | a {
57 | text-decoration: none;
58 | }
59 | }
60 |
61 | .logo {
62 | height: 44px;
63 | vertical-align: top;
64 | margin-right: 16px;
65 | }
66 |
67 | .title {
68 | font-size: 33px;
69 | color: @heading-color;
70 | font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
71 | font-weight: 600;
72 | position: relative;
73 | top: 2px;
74 | }
75 |
76 | .desc {
77 | font-size: @font-size-base;
78 | color: #ffffff;
79 | margin-top: 12px;
80 | margin-bottom: 40px;
81 | }
82 |
--------------------------------------------------------------------------------
/tests/run-tests.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | const { spawn } = require("child_process");
19 | const { kill } = require("cross-port-killer");
20 |
21 | const env = Object.create(process.env);
22 | env.BROWSER = "none";
23 | const startServer = spawn(
24 | /^win/.test(process.platform) ? "npm.cmd" : "npm",
25 | ["start"],
26 | {
27 | env,
28 | },
29 | );
30 |
31 | startServer.stderr.on("data", (data) => {
32 | // eslint-disable-next-line
33 | console.log(data);
34 | });
35 |
36 | startServer.on("exit", () => {
37 | kill(process.env.PORT || 8000);
38 | });
39 |
40 | // eslint-disable-next-li
41 | // eslint-disable-next-line no-console
42 | console.log("Starting development server for e2e tests...");
43 | startServer.stdout.on("data", (data) => {
44 | // eslint-disable-next-line
45 | console.log(data.toString());
46 | if (
47 | data.toString().indexOf("Compiled successfully") >= 0 ||
48 | data.toString().indexOf("Compiled with warnings") >= 0
49 | ) {
50 | // eslint-disable-next-line
51 | console.log('Development server is started, ready to run tests.');
52 | const testCmd = spawn(
53 | /^win/.test(process.platform) ? "npm.cmd" : "npm",
54 | ["test"],
55 | {
56 | stdio: "inherit",
57 | },
58 | );
59 | testCmd.on("exit", (code) => {
60 | startServer.kill();
61 | process.exit(code);
62 | });
63 | }
64 | });
65 |
--------------------------------------------------------------------------------
/src/assets/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/Exception/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React, { createElement } from "react";
19 | import classNames from "classnames";
20 | import { Button } from "antd";
21 | import config from "./typeConfig";
22 | import styles from "./index.less";
23 |
24 | const Exception = ({
25 | className,
26 | linkElement = "a",
27 | type,
28 | title,
29 | desc,
30 | img,
31 | actions,
32 | ...rest
33 | }) => {
34 | const pageType = type in config ? type : "404";
35 | const clsString = classNames(styles.exception, className);
36 | return (
37 |
95 | , mountNode);
96 | ````
97 |
98 |
103 |
--------------------------------------------------------------------------------
/src/components/Authorized/Secured.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import Exception from "../Exception/index";
20 | import CheckPermissions from "./CheckPermissions";
21 | /**
22 | * 默认不能访问任何页面
23 | * default is "NULL"
24 | */
25 | const Exception403 = () => (
26 |
27 | );
28 |
29 | // Determine whether the incoming component has been instantiated
30 | // AuthorizedRoute is already instantiated
31 | // Authorized render is already instantiated, children is no instantiated
32 | // Secured is not instantiated
33 | const checkIsInstantiation = (target) => {
34 | if (!React.isValidElement(target)) {
35 | return target;
36 | }
37 | return () => target;
38 | };
39 |
40 | /**
41 | * 用于判断是否拥有权限访问此view权限
42 | * authority 支持传入 string ,funtion:()=>boolean|Promise
43 | * e.g. 'user' 只有user用户能访问
44 | * e.g. 'user,admin' user和 admin 都能访问
45 | * e.g. ()=>boolean 返回true能访问,返回false不能访问
46 | * e.g. Promise then 能访问 catch不能访问
47 | * e.g. authority support incoming string, funtion: () => boolean | Promise
48 | * e.g. 'user' only user user can access
49 | * e.g. 'user, admin' user and admin can access
50 | * e.g. () => boolean true to be able to visit, return false can not be accessed
51 | * e.g. Promise then can not access the visit to catch
52 | * @param {string | function | Promise} authority
53 | * @param {ReactNode} error 非必需参数
54 | */
55 | const authorize = (authority, error) => {
56 | /**
57 | * conversion into a class
58 | * 防止传入字符串时找不到staticContext造成报错
59 | * String parameters can cause staticContext not found error
60 | */
61 | let classError = false;
62 | if (error) {
63 | classError = () => error;
64 | }
65 | if (!authority) {
66 | throw new Error("authority is required");
67 | }
68 | return function decideAuthority(target) {
69 | const component = CheckPermissions(
70 | authority,
71 | target,
72 | classError || Exception403,
73 | );
74 | return checkIsInstantiation(component);
75 | };
76 | };
77 |
78 | export default authorize;
79 |
--------------------------------------------------------------------------------
/src/components/Authorized/PromiseRender.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Spin } from "antd";
20 |
21 | export default class PromiseRender extends React.PureComponent {
22 | constructor(props) {
23 | super(props);
24 | this.state = {
25 | component: null,
26 | prevPropsPromise: null,
27 | };
28 | }
29 |
30 | componentDidMount() {
31 | this.setRenderComponent(this.props);
32 | }
33 |
34 | static getDerivedStateFromProps(nextProps, prevState) {
35 | if (nextProps.promise !== prevState.prevPropsPromise) {
36 | return {
37 | prevPropsPromise: nextProps.promise,
38 | };
39 | }
40 | return null;
41 | }
42 |
43 | componentDidUpdate(prevProps) {
44 | if (this.props.promise !== prevProps.promise) {
45 | this.setRenderComponent(this.props);
46 | }
47 | }
48 |
49 | // set render Component : ok or error
50 | setRenderComponent(props) {
51 | const ok = this.checkIsInstantiation(props.ok);
52 | const error = this.checkIsInstantiation(props.error);
53 | props.promise
54 | .then(() => {
55 | this.setState({
56 | component: ok,
57 | });
58 | })
59 | .catch(() => {
60 | this.setState({
61 | component: error,
62 | });
63 | });
64 | }
65 |
66 | // Determine whether the incoming component has been instantiated
67 | // AuthorizedRoute is already instantiated
68 | // Authorized render is already instantiated, children is no instantiated
69 | // Secured is not instantiated
70 | checkIsInstantiation = (target) => {
71 | if (!React.isValidElement(target)) {
72 | return target;
73 | }
74 | return () => target;
75 | };
76 |
77 | render() {
78 | const { component: Component } = this.state;
79 | return Component ? (
80 |
81 | ) : (
82 |
91 |
92 |
93 | );
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/components/SiderMenu/index.less:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | @import "~antd/lib/style/themes/default.less";
19 | @ease-in-out-circ: cubic-bezier(0.78, 0.14, 0.15, 0.86);
20 |
21 | .logo {
22 | height: 64px;
23 | position: relative;
24 | padding-left: (@menu-collapsed-width - 32px) / 2;
25 | transition: all 0.3s;
26 | background: #002140;
27 | overflow: hidden;
28 | display: flex;
29 | flex-direction: row;
30 | align-items: center;
31 |
32 | .icon {
33 | width: 32px;
34 | height: 32px;
35 | }
36 |
37 | .TitleLogo {
38 | width: 184px;
39 | height: 184px;
40 | }
41 |
42 | .systemTitle {
43 | color: #ffffff;
44 | font-family: "Myriad Pro", "Helvetica Neue", Arial, Helvetica, sans-serif;
45 | font-weight: 600;
46 |
47 | .title {
48 | font-size: 18px;
49 | line-height: 18px;
50 | }
51 |
52 | .subTitle {
53 | font-size: 14px;
54 | line-height: 17px;
55 | }
56 | }
57 | }
58 |
59 | .sider {
60 | min-height: 100vh;
61 | box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
62 | position: relative;
63 | z-index: 10;
64 |
65 | &.ligth {
66 | background-color: white;
67 |
68 | .logo {
69 | background: white;
70 |
71 | h1 {
72 | color: #002140;
73 | }
74 | }
75 | }
76 | }
77 |
78 | .changeMode {
79 | margin: 10px 0px 0px 20px !important;
80 | }
81 |
82 | .icon {
83 | width: 14px;
84 | margin-right: 10px;
85 | }
86 |
87 | :global {
88 | .drawer .drawer-content {
89 | background: #001529;
90 | }
91 |
92 | .ant-menu-inline-collapsed {
93 |
94 | &>.ant-menu-item .sider-menu-item-img+span,
95 | &>.ant-menu-item-group>.ant-menu-item-group-list>.ant-menu-item .sider-menu-item-img+span,
96 | &>.ant-menu-submenu>.ant-menu-submenu-title .sider-menu-item-img+span {
97 | max-width: 0;
98 | display: inline-block;
99 | opacity: 0;
100 | }
101 | }
102 |
103 | .ant-menu-item .sider-menu-item-img+span,
104 | .ant-menu-submenu-title .sider-menu-item-img+span {
105 | transition: opacity 0.3s @ease-in-out, width 0.3s @ease-in-out;
106 | opacity: 1;
107 | }
108 | }
--------------------------------------------------------------------------------
/src/utils/plugin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { refreshAuthMenus } from "./AuthRoute";
20 | import AddModal from "../routes/System/Plugin/AddModal";
21 |
22 | export function getUpdateModal({
23 | pluginId,
24 | dispatch,
25 | fetchValue,
26 | callback,
27 | updatedCallback,
28 | canceledCallback,
29 | }) {
30 | dispatch({
31 | type: "plugin/fetchItem",
32 | payload: {
33 | id: pluginId,
34 | },
35 | callback: (plugin) => {
36 | dispatch({
37 | type: "plugin/fetchByPluginId",
38 | payload: {
39 | pluginId: plugin.id,
40 | type: "3",
41 | },
42 | callback: (pluginConfigList) => {
43 | callback(
44 | {
49 | const { name, enabled, id, role, config, sort, file } = values;
50 | dispatch({
51 | type: "plugin/update",
52 | payload: {
53 | config,
54 | role,
55 | name,
56 | enabled,
57 | id,
58 | sort,
59 | file,
60 | },
61 | fetchValue,
62 | callback: () => {
63 | if (updatedCallback) {
64 | updatedCallback(values);
65 | }
66 | refreshAuthMenus({ dispatch });
67 | },
68 | });
69 | }}
70 | handleCancel={canceledCallback}
71 | />,
72 | );
73 | },
74 | });
75 | },
76 | });
77 | }
78 |
79 | export function updatePluginsEnabled({
80 | list,
81 | enabled,
82 | dispatch,
83 | fetchValue,
84 | callback,
85 | }) {
86 | dispatch({
87 | type: "plugin/updateEn",
88 | payload: {
89 | list,
90 | enabled,
91 | },
92 | fetchValue,
93 | callback: () => {
94 | if (callback) {
95 | callback();
96 | }
97 | refreshAuthMenus({ dispatch });
98 | },
99 | });
100 | }
101 |
--------------------------------------------------------------------------------
/src/components/Login/map.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import React from "react";
19 | import { Input, Icon } from "antd";
20 | import styles from "./index.less";
21 | import { getIntlContent } from "../../utils/IntlUtils";
22 |
23 | const map = {
24 | VerifyCode: {
25 | component: Input,
26 | props: {
27 | size: "large",
28 | allowClear: true,
29 | prefix: ,
30 | },
31 | rules: [
32 | {
33 | required: true,
34 | message: getIntlContent("SHENYU.SYSTEM.VERIFICATION.CODE"),
35 | },
36 | ],
37 | },
38 | UserName: {
39 | component: Input,
40 | props: {
41 | size: "large",
42 | allowClear: true,
43 | prefix: ,
44 | placeholder: "admin",
45 | },
46 | rules: [
47 | {
48 | required: true,
49 | message: getIntlContent("SHENYU.SYSTEM.USER.NAME"),
50 | },
51 | ],
52 | },
53 | Password: {
54 | component: Input.Password,
55 | props: {
56 | size: "large",
57 | allowClear: true,
58 | prefix: ,
59 | placeholder: "888888",
60 | },
61 | rules: [
62 | {
63 | required: true,
64 | message: getIntlContent("SHENYU.SYSTEM.USER.PASSWORD"),
65 | },
66 | ],
67 | },
68 | Mobile: {
69 | component: Input,
70 | props: {
71 | size: "large",
72 | allowClear: true,
73 | prefix: ,
74 | placeholder: "mobile number",
75 | },
76 | rules: [
77 | {
78 | required: true,
79 | message: "Please enter mobile number!",
80 | },
81 | {
82 | pattern: /^1\d{10}$/,
83 | message: "Wrong mobile number format!",
84 | },
85 | ],
86 | },
87 | Captcha: {
88 | component: Input,
89 | props: {
90 | size: "large",
91 | allowClear: true,
92 | prefix: ,
93 | placeholder: "captcha",
94 | },
95 | rules: [
96 | {
97 | required: true,
98 | message: "Please enter Captcha!",
99 | },
100 | ],
101 | },
102 | };
103 |
104 | export default map;
105 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | module.exports = {
19 | parser: 'babel-eslint',
20 | extends: [
21 | 'airbnb',
22 | 'prettier'
23 | ],
24 | plugins: [
25 | 'prettier',
26 | ],
27 | env: {
28 | browser: true,
29 | node: true,
30 | es6: true,
31 | mocha: true,
32 | jest: true,
33 | jasmine: true,
34 | },
35 | rules: {
36 | 'react/jsx-boolean-value': [0],
37 | 'one-var': [0],
38 | 'prefer-destructuring': [0],
39 | 'react/destructuring-assignment':[0],
40 | 'comma-dangle': [0],
41 | 'react/no-array-index-key':[0],
42 | 'no-param-reassign': [0],
43 | 'prefer-const': [0],
44 | 'linebreak-style': [0],
45 | 'generator-star-spacing': [0],
46 | 'consistent-return': [0],
47 | 'react/forbid-prop-types': [0],
48 | 'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
49 | 'global-require': [1],
50 | 'import/prefer-default-export': [0],
51 | 'react/jsx-no-bind': [0],
52 | 'react/prop-types': [0],
53 | 'react/prefer-stateless-function': [0],
54 | 'react/jsx-one-expression-per-line': [0],
55 | 'react/jsx-wrap-multilines': [
56 | 'error',
57 | {
58 | declaration: 'parens-new-line',
59 | assignment: 'parens-new-line',
60 | return: 'parens-new-line',
61 | arrow: 'parens-new-line',
62 | condition: 'parens-new-line',
63 | logical: 'parens-new-line',
64 | prop: 'ignore',
65 | },
66 | ],
67 | 'react/jsx-props-no-spreading': 'off',
68 | 'react/function-component-definition': 'off',
69 | 'no-else-return': [0],
70 | 'no-restricted-syntax': [0],
71 | 'import/no-extraneous-dependencies': [0],
72 | 'no-use-before-define': [0],
73 | 'jsx-a11y/no-static-element-interactions': [0],
74 | 'jsx-a11y/no-noninteractive-element-interactions': [0],
75 | 'jsx-a11y/click-events-have-key-events': [0],
76 | 'jsx-a11y/anchor-is-valid': [0],
77 | 'no-nested-ternary': [0],
78 | 'arrow-body-style': [0],
79 | 'import/extensions': [0],
80 | 'no-bitwise': [0],
81 | 'no-cond-assign': [0],
82 | 'import/no-unresolved': [0],
83 | 'object-curly-newline': [0],
84 | 'function-paren-newline': [0],
85 | 'no-restricted-globals': [0],
86 | 'require-yield': [1],
87 | 'prettier/prettier': 'error',
88 | },
89 | parserOptions: {
90 | ecmaFeatures: {
91 | experimentalObjectRestSpread: true,
92 | },
93 | },
94 | settings: {
95 | polyfills: ['fetch', 'promises'],
96 | },
97 | };
98 |
--------------------------------------------------------------------------------
/src/routes/Document/components/HeadersEditor.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | import { Col, Input, Row, Button, Icon, Typography } from "antd";
19 | import React, { Fragment, useEffect, useState } from "react";
20 |
21 | const { Text } = Typography;
22 |
23 | function HeadersEditor(props) {
24 | const { value: propsValue, onChange, buttonText } = props;
25 | const jsonObj = JSON.parse(propsValue || "[]");
26 | const [value, setValue] = useState(jsonObj);
27 |
28 | useEffect(() => {
29 | setValue(jsonObj);
30 | }, [propsValue]);
31 |
32 | const onChangeItem = (e, key, index) => {
33 | changeValue(
34 | value.map((item) =>
35 | item.index === index ? { ...item, [key]: e } : item,
36 | ),
37 | );
38 | };
39 |
40 | const onDeleteItem = (key) => {
41 | changeValue(value.filter((item) => item.key !== key));
42 | };
43 |
44 | const onAddItem = () => {
45 | changeValue([...value, { index: value.length, key: "", value: "" }]);
46 | };
47 |
48 | const changeValue = (newValue) => {
49 | setValue(newValue);
50 | onChange(JSON.stringify(newValue));
51 | };
52 |
53 | return (
54 |
55 | {value.map((item) => (
56 |
57 |