pocketdigi / kong-admin-ui

Kong admin UI
https://www.pocketdigi.com
Apache License 2.0
332 stars 99 forks source link

Impossible to edit a plugin that does not have a service #22

Open yassinb opened 3 years ago

yassinb commented 3 years ago

Hello,

I am using your kong-admin-ui which works well with my Kong Community, thanks a lot. It allows me to create the desired routes, services and upstreams. However, I noticed an issue in the pluggins section. Indeed, when I create a plugin without a service associate, and I want to edit it later, I end up with an error and a redirect to the authentication page.

Here are some screens to describe this issue:

image

When you click on "View" :

image

I looked at your code, and the problem seems (AddPlugin.vue) indeed to come from the getter for this.formItem.service.id which is set to null and you are trying to returning and reading a little lower in the loadPlugin() method .

For my part, I was able to fix this problem, it is necessary to check if this.formItem.service is not undefined or null. If so, set and return, this.formItem.service.id to an empty string. Otherwise, we correctly set the value of formItem.service.id that we return.

The line 134 to 136 :

...
get() {
    return this.formItem.service.id;
},
...

must become something like this :

...
get() {
    if(this.formItem.service === null || this.formItem.service === undefined) { 
        return { id: '' };
    }
    return this.formItem.service.id;
}, 
...

And in the loadPlugin() function we should replace on line 166:

this.serviceId = this.formItem.service.id;

to :

if(this.formItem.service === null || this.formItem.service === undefined) { 
    this.serviceId = '';
}
else { 
    this.serviceId = this.formItem.service.id;
}

After these modifications, we can edit a plugin that does not have a service :

image

From my side, this modification works well, thank you for this tool which greatly facilitates the configuration of Kong. 👍

lukasa1993 commented 3 years ago

please this is deal breaker