-
Notifications
You must be signed in to change notification settings - Fork 543
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: support show all enable plugin list tab #2585
Changes from 11 commits
a9bd4eb
22fc396
cb04768
158ecb3
6964c14
1f25dca
3c87d96
5ac8d68
5ee1637
553b0fc
2877db8
ffb7468
1d1c056
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,7 +15,7 @@ | |||||||||||||
* limitations under the License. | ||||||||||||||
*/ | ||||||||||||||
import React, { useEffect, useState } from 'react'; | ||||||||||||||
import { Anchor, Layout, Card, Button, Form, Select, Alert } from 'antd'; | ||||||||||||||
import { Anchor, Layout, Card, Button, Form, Select, Alert, Tabs } from 'antd'; | ||||||||||||||
import { orderBy, omit } from 'lodash'; | ||||||||||||||
import { useIntl } from 'umi'; | ||||||||||||||
|
||||||||||||||
|
@@ -66,9 +66,11 @@ const PluginPage: React.FC<Props> = ({ | |||||||||||||
const { formatMessage } = useIntl(); | ||||||||||||||
const [form] = Form.useForm(); | ||||||||||||||
const [pluginList, setPluginList] = useState<PluginComponent.Meta[]>([]); | ||||||||||||||
const [enablePluginsList, setEnablePluginsList] = useState<PluginComponent.Meta[]>([]); | ||||||||||||||
const [pluginTemplateList, setPluginTemplateList] = useState<PluginTemplateModule.ResEntity[]>( | ||||||||||||||
[], | ||||||||||||||
); | ||||||||||||||
const [showEnablePlugin, setShowEnablePlugin] = useState<boolean>(false); | ||||||||||||||
const [name, setName] = useState<string>(NEVER_EXIST_PLUGIN_FLAG); | ||||||||||||||
const [typeList, setTypeList] = useState<string[]>([]); | ||||||||||||||
const [plugins, setPlugins] = useState({}); | ||||||||||||||
|
@@ -96,6 +98,14 @@ const PluginPage: React.FC<Props> = ({ | |||||||||||||
form.setFieldsValue({ plugin_config_id }); | ||||||||||||||
}); | ||||||||||||||
}, []); | ||||||||||||||
|
||||||||||||||
useEffect(() => { | ||||||||||||||
const openList = pluginList.filter( | ||||||||||||||
(item) => initialData[item.name] && !initialData[item.name].disable, | ||||||||||||||
); | ||||||||||||||
setEnablePluginsList(openList); | ||||||||||||||
}, [initialData]); | ||||||||||||||
|
||||||||||||||
const openPluginList = pluginList.filter( | ||||||||||||||
(item) => initialData[item.name] && !initialData[item.name].disable, | ||||||||||||||
); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you help us improve this section, please? Like you've done here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will improve it |
||||||||||||||
|
@@ -104,6 +114,34 @@ const PluginPage: React.FC<Props> = ({ | |||||||||||||
return index === self.indexOf(elem); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
const tabsList = [ | ||||||||||||||
{ | ||||||||||||||
title: formatMessage({ id: 'component.plugin.all' }), | ||||||||||||||
key: 'allPlugins', | ||||||||||||||
}, | ||||||||||||||
{ | ||||||||||||||
title: formatMessage({ id: 'component.plugin.enable' }), | ||||||||||||||
key: 'enablePlugins', | ||||||||||||||
}, | ||||||||||||||
]; | ||||||||||||||
|
||||||||||||||
const SwitchTab = () => ( | ||||||||||||||
<Tabs | ||||||||||||||
defaultActiveKey={showEnablePlugin ? 'enablePlugins' : 'allPlugins'} | ||||||||||||||
onChange={(val: string) => { | ||||||||||||||
if (val === 'enablePlugins') { | ||||||||||||||
setShowEnablePlugin(true); | ||||||||||||||
} else { | ||||||||||||||
setShowEnablePlugin(false); | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
}} | ||||||||||||||
> | ||||||||||||||
{tabsList.map((tab) => ( | ||||||||||||||
<Tabs.TabPane tab={tab.title} key={tab.key} /> | ||||||||||||||
))} | ||||||||||||||
</Tabs> | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
const PluginList = () => ( | ||||||||||||||
<> | ||||||||||||||
<style> | ||||||||||||||
|
@@ -199,7 +237,7 @@ const PluginPage: React.FC<Props> = ({ | |||||||||||||
id={`plugin-category-${typeItem}`} | ||||||||||||||
> | ||||||||||||||
{orderBy( | ||||||||||||||
pluginList.filter( | ||||||||||||||
(showEnablePlugin ? enablePluginsList : pluginList).filter( | ||||||||||||||
readonly | ||||||||||||||
? (item) => item.type === typeItem && !item.hidden && initialData[item.name] | ||||||||||||||
: (item) => item.type === typeItem && !item.hidden, | ||||||||||||||
|
@@ -303,6 +341,7 @@ const PluginPage: React.FC<Props> = ({ | |||||||||||||
background-color: transparent; | ||||||||||||||
} | ||||||||||||||
`}</style> | ||||||||||||||
{!readonly && <SwitchTab />} | ||||||||||||||
<Layout> | ||||||||||||||
<PluginList /> | ||||||||||||||
<Plugin /> | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enablePluginsList can be obtained from the
pluginList
after calculation, no need to define a new state.