Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resultList: add extra information #341

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Grid,
Header,
Icon,
Card,

Check warning on line 18 in assets/js/components/communities_carousel/overrides/CommunitiesCarousel.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.9, postgresql14, opensearch2, redis, rabbitmq, 18)

'Card' is defined but never used

Check warning on line 18 in assets/js/components/communities_carousel/overrides/CommunitiesCarousel.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.12, postgresql14, opensearch2, redis, rabbitmq, 18)

'Card' is defined but never used
} from "semantic-ui-react";
import _isEmpty from "lodash/isEmpty";

Expand Down Expand Up @@ -74,7 +74,7 @@
>
<Transition.Group
duration={animationSpeed}
visible={true}
visible
animation={`fade ${animationDirection}`}
>
<div className="ui three cards flex">{carouselSlides}</div>
Expand Down Expand Up @@ -118,5 +118,5 @@
stopCarousel: PropTypes.func.isRequired,
startCarousel: PropTypes.func.isRequired,
runCarousel: PropTypes.func.isRequired,
itemsPerPage: PropTypes.number.isRequired
itemsPerPage: PropTypes.number.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@
isOrganization,
idString,
makeSubheader,
makeIdEntry
makeIdEntry,
}) => {
const CDSmakeIdEntry = (creatibutor) => {
const { department, group, section } = creatibutor.props || {};

Check warning on line 19 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.9, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment

Check warning on line 19 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.12, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment
const workgroup = [department, group, section].filter(Boolean).join("-");
return (
<span className="font-weight-normal" key={creatibutor.props.email}>

Check warning on line 22 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.9, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment

Check warning on line 22 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.12, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment
<Image
src="/static/images/cern-favicon.ico"
className="inline-id-icon ml-5 mr-5"
verticalAlign="middle"
/>
{creatibutor.props.email}

Check warning on line 28 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.9, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment

Check warning on line 28 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.12, postgresql14, opensearch2, redis, rabbitmq, 18)

Must use destructuring creatibutor assignment
{workgroup && (
<Label size="tiny">
{workgroup}
</Label>
)}
{workgroup && <Label size="tiny">{workgroup}</Label>}
</span>
);
};
Expand All @@ -52,7 +48,7 @@

return (
<Header color={isUnlisted ? "grey" : ""}>
{name} {CDSidString.length > 0 && <>{CDSidString}</>}

Check warning on line 51 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.9, postgresql14, opensearch2, redis, rabbitmq, 18)

Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all

Check warning on line 51 in assets/js/components/deposit/overrides/CDSAffiliationsSuggestions.js

View workflow job for this annotation

GitHub Actions / Tests (site, 3.12, postgresql14, opensearch2, redis, rabbitmq, 18)

Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all
{subheader.length > 0 && <Header.Subheader>{subheader}</Header.Subheader>}
</Header>
);
Expand All @@ -68,4 +64,4 @@

CDSAffiliationsSuggestions.defaultProps = {
idString: [],
};
};
12 changes: 12 additions & 0 deletions assets/js/components/frontpage/overrides/RecordsResultsListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ const ResultHeader = ({
);
};

ResultHeader.propTypes = {
result: PropTypes.object.isRequired,
accessStatusId: PropTypes.string.isRequired,
accessStatus: PropTypes.string.isRequired,
accessStatusIcon: PropTypes.string.isRequired,
publicationDate: PropTypes.string.isRequired,
resourceType: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
version: PropTypes.object.isRequired,
community: PropTypes.object.isRequired,
};

export const CDSRecordsResultsListItem = ({
result,
accessStatusId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// This file is part of CDS RDM
// Copyright (C) 2025 CERN.
//
// CDS 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 _get from "lodash/get";
import PropTypes from "prop-types";
import React from "react";
import { Item } from "semantic-ui-react";

export const CDSRecordsResultsListItemDescription = ({
result,
descriptionStripped,
}) => {
const getMetadataField = (path) => _get(result, path, []);

const cdsReferenceId = getMetadataField("metadata.identifiers").find(
(id) => id.scheme === "cds_ref"
)?.identifier;

const experiments = getMetadataField("custom_fields.cern:experiments").map(
(exp) => exp.title.en
);
const accelerators = getMetadataField("custom_fields.cern:accelerators").map(
(acc) => acc.title.en
);

const hasMetaData =
cdsReferenceId || accelerators.length > 0 || experiments.length > 0;
const referenceOrAccelerators = cdsReferenceId || accelerators.length > 0;
return (
<>
<Item.Description className="truncate-lines-2">
{descriptionStripped}
</Item.Description>

{hasMetaData && (
<Item.Meta className="pt-20">
{cdsReferenceId && <span className="mr-5">{cdsReferenceId}</span>}
{accelerators.length > 0 && (
<>
{cdsReferenceId && <span className="ml- mr-5">|</span>}
<span className={cdsReferenceId ? "ml-5 mr-5" : "mr-5"}>
Accelerators: {accelerators.join(", ")}
</span>
</>
)}
{experiments.length > 0 && (
<>
{referenceOrAccelerators && <span className="ml-5 mr-5">|</span>}
<span className={referenceOrAccelerators ? "ml-5 mr-5" : "mr-5"}>
Experiments: {experiments.join(", ")}
</span>
</>
)}
</Item.Meta>
)}
</>
);
};

CDSRecordsResultsListItemDescription.propTypes = {
result: PropTypes.object.isRequired,
descriptionStripped: PropTypes.string.isRequired,
};
4 changes: 3 additions & 1 deletion assets/js/invenio_app_rdm/overridableRegistry/mapping.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BasicCERNInformation } from "../../components/deposit/BasicInformation";
import { CDSCarouselItem } from "../../components/communities_carousel/overrides/CarouselItem";
import { CDSCommunitiesCarousel } from "../../components/communities_carousel/overrides/CommunitiesCarousel";
import { CDSRecordsList } from "../../components/frontpage/overrides/RecordsList";
import { CDSRecordsResultsListItem } from "../../components/frontpage/overrides/RecordsResultsListItem";
import { CDSRecordsResultsListItemDescription } from "../../components/search/overrides/CDSRecordsResultsListItemDescription";
import { CDSAffiliationsSuggestions } from "../../components/deposit/overrides/CDSAffiliationsSuggestions";

export const overriddenComponents = {
Expand All @@ -15,4 +15,6 @@ export const overriddenComponents = {
"InvenioAppRdm.Deposit.CustomFields.container": () => null,
"ReactInvenioForms.AffiliationsSuggestions.content":
CDSAffiliationsSuggestions,
"InvenioAppRdm.Search.RecordsResultsListItem.description":
CDSRecordsResultsListItemDescription,
};
2 changes: 1 addition & 1 deletion run-js-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ for arg in $@; do
done

printf "${GREEN}Run eslint${NC}\n"
npx eslint --no-error-on-unmatched-pattern -c .eslintrc.yml site/**/*.js
npx eslint --no-error-on-unmatched-pattern -c .eslintrc.yml site/**/*.js assets/**/*.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot!

Loading