Skip to content

Commit

Permalink
Merge branch 'master' into Dependency-Update
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 authored Apr 19, 2024
2 parents 17df435 + aba410f commit ec2e4aa
Show file tree
Hide file tree
Showing 33 changed files with 396 additions and 234 deletions.
33 changes: 12 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
# Copyright (C) 2020-2024 CERN.
# Copyright (C) 2022 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,60 +30,51 @@ jobs:
Tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
requirements-level: [pypi]
python-version: ['3.9', '3.10', '3.11', '3.12']
db-service: [postgresql14]
search-service: [opensearch2, elasticsearch7]
node-version: [16.x]
node-version: [18.x, 20.x]
include:
- search-service: opensearch2
SEARCH_EXTRAS: "opensearch2"
- search-service: elasticsearch7
SEARCH_EXTRAS: "elasticsearch7"

env:
DB: ${{ matrix.db-service }}
SEARCH: ${{ matrix.search-service }}
EXTRAS: tests,${{ matrix.SEARCH_EXTRAS }}

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Run eslint test
run: ./run-js-linter.sh -i

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Generate dependencies
run: |
pip install wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
cache: pip
cache-dependency-path: setup.cfg

- name: Install dependencies
run: |
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
pip install ".[$EXTRAS]"
pip freeze
docker --version
docker-compose --version
- name: Run tests
run: |
./run-tests.sh
run: ./run-tests.sh

- name: Install deps for frontend tests
working-directory: ./invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies
Expand Down
25 changes: 24 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
..
Copyright (C) 2020-2023 CERN.
Copyright (C) 2020-2024 CERN.
Invenio-Vocabularies is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
Expand All @@ -8,6 +8,29 @@
Changes
=======

Version 3.3.0 (released 2024-04-16)

- assets: add overridable awards and funding

Version 3.2.0 (released 2024-03-22)

- funding: add country and ror to funder search results
- init: move record_once to finalize_app (removes deprecation on `before_first_request`)
- installation: upgrade invenio-app


Version 3.1.0 (released 2024-03-05)

- custom_fields: added subject field
- custom_fields: add pid_field to custom fields
- mappings: change "dynamic" values to string
- ci: upgrade tests matrix
- bumps react-invenio-forms

Version 3.0.0 (released 2024-01-30)

- installation: bump invenio-records-resources

Version 2.4.0 (2023-12-07)

- schema: add validation for affiliations
Expand Down
4 changes: 2 additions & 2 deletions invenio_vocabularies/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2023 CERN.
# Copyright (C) 2020-2024 CERN.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
Expand All @@ -10,6 +10,6 @@

from .ext import InvenioVocabularies

__version__ = "2.4.0"
__version__ = "3.3.0"

__all__ = ("__version__", "InvenioVocabularies")
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,32 @@ import { TextField, RemoteSelectField } from "react-invenio-forms";
import { i18next } from "@translations/invenio_rdm_records/i18next";
import _isEmpty from "lodash/isEmpty";

import Overridable from "react-overridable";

function CustomAwardForm({ deserializeFunder, selectedFunding }) {
function deserializeFunderToDropdown(funderItem) {
let funderName = null;
let funderPID = null;
let funderCountry = null;

if (funderItem.name) {
funderName = funderItem.name;
}

if (funderItem.pid) {
funderPID = funderItem.pid;
if (funderItem.id) {
funderPID = funderItem.id;
}

if (funderItem.country) {
funderCountry = funderItem.country;
}

if (!funderName && !funderPID) {
return {};
}

return {
text: funderName || funderPID,
text: [funderName, funderCountry, funderPID].filter((val) => val).join(", "),
value: funderItem.id,
key: funderItem.id,
...(funderName && { name: funderName }),
Expand All @@ -48,64 +55,85 @@ function CustomAwardForm({ deserializeFunder, selectedFunding }) {

return (
<Form>
<RemoteSelectField
<Overridable
id="InvenioVocabularies.CustomAwardForm.RemoteSelectField.Container"
fieldPath="selectedFunding.funder.id"
suggestionAPIUrl="/api/funders"
suggestionAPIHeaders={{
Accept: "application/vnd.inveniordm.v1+json",
}}
placeholder={i18next.t("Search for a funder by name")}
serializeSuggestions={(funders) => {
return funders.map((funder) =>
deserializeFunderToDropdown(deserializeFunder(funder))
);
}}
searchInput={{
autoFocus: _isEmpty(selectedFunding),
}}
label={i18next.t("Funder")}
noQueryMessage={i18next.t("Search for funder...")}
clearable
allowAdditions={false}
multiple={false}
selectOnBlur={false}
selectOnNavigation={false}
required
search={(options) => options}
isFocused
onValueChange={({ formikProps }, selectedFundersArray) => {
if (selectedFundersArray.length === 1) {
const selectedFunder = selectedFundersArray[0];
if (selectedFunder) {
const deserializedFunder = serializeFunderFromDropdown(selectedFunder);
formikProps.form.setFieldValue(
"selectedFunding.funder",
deserializedFunder
);
>
<RemoteSelectField
fieldPath="selectedFunding.funder.id"
suggestionAPIUrl="/api/funders"
suggestionAPIHeaders={{
Accept: "application/vnd.inveniordm.v1+json",
}}
placeholder={i18next.t("Search for a funder by name")}
serializeSuggestions={(funders) => {
return funders.map((funder) =>
deserializeFunderToDropdown(deserializeFunder(funder))
);
}}
searchInput={{
autoFocus: _isEmpty(selectedFunding),
}}
label={i18next.t("Funder")}
noQueryMessage={i18next.t("Search for funder...")}
clearable
allowAdditions={false}
multiple={false}
selectOnBlur={false}
selectOnNavigation={false}
required
search={(options) => options}
isFocused
onValueChange={({ formikProps }, selectedFundersArray) => {
if (selectedFundersArray.length === 1) {
const selectedFunder = selectedFundersArray[0];
if (selectedFunder) {
const deserializedFunder = serializeFunderFromDropdown(selectedFunder);
formikProps.form.setFieldValue(
"selectedFunding.funder",
deserializedFunder
);
}
}
}
}}
/>

<Header as="h3" size="small">
{i18next.t("Award information")} ({i18next.t("optional")})
</Header>
}}
/>
</Overridable>
<Overridable id="InvenioVocabularies.CustomAwardForm.AwardInformationHeader.Container">
<Header as="h3" size="small">
{i18next.t("Award information")} ({i18next.t("optional")})
</Header>
</Overridable>
<Form.Group widths="equal">
<TextField
label={i18next.t("Number")}
placeholder={i18next.t("Award number")}
<Overridable
id="InvenioVocabularies.CustomAwardForm.AwardNumberTextField.Container"
fieldPath="selectedFunding.award.number"
/>
<TextField
label={i18next.t("Title")}
placeholder={i18next.t("Award Title")}
>
<TextField
label={i18next.t("Number")}
placeholder={i18next.t("Award number")}
fieldPath="selectedFunding.award.number"
/>
</Overridable>
<Overridable
id="InvenioVocabularies.CustomAwardForm.AwardTitleTextField.Container"
fieldPath="selectedFunding.award.title"
/>
<TextField
label={i18next.t("URL")}
placeholder={i18next.t("Award URL")}
>
<TextField
label={i18next.t("Title")}
placeholder={i18next.t("Award Title")}
fieldPath="selectedFunding.award.title"
/>
</Overridable>
<Overridable
id="InvenioVocabularies.CustomAwardForm.AwardUrlTextField.Container"
fieldPath="selectedFunding.award.url"
/>
>
<TextField
label={i18next.t("URL")}
placeholder={i18next.t("Award URL")}
fieldPath="selectedFunding.award.url"
/>
</Overridable>
</Form.Group>
</Form>
);
Expand Down
Loading

0 comments on commit ec2e4aa

Please sign in to comment.