Skip to content

Commit 72f6110

Browse files
committed
landing_page: add manage button
* closes zenodo/rdm-project#262
1 parent 010c6af commit 72f6110

File tree

6 files changed

+61
-3
lines changed

6 files changed

+61
-3
lines changed

invenio_app_rdm/communities_ui/views/communities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def communities_detail(pid_value, community, community_ui):
1717
"""Community detail page."""
1818
permissions = community.has_permissions_to(
19-
["update", "read", "search_requests", "search_invites"]
19+
["update", "read", "search_requests", "search_invites", "manage_communities"]
2020
)
2121
endpoint = "/api/communities/{pid_value}/records"
2222

invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/details/side_bar/manage_menu.html

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
data-is-draft="{{ is_draft | tojson }}"
1818
data-is-preview-submission-request="{{ is_preview_submission_request | tojson }}"
1919
data-current-user-id="{{ current_user.id }}"
20+
data-record-owner-email='{{ record_owner_email }}'
2021
data-access-links-search-config='{{ search_app_access_links_config(app_id="InvenioAppRdm.AccessLinks", endpoint=record.links.access_links) | tojson }}'
2122
>
2223
<div class="ui placeholder">

invenio_app_rdm/records_ui/views/records.py

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def record_detail(
126126
pid_value, record, files, media_files, is_preview=False, include_deleted=False
127127
):
128128
"""Record detail page (aka landing page)."""
129+
record_owner = current_rdm_records.records_service.get_owner(pid_value)
129130
files_dict = None if files is None else files.to_dict()
130131
media_files_dict = None if media_files is None else media_files.to_dict()
131132
record_ui = UIJSONSerializer().dump_obj(record.to_dict())
@@ -191,6 +192,7 @@ def record_detail(
191192
is_draft=is_draft,
192193
community=resolved_community,
193194
external_resources=get_external_resources(record_ui),
195+
record_owner_email=record_owner.email,
194196
)
195197

196198

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is part of InvenioRDM
2+
// Copyright (C) 2021 Northwestern University.
3+
// Copyright (C) 2021 Graz University of Technology.
4+
//
5+
// Invenio RDM Records is free software; you can redistribute it and/or modify it
6+
// under the terms of the MIT License; see LICENSE file for more details.
7+
8+
import React from "react";
9+
import { Dropdown } from "semantic-ui-react";
10+
import { i18next } from "@translations/invenio_app_rdm/i18next";
11+
import PropTypes from "prop-types";
12+
13+
export const ManageButton = ({ recid, recordOwnerEmail }) => {
14+
return (
15+
<Dropdown
16+
fluid
17+
text={i18next.t("Manage")}
18+
icon="cog"
19+
floating
20+
labeled
21+
button
22+
className="icon text-align-center"
23+
>
24+
<Dropdown.Menu>
25+
<Dropdown.Item
26+
as="a"
27+
href={`/administration/records?q=id:${recid}`}
28+
target="_blank"
29+
key="manage_record"
30+
text={i18next.t("Manage record")}
31+
/>
32+
<Dropdown.Item
33+
as="a"
34+
href={`/administration/users?q=email:${recordOwnerEmail}`}
35+
target="_blank"
36+
key="manage_user"
37+
text={i18next.t("Manage user")}
38+
/>
39+
</Dropdown.Menu>
40+
</Dropdown>
41+
);
42+
};
43+
44+
ManageButton.propTypes = {
45+
recid: PropTypes.string.isRequired,
46+
recordOwnerEmail: PropTypes.string.isRequired,
47+
};

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordManagement.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ShareButton } from "./ShareOptions/ShareButton";
1515
import { NewVersionButton } from "@js/invenio_rdm_records/";
1616
import PropTypes from "prop-types";
1717
import Overridable from "react-overridable";
18+
import { ManageButton } from "./ManageButton";
1819

1920
export class RecordManagement extends Component {
2021
constructor(props) {
@@ -32,19 +33,24 @@ export class RecordManagement extends Component {
3233
isPreviewSubmissionRequest,
3334
currentUserId,
3435
accessLinksSearchConfig,
36+
recordOwnerEmail,
3537
} = this.props;
3638
const { error } = this.state;
3739
const { id: recid } = record;
38-
3940
const handleError = (errorMessage) => {
4041
console.error(errorMessage);
4142
this.setState({ error: errorMessage });
4243
};
4344

4445
return (
4546
<Grid columns={1} className="record-management">
46-
{permissions.can_edit && !isDraft && (
47+
{permissions.can_manage && (
4748
<Grid.Column className="pb-5">
49+
<ManageButton recid={recid} recordOwnerEmail={recordOwnerEmail} />
50+
</Grid.Column>
51+
)}
52+
{permissions.can_edit && !isDraft && (
53+
<Grid.Column className={permissions.can_manage ? "pb-5 pt-5" : "pb-5"}>
4854
<EditButton recid={recid} onError={handleError} />
4955
</Grid.Column>
5056
)}
@@ -111,5 +117,6 @@ RecordManagement.propTypes = {
111117
isDraft: PropTypes.bool.isRequired,
112118
isPreviewSubmissionRequest: PropTypes.bool.isRequired,
113119
currentUserId: PropTypes.string.isRequired,
120+
recordOwnerEmail: PropTypes.object.isRequired,
114121
accessLinksSearchConfig: PropTypes.object.isRequired,
115122
};

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function renderRecordManagement(element) {
4242
recordManagementAppDiv.dataset.isPreviewSubmissionRequest
4343
)}
4444
currentUserId={recordManagementAppDiv.dataset.currentUserId}
45+
recordOwnerEmail={recordManagementAppDiv.dataset.recordOwnerEmail}
4546
accessLinksSearchConfig={JSON.parse(
4647
recordManagementAppDiv.dataset.accessLinksSearchConfig
4748
)}

0 commit comments

Comments
 (0)