إضافة أعمدة جديدة إلى قوائم المستخدمين في المجموعات

Is it possible to add additional columns to the user lists in groups? I have a plugin that I’m attempting to add functionality to, which is adding a column to the users list in groups showing whether a user is Active, Suspended, Silenced, or Deactivated. It looks like the group-index Handlebars template and group-index controller is what I need to target for this, but there isn’t a plugin outlet so I’m wondering what the correct way of adding a new column would be, if that’s able to be done. I’m new to Discourse development so I could be missing something here, but would greatly appreciate any tips. I’ve read through these development guides which are great resources, but I’m currently stuck.

إعجاب واحد (1)

Hello, welcome to meta :wave:

You can use the group-index-table-header-after-username and group-index-table-row-after-username outlets to insert a header/row next to the username column.

For example:

For the header, you can use the TableHeaderToggle component.
For the row, you can use for example <div class="directory-table__cell directory-table__cell--status">{{this.args.member}} – you can access data with {{this.args.member}}

You will need to fix the grid CSS to include a new column.

.group-members--can-manage {
    grid-template-columns: 3fr repeat(5, minmax(min-content, 1fr)) 3em;
                                      ^
}

If you want to move the column, the positioning is a bit tricky because of display: contents; however, using order can work.

On a side note, you might have issues getting the user’s status. In my tests, the data was not reflected in member with a user suspended or silenced (silencedTillDate or suspendedTillDate are undefined). I’m not sure if there is a bug here. I did not dig up more, for now!

I hope that helps.

5 إعجابات

Great, thank you! This helps a lot. I’m realizing now that I wasn’t seeing the group-index-table-header-after-username and group-index-table-row-after-username outlets because the site is using an outdated version of Discourse (2.7).

إعجاب واحد (1)

You’re welcome!. 2.7! That’s quite old, indeed. :smile:

As a side note, I would highly encourage you to use this component: Plugin outlet locations theme component. Super useful! :+1:

4 إعجابات

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.