Skip to content

Commit

Permalink
Merge pull request #118 from openshift-cherrypick-robot/cherry-pick-1…
Browse files Browse the repository at this point in the history
…17-to-release-4.15

[release-4.15] OU-417: throw an error when a custom datasource is not found
  • Loading branch information
openshift-merge-bot[bot] committed Apr 24, 2024
2 parents 813a702 + 71970c6 commit 53c1862
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/dashboards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ const VariableDropdown: React.FC<VariableDropdownProps> = ({ id, name, namespace
);
const getDataSource = extension?.properties?.getDataSource;
const dataSource = await getDataSource?.(customDataSourceName);

if (!dataSource || !dataSource.basePath) {
setIsError(true);
return;
}
return getPrometheusURL(prometheusProps, dataSource?.basePath);
}
} catch (error) {
Expand Down Expand Up @@ -580,8 +585,14 @@ const Card: React.FC<CardProps> = React.memo(({ panel }) => {
);
const getDataSource = extension?.properties?.getDataSource;
const dataSource = await getDataSource?.(customDataSourceName);
setCustomDataSource(dataSource);
setDataSourceInfoLoading(false);

if (!dataSource || !dataSource.basePath) {
setIsError(true);
setDataSourceInfoLoading(false);
} else {
setCustomDataSource(dataSource);
setDataSourceInfoLoading(false);
}
} else {
setDataSourceInfoLoading(false);
setIsError(true);
Expand Down

0 comments on commit 53c1862

Please sign in to comment.