Skip to content

Commit

Permalink
ui: refactored and generalized OrganizationsList
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Nov 29, 2024
1 parent 95ab2b5 commit be062d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ const OrganizationsList = ({ organizations }) => {
<i className="building outline icon" aria-hidden="true" />
{organizations[0].id ? (
<a
href={`https://ror.org/${organizations[0].id}`}
aria-label={`${organizations[0].name}'s ROR profile`}
title={`${organizations[0].name}'s ROR profile`}
href={organizations[0].url}
aria-label={`${organizations[0].name}'s ${organizations[0].label} profile`}
title={`${organizations[0].name}'s ${organizations[0].label} profile`}
target="_blank"
rel="noreferrer"
>
{organizations[0].name}
<span>&nbsp;</span>
<img
className="inline-id-icon"
src="/static/images/ror-icon.svg"
alt={`${organizations[0].name}'s ROR profile`}
src={organizations[0].icon}
alt={`${organizations[0].name}'s ${organizations[0].label} profile`}
/>
</a>
) : (
Expand All @@ -50,18 +50,18 @@ const OrganizationsList = ({ organizations }) => {
<div key={org.id || org.name} className="inline-computer mt-5">
{org.id ? (
<a
href={`https://ror.org/${org.id}`}
aria-label={`${org.name}'s ROR profile`}
title={`${org.name}'s ROR profile`}
href={org.url}
aria-label={`${org.name}'s ${org.label} profile`}
title={`${org.name}'s ${org.label} profile`}
target="_blank"
rel="noreferrer"
>
{org.name}
<span>&nbsp;</span>
<img
className="inline-id-icon"
src="/static/images/ror-icon.svg"
alt={`${organizations[0].name}'s ROR profile`}
src={org.icon}
alt={`${org.name}'s ${org.label} profile`}
/>
</a>
) : (
Expand Down Expand Up @@ -89,6 +89,9 @@ OrganizationsList.propTypes = {
PropTypes.shape({
id: PropTypes.string,
name: PropTypes.string.isRequired,
label: PropTypes.string,
icon: PropTypes.string,
url: PropTypes.string,
})
).isRequired,
};
Expand Down
2 changes: 1 addition & 1 deletion invenio_communities/communities/resources/ui_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_organizations(self, obj):
organizations = obj.get("metadata", {}).get("organizations", [])

for org in organizations:
if org["identifiers"]:
if "id" in org:
scheme = detect_identifier_schemes(org["id"])[0]
org["icon"] = f"/static/images/{scheme}-icon.svg"
org["url"] = to_url(org["id"], scheme)
Expand Down

0 comments on commit be062d5

Please sign in to comment.