From f99a7353f92e9f869f1a9b62042d8b30d40bcbe6 Mon Sep 17 00:00:00 2001 From: Gregory Rushton Date: Mon, 13 Nov 2023 09:35:29 -0500 Subject: [PATCH] [DUOS-2695][risk=no] Fix ontology lookups for DAC Datasets (#2395) --- .../dac_dataset_table/DACDatasetTableCellData.js | 4 ++-- src/libs/ajax.js | 8 +++++++- src/libs/ontologyService.js | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/dac_dataset_table/DACDatasetTableCellData.js b/src/components/dac_dataset_table/DACDatasetTableCellData.js index 9ee1789a9..101b2d392 100644 --- a/src/components/dac_dataset_table/DACDatasetTableCellData.js +++ b/src/components/dac_dataset_table/DACDatasetTableCellData.js @@ -59,8 +59,8 @@ export function dataCustodianCellData({dataset, label = 'dataCustodianCellData'} } export function dataUseCellData({dataset, label = 'dataUseCellData'}) { - const translationList = map((translation) => { - return
  • {translation.code}: {translation.description}
  • ; + const translationList = map((translation, index) => { + return
  • {translation.code}: {translation.description}
  • ; })(dataset.translations); const display =
    diff --git a/src/libs/ajax.js b/src/libs/ajax.js index e76c79992..69b492a97 100644 --- a/src/libs/ajax.js +++ b/src/libs/ajax.js @@ -205,8 +205,14 @@ export const DAR = { }, searchOntologyIdList: async ids => { + if (isNil(ids) || ids.length === 0) { + return []; + } const url = `${await getOntologyUrl()}/search?id=${ids}`; - const res = await fetchOk(url, Config.authOpts()); + const res = await fetchAny(url, Config.authOpts()); + if (res.status >= 400) { + return []; + } return await res.json(); }, diff --git a/src/libs/ontologyService.js b/src/libs/ontologyService.js index 5a0b84755..956914336 100644 --- a/src/libs/ontologyService.js +++ b/src/libs/ontologyService.js @@ -1,10 +1,14 @@ import axios from 'axios'; -import { Notifications } from '../libs/utils'; +import { Notifications } from './utils'; import { getOntologyUrl } from './ajax'; +import isNil from 'lodash'; export const OntologyService = { searchOntology: async (obolibraryURL) => { + if (isNil(obolibraryURL) || obolibraryURL.length === 0) { + return []; + } const baseURL = await getOntologyUrl(); const params = {id: obolibraryURL}; try{