guoqqqi commented on code in PR #2573:
URL: https://github.com/apache/apisix-dashboard/pull/2573#discussion_r939677456


##########
web/cypress/integration/plugin/create-delete-in-drawer-plugin.spec.js:
##########
@@ -109,4 +109,42 @@ context('Delete Plugin List with the Drawer', () => {
     });
     cy.get(selector.empty).should('be.visible');
   });
+
+  it('should delete the plugin with the drawer in the list of plugins', 
function () {
+    cy.visit('/plugin/list');
+    cy.get(selector.refresh).click();
+    cy.contains('Enable').click();
+
+    cy.contains(data.basicAuthPlugin)
+      .parents(selector.pluginCardBordered)
+      .within(() => {
+        cy.get('button').click({
+          force: true,
+        });
+      });
+    cy.get(selector.drawer)
+      .should('be.visible')
+      .within(() => {
+        cy.get(selector.disabledSwitcher).click();
+        cy.get(selector.checkedSwitcher).should('exist');
+      });
+    cy.contains('button', 'Submit').click();
+
+    cy.contains(data.basicAuthPlugin)
+      .parents(selector.pluginCardBordered)
+      .within(() => {
+        cy.get('button').click({
+          force: true,

Review Comment:
   It is not usually advisable to use so many `force` attributes, as it may 
cause unsuccessful clicks, and we should use some assertions to ensure that the 
state of the button is normal.



##########
web/src/components/Plugin/PluginPage.tsx:
##########
@@ -277,12 +277,12 @@ const PluginPage: React.FC<Props> = ({
         setName(NEVER_EXIST_PLUGIN_FLAG);
       }}
       onChange={({ monacoData, formData, shouldDelete }) => {
-        let newPlugins = {
+        const newPlugins = {
           ...initialData,
           [name]: { ...monacoData, disable: !formData.disable },
         };
         if (shouldDelete === true) {
-          newPlugins = omit(newPlugins, name);
+          newPlugins[name] = null;

Review Comment:
   This method is not very good, we do not usually modify the value of an 
object's properties directly.
   An extended question, we should normally have an indication of successful 
deletion when we delete data. 



-- 
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]

Reply via email to