Skip to content

Commit

Permalink
change order of validation and add try catch in semver check (#297)
Browse files Browse the repository at this point in the history
Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 71411b4)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 30, 2024
1 parent 84cef98 commit 3f2256c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,22 @@ export default class Main extends Component<MainProps, MainState> {
};

dataSourceFilterFn = (dataSource: SavedObject<DataSourceAttributes>) => {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || "";
const installedPlugins = dataSource?.attributes?.installedPlugins || [];
return (
semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) &&
pluginManifest.requiredOSDataSourcePlugins.every((plugin) => installedPlugins.includes(plugin))
);
try {
const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || '';
const installedPlugins = dataSource?.attributes?.installedPlugins || [];
return (
pluginManifest.requiredOSDataSourcePlugins.every((plugin) =>
installedPlugins.includes(plugin)
) &&
semver.satisfies(
dataSourceVersion,
pluginManifest.supportedOSDataSourceVersions
)
);
} catch (error) {
// Filter out invalid data source
return false;
}
};

getServices(http: HttpSetup) {
Expand Down

0 comments on commit 3f2256c

Please sign in to comment.