Skip to content

Commit

Permalink
change order of validation and add try catch in semver check
Browse files Browse the repository at this point in the history
Signed-off-by: Joanne Wang <[email protected]>
  • Loading branch information
jowg-amazon committed Oct 30, 2024
1 parent 449c3ec commit 9f5cacf
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 9f5cacf

Please sign in to comment.