Skip to content
Snippets Groups Projects
Commit c3aa1f85 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

if plugin is trying to access minervaDefine report that the plugin is not supported byt his version

parent 2c31de1f
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!211Resolve "Plugins don't work"
Pipeline #92408 passed
...@@ -50,6 +50,9 @@ declare global { ...@@ -50,6 +50,9 @@ declare global {
ADMIN_PANEL_URL: string; ADMIN_PANEL_URL: string;
}; };
// plugins try to access those in the previous version of minerva
minervaDefine: typeof minervaDefine;
minerva: { minerva: {
configuration?: MinervaConfiguration; configuration?: MinervaConfiguration;
plugins: { plugins: {
......
...@@ -14,6 +14,7 @@ import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; ...@@ -14,6 +14,7 @@ import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { getErrorMessage } from '@/utils/getErrorMessage'; import { getErrorMessage } from '@/utils/getErrorMessage';
import { showToast } from '@/utils/showToast'; import { showToast } from '@/utils/showToast';
import axios from 'axios'; import axios from 'axios';
import { PLUGIN_MINERVA_VERSION_NOT_SUPPORTED } from '@/redux/plugins/plugins.constants';
import { PLUGIN_LOADING_ERROR_PREFIX } from '../../AvailablePluginsDrawer.constants'; import { PLUGIN_LOADING_ERROR_PREFIX } from '../../AvailablePluginsDrawer.constants';
type UseLoadPluginReturnType = { type UseLoadPluginReturnType = {
...@@ -74,11 +75,24 @@ export const useLoadPlugin = ({ ...@@ -74,11 +75,24 @@ export const useLoadPlugin = ({
onPluginLoaded(); onPluginLoaded();
} }
} catch (error) { } catch (error) {
const errorMessage = getErrorMessage({ let message;
error, if (typeof error === 'string') {
prefix: PLUGIN_LOADING_ERROR_PREFIX, message = error;
}); } else if (error instanceof Error) {
showToast({ type: 'error', message: errorMessage }); message = error.message;
}
if (message === PLUGIN_MINERVA_VERSION_NOT_SUPPORTED) {
showToast({
type: 'error',
message: 'This minerva version is not supported by selected plugin',
});
} else {
const errorMessage = getErrorMessage({
error,
prefix: PLUGIN_LOADING_ERROR_PREFIX,
});
showToast({ type: 'error', message: errorMessage });
}
} }
}; };
......
...@@ -18,4 +18,5 @@ export const PLUGINS_INITIAL_STATE: PluginsState = { ...@@ -18,4 +18,5 @@ export const PLUGINS_INITIAL_STATE: PluginsState = {
export const PLUGIN_REGISTER_ERROR_PREFIX = 'Failed to register plugin'; export const PLUGIN_REGISTER_ERROR_PREFIX = 'Failed to register plugin';
export const PLUGIN_INIT_FETCHING_ERROR_PREFIX = 'Failed to initialize fetching plugin'; export const PLUGIN_INIT_FETCHING_ERROR_PREFIX = 'Failed to initialize fetching plugin';
export const PLUGIN_MINERVA_VERSION_NOT_SUPPORTED = 'Minerva version not supported';
export const PLUGIN_FETCHING_ALL_ERROR_PREFIX = 'Failed to fetch all plugins'; export const PLUGIN_FETCHING_ALL_ERROR_PREFIX = 'Failed to fetch all plugins';
...@@ -96,6 +96,7 @@ export const getInitPlugins = createAsyncThunk<void, GetInitPluginsProps, ThunkC ...@@ -96,6 +96,7 @@ export const getInitPlugins = createAsyncThunk<void, GetInitPluginsProps, ThunkC
if (isDataValid) { if (isDataValid) {
const { urls } = res.data; const { urls } = res.data;
const scriptRes = await axios(urls[0]); const scriptRes = await axios(urls[0]);
let pluginScript = scriptRes.data; let pluginScript = scriptRes.data;
setHashedPlugin({ pluginUrl: urls[0], pluginScript }); setHashedPlugin({ pluginUrl: urls[0], pluginScript });
......
import { PLUGIN_MINERVA_VERSION_NOT_SUPPORTED } from '@/redux/plugins/plugins.constants';
export const minervaDefine = (): void => {
throw new Error(PLUGIN_MINERVA_VERSION_NOT_SUPPORTED);
};
...@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid'; ...@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from 'uuid';
import { isPluginHashWithPrefix } from '@/utils/plugins/isPluginHashWithPrefix'; import { isPluginHashWithPrefix } from '@/utils/plugins/isPluginHashWithPrefix';
import { getPluginHashWithoutPrefix } from '@/utils/plugins/getPluginHashWithoutPrefix'; import { getPluginHashWithoutPrefix } from '@/utils/plugins/getPluginHashWithoutPrefix';
import { ONE, ZERO } from '@/constants/common'; import { ONE, ZERO } from '@/constants/common';
import { minervaDefine } from '@/services/pluginsManager/map/minervaDefine';
import { bioEntitiesMethods } from './bioEntities'; import { bioEntitiesMethods } from './bioEntities';
import { getModels } from './map/models/getModels'; import { getModels } from './map/models/getModels';
import { openMap } from './map/openMap'; import { openMap } from './map/openMap';
...@@ -68,6 +69,7 @@ export const PluginsManager: PluginsManagerType = { ...@@ -68,6 +69,7 @@ export const PluginsManager: PluginsManagerType = {
} }
}, },
init() { init() {
window.minervaDefine = minervaDefine;
window.minerva = { window.minerva = {
plugins: { plugins: {
registerPlugin: PluginsManager.registerPlugin, registerPlugin: PluginsManager.registerPlugin,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment