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 72eaed4b93..584f290bc9 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 @@ -53,18 +53,18 @@ export const MobileCommunitiesItem = ({ result, index }) => { )} - + - + ); 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 ec3250d816..916ea6f11c 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, @@ -190,18 +190,18 @@ export function RequestsResultsItemTemplateDashboard({ result, index }) { } else if (isCreatorCommunity) { creatorName = result.expanded?.created_by.metadata?.title || createdBy.community; } - const ComputerTabletRequestsItemsWithState = withState(ComputerTabletRequestsItems); - const MobileRequestsItemsWithState = withState(MobileRequestsItems); + const ComputerTabletRequestsItemWithState = withState(ComputerTabletRequestsItem); + const MobileRequestsItemWithState = withState(MobileRequestsItem); return ( <> - - { - const accessStatusId = _get(result, "ui.access_status.id", "open"); - const accessStatus = _get(result, "ui.access_status.title_l10n", "Open"); - const accessStatusIcon = _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 descriptionStripped = _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 resourceType = _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 isPublished = result.is_published; - - // Derivatives const editRecord = () => { axiosWithconfig .post(`/api/records/${result.id}/draft`) @@ -88,78 +49,21 @@ export const RDMRecordResultsListItem = ({ result, index }) => { }); }; - const viewLink = isPublished ? `/records/${result.id}` : `/uploads/${result.id}`; return ( - -
- - - {isPublished ? ( - - ) : ( - - )} - - -
- - - {/* For reduced spacing between labels. */} - {result.status in statuses && result.status !== "published" && ( - - )} - - - - - {isPublished && ( - - )} - - - {title} - - -
- -
-
- - {_truncate(descriptionStripped, { - length: 350, - })} - - - {subjects.map((subject) => ( - - ))} - {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..43c8fbf1da --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/ComputerTabletUploadsItem.js @@ -0,0 +1,131 @@ +// 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"; +import PropTypes from "prop-types"; + +export const ComputerTabletUploadsItem = ({ result, index, editRecord, statuses }) => { + const accessStatusId = _get(result, "ui.access_status.id", i18next.t("open")); + const accessStatus = _get(result, "ui.access_status.title_l10n", i18next.t("Open")); + const accessStatusIcon = _get(result, "ui.access_status.icon", i18next.t("unlock")); + const descriptionStripped = _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 publicationDate = _get( + result, + "ui.publication_date_l10n_long", + i18next.t("No publication date found.") + ); + const resourceType = _get( + result, + "ui.resource_type.title_l10n", + i18next.t("No resource type") + ); + const createdDate = result.ui?.created_date_l10n_long; + const version = result.ui?.version ?? ""; + const isPublished = result.is_published; + + const viewLink = isPublished ? `/records/${result.id}` : `/uploads/${result.id}`; + const icon = isPublished ? ( + + ) : ( + + ); + + return ( + +
+ + {icon} + +
+ + + {result.status in statuses && result.status !== "published" && ( + + )} + + + + + {isPublished && ( + + )} + + + + {title} + + + +
+ +
+
+ + {_truncate(descriptionStripped, { + length: 350, + })} + + + {subjects.map((subject) => ( + + ))} +
+ {} + + {createdDate ? ( + <> + {i18next.t("Uploaded on")} {createdDate} + + ) : ( + i18next.t("No creation date found.") + )} + +
+
+
+
+ ); +}; + +ComputerTabletUploadsItem.propTypes = { + result: PropTypes.object.isRequired, + index: PropTypes.string, + editRecord: PropTypes.string.isRequired, + statuses: PropTypes.bool.isRequired, +}; + +ComputerTabletUploadsItem.defaultProps = { + index: null, +}; 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..b9b9fc8126 --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/MobileUploadsItem.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"; +import PropTypes from "prop-types"; + +export const MobileUploadsItem = ({ result, index, editRecord, statuses }) => { + const accessStatusId = _get(result, "ui.access_status.id", i18next.t("open")); + const accessStatus = _get(result, "ui.access_status.title_l10n", i18next.t("Open")); + const accessStatusIcon = _get(result, "ui.access_status.icon", i18next.t("unlock")); + const descriptionStripped = _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 publicationDate = _get( + result, + "ui.publication_date_l10n_long", + i18next.t("No publication date found.") + ); + const resourceType = _get( + result, + "ui.resource_type.title_l10n", + i18next.t("No resource type") + ); + const createdDate = result.ui?.created_date_l10n_long; + const version = result.ui?.version ?? ""; + const isPublished = result.is_published; + + const viewLink = isPublished ? `/records/${result.id}` : `/uploads/${result.id}`; + const icon = isPublished ? ( + + ) : ( + + ); + + return ( + + + + {result.status in statuses && result.status !== "published" && ( + + )} + + + + + + + {icon} + {title} + + + +
+ +
+
+ + {_truncate(descriptionStripped, { + length: 100, + })} + + + + {subjects.map((subject) => ( + + ))} +
+ {} + + {createdDate ? ( + <> + {i18next.t("Uploaded on")} {createdDate} + + ) : ( + i18next.t("No creation date found.") + )} + +
+
+
+ + + {isPublished && ( + + )} + +
+
+ ); +}; + +MobileUploadsItem.propTypes = { + result: PropTypes.object.isRequired, + index: PropTypes.string, + editRecord: PropTypes.string.isRequired, + statuses: PropTypes.bool.isRequired, +}; + +MobileUploadsItem.defaultProps = { + index: null, +}; 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 c31e4cd5ce..c2382e24b6 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,10 @@ const apiConfig = { export const axiosWithconfig = axios.create(apiConfig); -export function SearchItemCreators({ creators }) { +export function SearchItemCreators({ creators, className }) { + let spanClass = "creatibutor-wrap separated"; + className && (spanClass += ` ${className}`); + function makeIcon(scheme, identifier, name) { let link = null; let linkTitle = null; @@ -51,17 +54,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;