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

Merge branch '273-plugins-don-t-work' into 'development'

Resolve "Plugins don't work"

Closes #273

See merge request !211
parents 7fd89073 c3aa1f85
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 #92411 passed
......@@ -50,6 +50,9 @@ declare global {
ADMIN_PANEL_URL: string;
};
// plugins try to access those in the previous version of minerva
minervaDefine: typeof minervaDefine;
minerva: {
configuration?: MinervaConfiguration;
plugins: {
......
......@@ -14,6 +14,7 @@ import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { getErrorMessage } from '@/utils/getErrorMessage';
import { showToast } from '@/utils/showToast';
import axios from 'axios';
import { PLUGIN_MINERVA_VERSION_NOT_SUPPORTED } from '@/redux/plugins/plugins.constants';
import { PLUGIN_LOADING_ERROR_PREFIX } from '../../AvailablePluginsDrawer.constants';
type UseLoadPluginReturnType = {
......@@ -74,11 +75,24 @@ export const useLoadPlugin = ({
onPluginLoaded();
}
} catch (error) {
const errorMessage = getErrorMessage({
error,
prefix: PLUGIN_LOADING_ERROR_PREFIX,
});
showToast({ type: 'error', message: errorMessage });
let message;
if (typeof error === 'string') {
message = error;
} else if (error instanceof Error) {
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 = {
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_MINERVA_VERSION_NOT_SUPPORTED = 'Minerva version not supported';
export const PLUGIN_FETCHING_ALL_ERROR_PREFIX = 'Failed to fetch all plugins';
......@@ -96,6 +96,7 @@ export const getInitPlugins = createAsyncThunk<void, GetInitPluginsProps, ThunkC
if (isDataValid) {
const { urls } = res.data;
const scriptRes = await axios(urls[0]);
let pluginScript = scriptRes.data;
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';
import { isPluginHashWithPrefix } from '@/utils/plugins/isPluginHashWithPrefix';
import { getPluginHashWithoutPrefix } from '@/utils/plugins/getPluginHashWithoutPrefix';
import { ONE, ZERO } from '@/constants/common';
import { minervaDefine } from '@/services/pluginsManager/map/minervaDefine';
import { bioEntitiesMethods } from './bioEntities';
import { getModels } from './map/models/getModels';
import { openMap } from './map/openMap';
......@@ -68,6 +69,7 @@ export const PluginsManager: PluginsManagerType = {
}
},
init() {
window.minervaDefine = minervaDefine;
window.minerva = {
plugins: {
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