Commit 80386b85 authored by Piotr Gawron's avatar Piotr Gawron

Merge branch '626-add-option-to-disable-request-an-account' into 'master'

Resolve "Add option to disable `REQUEST AN ACCOUNT`"

Closes #626

See merge request !565
parents 4bec58cb fbcae4e0
Pipeline #8130 failed with stage
in 3 minutes and 2 seconds
......@@ -654,9 +654,10 @@ function createFooter() {
/**
*
* @returns {HTMLElement}
* @param {Configuration} configuration
* @return {HTMLElement}
*/
function createLoginDiv() {
function createLoginDiv(configuration) {
var loggedIn = false;
var result = functions.createElement({type: "center"});
......@@ -707,11 +708,17 @@ function createLoginDiv() {
$("#go_to_map_button", resultDiv).hide();
resultDiv.appendChild(functions.createElement({type: "br"}));
var requestAccountStyle = "";
if (configuration.getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).getValue() === "" ||
configuration.getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).getValue() === undefined) {
requestAccountStyle = "display: none";
}
resultDiv.appendChild(functions.createElement({
type: "a",
href: "javascript:;",
id: "register_button",
className: "adminLink",
style: requestAccountStyle,
content: '<i class="fa fa-chevron-right"></i> REQUEST AN ACCOUNT</a>',
xss: false
}));
......@@ -757,9 +764,9 @@ function createLoginDiv() {
});
$('#register_button', result).click(function () {
var email, content;
return ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_EMAIL").then(function (result) {
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (result) {
email = result;
return ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_DEFAULT_CONTENT");
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_DEFAULT_CONTENT);
}).then(function (result) {
content = encodeURIComponent(result);
document.location.href = 'mailto:' + email + '?subject=MINERVA account request&body=' + content;
......@@ -783,8 +790,8 @@ function createLogin(params) {
// make sure that we are logged in
return ServerConnector.createSession().then(function () {
return ServerConnector.getConfiguration();
}).then(function () {
var loginDiv = createLoginDiv();
}).then(function (configuration) {
var loginDiv = createLoginDiv(configuration);
params.getElement().appendChild(loginDiv);
return createFooter();
}).then(function (footer) {
......
......@@ -5,6 +5,7 @@ require("./mocha-config");
var Promise = require("bluebird");
var minerva = require('../../main/js/minerva');
var ConfigurationType = require('../../main/js/ConfigurationType');
var SecurityError = require('../../main/js/SecurityError');
var ServerConnectorMock = require('./ServerConnector-mock');
var Point = require('../../main/js/map/canvas/Point');
......@@ -279,8 +280,15 @@ describe('minerva global', function () {
});
});
describe('createLogin', function () {
it('no request account email configured', function () {
helper.getConfiguration().getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).setValue("");
return minerva.createLogin({element: testDiv}).then(function () {
assert.ok($("#register_button").css("display") === "none");
});
});
it('default', function () {
return minerva.createLogin({element: testDiv}).then(function () {
assert.ok($("#register_button").css("display") !== "none");
assert.ok(testDiv.innerHTML.indexOf("MiNERVA") >= 0);
});
});
......
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