diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities_items/MobileCommunitiesItem.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities_items/MobileCommunitiesItem.js index 3c22abfc6a..9a946ff5a1 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities_items/MobileCommunitiesItem.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities_items/MobileCommunitiesItem.js @@ -59,18 +59,18 @@ export const MobileCommunitiesItem = ({ result, index }) => { )} - + {i18next.t("Edit")} - + ); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js index 7a4da64039..cd5655e59b 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js @@ -61,8 +61,8 @@ import { SearchHelpLinks, } from "../search/components"; import { timestampToRelativeTime } from "../utils"; -import { ComputerTabletRequestsItems } from "./requests_items/ComputerTabletRequestsItems"; -import { MobileRequestsItems } from "./requests_items/MobileRequestsItems"; +import { ComputerTabletRequestsItem } from "./requests_items/ComputerTabletRequestsItem"; +import { MobileRequestsItem } from "./requests_items/MobileRequestsItem"; export const RequestsResults = ({ sortOptions, @@ -182,20 +182,20 @@ export function RequestsResultsItemTemplateDashboard({ result, index }) { creatorName = result.expanded?.created_by.metadata?.title || createdBy.community; } - const ComputerTabletRequestsItemsWithState = withState( - ComputerTabletRequestsItems + const ComputerTabletRequestsItemWithState = withState( + ComputerTabletRequestsItem ); - const MobileRequestsItemsWithState = withState(MobileRequestsItems); + const MobileRequestsItemWithState = withState(MobileRequestsItem); return ( <> - - ( -) +); const CommunityInvitation = () => ( -) +); const Submitted = () => ( -) +); const Deleted = () => ( -) +); const Accepted = () => ( -) +); const Declined = () => ( -) +); const Cancelled = () => ( -) +); const Expired = () => ( -) +); export const defaultComponents = { "BucketAggregation.element": RDMBucketAggregationElement, diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItems.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItem.js similarity index 98% rename from invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItems.js rename to invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItem.js index cc1e47dd8e..a611e0a86f 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItems.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/ComputerTabletRequestsItem.js @@ -14,7 +14,7 @@ import { RequestActionController } from "@js/invenio_requests/request/actions/Re import { Icon, Item } from "semantic-ui-react"; import { RightBottomLabel } from "@js/invenio_communities/requests/requests_items/RightBottomLabel"; -export const ComputerTabletRequestsItems = ({ +export const ComputerTabletRequestsItem = ({ result, index, differenceInDays, diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItems.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItem.js similarity index 98% rename from invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItems.js rename to invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItem.js index fbe91323ba..328f9ec7b5 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItems.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests_items/MobileRequestsItem.js @@ -14,7 +14,7 @@ import { RequestActionController } from "@js/invenio_requests/request/actions/Re import { Icon, Item } from "semantic-ui-react"; import { RightBottomLabel } from "@js/invenio_communities/requests/requests_items/RightBottomLabel"; -export const MobileRequestsItems = ({ +export const MobileRequestsItem = ({ result, index, differenceInDays, diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js index 7359b7ba81..4ef21b8cdd 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js @@ -10,18 +10,8 @@ import { i18next } from "@translations/invenio_app_rdm/i18next"; import _get from "lodash/get"; import _truncate from "lodash/truncate"; -import React, { useState } from "react"; -import { - Button, - Card, - Divider, - Header, - Icon, - Item, - Label, - Modal, - Segment, -} from "semantic-ui-react"; +import React from "react"; +import { Button, Card, Divider, Header, Segment } from "semantic-ui-react"; import { RDMBucketAggregationElement, RDMCountComponent, @@ -31,9 +21,11 @@ import { RDMRecordSearchBarElement, RDMToggleComponent, } from "../search/components"; -import { axiosWithconfig, SearchItemCreators } from "../utils"; +import { axiosWithconfig } from "../utils"; import { DashboardResultView, DashboardSearchLayoutHOC } from "./base"; import { createSearchAppInit } from "@js/invenio_search_ui"; +import { ComputerTabletUploadsItem } from "./uploads_items/ComputerTabletUploadsItem"; +import { MobileUploadsItem } from "./uploads_items/MobileUploadsItem"; const statuses = { in_review: { color: "yellow", title: i18next.t("In review") }, @@ -45,38 +37,6 @@ const statuses = { }; export const RDMRecordResultsListItem = ({ result, index }) => { - const access_status_id = _get(result, "ui.access_status.id", "open"); - const access_status = _get(result, "ui.access_status.title_l10n", "Open"); - const access_status_icon = _get(result, "ui.access_status.icon", "unlock"); - const createdDate = _get( - result, - "ui.created_date_l10n_long", - i18next.t("No creation date found.") - ); - const creators = _get(result, "ui.creators.creators", []).slice(0, 3); - - const description_stripped = _get( - result, - "ui.description_stripped", - i18next.t("No description") - ); - - const publicationDate = _get( - result, - "ui.publication_date_l10n_long", - i18next.t("No publication date found.") - ); - const resource_type = _get( - result, - "ui.resource_type.title_l10n", - i18next.t("No resource type") - ); - const title = _get(result, "metadata.title", i18next.t("No title")); - const subjects = _get(result, "ui.subjects", []); - const version = _get(result, "ui.version", null); - const is_published = result.is_published; - - // Derivatives const editRecord = () => { axiosWithconfig .post(`/api/records/${result.id}/draft`) @@ -88,87 +48,21 @@ export const RDMRecordResultsListItem = ({ result, index }) => { }); }; - const viewLink = is_published - ? `/records/${result.id}` - : `/uploads/${result.id}`; return ( - - - - - {is_published ? ( - - ) : ( - - )} - - - - - - {/* For reduced spacing between labels. */} - {result.status in statuses && result.status !== "published" && ( - - {statuses[result.status].title} - - )} - - {publicationDate} ({version}) - - - {resource_type} - - - {access_status_icon && ( - - )} - {access_status} - - editRecord()} - > - - {i18next.t("Edit")} - - {is_published && ( - - - {i18next.t("View")} - - )} - - - {title} - - - - - - - - {_truncate(description_stripped, { - length: 350, - })} - - - {subjects.map((subject, index) => ( - - {subject.title_l10n} - - ))} - {createdDate && ( - - - {i18next.t("Uploaded on")} {createdDate} - - - )} - - - + <> + + + > ); }; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/ComputerTabletUploadsItem.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/ComputerTabletUploadsItem.js new file mode 100644 index 0000000000..f16234f1b3 --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/ComputerTabletUploadsItem.js @@ -0,0 +1,143 @@ +// This file is part of InvenioRDM +// Copyright (C) 2022 CERN. +// +// Invenio App RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { i18next } from "@translations/invenio_app_rdm/i18next"; +import _get from "lodash/get"; +import _truncate from "lodash/truncate"; +import React from "react"; +import { Button, Icon, Item, Label } from "semantic-ui-react"; +import { SearchItemCreators } from "../../utils"; + +export const ComputerTabletUploadsItem = ({ + result, + index, + editRecord, + statuses, +}) => { + const access_status_id = _get( + result, + "ui.access_status.id", + i18next.t("open") + ); + const access_status = _get( + result, + "ui.access_status.title_l10n", + i18next.t("Open") + ); + const access_status_icon = _get( + result, + "ui.access_status.icon", + i18next.t("unlock") + ); + const description_stripped = _get( + result, + "ui.description_stripped", + i18next.t("No description") + ); + const title = _get(result, "metadata.title", i18next.t("No title")); + const creators = _get(result, "ui.creators.creators", []).slice(0, 3); + const subjects = _get(result, "ui.subjects", []); + const createdDate = _get( + result, + "ui.created_date_l10n_long", + i18next.t("No creation date found.") + ); + const publicationDate = _get( + result, + "ui.publication_date_l10n_long", + i18next.t("No publication date found.") + ); + const resource_type = _get( + result, + "ui.resource_type.title_l10n", + i18next.t("No resource type") + ); + const version = result.ui?.version; + const is_published = result.is_published; + + const viewLink = is_published + ? `/records/${result.id}` + : `/uploads/${result.id}`; + const icon = is_published ? ( + + ) : ( + + ); + + return ( + + + + {icon} + + + + + {result.status in statuses && result.status !== "published" && ( + + {statuses[result.status].title} + + )} + + {publicationDate} ({version}) + + + {resource_type} + + + + {access_status} + + editRecord()} + > + + {i18next.t("Edit")} + + {is_published && ( + + + {i18next.t("View")} + + )} + + + + {title} + + + + + + + + + {_truncate(description_stripped, { + length: 350, + })} + + + {subjects.map((subject, index) => ( + + {subject.title_l10n} + + ))} + + + {i18next.t("Uploaded on")} {createdDate} + + + + + + ); +}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/MobileUploadsItem.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/MobileUploadsItem.js new file mode 100644 index 0000000000..0e243152c2 --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/MobileUploadsItem.js @@ -0,0 +1,145 @@ +// This file is part of InvenioRDM +// Copyright (C) 2022 CERN. +// +// Invenio App RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { i18next } from "@translations/invenio_app_rdm/i18next"; +import _get from "lodash/get"; +import _truncate from "lodash/truncate"; +import React from "react"; +import { Button, Icon, Item, Label } from "semantic-ui-react"; +import { SearchItemCreators } from "../../utils"; + +export const MobileUploadsItem = ({ result, index, editRecord, statuses }) => { + const access_status_id = _get( + result, + "ui.access_status.id", + i18next.t("open") + ); + const access_status = _get( + result, + "ui.access_status.title_l10n", + i18next.t("Open") + ); + const access_status_icon = _get( + result, + "ui.access_status.icon", + i18next.t("unlock") + ); + const description_stripped = _get( + result, + "ui.description_stripped", + i18next.t("No description") + ); + const title = _get(result, "metadata.title", i18next.t("No title")); + const creators = _get(result, "ui.creators.creators", []).slice(0, 3); + const subjects = _get(result, "ui.subjects", []); + const createdDate = _get( + result, + "ui.created_date_l10n_long", + i18next.t("No creation date found.") + ); + const publicationDate = _get( + result, + "ui.publication_date_l10n_long", + i18next.t("No publication date found.") + ); + const resource_type = _get( + result, + "ui.resource_type.title_l10n", + i18next.t("No resource type") + ); + const version = result.ui?.version; + const is_published = result.is_published; + + const viewLink = is_published + ? `/records/${result.id}` + : `/uploads/${result.id}`; + const icon = is_published ? ( + + ) : ( + + ); + + return ( + + + + {result.status in statuses && result.status !== "published" && ( + + {statuses[result.status].title} + + )} + + {publicationDate} ({version}) + + + {resource_type} + + + + {access_status} + + + + + {icon} + {title} + + + + + + + + + {_truncate(description_stripped, { + length: 100, + })} + + + + {subjects.map((subject, index) => ( + + {subject.title_l10n} + + ))} + + + {i18next.t("Uploaded on")} {createdDate} + + + + + + editRecord()} + className="fluid-responsive" + > + + {i18next.t("Edit")} + + {is_published && ( + + + {i18next.t("View")} + + )} + + + + ); +}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/utils.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/utils.js index 0d9e9b36f6..d77bd3014d 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/utils.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/utils.js @@ -43,7 +43,9 @@ const apiConfig = { export const axiosWithconfig = axios.create(apiConfig); -export function SearchItemCreators({ creators }) { +export function SearchItemCreators({ creators, className }) { + const spanClass = className ?? "creatibutor-wrap separated"; + function makeIcon(scheme, identifier, name) { let link = null; let linkTitle = null; @@ -51,17 +53,17 @@ export function SearchItemCreators({ creators }) { switch (scheme) { case "orcid": - link = "https://orcid.org/" + identifier; + link = `https://orcid.org/${identifier}`; linkTitle = i18next.t("ORCID profile"); icon = "/static/images/orcid.svg"; break; case "ror": - link = "https://ror.org/"+identifier; + link = `https://ror.org/${identifier}`; linkTitle = i18next.t("ROR profile"); icon = "/static/images/ror-icon.svg"; break; case "gnd": - link = "https://d-nb.info/gnd/"+identifier; + link = `https://d-nb.info/gnd/${identifier}`; linkTitle = i18next.t("GND profile"); icon = "/static/images/gnd-icon.svg"; break; @@ -71,26 +73,22 @@ export function SearchItemCreators({ creators }) { icon = ( - + - ) - return (icon); + ); + return icon; } function getIcons(creator) { let ids = _get(creator, "person_or_org.identifiers", []); let creatorName = _get(creator, "person_or_org.name", "No name"); - let icons = ids.map(c => makeIcon(c.scheme, c.identifier, creatorName)); + let icons = ids.map((c) => makeIcon(c.scheme, c.identifier, creatorName)); return icons; } @@ -108,7 +106,7 @@ export function SearchItemCreators({ creators }) { return link; } return creators.map((creator, index) => ( - + {getLink(creator)} {getIcons(creator)}