Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Updated onto-deside configuration 2025-04-09 (#202).
- In the configuration file: per query `httpProxies` setting replaces global `httpProxy` setting (#4, #47).
- Error message when query has no sources was replaced with an application message in the empty result list (#204).

## [1.7.0] - 2025-04-09

Expand Down
11 changes: 11 additions & 0 deletions main/configs/test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,17 @@
"httpProxy": "http://localhost:8000/"
}
]
},
{
"id": "9140",
"queryGroupId": "gr-test",
"queryLocation": "components_materials.rq",
"name": "Sources from an index file - no sources",
"description": "Test what happens if the sourceIndex query results in 0 sources.",
"sourcesIndex": {
"url": "http://localhost:8080/example/index-example-file-does-not-exist",
"queryLocation": "/sourceQueries/index_example_common_lt.rq"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function QueryResultList(props) {
disableAuthentication={true} // needed to overrule the default, which is to force logging in
title=" "
actions={ <ActionBar />}
empty={<NoValuesDisplay />}
empty={<NoValuesDisplay query={query} />}
queryOptions={{
keepPreviousData: false,
meta: {
Expand Down Expand Up @@ -78,12 +78,13 @@ const Aside = (props) => {
);
}

const NoValuesDisplay = () => {
const NoValuesDisplay = (props) => {
const msg = props?.query?.comunicaContext?.sources?.length ? "The result list is empty." : "The result list is empty (no sources found).";
return (
<div>
<Box display="flex" alignItems="center" sx={{ m: 3 }}>
<SvgIcon component={SearchOffIcon} />
<span>The result list is empty.</span>
<span>{msg}</span>
</Box>
</div>
);
Expand All @@ -96,7 +97,7 @@ const MyDatagrid = (props) => {
if (isLoading) {
return <Loading loadingSecondary={"The list is loading. Just a moment please."} />;
}

let values = {};
if (!isLoading && data && data.length > 0) {
data.forEach((record) => {
Expand Down
10 changes: 5 additions & 5 deletions main/src/dataProvider/SparqlDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export default {
// LOG console.log(`reusing listCache.results: ${JSON.stringify(listCache.results, null, 2)}`);
results = listCache.results;
} else {
results = await executeQuery(query);
if (query.comunicaContext?.sources?.length) {
results = await executeQuery(query);
} else {
results = [];
}
listCache.hash = hash;
listCache.results = results;
// LOG console.log(`new listCache.results: ${JSON.stringify(listCache.results, null, 2)}`);
Expand Down Expand Up @@ -285,10 +289,6 @@ async function getSourcesFromSourcesIndex(sourcesIndex, httpProxies) {
throw new Error(`Error adding sources from index: ${error.message}`);
}

if (sourcesList.length == 0) {
throw new Error(`The resulting list of sources is empty`);
}

return sourcesList;
}

Expand Down
12 changes: 12 additions & 0 deletions test/cypress/e2e/sources-from-indexfile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,16 @@ describe("Sources from index file", () => {
cy.contains("Material 1").should("exist");
})

it("Sources obtained only from sourcesIndex, but no sources found", () => {
cy.visit("/");

// Navigate to correct query
cy.contains("For testing only").click();
cy.contains("Sources from an index file - no sources").click();

// Check for the expected message
cy.get('span').contains("The result list is empty (no sources found).").should("exist");

});

});