GMOD / Apollo3

JBrowse 2 plugin for editing annotations on an Apollo server
Apache License 2.0
7 stars 4 forks source link

Connect user management UI to backend #149

Closed garrettjstevens closed 1 year ago

garrettjstevens commented 2 years ago

To fetch user info, you will query the /users endpoint. A good place to reference for this sort of thing is packages/jbrowse-plugin-apollo/src/components/index.ts, which has a useAssemblies hook that queries the /assemblies endpoint.

Before you can fetch the user info, you'll have to add it to the db (make sure you're using the latest main branch). In the MongoDB extension of VS Code, you can right-click on the connection and select "Launch MongoDB Shell". Then in the shell execute these commands to load a couple users:

use apolloDb
db.users.insertOne({ _id: '632d5d1025e16ef49ce75667', id: 1, email: 'demo@ebi.ac.uk', role: 'readOnly', username: 'demo' })
db.users.insertOne({ _id: '632d5d9625e16ef49ce75669', username: 'john', id: 2, email: 'pomo@ebi.ac.uk', role: ['user'] })

To update user information, you'll want to create a class that extends the Change class. The logic for changing the user info in the db will be in the applyToServer method. This change will be added in packages/apollo-shared/src/ChangeManager/ (and added to the exports in packages/apollo-shared/src/ChangeManager/index.ts), and you can look at the other changes there for examples.

The change will be submitted to the changeManager, and an example of that can be found in packages/jbrowse-plugin-apollo/src/components/AddAssembly.tsx.

haessar commented 2 years ago

Pushed some changes to branch 142. I can see the request to /users endpoint is working and successfully getting the two dummy users I added to db, but struggling to get them into the rows of the datagrid. Through debugging in the browser, I can see the problematic lines are the following: image (lines 40-41 of ManageUsers.tsx), where rows are always being initialised as empty even when users is populated. I'll fix it tomorrow morning (I'm sure it's a simple tweak), then spend some time integrating changes to it.

haessar commented 2 years ago

I've bulked out all the changeManager infrastructure for the ManageUsers panel. The async function onChangeTableCell is correctly triggering when changing the role dropdown value, and the params from onCellEditCommit contains the necessary information to apply the change, but for some reason I continue to see the message Uncaught (in promise) TypeError: changeManager is undefined in the browser console. I'm not getting any linting issues, and I've added it to ManageUsersProps etc in the same way as seen in AddAssembly.tsx, so I'm a bit stumped

haessar commented 2 years ago

On another note, the requirement for an assemblyId in all Change class descendants feels a bit redundant with User model changes (as assemblies don't come into it). Is it worth making a parallel Change class that duplicates the functionality of the original Change class without that parameter, or should that parameter requirement be moved to a child of the Change class?

haessar commented 2 years ago

I also assumed i'd need to define the dto / entity stuff as they are tied to update/create/destroy endpoints elsewhere.

garrettjstevens commented 1 year ago

Probably best to continue this discussion in the PR thread

garrettjstevens commented 1 year ago

Done in #146