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

fix: drawer components delete plugin not working #2573

Merged
merged 5 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ context('Delete Plugin List with the Drawer', () => {
checkedSwitcher: '.ant-switch-checked',
refresh: '.anticon-reload',
empty: '.ant-empty-normal',
notification: '.ant-notification-notice',
notificationCloseIcon: '.ant-notification-notice-close',
};

const data = {
Expand Down Expand Up @@ -107,6 +109,8 @@ context('Delete Plugin List with the Drawer', () => {
cy.contains('button', 'Confirm').click({
force: true,
});
cy.get(selector.notification).should('contain', 'Delete Plugin Successfully');
cy.get(selector.notificationCloseIcon).click({ multiple: true });
cy.get(selector.empty).should('be.visible');
});

Expand Down Expand Up @@ -144,6 +148,8 @@ context('Delete Plugin List with the Drawer', () => {
cy.contains('button', 'Confirm').click({
force: true,
});
cy.get(selector.notification).should('contain', 'Delete Plugin Successfully');
cy.get(selector.notificationCloseIcon).click({ multiple: true });
Baoyuantop marked this conversation as resolved.
Show resolved Hide resolved
cy.visit('/plugin/list');
cy.get(selector.empty).should('be.visible');
});
Expand Down
13 changes: 8 additions & 5 deletions web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ type Props = {
schemaType?: PluginComponent.Schema;
referPage?: PluginComponent.ReferPage;
showSelector?: boolean;
onChange?: (plugins: PluginComponent.Data, plugin_config_id?: string) => void;
onChange?: (
plugins: PluginComponent.Data,
handleType: 'edit' | 'delete',
plugin_config_id?: string,
) => void;
};

const PanelSectionStyle = {
Expand Down Expand Up @@ -280,11 +284,10 @@ const PluginPage: React.FC<Props> = ({
const newPlugins = {
...initialData,
[name]: { ...monacoData, disable: !formData.disable },
...(shouldDelete ? { [name]: null } : {}),
guoqqqi marked this conversation as resolved.
Show resolved Hide resolved
};
if (shouldDelete === true) {
newPlugins[name] = null;
}
onChange(newPlugins, form.getFieldValue('plugin_config_id'));
const handleType = shouldDelete ? 'delete' : 'edit';
onChange(newPlugins, handleType, form.getFieldValue('plugin_config_id'));
guoqqqi marked this conversation as resolved.
Show resolved Hide resolved
setPlugins(newPlugins);
setName(NEVER_EXIST_PLUGIN_FLAG);
}}
Expand Down
7 changes: 7 additions & 0 deletions web/src/pages/Plugin/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ const Page: React.FC = () => {
setVisible(false);
setName('');
ref.current?.reload();
notification.success({
message: `${formatMessage({
id: `component.global.${shouldDelete ? 'delete' : 'edit'}`,
})} ${formatMessage({
id: 'menu.plugin',
})} ${formatMessage({ id: 'component.status.success' })}`,
guoqqqi marked this conversation as resolved.
Show resolved Hide resolved
});
});
}}
/>
Expand Down
11 changes: 9 additions & 2 deletions web/src/pages/Plugin/PluginMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/
import React, { useEffect, useState } from 'react';
import { Card } from 'antd';
import { Card, notification } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';

import PluginPage from '@/components/Plugin';
Expand Down Expand Up @@ -48,14 +48,21 @@ const PluginMarket: React.FC = () => {
initialData={initialData}
type="global"
schemaType="route"
onChange={(pluginsData) => {
onChange={(pluginsData, handleType) => {
createOrUpdate({
plugins: {
...initialData,
...pluginsData,
},
}).then(() => {
initPageData();
notification.success({
message: `${formatMessage({
id: `component.global.${handleType}`,
})} ${formatMessage({
id: 'menu.plugin',
})} ${formatMessage({ id: 'component.status.success' })}`,
guoqqqi marked this conversation as resolved.
Show resolved Hide resolved
});
});
}}
/>
Expand Down