Skip to content

Commit

Permalink
Merge branch 'inveniosoftware:master' into creatibutor-modal-overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloeppe authored Dec 16, 2024
2 parents 4034570 + 938b7cf commit 6de73c4
Show file tree
Hide file tree
Showing 34 changed files with 1,054 additions and 94 deletions.
48 changes: 48 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,54 @@
Changes
=======

Version v16.5.0 (released 2024-12-16)

- pids: add support for optional DOI

Version v16.4.1 (released 2024-12-11)

- mappings: add missing `identifiers` to community orgs
* Adds the missing `identifiers` mapping field to community organizations

Version v16.4.0 (released 2024-12-10)

- bibtex: add trailing comma in url field
- community-records: allow scan search
* Adds `scan` and `scan_params` arguments to
`CommunityRecordsService.search(...)`, to allow for serving scan
results (but only via the service).
- serializer: updated subjects and affiliations in dcat
- schema: added identifiers to subjects
- serializers: add datapackage serializer (#1742)

Version v16.3.4 (released 2024-12-06)

- github: return None for `NOASSERTION` license
- datacite: fix funding serialization for optional award fields
* Makes sure that we handle missing values for optional award fields
like "title" and "number".

Version v16.3.3 (released 2024-12-04)

- github: handle missing repo license

Version v16.3.2 (released 2024-12-04)

- github: lower license spdx id

Version v16.3.1 (released 2024-12-02)

- deposit-ui: make sure we handle null/undefined for SchemaField
- deposit-ui: skip unecessary removal of empty values in serialization
* This initial removal of empty values can be dangerous, since the
`record` at this point is a UI object representation that could
potentially include circular references or very deeply nested objects.
Since `_removeEmptyValues` is recursive this can lead to stack
overflow errors.
- deposit-ui: log errors on all deposit form actions
* This can help with debugging unexpected non-network related errors
that might occur in the logic before/after a REST API requests.

Version v16.3.0 (released 2024-11-27)

- github: added default license from Github API
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

from .ext import InvenioRDMRecords

__version__ = "16.3.0"
__version__ = "16.5.0"

__all__ = ("__version__", "InvenioRDMRecords")
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ export class RDMDepositApiClient extends DepositApiClient {
);
return new DepositApiClientResponse(data, errors);
} catch (error) {
const errorData = error.response.data;
let errorData = error.response.data;
const errors = this.recordSerializer.deserializeErrors(
error.response.data.errors || []
);
// this is to serialize raised error from the backend on publish
if (errors) errorData = errors;
throw new DepositApiClientResponse({}, errorData);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class RDMDepositRecordSerializer extends DepositRecordSerializer {
*
*/
serialize(record) {
// NOTE: cloning nows allows us to manipulate the copy with impunity without
// NOTE: cloning now allows us to manipulate the copy with impunity without
// affecting the original
let originalRecord = _pick(_cloneDeep(record), [
"access",
Expand All @@ -400,8 +400,7 @@ export class RDMDepositRecordSerializer extends DepositRecordSerializer {
// Save pids so they are not removed when an empty value is passed
let savedPIDsFieldValue = originalRecord.pids || {};

let serializedRecord = this._removeEmptyValues(originalRecord);

let serializedRecord = originalRecord;
for (let key in this.depositRecordSchema) {
serializedRecord = this.depositRecordSchema[key].serialize(
serializedRecord,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
DepositFormSubmitContext,
} from "../../api/DepositFormSubmitContext";
import { DRAFT_PUBLISH_STARTED } from "../../state/types";
import { scrollTop } from "../../utils";
import { DRAFT_PUBLISH_FAILED_WITH_VALIDATION_ERRORS } from "../../state/types";

class PublishButtonComponent extends Component {
state = { isConfirmModalOpen: false };
Expand All @@ -30,14 +32,36 @@ class PublishButtonComponent extends Component {

handlePublish = (event, handleSubmit, publishWithoutCommunity) => {
const { setSubmitContext } = this.context;

setSubmitContext(
publishWithoutCommunity
? DepositFormSubmitActions.PUBLISH_WITHOUT_COMMUNITY
: DepositFormSubmitActions.PUBLISH
);
handleSubmit(event);
this.closeConfirmModal();
const { formik, raiseDOINeededButNotReserved, isDOIRequired } = this.props;
const noINeedOne = formik?.values?.noINeedOne;
// Check for explicit DOI reservation via the "GET DOI button" only when DOI is
// optional in the instance's settings. If it is required, backend will automatically
// mint one even if it was not explicitly reserved
const shouldCheckForExplicitDOIReservation =
isDOIRequired !== undefined && // isDOIRequired is undefined when no value was provided from Invenio-app-rdm
!isDOIRequired &&
noINeedOne &&
Object.keys(formik?.values?.pids).length === 0;
if (shouldCheckForExplicitDOIReservation) {
const errors = {
pids: {
doi: i18next.t("DOI is needed. Please click on the button to reserve it."),
},
};
formik.setErrors(errors);
raiseDOINeededButNotReserved(formik?.values, errors);
this.closeConfirmModal();
} else {
setSubmitContext(
publishWithoutCommunity
? DepositFormSubmitActions.PUBLISH_WITHOUT_COMMUNITY
: DepositFormSubmitActions.PUBLISH
);
handleSubmit(event);
this.closeConfirmModal();
}
// scroll top to show the global error
scrollTop();
};

isDisabled = (values, isSubmitting, filesState) => {
Expand Down Expand Up @@ -67,6 +91,7 @@ class PublishButtonComponent extends Component {
publishWithoutCommunity,
formik,
publishModalExtraContent,
raiseDOINeededButNotReserved,
...ui
} = this.props;
const { isConfirmModalOpen } = this.state;
Expand Down Expand Up @@ -139,6 +164,8 @@ PublishButtonComponent.propTypes = {
formik: PropTypes.object.isRequired,
publishModalExtraContent: PropTypes.string,
filesState: PropTypes.object,
raiseDOINeededButNotReserved: PropTypes.func.isRequired,
isDOIRequired: PropTypes.bool,
};

PublishButtonComponent.defaultProps = {
Expand All @@ -147,15 +174,22 @@ PublishButtonComponent.defaultProps = {
actionState: undefined,
publishModalExtraContent: undefined,
filesState: undefined,
isDOIRequired: undefined,
};

const mapStateToProps = (state) => ({
actionState: state.deposit.actionState,
publishModalExtraContent: state.deposit.config.publish_modal_extra,
filesState: state.files,
isDOIRequired: state.deposit.config.is_doi_required,
});

export const PublishButton = connect(
mapStateToProps,
null
)(connectFormik(PublishButtonComponent));
export const PublishButton = connect(mapStateToProps, (dispatch) => {
return {
raiseDOINeededButNotReserved: (data, errors) =>
dispatch({
type: DRAFT_PUBLISH_FAILED_WITH_VALIDATION_ERRORS,
payload: { data: data, errors: errors },
}),
};
})(connectFormik(PublishButtonComponent));
Loading

0 comments on commit 6de73c4

Please sign in to comment.