guoqqqi commented on code in PR #2573:
URL: https://github.com/apache/apisix-dashboard/pull/2573#discussion_r939845765
##########
web/src/components/Plugin/PluginPage.tsx:
##########
@@ -280,11 +284,10 @@ const PluginPage: React.FC<Props> = ({
const newPlugins = {
...initialData,
[name]: { ...monacoData, disable: !formData.disable },
+ ...(shouldDelete ? { [name]: null } : {}),
};
- 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'));
Review Comment:
Please check the code here, I think it is the data there that is having an
effect, we may not need to pass the `initialData` data. The onChange logic here
I don't think should be changed, but the source of the problem should be looked
at.
https://github.com/apache/apisix-dashboard/blob/master/web/src/pages/Plugin/PluginMarket.tsx#L54
##########
web/src/components/Plugin/PluginPage.tsx:
##########
@@ -280,11 +284,10 @@ const PluginPage: React.FC<Props> = ({
const newPlugins = {
...initialData,
[name]: { ...monacoData, disable: !formData.disable },
+ ...(shouldDelete ? { [name]: null } : {}),
Review Comment:
As this component is used in a number of places, we need to be extra careful
in modifying this part of the code
##########
web/src/pages/Plugin/List.tsx:
##########
@@ -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' })}`,
Review Comment:
This writing style will result in a Chinese state with extra spaces
##########
web/src/pages/Plugin/PluginMarket.tsx:
##########
@@ -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' })}`,
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]