Commit 7e6b7ad0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '742-edit-project-privileges' into 'devel_12.2.x'

update/remove button is disabled when user has no privileges for managing overlays

See merge request minerva/core!711
parents d72b4887 f48493f6
Pipeline #9439 passed with stage
in 16 minutes and 36 seconds
......@@ -12,6 +12,8 @@ minerva (12.2.0~beta.3) unstable; urgency=medium
is default on Ubuntu 14 (#762)
* Bug fix: after project was modified it could happen that user was unable to
upload data overlay (#752)
* Bug fix: update/remove button is disabled when user has no privileges for
managing overlays (#742)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 6 Mar 2019 14:00:00 +0200
......
......@@ -774,9 +774,13 @@ EditProjectDialog.prototype.userToTableRow = function (user, columns) {
* @returns {Array}
*/
EditProjectDialog.prototype.overlayToTableRow = function (overlay, users) {
var self = this;
var row = [];
var id = overlay.getId();
var creatorSelect;
var loggedUser = null;
if (overlay.getCreator() === "") {
creatorSelect = "<select name='creator-" + id + "' value=''>";
} else {
......@@ -795,6 +799,10 @@ EditProjectDialog.prototype.overlayToTableRow = function (overlay, users) {
creatorSelect += "<option value='" + user.getLogin() + "' " + selected + ">" + user.getLogin() + "("
+ user.getName() + " " + user.getSurname() + ")</option>";
if (user.getLogin() === self.getServerConnector().getSessionData().getLogin()) {
loggedUser = user;
}
}
creatorSelect += "</select>";
......@@ -825,8 +833,15 @@ EditProjectDialog.prototype.overlayToTableRow = function (overlay, users) {
row[4] = defaultOverlayCheckbox;
row[5] = creatorSelect;
row[6] = downloadSourceButton;
row[7] = "<button name='saveOverlay' data='" + id + "'><i class=\"fa fa-save\" style=\"font-size:17px\"></i></button>";
row[8] = "<button name='removeOverlay' data='" + id + "'><i class='fa fa-trash-o' style='font-size:17px'></button>";
var disabled = " disabled ";
if (loggedUser.hasPrivilege(self.getConfiguration().getPrivilegeType(PrivilegeType.LAYOUT_MANAGEMENT), self.getProject().getId())) {
disabled = "";
}
row[7] = "<button name='saveOverlay' data='" + id + "'" + disabled + "><i class=\"fa fa-save\" style=\"font-size:17px\"></i></button>";
row[8] = "<button name='removeOverlay' data='" + id + "'" + disabled + "><i class='fa fa-trash-o' style='font-size:17px'></button>";
return row;
};
......@@ -1053,7 +1068,7 @@ EditProjectDialog.prototype.openAddOverlayDialog = function () {
});
return self._addOverlayDialog.init().then(function () {
return self._addOverlayDialog.open();
}).then(function(){
}).then(function () {
return self._addOverlayDialog;
});
};
......
......@@ -36,6 +36,7 @@ PrivilegeType.MANAGE_PLUGINS = 'MANAGE_PLUGINS';
PrivilegeType.PROJECT_MANAGEMENT = 'PROJECT_MANAGEMENT';
PrivilegeType.ADD_MAP = 'ADD_MAP';
PrivilegeType.USER_MANAGEMENT = 'USER_MANAGEMENT';
PrivilegeType.LAYOUT_MANAGEMENT = 'LAYOUT_MANAGEMENT';
/**
*
......
......@@ -6,7 +6,8 @@ var EditProjectDialog = require('../../../../main/js/gui/admin/EditProjectDialog
var ServerConnector = require('../../ServerConnector-mock');
var logger = require('../../logger');
var assert = require('assert');
var chai = require('chai');
var assert = chai.assert;
var Promise = require('bluebird');
describe('EditProjectDialog', function () {
......@@ -130,4 +131,37 @@ describe('EditProjectDialog', function () {
});
});
describe('overlayToTableRow', function () {
it('as not admin', function () {
var dialog;
helper.loginAsAdmin();
return createDialog().then(function (result) {
dialog = result;
return ServerConnector.getUsers();
}).then(function (users) {
helper.loginWithoutAccess();
var overlay = helper.createOverlay();
var data = dialog.overlayToTableRow(overlay, users);
assert.ok(data[7].indexOf("disabled") >= 0)
}).then(function () {
return dialog.destroy();
});
});
it('as admin', function () {
var dialog;
helper.loginAsAdmin();
return createDialog().then(function (result) {
dialog = result;
return ServerConnector.getUsers();
}).then(function (users) {
var overlay = helper.createOverlay();
var data = dialog.overlayToTableRow(overlay, users);
assert.equal(data[7].indexOf("disabled"), -1)
}).then(function () {
return dialog.destroy();
});
});
});
});
......@@ -7,6 +7,7 @@ var ServerConnector = require('../../ServerConnector-mock');
var logger = require('../../logger');
var assert = require('assert');
var Promise = require('bluebird');
function createMapsAdminPanel() {
return new MapsAdminPanel({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment