Skip to content

Commit

Permalink
Merge branch 'master' into resource-types
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell authored Sep 4, 2024
2 parents 9156578 + 8139d44 commit 155ee48
Show file tree
Hide file tree
Showing 43 changed files with 6,038 additions and 407 deletions.
71 changes: 8 additions & 63 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,66 +26,11 @@ on:
default: "Manual trigger"

jobs:
Tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.9, 3.12]
db-service: [postgresql14]
search-service: [opensearch2]
node-version: [18.x, 20.x]
include:
- db-service: postgresql14
DB_EXTRAS: "postgresql"

- search-service: opensearch2
SEARCH_EXTRAS: "opensearch2"

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

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.cfg

- name: Install dependencies
run: |
pip install ".[$EXTRAS]"
pip freeze
docker version
- name: Run backend tests
run: ./run-tests.sh

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

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

- name: Run translations test
run: ./run-i18n-tests.sh

- name: Install deps for frontend tests
working-directory: ./invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records
run: npm install

- name: Install deps for frontend tests - translations
working-directory: ./invenio_rdm_records/assets/semantic-ui/translations/invenio_rdm_records
run: npm install

- name: Run frontend tests
working-directory: ./invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records
run: npm test
Python:
uses: inveniosoftware/workflows/.github/workflows/tests-python.yml@master

JS:
uses: inveniosoftware/workflows/.github/workflows/tests-js.yml@master
with:
js-working-directory: ./invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records
translations-working-directory: ./invenio_rdm_records/assets/semantic-ui/translations/invenio_rdm_records
4 changes: 2 additions & 2 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type = PO
# $ npm run compile_catalog lang <lang>

[o:inveniosoftware:p:invenio:r:invenio-rdm-records-messages-ui]
file_filter = invenio-rdm-records/assets/semantic-ui/translations/invenio-rdm-records/messages/<lang>/messages.po
source_file = invenio-rdm-records/assets/semantic-ui/translations/invenio-rdm-records/translations.pot
file_filter = invenio_rdm_records/assets/semantic-ui/translations/invenio_rdm_records/messages/<lang>/messages.po
source_file = invenio_rdm_records/assets/semantic-ui/translations/invenio_rdm_records/translations.pot
source_lang = en
type = PO
41 changes: 40 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

..
Copyright (C) 2019-2024 CERN.
Copyright (C) 2019 Northwestern University.
Copyright (C) 2019-2024 Northwestern University.

Invenio-RDM-Records is free software; you can redistribute it and/or
Expand All @@ -11,6 +11,45 @@
Changes
=======

Version v12.1.0 (released 2024-08-30)

- config: added links for thumbnails (#1799)

Version v12.0.4 (released 2024-08-28)

- stats: add missing "is_machine" field

Version v12.0.3 (released 2024-08-27)

- add permissions checks for community submission policy

Version v12.0.2 (released 2024-08-26)

- update file quota and size vars
- add quota config for media_files bucket

Version v12.0.1 (released 2024-08-22)

- bump invenio-vocabularies

Version v12.0.0 (released 2024-08-22)

- mappings: add analyzers and filters to improve results when searching records

Version v11.8.0 (released 2024-08-21)

- pids: fix parent DOI link generation
- schemaorg: add ``dateCreated`` field (closes #1777)
- i18n: push translations
- package: bump react-invenio-forms
- subjects: remove suggest from dropdown if not required
* closes https://github.com/inveniosoftware/invenio-app-rdm/issues/2767

Version v11.7.0 (released 2024-08-12)

- resources: add vnd.inveniordm.v1+json http header
- translation: update file paths for strings (UI)

Version v11.6.0 (released 2024-08-07)

- creatibutors: fix buttons order
Expand Down
4 changes: 2 additions & 2 deletions invenio_rdm_records/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019-2024 CERN.
# Copyright (C) 2019-2022 Northwestern University.
# Copyright (C) 2019-2024 Northwestern University.
#
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -10,6 +10,6 @@

from .ext import InvenioRDMRecords

__version__ = "11.6.0"
__version__ = "12.1.0"

__all__ = ("__version__", "InvenioRDMRecords")
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"coveralls": "^3.0.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.0",
"enzyme-to-json": "^3.4.0",
"expect": "^26.0.0",
"formik": "^2.1.0",
"i18next": "^20.3.0",
Expand Down Expand Up @@ -59,10 +58,5 @@
"tinymce": "^6.7.2",
"typescript": "^4.9.5",
"yup": "^0.32.11"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class DepositFileApiClient {
withCredentials: true,
xsrfCookieName: "csrftoken",
xsrfHeaderName: "X-CSRFToken",
headers: this.apiHeaders.json,
headers: this.apiHeaders["vnd+json"],
};
this.axiosWithConfig = axios.create(apiConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ export const CommunityListItem = ({ result, record, isInitialSubmission }) => {
const userMembership = userCommunitiesMemberships[result["id"]];
const invalidPermissionLevel =
record.access.record === "public" && result.access.visibility === "restricted";
const canSubmitRecord = result.ui.permissions.can_submit_record;
const hasTheme = get(result, "theme.enabled");
const dedicatedUpload = isInitialSubmission && hasTheme;
const isDisabled = invalidPermissionLevel || dedicatedUpload;
const isDisabled = invalidPermissionLevel || dedicatedUpload || !canSubmitRecord;
const actions = (
<>
{invalidPermissionLevel && (
Expand All @@ -45,6 +46,21 @@ export const CommunityListItem = ({ result, record, isInitialSubmission }) => {
)}
/>
)}
{!canSubmitRecord && (
<InvenioPopup
popupId="community-inclusion-info-popup"
size="small"
trigger={
<Icon className="mb-5" color="grey" name="question circle outline" />
}
ariaLabel={i18next.t(
"Submission to this community is only allowed to community members."
)}
content={i18next.t(
"Submission to this community is only allowed to community members."
)}
/>
)}
{dedicatedUpload && (
<>
<InvenioPopup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,29 @@ class PublishButtonComponent extends Component {
this.closeConfirmModal();
};

isDisabled = (values, isSubmitting, numberOfFiles) => {
isDisabled = (values, isSubmitting, filesState) => {
if (isSubmitting) {
return true;
}

const filesEnabled = _get(values, "files.enabled", false);
const filesMissing = filesEnabled && !numberOfFiles;
return isSubmitting || filesMissing;
const filesArray = Object.values(filesState.entries ?? {});
const filesMissing = filesEnabled && filesArray.length === 0;

if (filesMissing) {
return true;
}

// All files must be finished uploading
const allCompleted = filesArray.every((file) => file.status === "finished");

return !allCompleted;
};

render() {
const {
actionState,
numberOfFiles,
filesState,
buttonLabel,
publishWithoutCommunity,
formik,
Expand All @@ -64,7 +77,7 @@ class PublishButtonComponent extends Component {
return (
<>
<Button
disabled={this.isDisabled(values, isSubmitting, numberOfFiles)}
disabled={this.isDisabled(values, isSubmitting, filesState)}
name="publish"
onClick={this.openConfirmModal}
positive
Expand Down Expand Up @@ -123,22 +136,23 @@ PublishButtonComponent.propTypes = {
buttonLabel: PropTypes.string,
publishWithoutCommunity: PropTypes.bool,
actionState: PropTypes.string,
numberOfFiles: PropTypes.number.isRequired,
formik: PropTypes.object.isRequired,
publishModalExtraContent: PropTypes.string,
filesState: PropTypes.object,
};

PublishButtonComponent.defaultProps = {
buttonLabel: i18next.t("Publish"),
publishWithoutCommunity: false,
actionState: undefined,
publishModalExtraContent: undefined,
filesState: undefined,
};

const mapStateToProps = (state) => ({
actionState: state.deposit.actionState,
numberOfFiles: Object.values(state.files.entries).length,
publishModalExtraContent: state.deposit.config.publish_modal_extra,
filesState: state.files,
});

export const PublishButton = connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,26 @@ class SubmitReviewButtonComponent extends Component {
this.closeConfirmModal();
};

isDisabled = (numberOfFiles, disableSubmitForReviewButton) => {
isDisabled = (disableSubmitForReviewButton, filesState) => {
const { formik } = this.props;
const { values, isSubmitting } = formik;

if (disableSubmitForReviewButton || isSubmitting) {
return true;
}

const filesEnabled = _get(values, "files.enabled", false);
const filesMissing = filesEnabled && !numberOfFiles;
return isSubmitting || filesMissing || disableSubmitForReviewButton;
const filesArray = Object.values(filesState.entries ?? {});
const filesMissing = filesEnabled && filesArray.length === 0;

if (filesMissing) {
return true;
}

// All files must be finished uploading
const allCompleted = filesArray.every((file) => file.status === "finished");

return !allCompleted;
};

render() {
Expand All @@ -59,8 +72,8 @@ class SubmitReviewButtonComponent extends Component {
directPublish,
formik,
isRecordSubmittedForReview,
numberOfFiles,
publishModalExtraContent,
filesState,
...ui
} = this.props;

Expand All @@ -80,7 +93,7 @@ class SubmitReviewButtonComponent extends Component {
return (
<>
<Button
disabled={this.isDisabled(numberOfFiles, disableSubmitForReviewButton)}
disabled={this.isDisabled(disableSubmitForReviewButton, filesState)}
name="SubmitReview"
onClick={this.openConfirmModal}
positive={directPublish}
Expand Down Expand Up @@ -112,20 +125,20 @@ SubmitReviewButtonComponent.propTypes = {
actionState: PropTypes.string,
actionStateExtra: PropTypes.object.isRequired,
community: PropTypes.object.isRequired,
numberOfFiles: PropTypes.number,
disableSubmitForReviewButton: PropTypes.bool,
isRecordSubmittedForReview: PropTypes.bool.isRequired,
directPublish: PropTypes.bool,
formik: PropTypes.object.isRequired,
publishModalExtraContent: PropTypes.string,
filesState: PropTypes.object,
};

SubmitReviewButtonComponent.defaultProps = {
actionState: undefined,
numberOfFiles: undefined,
disableSubmitForReviewButton: undefined,
publishModalExtraContent: undefined,
directPublish: false,
filesState: undefined,
};

const mapStateToProps = (state) => ({
Expand All @@ -135,8 +148,8 @@ const mapStateToProps = (state) => ({
isRecordSubmittedForReview: state.deposit.record.status === DepositStatus.IN_REVIEW,
disableSubmitForReviewButton:
state.deposit.editorState.ui.disableSubmitForReviewButton,
numberOfFiles: Object.values(state.files.entries).length,
publishModalExtraContent: state.deposit.config.publish_modal_extra,
filesState: state.files,
});

export const SubmitReviewButton = connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AffiliationsField extends Component {
fieldPath={fieldPath}
suggestionAPIUrl="/api/affiliations"
suggestionAPIHeaders={{
Accept: "application/json",
Accept: "application/vnd.inveniordm.v1+json",
}}
initialSuggestions={getIn(values, fieldPath, [])}
serializeSuggestions={this.serializeAffiliations}
Expand Down
Loading

0 comments on commit 155ee48

Please sign in to comment.