Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-90318 || Remote plugins support. Add mocked manifest #3834

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app/src/controllers/plugins/uiExtensions/sagas.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { select, call, put } from 'redux-saga/effects';
import { URLS } from 'common/urls';
import { fetch } from 'common/utils/fetch';
import { fetch as internalFetch } from 'common/utils/fetch';
import { activeProjectSelector } from 'controllers/user';
import { PUBLIC_PLUGINS } from 'controllers/plugins/constants';
import { COMMAND_GET_FILE, METADATA_FILE_KEY, MAIN_FILE_KEY } from './constants';
Expand Down Expand Up @@ -29,7 +29,7 @@ export function* fetchExtensionsMetadata(action) {
// TODO: discuss with BE whether we can fetch plugins metadata via single API call
const calls = uiExtensionPlugins.map((plugin) => {
const metadataFile = plugin.details.binaryData[METADATA_FILE_KEY];
return fetch(URLS.pluginPublicFile(plugin.name, metadataFile), {
return internalFetch(URLS.pluginPublicFile(plugin.name, metadataFile), {
contentType: 'application/json',
});
});
Expand All @@ -40,6 +40,7 @@ export function* fetchExtensionsMetadata(action) {

try {
const results = yield Promise.allSettled(calls);
// const results = [];
const metadataArray = results.reduce((acc, result, index) => {
if (result.status !== 'fulfilled') {
return acc;
Expand All @@ -50,7 +51,17 @@ export function* fetchExtensionsMetadata(action) {
});
}, []);

yield put(fetchExtensionsMetadataSuccessAction(metadataArray));
const REMOTE_PLUGIN_MANIFEST_URL =
'https://raw.githubusercontent.com/AmsterGet/remote-plugin-config/main/manifest.json';

const response = yield call(fetch, REMOTE_PLUGIN_MANIFEST_URL, {
method: 'get',
contentType: 'application/json',
});

const remotePluginsManifest = yield response.json();

yield put(fetchExtensionsMetadataSuccessAction(metadataArray.concat(remotePluginsManifest)));
} catch (error) {
console.error('Plugins metadata load error'); // eslint-disable-line no-console
}
Expand All @@ -60,7 +71,6 @@ export function* fetchExtensionsMetadata(action) {
export function* fetchUiExtensions() {
yield call(fetchExtensionsMetadata);
// TODO: In the future plugins with js parts should not depend on integrations, only on plugins.
// TODO: This should be removed when common getFile plugin command will be presented in all plugins with js files.
const globalIntegrations = yield select(globalIntegrationsSelector);
if (!globalIntegrations?.length) {
return;
Expand Down Expand Up @@ -90,7 +100,7 @@ export function* fetchUiExtensions() {
url = URLS.projectIntegrationByIdCommand(activeProject, integration.id, COMMAND_GET_FILE);
}

return fetch(url, {
return internalFetch(url, {
method: 'PUT',
data: { fileKey: 'main' },
});
Expand Down
Loading