From 2b18ff5bee0fa4e54d22df099b004da2a99a3d05 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Tue, 1 Oct 2024 15:17:23 +0200 Subject: [PATCH 1/2] fix: propTypes warning * the recordRestrictionGracePeriod property is a number. the object which it is in the beginning in python (timedelta object) is reduced to the days in https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/deposit.html#L45 --- .../src/deposit/fields/AccessField/AccessRightField.js | 4 ++-- .../deposit/fields/AccessField/components/MetadataAccess.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/AccessRightField.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/AccessRightField.js index c77e505c7..47b801192 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/AccessRightField.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/AccessRightField.js @@ -104,7 +104,7 @@ AccessRightFieldCmp.propTypes = { showMetadataAccess: PropTypes.bool, community: PropTypes.object, record: PropTypes.object.isRequired, - recordRestrictionGracePeriod: PropTypes.object.isRequired, + recordRestrictionGracePeriod: PropTypes.number.isRequired, allowRecordRestriction: PropTypes.bool.isRequired, }; @@ -140,7 +140,7 @@ AccessRightField.propTypes = { labelIcon: PropTypes.string, isMetadataOnly: PropTypes.bool, record: PropTypes.object.isRequired, - recordRestrictionGracePeriod: PropTypes.object.isRequired, + recordRestrictionGracePeriod: PropTypes.number.isRequired, allowRecordRestriction: PropTypes.bool.isRequired, }; diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/MetadataAccess.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/MetadataAccess.js index fc3a904b0..c146f8762 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/MetadataAccess.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/MetadataAccess.js @@ -62,6 +62,6 @@ MetadataAccess.propTypes = { recordAccess: PropTypes.string.isRequired, communityAccess: PropTypes.string.isRequired, record: PropTypes.object.isRequired, - recordRestrictionGracePeriod: PropTypes.object.isRequired, + recordRestrictionGracePeriod: PropTypes.number.isRequired, allowRecordRestriction: PropTypes.bool.isRequired, }; From 22cd5ad830ce8c9bc0880961611ae99892ac7b09 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Tue, 1 Oct 2024 15:15:07 +0200 Subject: [PATCH 2/2] fix: propTypes warning * the canRestrictRecord property is optional in ProtectionButtonsComponent but required in ProtectionButtons. * Since it is working without a problem, because of the default value in ProtectionButtonsComponent, the required has been removed from ProtectionButtons and replaced by a defaultProps definition to be consistent with the ProtectionButtonsComponent definition. --- .../fields/AccessField/components/ProtectionButtons.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/ProtectionButtons.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/ProtectionButtons.js index 6cfe988d4..b3ec39d77 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/ProtectionButtons.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/AccessField/components/ProtectionButtons.js @@ -1,7 +1,7 @@ // This file is part of Invenio-RDM-Records // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. -// Copyright (C) 2021 Graz University of Technology. +// Copyright (C) 2021-2024 Graz University of Technology. // // 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. @@ -109,7 +109,11 @@ export class ProtectionButtons extends Component { } } +ProtectionButtons.defaultProps = { + canRestrictRecord: true, +}; + ProtectionButtons.propTypes = { - canRestrictRecord: PropTypes.bool.isRequired, + canRestrictRecord: PropTypes.bool, fieldPath: PropTypes.string.isRequired, };