Skip to content

Commit dcc8682

Browse files
0einstein0slint
authored andcommitted
ui: refactored and generalized OrganizationsList
1 parent c89500a commit dcc8682

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

invenio_communities/assets/semantic-ui/js/invenio_communities/organizations/OrganizationsList.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ const OrganizationsList = ({ organizations }) => {
1515
<i className="building outline icon" aria-hidden="true" />
1616
{organizations[0].id ? (
1717
<a
18-
href={`https://ror.org/${organizations[0].id}`}
19-
aria-label={`${organizations[0].name}'s ROR profile`}
20-
title={`${organizations[0].name}'s ROR profile`}
18+
href={organizations[0].url}
19+
aria-label={`${organizations[0].name}'s ${organizations[0].label} profile`}
20+
title={`${organizations[0].name}'s ${organizations[0].label} profile`}
2121
target="_blank"
2222
rel="noreferrer"
2323
>
2424
{organizations[0].name}
2525
<span>&nbsp;</span>
2626
<img
2727
className="inline-id-icon"
28-
src="/static/images/ror-icon.svg"
29-
alt={`${organizations[0].name}'s ROR profile`}
28+
src={organizations[0].icon}
29+
alt={`${organizations[0].name}'s ${organizations[0].label} profile`}
3030
/>
3131
</a>
3232
) : (
@@ -50,18 +50,18 @@ const OrganizationsList = ({ organizations }) => {
5050
<div key={org.id || org.name} className="inline-computer mt-5">
5151
{org.id ? (
5252
<a
53-
href={`https://ror.org/${org.id}`}
54-
aria-label={`${org.name}'s ROR profile`}
55-
title={`${org.name}'s ROR profile`}
53+
href={org.url}
54+
aria-label={`${org.name}'s ${org.label} profile`}
55+
title={`${org.name}'s ${org.label} profile`}
5656
target="_blank"
5757
rel="noreferrer"
5858
>
5959
{org.name}
6060
<span>&nbsp;</span>
6161
<img
6262
className="inline-id-icon"
63-
src="/static/images/ror-icon.svg"
64-
alt={`${organizations[0].name}'s ROR profile`}
63+
src={org.icon}
64+
alt={`${org.name}'s ${org.label} profile`}
6565
/>
6666
</a>
6767
) : (
@@ -89,6 +89,9 @@ OrganizationsList.propTypes = {
8989
PropTypes.shape({
9090
id: PropTypes.string,
9191
name: PropTypes.string.isRequired,
92+
label: PropTypes.string,
93+
icon: PropTypes.string,
94+
url: PropTypes.string,
9295
})
9396
).isRequired,
9497
};

invenio_communities/communities/resources/ui_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_organizations(self, obj):
118118
organizations = obj.get("metadata", {}).get("organizations", [])
119119

120120
for org in organizations:
121-
if org["identifiers"]:
121+
if "id" in org:
122122
scheme = detect_identifier_schemes(org["id"])[0]
123123
org["icon"] = f"/static/images/{scheme}-icon.svg"
124124
org["url"] = to_url(org["id"], scheme)

0 commit comments

Comments
 (0)