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

Fix catalogue bugs #401

Merged
merged 5 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2016 CoNWeT Lab., Universidad Politécnica de Madrid
* Copyright (c) 2019 Future Internet Consulting and Development Solutions S.L.
*
* This file is part of Wirecloud Platform.
*
Expand Down Expand Up @@ -40,7 +41,13 @@
details = new StyledElements.Notebook();
details.addEventListener('changed', function (notebook, oldTab, newTab, context) {
if (context == null || context.init !== true) {
var new_status = this.mainview.buildStateData();
let new_status;
if ('mainview' in this.mainview) {
new_status = this.mainview.mainview.buildStateData();
} else {
new_status = this.mainview.buildStateData();
}

Wirecloud.HistoryManager.pushState(new_status);
}
Wirecloud.dispatchEvent('viewcontextchanged');
Expand Down
1 change: 0 additions & 1 deletion src/wirecloud/catalogue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ def get_resource_data(resource, user, request=None):
longdescription = resource_info['description']

return {
'id': resource.pk,
'vendor': resource.vendor,
'name': resource.short_name,
'version': resource.version,
Expand Down
2 changes: 1 addition & 1 deletion src/wirecloud/commons/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Migration(migrations.Migration):
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('auth', '0008_alter_user_username_max_length'),
]
if global_apps.is_installed('platform'):
if global_apps.is_installed('wirecloud.platform'):
dependencies.append(('platform', '0015_remove_organization_models'))

operations = [
Expand Down
6 changes: 3 additions & 3 deletions src/wirecloud/commons/utils/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def has_state(self, state):

def change_version(self, version):
super(WiringComponentTester, self).change_version(version)
WebDriverWait(self.testcase.driver, timeout=5).until(lambda driver: self.version == "v" + version)
WebDriverWait(self.testcase.driver, timeout=5).until(lambda driver: self.version == "v" + version)
return self


Expand Down Expand Up @@ -1138,7 +1138,7 @@ def title(self):

def change_position(self, endpoint):
new_index = endpoint.index
actions = ActionChains(self.testcase.driver).click_and_hold(self.element).move_to_element(endpoint.element).release().perform()
ActionChains(self.testcase.driver).click_and_hold(self.element).move_to_element(endpoint.element).release().perform()

WebDriverWait(self.testcase.driver, 3).until(lambda driver: self.index == new_index)
return self
Expand Down Expand Up @@ -1677,7 +1677,7 @@ def delete(self, expect_error=False):
if window_menus != 1:
self.testcase.fail('Error: marketplace was not deleted')

self.testcase.assertNotEqual(self.get_current_marketplace_name(), market)
WebDriverWait(self.testcase.driver, 3).until(lambda driver: self.get_current_marketplace_name() != market)

def search(self, keyword):
catalogue_base_element = self.wait_catalogue_ready()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type": "widget", "vendor": "Wirecloud", "name": "Test", "versions": [{"license": "", "contributors": [], "title": "Test", "licenseurl": "", "homepage": "", "description": "This widget is used to test some of the features of the Wirecloud platform", "changelog": "CHANGELOG.md", "uriTemplate": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/Wirecloud_Test_1.0.wgt", "longdescription": "<p>This widget is used for <strong>testing</strong> some of the features provided by Wirecloud</p>", "doc": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/doc/index.md", "email": "aarranz@conwet.com", "version": "1.0", "image": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/images/catalogue.png", "authors": [{"name": "aarranz"}], "date": 1417631958883.257, "size": 41384, "id": 18, "permissions": {"uninstall": true, "delete": true}}]}
{"type": "widget", "vendor": "Wirecloud", "name": "Test", "versions": [{"license": "", "contributors": [], "title": "Test", "licenseurl": "", "homepage": "", "description": "This widget is used to test some of the features of the Wirecloud platform", "changelog": "CHANGELOG.md", "uriTemplate": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/Wirecloud_Test_1.0.wgt", "longdescription": "<p>This widget is used for <strong>testing</strong> some of the features provided by Wirecloud</p>", "doc": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/doc/index.md", "email": "aarranz@conwet.com", "version": "1.0", "image": "http://wcatalogue.example.com/catalogue/media/Wirecloud/Test/1.0/images/catalogue.png", "authors": [{"name": "aarranz"}], "date": 1417631958883.257, "size": 41384, "id": 18, "permissions": {"uninstall": false, "delete": false}}]}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type": "mashup", "vendor": "Wirecloud", "name": "test-mashup", "versions": [{"license": "", "contributors": [], "title": "Test Mashup", "licenseurl": "", "homepage": "", "description": "Wirecloud Mashup composed of: Test, Test", "changelog": "", "uriTemplate": "http://wcatalogue.example.com/catalogue/media/Wirecloud/test-mashup/1.0/Wirecloud_test-mashup_1.0.wgt", "longdescription": "Wirecloud Mashup composed of: Test, Test", "doc": "", "email": "wirecloud@conwet.com", "version": "1.0", "image": "http://wcatalogue.example.com/images/catalogue/widget_image.png", "authors": [{"name": "admin"}], "date": 1418139895196.074, "size": 747, "id": 22, "permissions": {"uninstall": true, "delete": true}}]}
{"type": "mashup", "vendor": "Wirecloud", "name": "test-mashup", "versions": [{"license": "", "contributors": [], "title": "Test Mashup", "licenseurl": "", "homepage": "", "description": "Wirecloud Mashup composed of: Test, Test", "changelog": "", "uriTemplate": "http://wcatalogue.example.com/catalogue/media/Wirecloud/test-mashup/1.0/Wirecloud_test-mashup_1.0.wgt", "longdescription": "Wirecloud Mashup composed of: Test, Test", "doc": "", "email": "wirecloud@conwet.com", "version": "1.0", "image": "http://wcatalogue.example.com/images/catalogue/widget_image.png", "authors": [{"name": "admin"}], "date": 1418139895196.074, "size": 747, "id": 22, "permissions": {"uninstall": false, "delete": false}}]}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'scope': 'all',
'requestFunc': this._search.bind(this),
'processFunc': function (elements, search_info) {
var i, msg;
var msg;

this.resource_list.clear();

Expand All @@ -71,9 +71,11 @@
}));
}

