From 629ecb9ed378bddd3e8afcc6abab6009a03ad714 Mon Sep 17 00:00:00 2001 From: Anika Churilova Date: Tue, 30 Jan 2024 18:24:25 +0100 Subject: [PATCH] http headers: use and adjust vnd.inveniordm.v1+json http accept header * closes https://github.com/zenodo/rdm-project/issues/598 --- invenio_app_rdm/records_ui/searchapp.py | 4 ++-- .../administration/records/RemovalReasonsSelect.js | 6 +----- .../js/invenio_app_rdm/frontpage/RecordsList.js | 6 +----- .../invenio_app_rdm/landing_page/CommunitiesManagement.js | 6 +----- .../js/invenio_app_rdm/landing_page/EditButton.js | 1 - .../js/invenio_app_rdm/landing_page/RecordVersionsList.js | 7 +------ .../js/invenio_app_rdm/user_dashboard/uploads.js | 1 - invenio_app_rdm/users_ui/searchapp.py | 2 +- 8 files changed, 7 insertions(+), 26 deletions(-) diff --git a/invenio_app_rdm/records_ui/searchapp.py b/invenio_app_rdm/records_ui/searchapp.py index ce0f19a805..3b35f32b02 100644 --- a/invenio_app_rdm/records_ui/searchapp.py +++ b/invenio_app_rdm/records_ui/searchapp.py @@ -31,7 +31,7 @@ def search_app_context(): config_name="RDM_SEARCH_USER_REQUESTS", available_facets=current_app.config["REQUESTS_FACETS"], sort_options=current_app.config["RDM_SORT_OPTIONS"], - headers={"Accept": "application/json"}, + headers={"Accept": "application/vnd.inveniordm.v1+json"}, hidden_params=[ ["expand", "1"], ["is_open", "true"], @@ -65,6 +65,6 @@ def search_app_context(): config_name="RDM_SEARCH", available_facets=current_app.config["RDM_FACETS"], sort_options=current_app.config["RDM_SORT_OPTIONS"], - headers={"Accept": "application/json"}, + headers={"Accept": "application/vnd.inveniordm.v1+json"}, ), } diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/records/RemovalReasonsSelect.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/records/RemovalReasonsSelect.js index 3eac9aef48..baf9bc3abc 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/records/RemovalReasonsSelect.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/records/RemovalReasonsSelect.js @@ -35,11 +35,7 @@ export default class RemovalReasonsSelect extends Component { this.setState({ loading: true }); const url = "/api/vocabularies/removalreasons"; this.cancellableAction = withCancel( - http.get(url, { - headers: { - Accept: "application/vnd.inveniordm.v1+json", - }, - }) + http.get(url) ); try { const response = await this.cancellableAction.promise; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js index ee0a02cf34..5ec5fea883 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js @@ -46,11 +46,7 @@ export class RecordsList extends Component { this.setState({ isLoading: true }); this.cancellableFetch = withCancel( - http.get(fetchUrl, { - headers: { - Accept: "application/vnd.inveniordm.v1+json", - }, - }) + http.get(fetchUrl) ); try { diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/CommunitiesManagement.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/CommunitiesManagement.js index 1c223ba5a1..f04ab6e225 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/CommunitiesManagement.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/CommunitiesManagement.js @@ -45,11 +45,7 @@ export class CommunitiesManagement extends Component { fetchRecordCommunities = async () => { const { recordCommunityEndpoint } = this.props; - return await http.get(recordCommunityEndpoint, { - headers: { - Accept: "application/vnd.inveniordm.v1+json", - }, - }); + return await http.get(recordCommunityEndpoint); }; getCommunities = async () => { diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/EditButton.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/EditButton.js index 5925182696..79168bdf55 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/EditButton.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/EditButton.js @@ -23,7 +23,6 @@ export const EditButton = ({ recid, onError }) => { { headers: { "Content-Type": "application/json", - "Accept": "application/vnd.inveniordm.v1+json", }, } ); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordVersionsList.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordVersionsList.js index 70738d9ffb..57e83faa93 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordVersionsList.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordVersionsList.js @@ -89,12 +89,7 @@ export const RecordVersionsList = ({ record, isPreview }) => { const fetchVersions = async () => { return await http.get( `${recordDeserialized.links.versions}?size=${NUMBER_OF_VERSIONS}&sort=version&allversions=true`, - { - headers: { - Accept: "application/vnd.inveniordm.v1+json", - }, - withCredentials: true, - } + { withCredentials: true, } ); }; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js index c8c368c355..8455185c92 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js @@ -49,7 +49,6 @@ export const RDMRecordResultsListItem = ({ result }) => { { headers: { "Content-Type": "application/json", - "Accept": "application/vnd.inveniordm.v1+json", }, } ) diff --git a/invenio_app_rdm/users_ui/searchapp.py b/invenio_app_rdm/users_ui/searchapp.py index c38d32886b..24e3c1374a 100644 --- a/invenio_app_rdm/users_ui/searchapp.py +++ b/invenio_app_rdm/users_ui/searchapp.py @@ -40,7 +40,7 @@ def search_app_context(): current_app.config["REQUESTS_FACETS"], current_app.config["RDM_SORT_OPTIONS"], "/api/user/requests", - {"Accept": "application/json"}, + {"Accept": "application/vnd.inveniordm.v1+json"}, initial_filters=[["is_open", "true"]], hidden_params=[["expand", "1"]], ),