Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show warning notification when dashboard version not matching apisix #1435

Merged
merged 4 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,18 @@ const PluginDetail: React.FC<Props> = ({
okText={formatMessage({ id: 'component.global.confirm' })}
cancelText={formatMessage({ id: 'component.global.cancel' })}
onConfirm={() => {
onChange({ formData: form.getFieldsValue(), codemirrorData: {}, shouldDelete: true });
onChange({
formData: form.getFieldsValue(),
codemirrorData: {},
shouldDelete: true,
});
}}
>
{
initialData[name]
? <Button
key={3}
type="primary"
danger
>
{formatMessage({ id: 'component.global.delete' })}
</Button>
: null
}
{initialData[name] ? (
<Button key={3} type="primary" danger>
{formatMessage({ id: 'component.global.delete' })}
</Button>
) : null}
</Popconfirm>
<Button
key={2}
Expand Down Expand Up @@ -250,8 +248,8 @@ const PluginDetail: React.FC<Props> = ({
pluginType === 'auth' && schemaType !== 'consumer' ? (
<Alert message={`${name} does not require configuration`} type="warning" />
) : (
<>Current plugin: {name}</>
)
<>Current plugin: {name}</>
)
}
ghost={false}
extra={[
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const PluginPage: React.FC<Props> = ({
};
if (shouldDelete === true) {
plugins = omit(plugins, name);
};
}
onChange(plugins);
setName(NEVER_EXIST_PLUGIN_FLAG);
}}
Expand Down
7 changes: 6 additions & 1 deletion web/src/components/RightContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
*/
import { Tooltip, Tag, Space } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import React from 'react';
import React, { useEffect } from 'react';
import { useModel, SelectLang } from 'umi';

import { fetchVersionMatch } from '@/services/tool';
import Avatar from './AvatarDropdown';
import styles from './index.less';

Expand All @@ -49,6 +51,9 @@ const GlobalHeaderRight: React.FC = () => {
if ((navTheme === 'dark' && layout === 'top') || layout === 'mix') {
className = `${styles.right} ${styles.dark}`;
}
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your React function. You can follow the documentation here. (from https://stackoverflow.com/questions/57620799/react-hook-useeffect-is-called-conditionally)

just move this useEffect before line 44

fetchVersionMatch();
}, []);
return (
<Space className={className}>
<Tooltip title="Documentation">
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Plugin/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ const Page: React.FC = () => {
};
if (shouldDelete === true) {
plugins = omit(plugins, name);
};
}
createOrUpdate({
plugins
plugins,
}).then(() => {
setVisible(false);
setName('');
Expand Down
19 changes: 19 additions & 0 deletions web/src/services/tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { request } from 'umi';

export const fetchVersionMatch = () => request<Res<any>>('/tool/version_match');