Bug 29787

Summary: Add plugin version to plugin search results
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Plugin architectureAssignee: Tomás Cohen Arazi <tomascohen>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrewfh, jonathan.druart+koha, kyle, martin.renvoize, nick
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24631
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30367
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.05
Attachments: Bug 29787: Add plugin version to plugin search results
Bug 29787: Add plugin version to plugin search results
Bug 29787: Add plugin version to plugin search results

Description Tomás Cohen Arazi 2022-01-04 13:57:00 UTC
When you search for a plugin it doesn't tell which version it is going to install.
Additionally, it would be great if instead of just an 'install' button, they mutated to 'upgrade' or 'reinstall' if that applies. Otherwise you don't know what's going on.
Comment 1 Tomás Cohen Arazi 2022-01-04 13:58:48 UTC
I haven't checked if it is actually possible with the gitlab/github APIs. Just reporting this needs improvement.
Comment 2 Tomás Cohen Arazi 2022-01-10 12:11:16 UTC
Created attachment 129250 [details] [review]
Bug 29787: Add plugin version to plugin search results

This patch adds a new column to plugins search results: 'Latest
version'.

It takes the tag_name in both GitHub and GitLab cases and passes it to
the template.

To test:
1. Have this on your koha-conf.xml file:

 <plugin_repos>
    <repo>
        <name>ByWater Solutions</name>
        <org_name>bywatersolutions</org_name>
        <service>github</service>
    </repo>
    <repo>
        <name>Theke Solutions</name>
        <org_name>thekesolutions</org_name>
        <service>gitlab</service>
    </repo>
    <repo>
        <name>PTFS Europe</name>
        <org_name>ptfs-europe</org_name>
        <service>github</service>
    </repo>
 </plugin_repos>

2. Restart all services:
   $ restart_all
3. Search for the term 'barclaycard'
=> SUCCESS: You get results from PTFS Europe (Github)
=> FAIL: They don't include plugin version
4. Search for the term 'innreach'
=> SUCCESS: You get results from Theke (Gitlab)
=> FAIL: They don't include plugin version
5. Apply this patch
6. Repeat 2-4
=> SUCCESS: Results show up
=> SUCCESS: Results include the plugin version
7. Sign off :-D
Comment 3 Tomás Cohen Arazi 2022-01-10 12:13:36 UTC
I didn't go as far as including the upgrade button, because we need more information about the plugins to be able to do that. In particular, we don't store the plugin 'name' (as in koha-plugin-kitchensink) anywhere, and the same for the plugin URL. So if there are overlaps between vendors/devs things could get messy.

Kyle and I are thinking about it, and will submit a different bug for that.
Comment 4 Martin Renvoize 2022-01-18 08:21:02 UTC
This is where I was hoping bug 24631 would end up.. but not just for version.. but also name, description, compatibility etc.
Comment 5 Owen Leonard 2022-01-20 12:41:18 UTC
Created attachment 129649 [details] [review]
Bug 29787: Add plugin version to plugin search results

This patch adds a new column to plugins search results: 'Latest
version'.

It takes the tag_name in both GitHub and GitLab cases and passes it to
the template.

To test:
1. Have this on your koha-conf.xml file:

 <plugin_repos>
    <repo>
        <name>ByWater Solutions</name>
        <org_name>bywatersolutions</org_name>
        <service>github</service>
    </repo>
    <repo>
        <name>Theke Solutions</name>
        <org_name>thekesolutions</org_name>
        <service>gitlab</service>
    </repo>
    <repo>
        <name>PTFS Europe</name>
        <org_name>ptfs-europe</org_name>
        <service>github</service>
    </repo>
 </plugin_repos>

2. Restart all services:
   $ restart_all
3. Search for the term 'barclaycard'
=> SUCCESS: You get results from PTFS Europe (Github)
=> FAIL: They don't include plugin version
4. Search for the term 'innreach'
=> SUCCESS: You get results from Theke (Gitlab)
=> FAIL: They don't include plugin version
5. Apply this patch
6. Repeat 2-4
=> SUCCESS: Results show up
=> SUCCESS: Results include the plugin version
7. Sign off :-D

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Katrin Fischer 2022-03-26 23:47:55 UTC
I've followed the steps of the test plan and I quite like it - I hadn't seen the 'search for plugins' feature yet!

But following the test plan also lead me to an issue:

1) Search for barclaycard

malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/JSON.pm line 190

2) Search for innreach
Results show nicely

3) Search for gibberish
No results show as expected.

4) Search for patron
Get a longer result list as expected.

So we are really close!

I assume 1) could be a problem with this specific plugin, but can we catch the problem in a better way so we don't explode?
Comment 7 Katrin Fischer 2022-03-26 23:51:53 UTC
Ok, I realize, this is an error before and after the patch... so no blocker.

I've filed a new bug: 
Bug 30367 - Plugins: Search explodes in error when searching for specific keywords
Comment 8 Katrin Fischer 2022-03-26 23:53:23 UTC
Created attachment 132266 [details] [review]
Bug 29787: Add plugin version to plugin search results

This patch adds a new column to plugins search results: 'Latest
version'.

It takes the tag_name in both GitHub and GitLab cases and passes it to
the template.

To test:
1. Have this on your koha-conf.xml file:

 <plugin_repos>
    <repo>
        <name>ByWater Solutions</name>
        <org_name>bywatersolutions</org_name>
        <service>github</service>
    </repo>
    <repo>
        <name>Theke Solutions</name>
        <org_name>thekesolutions</org_name>
        <service>gitlab</service>
    </repo>
    <repo>
        <name>PTFS Europe</name>
        <org_name>ptfs-europe</org_name>
        <service>github</service>
    </repo>
 </plugin_repos>

2. Restart all services:
   $ restart_all
3. Search for the term 'barclaycard'
=> SUCCESS: You get results from PTFS Europe (Github)
=> FAIL: They don't include plugin version
4. Search for the term 'innreach'
=> SUCCESS: You get results from Theke (Gitlab)
=> FAIL: They don't include plugin version
5. Apply this patch
6. Repeat 2-4
=> SUCCESS: Results show up
=> SUCCESS: Results include the plugin version
7. Sign off :-D

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Tomás Cohen Arazi 2022-03-27 11:21:32 UTC
Maybe GitHub API changed. ByWater and PTFS both are on GitHub while Theke's is on Gitlab.
Comment 10 Fridolin Somers 2022-04-08 13:53:03 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 11 Kyle M Hall 2022-04-15 10:37:02 UTC
Pushed to 21.11.x for 21.11.05
Comment 12 Andrew Fuerste-Henry 2022-04-25 18:39:22 UTC
not backported to 21.05