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
…299)

(cherry picked from commit 71411b4)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent dedf385 commit 56a80a1
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 @@ -169,12 +169,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 56a80a1

Please sign in to comment.