for (i = 0; i < elements.length; i += 1) {
this.resource_list.appendChild(this.resource_painter.paint(elements[i]));
}
elements.forEach((element) => {
element.version = new Wirecloud.Version(element.version);
element.group_id = element.vendor_name;
this.resource_list.appendChild(this.resource_painter.paint(element));
});
}.bind(this)
});
this.source.addEventListener('optionsChanged', function (source, options) {
Expand Down
49 changes: 4 additions & 45 deletions src/wirecloud/platform/static/js/catalogue/CatalogueView.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
this.appendChild(this.alternatives);

resource_extra_context = {
'mainbutton': function (options, context, resource) {
'mainbutton': (options, context, resource) => {
var button, local_catalogue_view;

local_catalogue_view = Wirecloud.UserInterfaceManager.views.myresources;
Expand All @@ -50,18 +50,18 @@
'class': 'btn-danger',
'text': utils.gettext('Uninstall')
});
button.addEventListener('click', local_catalogue_view.createUserCommand('uninstall', resource, this.catalogue));
button.addEventListener('click', local_catalogue_view.createUserCommand('uninstall', resource, this));
} else {
button = new StyledElements.Button({
'class': 'btn-success',
'text': utils.gettext('Install')
});

button.addEventListener('click', local_catalogue_view.createUserCommand('install', resource, this.catalogue));
button.addEventListener('click', local_catalogue_view.createUserCommand('install', resource, this));
}
button.addClassName('mainbutton');
return button;
}.bind(this)
}
};

this.viewsByName = {
Expand Down Expand Up @@ -155,22 +155,6 @@

CatalogueView.prototype.ui_commands = {};

CatalogueView.prototype.ui_commands.install = function install(resource, catalogue_source) {
return function () {
Wirecloud.UserInterfaceManager.monitorTask(
this.catalogue.addComponent({url: resource.description_url}).then(
() => {
this.refresh_search_results();

catalogue_source.home();
catalogue_source.refresh_search_results();
},
logerror
)
);
}.bind(this);
};

CatalogueView.prototype.ui_commands.showDetails = function showDetails(resource, options) {
options = utils.merge({
history: "push"
Expand Down Expand Up @@ -209,31 +193,6 @@
}.bind(this);
};

CatalogueView.prototype.ui_commands.delete = function (resource) {
var doRequest, msg;

doRequest = function () {
Wirecloud.UserInterfaceManager.monitorTask(
this.catalogue.deleteResource(resource).then(
() => {
this.home();
this.refresh_search_results();
},
logerror
)
);
};

// First ask the user
msg = utils.gettext('Do you really want to remove the "%(name)s" (vendor: "%(vendor)s", version: "%(version)s") component?');
msg = utils.interpolate(msg, resource, true);
return function () {
var dialog = new Wirecloud.ui.AlertWindowMenu(msg);
dialog.setHandler(doRequest.bind(this));
dialog.show();
}.bind(this);
};

CatalogueView.prototype.refresh_if_needed = function refresh_if_needed() {
if (this.alternatives.getCurrentAlternative() === this.viewsByName.search) {
this.viewsByName.search.refresh_if_needed();
Expand Down