Align configuration for new design
Aligned the designers configuration according to the new design addition and changes
Change-Id: Id08942b5a8adbac10bbe76bdd8a2a6f093ec8b46
Issue-ID: SDC-975
Signed-off-by: Idan Amit <ia096e@intl.att.com>
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
index dcd5eef..55e7790 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
@@ -57,14 +57,9 @@
}
private boolean checkPluginAvailability(Plugin plugin) {
-
- StringBuilder requestString = new StringBuilder();
boolean result = false;
- requestString.append(plugin.getPluginProtocol()).append("://").append(plugin.getPluginHost()).append(":")
- .append(plugin.getPluginPort()).append(plugin.getPluginPath());
-
- HttpHead head = new HttpHead(requestString.toString());
+ HttpHead head = new HttpHead(plugin.getPluginDiscoveryUrl());
try (CloseableHttpResponse response = this.client.execute(head)) {
result = response != null && response.getStatusLine().getStatusCode() == 200;
diff --git a/catalog-fe/src/main/resources/config/plugins-configuration.yaml b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
index 4193b50..69598e0 100644
--- a/catalog-fe/src/main/resources/config/plugins-configuration.yaml
+++ b/catalog-fe/src/main/resources/config/plugins-configuration.yaml
@@ -1,22 +1,21 @@
pluginsList:
- pluginId: DCAE
- pluginHost: localhost
- pluginPort: 8080
- pluginPath: "/dcae"
+ pluginDiscoveryUrl: http://localhost:8702/dcae
+ pluginSourceUrl: http://localhost:8702/dcae
pluginStateUrl: "dcae"
- pluginProtocol: http
pluginDisplayOptions:
context:
displayName: "Monitor"
displayContext: ["VF", "SERVICE"]
- top:
- displayName: "DCAE"
+ displayRoles: ["DESIGNER"]
- pluginId: WORKFLOW
- pluginHost: localhost
- pluginPort: 9527
- pluginPath: "/"
+ pluginDiscoveryUrl: http://localhost:9527/
+ pluginSourceUrl: http://localhost:9527/
pluginStateUrl: "workflowDesigner"
- pluginProtocol: http
pluginDisplayOptions:
top:
- displayName: "WORKFLOW"
\ No newline at end of file
+ displayName: "WORKFLOW"
+ context:
+ displayName: "Workflow Designer"
+ displayContext: ["VF"]
+ displayRoles: ["DESIGNER", "TESTER"]
\ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
index 8a796a4..baef685 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
@@ -38,16 +38,10 @@
final static List<Plugin> testPluginsList = new ArrayList<>();
final static String offlinePluginsDisplayName = "offlinePlugin";
- final static String offlinePluginHost = "192.168.10.1";
- final static String offlinePluginPort = "1000";
- final static String offlinePluginPath = "/offline";
- final static String offlinePluginProtocol = "http";
+ final static String offlinePluginDiscoveryPath = "http://192.168.10.1:1000/offline";
final static String onlinePluginDisplayName = "onlinePlugin";
- final static String onlinePluginHost = "192.168.20.2";
- final static String onlinePluginPort = "2000";
- final static String onlinePluginPath = "/online";
- final static String onlinePluginProtocol = "http";
+ final static String onlinePluginDiscoveryPath = "http://192.168.10.1:2000/online";
@BeforeClass
public static void beforeClass() {
@@ -55,24 +49,10 @@
when(configurationManager.getPluginsConfiguration()).thenReturn(pluginsConfiguration);
offlinePlugin.setPluginId(offlinePluginsDisplayName);
- offlinePlugin.setPluginHost(offlinePluginHost);
- offlinePlugin.setPluginPort(offlinePluginPort);
- offlinePlugin.setPluginPath(offlinePluginPath);
- offlinePlugin.setPluginProtocol(offlinePluginProtocol);
-
- StringBuilder offlineRequestString = new StringBuilder();
- offlineRequestString.append(offlinePluginProtocol).append("://").append(onlinePluginHost).append(":")
- .append(offlinePluginPort).append(offlinePluginPath);
+ offlinePlugin.setPluginDiscoveryUrl(offlinePluginDiscoveryPath);
onlinePlugin.setPluginId(onlinePluginDisplayName);
- onlinePlugin.setPluginHost(onlinePluginHost);
- onlinePlugin.setPluginPort(onlinePluginPort);
- onlinePlugin.setPluginPath(onlinePluginPath);
- onlinePlugin.setPluginProtocol(onlinePluginProtocol);
-
- StringBuilder onlineRequestString = new StringBuilder();
- onlineRequestString.append(onlinePluginProtocol).append("://").append(onlinePluginHost).append(":")
- .append(offlinePluginPort).append(offlinePluginPath);
+ onlinePlugin.setPluginDiscoveryUrl(onlinePluginDiscoveryPath);
}
diff --git a/catalog-ui/src/app/models/plugins-config.ts b/catalog-ui/src/app/models/plugins-config.ts
index 18782ec..3f687a3 100644
--- a/catalog-ui/src/app/models/plugins-config.ts
+++ b/catalog-ui/src/app/models/plugins-config.ts
@@ -1,17 +1,16 @@
export class Plugin {
pluginId: string;
- pluginHost: string;
- pluginPort: string;
- pluginPath: string;
+ pluginDiscoveryUrl: string;
+ pluginSourceUrl: string;
pluginStateUrl: string;
- pluginProtocol: string;
pluginDisplayOptions: Map<string, PluginDisplayOptions>;
}
export class PluginDisplayOptions {
displayName: string;
displayContext: Array<string>;
+ displayRoles: Array<string>;
}
export type Plugins = Array<Plugin>;
diff --git a/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts b/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts
index 5e43fec..b8b0e80 100644
--- a/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts
+++ b/catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts
@@ -120,14 +120,15 @@
tmpArray.push(new MenuItem(hostedApp.navTitle, null, hostedApp.defaultState, "goToState", null, null));
}
});
-
- _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
- if (plugin.pluginDisplayOptions["top"]) {
- tmpArray.push(new MenuItem(plugin.pluginDisplayOptions["top"].displayName, null, "plugins", "goToState", {path: plugin.pluginStateUrl}, null));
- }
- })
}
+ // Adding plugins to top-nav only if they can be displayed for the current connected user role
+ _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
+ if (plugin.pluginDisplayOptions["tab"] && (this.user && plugin.pluginDisplayOptions["tab"].displayRoles.includes(this.user.role))) {
+ tmpArray.push(new MenuItem(plugin.pluginDisplayOptions["tab"].displayName, null, "plugins", "goToState", {path: plugin.pluginStateUrl}, null));
+ }
+ });
+
this.topLvlMenu = new MenuItemGroup(0, tmpArray, true);
this.topLvlMenu.selectedIndex = isNaN(this.topLvlSelectedIndex) ? this._getTopLvlSelectedIndexByState() : this.topLvlSelectedIndex;
diff --git a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
index 169cad0..801dfa9 100644
--- a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
+++ b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
@@ -21,10 +21,7 @@
ngOnInit(): void {
- this.pluginUrl = this.plugin.pluginProtocol + "://" +
- this.plugin.pluginHost + ":" +
- this.plugin.pluginPort +
- this.plugin.pluginPath;
+ this.pluginUrl = this.plugin.pluginSourceUrl;
if (this.queryParams && !_.isEmpty(this.queryParams)) {
_.forOwn(this.queryParams, (value, key) => {
diff --git a/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts b/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts
index ce09800..d9dc40b 100644
--- a/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts
+++ b/catalog-ui/src/app/view-models/plugins/plugins-tab-view-model.ts
@@ -34,7 +34,9 @@
this.$scope.user = this.cacheService.get('user');
this.$scope.queryParams = {
- userId: this.$scope.user.userId
+ userId: this.$scope.user.userId,
+ userRole: this.$scope.user.role,
+ displayType: "tab"
};
}
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts
index 76010b5..ca8c269 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view-model.ts
@@ -33,6 +33,8 @@
this.$scope.queryParams = {
userId: this.$scope.user.userId,
+ userRole: this.$scope.user.role,
+ displayType: "context",
contextType: this.$scope.component.componentType,
uuid: this.$scope.component.uuid,
lifecycleState: this.$scope.component.lifecycleState,
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
index 59dd2d8..0f9d759 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
@@ -719,23 +719,21 @@
this.$scope.leftBarTabs = new MenuItemGroup();
const menuItemsObjects:Array<any> = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
- // Only need to add plugins to the menu if the current role is Designer
- if (this.role === "DESIGNER") {
- _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
- if (plugin.pluginDisplayOptions["context"]) {
- let displayOptions : PluginDisplayOptions = plugin.pluginDisplayOptions["context"];
+ // Only adding plugins to the workspace if they can be displayed for the current user role
+ _.each(PluginsConfiguration.plugins, (plugin: Plugin) => {
+ if (plugin.pluginDisplayOptions["context"] && plugin.pluginDisplayOptions["context"].displayRoles.includes(this.role)) {
+ let displayOptions : PluginDisplayOptions = plugin.pluginDisplayOptions["context"];
- if (displayOptions.displayContext.indexOf(this.$scope.component.componentType) !== -1) {
- menuItemsObjects.push({
- text: displayOptions.displayName,
- action: 'onMenuItemPressed',
- state: 'workspace.plugins',
- params: {path: plugin.pluginStateUrl}
- });
- }
+ if (displayOptions.displayContext.indexOf(this.$scope.component.getComponentSubType()) !== -1) {
+ menuItemsObjects.push({
+ text: displayOptions.displayName,
+ action: 'onMenuItemPressed',
+ state: 'workspace.plugins',
+ params: {path: plugin.pluginStateUrl}
+ });
}
- });
- }
+ }
+ });
this.$scope.leftBarTabs.menuItems = menuItemsObjects.map((item:MenuItem) => {
if (item.params) {
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java
index ae04b7a..7865abd 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java
@@ -25,19 +25,33 @@
public static class Plugin {
private String pluginId;
- private String pluginHost;
- private String pluginPort;
- private String pluginPath;
+ private String pluginDiscoveryUrl;
+ private String pluginSourceUrl;
private String pluginStateUrl;
- private String pluginProtocol;
private Map<String, PluginDisplayOptions> pluginDisplayOptions;
- public Map<String, PluginDisplayOptions> getPluginDisplayOptions() {
- return pluginDisplayOptions;
+ public String getPluginId() {
+ return pluginId;
}
- public void setPluginDisplayOptions(Map<String, PluginDisplayOptions> pluginDisplayOptions) {
- this.pluginDisplayOptions = pluginDisplayOptions;
+ public void setPluginId(String pluginId) {
+ this.pluginId = pluginId;
+ }
+
+ public String getPluginDiscoveryUrl() {
+ return pluginDiscoveryUrl;
+ }
+
+ public void setPluginDiscoveryUrl(String pluginDiscoveryUrl) {
+ this.pluginDiscoveryUrl = pluginDiscoveryUrl;
+ }
+
+ public String getPluginSourceUrl() {
+ return pluginSourceUrl;
+ }
+
+ public void setPluginSourceUrl(String pluginSourceUrl) {
+ this.pluginSourceUrl = pluginSourceUrl;
}
public String getPluginStateUrl() {
@@ -48,44 +62,12 @@
this.pluginStateUrl = pluginStateUrl;
}
- public String getPluginProtocol() {
- return pluginProtocol;
+ public Map<String, PluginDisplayOptions> getPluginDisplayOptions() {
+ return pluginDisplayOptions;
}
- public void setPluginProtocol(String pluginProtocol) {
- this.pluginProtocol = pluginProtocol;
- }
-
- public String getPluginId() {
- return pluginId;
- }
-
- public void setPluginId(String pluginId) {
- this.pluginId = pluginId;
- }
-
- public String getPluginHost() {
- return pluginHost;
- }
-
- public void setPluginHost(String pluginHost) {
- this.pluginHost = pluginHost;
- }
-
- public String getPluginPort() {
- return pluginPort;
- }
-
- public void setPluginPort(String pluginPort) {
- this.pluginPort = pluginPort;
- }
-
- public String getPluginPath() {
- return pluginPath;
- }
-
- public void setPluginPath(String pluginPath) {
- this.pluginPath = pluginPath;
+ public void setPluginDisplayOptions(Map<String, PluginDisplayOptions> pluginDisplayOptions) {
+ this.pluginDisplayOptions = pluginDisplayOptions;
}
}
@@ -94,6 +76,15 @@
private String displayName;
private List<String> displayContext;
+ private List<String> displayRoles;
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
public List<String> getDisplayContext() {
return displayContext;
@@ -103,14 +94,16 @@
this.displayContext = displayContext;
}
- public String getDisplayName() {
- return displayName;
+ public List<String> getDisplayRoles() {
+ return displayRoles;
}
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
+ public void setDisplayRoles(List<String> displayRoles) {
+ this.displayRoles = displayRoles;
}
+
+
}
}
diff --git a/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb b/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
index 236bb46..9e5953c 100644
--- a/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
+++ b/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
@@ -23,12 +23,10 @@
group "jetty"
mode "0755"
variables({
- :dcae_protocol => node['Plugins']['DCAE']['dcae_protocol'],
- :dcae_host => node['Plugins']['DCAE']['dcae_host'],
- :dcae_port => node['Plugins']['DCAE']['dcae_port'],
- :workflow_protocol => node['Plugins']['WORKFLOW']['workflow_protocol'],
- :workflow_host => node['Plugins']['WORKFLOW']['workflow_host'],
- :workflow_port => node['Plugins']['WORKFLOW']['workflow_port']
+ :dcae_discovery_url => node['Plugins']['DCAE']['dcae_discovery_url'],
+ :dcae_source_url => node['Plugins']['DCAE']['dcae_source_url'],
+ :workflow_discovery_url => node['Plugins']['WORKFLOW']['workflow_discovery_url'],
+ :workflow_source_url => node['Plugins']['WORKFLOW']['workflow_source_url']
})
end
diff --git a/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-plugins-configuration.yaml.erb b/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-plugins-configuration.yaml.erb
index ab13d4f..0a3b15c 100644
--- a/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-plugins-configuration.yaml.erb
+++ b/sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-plugins-configuration.yaml.erb
@@ -1,23 +1,25 @@
pluginsList:
- pluginId: DCAE
- pluginProtocol: <%= @dcae_protocol %>
- pluginHost: <%= @dcae_host %>
- pluginPort: <%= @dcae_port %>
- pluginPath: "/openoui/vnfmarket/#!/marketplace"
+ pluginDiscoveryUrl: <%= @dcae_discovery_url %>
+ pluginSourceUrl: <%= @dcae_source_url %>
pluginStateUrl: "dcae"
pluginDisplayOptions:
+ tab:
+ displayName: "DCAE"
+ displayRoles: ["TESTER"]
context:
displayName: "Monitor"
- displayContext: ["RESOURCE", "SERVICE"]
+ displayContext: ["VF", "SERVICE"]
+ displayRoles: ["DESIGNER"]
- pluginId: WORKFLOW
- pluginProtocol: <%= @workflow_protocol %>
- pluginHost: <%= @workflow_host %>
- pluginPort: <%= @workflow_port %>
- pluginPath: "/"
+ pluginDiscoveryUrl: <%= @workflow_discovery_url %>
+ pluginSourceUrl: <%= @workflow_source_url %>
pluginStateUrl: "workflowDesigner"
pluginDisplayOptions:
- top:
+ tab:
displayName: "WORKFLOW"
+ displayRoles: ["DESIGNER", "TESTER"]
context:
displayName: "Workflow Designer"
- displayContext: ["RESOURCE"]
\ No newline at end of file
+ displayContext: ["VF"]
+ displayRoles: ["DESIGNER", "TESTER"]
\ No newline at end of file