pressbooks / pressbooks-multi-institution

Tools for managing Pressbooks networks shared by multiple institutions
GNU General Public License v3.0
0 stars 1 forks source link

Build institutional user lists for institutional managers on open source networks #42

Open SteelWagstaff opened 9 months ago

SteelWagstaff commented 9 months ago

As an institutional manager on a self-hosted open source PB network (i.e. one without pressbooks-network-analytics), I should see a user list with information specific to my institution, instead of the full network user list.

See https://www.figma.com/file/hAvkPJpDgJDDyh8g358AqR/PB-Site-Adjustments?type=design&node-id=34-10298&mode=design&t=6NpK2f6ILNHepftM-0

This should look like the current user list, but with a new column called 'Institution'. As an institutional manager, I should only be presented with the users assigned to my institution. If I try to view the full network user list, I should see a 'you don't have permissions to do this' style message.

DoD:

  1. The default user list should have a new 'institution' column that displays when this plugin is active for all users
  2. When an institutional manager loads the user list, the list should only display information that is relevant to their institution
  3. Institutional managers should be able to use the search feature of the existing user list without special restrictions. Bulk actions should only affect users in their user list.
  4. Hide the super admins link on this list when the user is an institutional manager
  5. Change the link for both the book title and the edit links in the default users list so that they point to the book dashboard BOOKTITLE/wp-admin rather than wp-admin/network/site-info.php?id=765 Screenshot from 2024-02-14 15-41-04
richard015ar commented 7 months ago

I got a WIP PR: https://github.com/pressbooks/pressbooks-multi-institution/pull/159 Pending: add tests

richard015ar commented 7 months ago

@tw77 I got a PR with a working solution for this. I pushed it to ricardodev so you could do some early testing if you are willing to. An example of a testing case is described at https://github.com/pressbooks/pressbooks-multi-institution/pull/159

richard015ar commented 7 months ago

@MichelleWeremczuk please, feel free to provide feedback as needed in https://ricardodev.pressbooks.network about this feature. Example of testing case described in #159.

MichelleWeremczuk commented 7 months ago

Everything seems to be working as expected except for one thing:

I recognize that I might not have something set up properly on my system, or I might be looking at the wrong thing.

richard015ar commented 7 months ago

@MichelleWeremczuk good catch! it is in the last item. I'll work on it

richard015ar commented 7 months ago

WP does not provide an easy way to change/edit an existing column from the user list, despite it does for custom columns like institutions. We have the manage_users_custom_column hook to change/add values to custom columns, but this is only for the newly added columns.

An option I can see today is to override the WP_List_Table class for users, something like:

class wpUserListTable extends WP_Users_List_Table {
    // Override the column method for the blogs column
    function column_blogs( $item ) {
        return str_replace($item, ...); // replace links here
    }
}

I do not like this approach because it would require to do some tricky things like:

add_action('load-users.php', function() {
    $GLOBALS['wp_list_table'] = new wpUserListTable;
});

since WP does not provide a hook or something to override it.

I need to find a better way to make this column change.

tw77 commented 7 months ago

@richard015ar aside from the item Michelle pointed out, the only other issue I notice so far in early testing is that as an institutional manager, I'm not able to add a new user to the network from https://ricardodev.pressbooks.network/wp/wp-admin/network/user-new.php, which the 'Add New User' button in the user list links to

Screenshot 2024-04-18 at 12 34 35 PM Screenshot 2024-04-18 at 12 37 33 PM
richard015ar commented 7 months ago

It seems to be a pre-existing bug. In addition, as an IM I cannot add users either through the Add User button at the top bar on dev.pressbooks.network.

I'll work on both cases in the same PR.

richard015ar commented 7 months ago

On the topic of modifying the blogs column of WP_Users_List_Table, another alternative I will explore is to completely remove the column through wpmu_users_columns which is being used for adding the institutions' column in my branch and add in the same method a new custom column called books. Later on, I can use the manage_users_custom_column hook already used to add the institution values to add the books value.

I will try it on.

richard015ar commented 7 months ago

Another bug found is when the H5P Plugin is active at the root site level, the menu item is displayed for IMs during root site pages navigation. We should remove it.

richard015ar commented 7 months ago

I was able to:

Pending to fix:

Although we estimated this task as a 5, I consider I already spent 5 story points working on this. We decided to move this task to future sprints, so I will consider in our metrics that we spent 5 points, but I will estimate the remaining effort needed to be 3.