From 4a99fc433780601ca4359b1a48b0a117be2e5b18 Mon Sep 17 00:00:00 2001 From: IanM Date: Sun, 3 Nov 2024 09:31:54 +0000 Subject: [PATCH] chore: use UserList userActionItems --- composer.json | 2 +- js/src/admin/extendUserListPage.tsx | 47 +++++------------------------ resources/locale/en.yml | 1 - 3 files changed, 8 insertions(+), 42 deletions(-) diff --git a/composer.json b/composer.json index 6e7578e..f95222a 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "require": { "php": "8.*", - "flarum/core": "^1.8.3", + "flarum/core": "^1.8.6", "nelexa/zip": "^4.0.2" }, "autoload": { diff --git a/js/src/admin/extendUserListPage.tsx b/js/src/admin/extendUserListPage.tsx index 139aa68..4dd8dcc 100644 --- a/js/src/admin/extendUserListPage.tsx +++ b/js/src/admin/extendUserListPage.tsx @@ -1,51 +1,18 @@ import app from 'flarum/admin/app'; import { extend } from 'flarum/common/extend'; import UserListPage from 'flarum/admin/components/UserListPage'; -import ItemList from 'flarum/common/utils/ItemList'; -import User from 'flarum/common/models/User'; -import Tooltip from 'flarum/common/components/Tooltip'; import Button from 'flarum/common/components/Button'; -import type Mithril from 'mithril'; import username from 'flarum/common/helpers/username'; import RequestDataExportModal from '../common/components/RequestDataExportModal'; -type ColumnData = { - /** - * Column title - */ - name: Mithril.Children; - /** - * Component(s) to show for this column. - */ - content: (user: User) => Mithril.Children; -}; - export default function extendUserListPage() { - extend(UserListPage.prototype, 'columns', function (columns: ItemList) { - columns.add( - 'gdpr', - { - name: app.translator.trans('flarum-gdpr.admin.userlist.columns.gdpr_actions.title'), - content: (user: User) => { - return
{this.gdprActions(user).toArray()}
; - }, - }, - 50 + extend(UserListPage.prototype, 'userActionItems', function (items, user) { + if (!user.canModerateExports()) return; + items.add( + 'export-data', + ); }); - - UserListPage.prototype.gdprActions = function (user: User): ItemList { - const items = new ItemList(); - - if (user.canModerateExports()) { - items.add( - 'export-data', - -