From 9f48bfb98e82489d609098272831f950aa4cbdd0 Mon Sep 17 00:00:00 2001 From: Sam Arbid Date: Thu, 27 Jun 2024 14:54:05 +0200 Subject: [PATCH] moderation: fix admin links generation * Update SearchResultItemLayout.js to use adminLinks for admin links --- .../users/search/SearchResultItemLayout.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/users/search/SearchResultItemLayout.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/users/search/SearchResultItemLayout.js index 4a742a12c..526cc5420 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/users/search/SearchResultItemLayout.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/users/search/SearchResultItemLayout.js @@ -1,6 +1,7 @@ /* * This file is part of Invenio. * Copyright (C) 2022-2024 CERN. + * Copyright (C) 2024 KTH Royal Institute of Technology. * * Invenio is free software; you can redistribute it and/or modify it * under the terms of the MIT License; see LICENSE file for more details. @@ -22,8 +23,18 @@ class SearchResultItemComponent extends Component { updateQueryState(currentQueryState); }; + buildAdminLinks = (userId) => { + const baseQuery = `parent.access.owned_by.user:${userId}`; + return { + admin_records_html: `/administration/records?q=${baseQuery}&f=allversions`, + admin_drafts_html: `/administration/drafts?q=${baseQuery}&f=allversions`, + admin_moderation_html: `/administration/moderation?q=topic.user:${userId}`, + }; + }; + render() { const { result, idKeyPath, listUIEndpoint } = this.props; + const adminLinks = this.buildAdminLinks(result.id); return ( @@ -153,15 +164,15 @@ class SearchResultItemComponent extends Component { (window.location = result.links.admin_records_html)} + onClick={() => (window.location = adminLinks.admin_records_html)} /> (window.location = result.links.admin_drafts_html)} + onClick={() => (window.location = adminLinks.admin_drafts_html)} /> (window.location = result.links.admin_moderation_html)} + onClick={() => (window.location = adminLinks.admin_moderation_html)} />