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]>
  • Loading branch information
jowg-amazon authored Oct 30, 2024
1 parent 449c3ec commit 71411b4
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 71411b4

Please sign in to comment.