Skip to content

Commit

Permalink
Support for searching components using an endpoint. Resolve Wirecloud…
Browse files Browse the repository at this point in the history
  • Loading branch information
jpajuelo committed Oct 20, 2016
1 parent 46cadaa commit 6fd6b1b
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wirecloud/commons/utils/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,10 @@ def name(self):
def title(self):
return self.find_element(".endpoint-title").text

@property
def btn_preferences(self):
return ButtonTester(self.testcase, self.find_element(".we-prefs-btn"))

def change_position(self, endpoint):
new_index = endpoint.index
actions = ActionChains(self.testcase.driver).click_and_hold(self.element)
Expand Down Expand Up @@ -1117,6 +1121,10 @@ def mouse_over(self, must_recommend=()):
self.testcase.assertTrue(endpoint.is_active)
return self

def show_preferences(self):
button = self.btn_preferences.click()
return PopupMenuTester(self.testcase, self.testcase.wait_element_visible(".se-popup-menu"), button)


class WiringBehaviourTester(WebElementTester):

Expand Down
49 changes: 49 additions & 0 deletions src/wirecloud/defaulttheme/static/css/wiring/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@
padding: ($endpoint-text-height / 2) ($endpoint-anchor-width / 2);
}

.endpoint-actions {
position: absolute;
top: -1px;

.se-btn {
padding: 0;
height: 20px;
width: 20px;
line-height: 20px;
font-size: 12px;
margin: 0;
background-image: none;
box-shadow: none;
border-color: rgba(0, 0, 0, 0);
background-color: transparent;
}
}

&:first-child {
margin-top: $endpoint-margin-vertical;
}
Expand All @@ -275,6 +293,17 @@
left,
$source-endpoint-anchor-bg
);

.endpoint {

.endpoint-title {
padding-left: 20px;
}

.endpoint-actions {
left: 0;
}
}
}

&.target-endpoints {
Expand All @@ -283,6 +312,17 @@
right,
$target-endpoint-anchor-bg
);

.endpoint {

.endpoint-title {
padding-right: 20px;
}

.endpoint-actions {
right: 0;
}
}
}

&:empty {
Expand All @@ -302,6 +342,15 @@
.endpoint-anchor {
background-color: $endpoint-active-bg;
}

.endpoint-actions > .se-btn {
color: rgb(255, 255 ,255);

&:hover,
&:focus {
background-color: darken($endpoint-active-bg, 10%);
}
}
}

.endpoint.missing .endpoint-anchor {
Expand Down
12 changes: 12 additions & 0 deletions src/wirecloud/platform/static/js/wirecloud/ui/WiringEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ Wirecloud.ui = Wirecloud.ui || {};
this.connectionEngine.appendEndpoint(endpoint);
this.suggestionManager.appendEndpoint(endpoint);

var menuItem = new se.MenuItem(utils.gettext("Search components"), function () {

if (!this.btnFindComponents.active) {
this.btnFindComponents.click();
}

this.componentManager.searchComponents.search((endpoint.type === "source" ? "input" : "output") + "_friendcodes:(" + endpoint.keywords.join(" OR ") + ") NOT (vendor:" + endpoint.component._component.meta.vendor + " AND name:" + endpoint.component._component.meta.name + ")");
}.bind(this));
menuItem.addIconClass("fa fa-search");

endpoint.btnPrefs.popup_menu.append(menuItem);

endpoint
.addEventListener('mouseenter', function () {
if (!this.connectionEngine.temporalConnection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@
this.anchorElement.className = "endpoint-anchor";
this.wrapperElement.appendChild(this.anchorElement);

this.optionsElement = document.createElement('span');
this.optionsElement.className = "endpoint-actions";
this.wrapperElement.appendChild(this.optionsElement);

this.btnPrefs = new se.PopupButton({
title: utils.gettext("More options"),
class: "we-prefs-btn",
iconClass: "fa fa-ellipsis-v"
});
this.btnPrefs.appendTo(this.optionsElement);

this._endpoint = wiringEndpoint;
this.component = component;

Expand Down
28 changes: 28 additions & 0 deletions src/wirecloud/platform/wiring/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,34 @@ def test_search_components_by_component_output_endpoints(self):
self.assertEqual(len(sidebar.find_component_groups('operator')), 0)
self.assertEqual(len(sidebar.find_component_groups('widget')), 1)

@uses_extra_resources(('Wirecloud_TestOperator_FriendcodeList_2.1.zip','Wirecloud_Test_FriendcodeList_3.1.wgt'), shared=True)
def test_search_components_by_component_specific_input_endpoint(self):
self.login(username='user_with_workspaces', next='/user_with_workspaces/ExistingWorkspace')

with self.wiring_view as wiring:
with wiring.component_sidebar as sidebar:
operator = sidebar.add_component('operator', "Wirecloud/TestOperator")

operator.find_endpoint('target', name="input").show_preferences().click_entry("Search components")

with wiring.component_sidebar as sidebar:
self.assertEqual(len(sidebar.find_component_groups('operator')), 0)
self.assertEqual(len(sidebar.find_component_groups('widget')), 1)

@uses_extra_resources(('Wirecloud_TestOperator_FriendcodeList_2.1.zip','Wirecloud_Test_FriendcodeList_3.1.wgt'), shared=True)
def test_search_components_by_component_specific_output_endpoint(self):
self.login(username='user_with_workspaces', next='/user_with_workspaces/ExistingWorkspace')

with self.wiring_view as wiring:
with wiring.component_sidebar as sidebar:
operator = sidebar.add_component('operator', "Wirecloud/TestOperator")

operator.find_endpoint('source', name="output-test").show_preferences().click_entry("Search components")

with wiring.component_sidebar as sidebar:
self.assertEqual(len(sidebar.find_component_groups('operator')), 0)
self.assertEqual(len(sidebar.find_component_groups('widget')), 1)


@wirecloud_selenium_test_case
class BehaviourManagementTestCase(WirecloudSeleniumTestCase):
Expand Down

0 comments on commit 6fd6b1b

Please sign in to comment.