ChRIS_store_ui icon indicating copy to clipboard operation
ChRIS_store_ui copied to clipboard

Sorting of plugin search results

Open jennydaman opened this issue 3 years ago • 7 comments

https://github.com/FNNDSC/ChRIS_store_ui/blob/ca45de40784ddb979445252c3d71c05bc3699b50/src/components/Plugins/Plugins.js#L218

Some sorts could be:

  • alphabetical, by author
  • alphabetical, by name
  • chronological, by date created

jennydaman avatar Apr 11 '21 14:04 jennydaman

Can I work on this one @jennydaman?

sonylomo avatar Apr 11 '21 14:04 sonylomo

conflict @jennydaman, I'm trying to resolve conflicts but my code isn't passing these 2 tests. I didn't change any code related to them. I've checking what's wrong and updated my branch to be inline with the master before fixing plugin sort.

I've also checked if the "mark as favorite" functionality on plugins store website is working but it's not - was it working before?

sonylomo avatar Apr 13 '21 08:04 sonylomo

Try these commands:

git remote add upstream [email protected]:FNNDSC/ChRIS_store_ui.git
git fetch upstream
git diff upstream/master

I found the bug:

diff --git a/src/components/Plugins/Plugins.js b/src/components/Plugins/Plugins.js
index a157f49..e5e2b45 100755
--- a/src/components/Plugins/Plugins.js
+++ b/src/components/Plugins/Plugins.js
@@ -113,20 +114,23 @@ export class Plugins extends Component {
     }
   }

-  fetchPlugins = () => {
-    const params = new URLSearchParams(window.location.search)
-    const name = params.get('q') //get value searched from the URL
+  fetchPlugins() {
+    const params = new URLSearchParams(window.location.search);
+    const name = params.get("q"); //get value searched from the URL
+
     const searchParams = {
       limit: 20,
       offset: 0,
       name_title_category:name,
-    };
+    }
+

Notice the declaration of fetchPlugins was changed. This is an oddity with syntax. If a function is defined as fetchPlugins() {, this will be undefined unless you manually "bind" it.

jennydaman avatar Apr 13 '21 20:04 jennydaman

Notice the declaration of fetchPlugins was changed. This is an oddity with syntax. If a function is defined as fetchPlugins() {, this will be undefined unless you manually "bind" it.

Thanks for that @jennydaman. What about the starsByPlugin test?

sonylomo avatar Apr 13 '21 20:04 sonylomo

@sonylomo all tests are passing on https://github.com/sonylomo/ChRIS_store_ui/commit/b154b309e04425a781d0a8f59aa033f665388d45

jennydaman avatar Apr 14 '21 17:04 jennydaman

Yeah, I spotted the problem with the tests. Everything is ok now.

sonylomo avatar Apr 15 '21 07:04 sonylomo

I've closed the other PR because I deleted that forked repo 😁.

sonylomo avatar Apr 17 '21 06:04 sonylomo