-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
8 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ColumnData>) { | ||
columns.add( | ||
'gdpr', | ||
{ | ||
name: app.translator.trans('flarum-gdpr.admin.userlist.columns.gdpr_actions.title'), | ||
content: (user: User) => { | ||
return <div className="gdprActions">{this.gdprActions(user).toArray()}</div>; | ||
}, | ||
}, | ||
50 | ||
extend(UserListPage.prototype, 'userActionItems', function (items, user) { | ||
if (!user.canModerateExports()) return; | ||
items.add( | ||
'export-data', | ||
<Button className="Button" icon="fas fa-file-export" onclick={() => app.modal.show(RequestDataExportModal, { user: user })}> | ||
{app.translator.trans('flarum-gdpr.admin.userlist.columns.gdpr_actions.export', { username: username(user) })} | ||
</Button> | ||
); | ||
}); | ||
|
||
UserListPage.prototype.gdprActions = function (user: User): ItemList<Mithril.Children> { | ||
const items = new ItemList<Mithril.Children>(); | ||
|
||
if (user.canModerateExports()) { | ||
items.add( | ||
'export-data', | ||
<Tooltip text={app.translator.trans('flarum-gdpr.admin.userlist.columns.gdpr_actions.export', { username: username(user) })}> | ||
<Button className="Button Button--icon" icon="fas fa-file-export" onclick={() => app.modal.show(RequestDataExportModal, { user: user })} /> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
return items; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters