Skip to content

Commit

Permalink
Merge pull request #104 from zowe/feature/v3/exclude-wrong-version-pl…
Browse files Browse the repository at this point in the history
…ugins

Exclude wrong version of angular plugins by checking entrypoint content
  • Loading branch information
DivergentEuropeans authored Aug 28, 2024
2 parents 5362708 + 9f03688 commit 49207af
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
27 changes: 25 additions & 2 deletions base/src/plugin-manager/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,33 @@ export class PluginManager {
try {
var result = JSON.parse(this.responseText);
let allPlugins = PluginManager.parsePluginDefinitions(result);
const searchParams = new URLSearchParams(window.location.search);
const useV2Desktop = searchParams.has("use-v2-desktop") && (searchParams.get("use-v2-desktop") == 'true');
let validPlugins = allPlugins.filter((plugin) => {
if (plugin.type != 'application') {
return true;
} else {
const webContent = plugin.getWebContent();
if (!webContent) {
return true;
} else if ((webContent.framework != 'angular') && (webContent.framework != 'angular2')) {
return true;
} else {
//exclude apps incompatible with the given desktop environment, depending upon their entryPoint content.
if (useV2Desktop && (!webContent.entryPoint || webContent.entryPoint['2.0'])) {
return true;
} else if (!useV2Desktop && webContent.entryPoint && webContent.entryPoint['3.0']) {
return true;
} else {
return false;
}
}
}
});
if (!pluginType) {
resolve(allPlugins);
resolve(validPlugins);
} else {
const filtered = allPlugins.filter(plugin => plugin.getType() == pluginType)
const filtered = validPlugins.filter(plugin => plugin.getType() == pluginType)
resolve(filtered);
}
} catch (error) {
Expand Down
16 changes: 16 additions & 0 deletions base/src/plugin-manager/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ class Plugin_2 extends Plugin_1 {
super(definition);
}

getWebEntrypoint():string|undefined {
let entryPoint = this.webContent?.entryPoint;
if (entryPoint) {
const searchParams = new URLSearchParams(window.location.search);
const useV2Desktop = searchParams.has("use-v2-desktop") && (searchParams.get("use-v2-desktop") == 'true');
if (useV2Desktop || !entryPoint['3.0']) {
return 'main.js';
} else {
return ''+entryPoint['3.0'];
}
} else if (this.webContent) {
return 'main.js';
}
return undefined;
}

}


Expand Down
4 changes: 4 additions & 0 deletions interface/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ declare namespace ZLUX {
getBasePlugin(): any;
}

interface PluginV2 extends Plugin {
getWebEntryPoint():string|undefined;
}

interface ContainerPluginDefinition {
getBasePlugin():Plugin;
}
Expand Down

0 comments on commit 49207af

Please sign in to comment.