Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

This commit is contained in:
ansuz
2019-03-27 17:01:20 +01:00
15 changed files with 193 additions and 2 deletions

View File

@@ -17,6 +17,6 @@ define(function () {
// Sub
plan: 'CryptPad_plan',
// Apps
criticalApps: ['profile', 'settings', 'debug']
criticalApps: ['profile', 'settings', 'debug', 'admin']
};
});

View File

@@ -1634,6 +1634,14 @@ define([
content: h('span', Messages.settingsButton)
});
}
// Add administration panel link if the user is an admin
if (priv.edPublic && Array.isArray(Config.adminKeys) && Config.adminKeys.indexOf(priv.edPublic) !== -1) {
options.push({
tag: 'a',
attributes: {'class': 'cp-toolbar-menu-admin fa fa-cogs'},
content: h('span', Messages.adminPage || 'Admin')
});
}
// Add login or logout button depending on the current status
if (accountName) {
options.push({
@@ -1729,6 +1737,13 @@ define([
window.parent.location = origin+'/settings/';
}
});
$userAdmin.find('a.cp-toolbar-menu-admin').click(function () {
if (padType) {
window.open(origin+'/admin/');
} else {
window.parent.location = origin+'/admin/';
}
});
$userAdmin.find('a.cp-toolbar-menu-profile').click(function () {
if (padType) {
window.open(origin+'/profile/');

View File

@@ -615,6 +615,11 @@ define([
});
};
// Admin
common.adminRpc = function (data, cb) {
postMessage("ADMIN_RPC", data, cb);
};
// Network
common.onNetworkDisconnect = Util.mkEvent();
common.onNetworkReconnect = Util.mkEvent();

View File

@@ -947,6 +947,14 @@ define([
}
};
// Admin
Store.adminRpc = function (clientId, data, cb) {
store.rpc.adminRpc(data, function (err, res) {
if (err) { return void cb({error: err}); }
cb(res);
});
};
//////////////////////////////////////////////////////////////////
/////////////////////// PAD //////////////////////////////////////
//////////////////////////////////////////////////////////////////

View File

@@ -77,6 +77,8 @@ define([
DRIVE_USEROBJECT: Store.userObjectCommand,
// Settings,
DELETE_ACCOUNT: Store.deleteAccount,
// Admin
ADMIN_RPC: Store.adminRpc,
};
Rpc.query = function (cmd, data, cb) {

View File

@@ -58,6 +58,18 @@ define([
rpc.send('UNPIN', channels, cb);
};
// Get data for the admin panel
exp.adminRpc = function (obj, cb) {
if (!obj.cmd) {
setTimeout(function () {
cb('[TypeError] admin rpc expects a command');
});
return;
}
var params = [obj.cmd, obj.data];
rpc.send('ADMIN', params, cb);
};
// ask the server what it thinks your hash is
exp.getServerHash = function (cb) {
rpc.send('GET_HASH', edPublic, function (e, hash) {

View File

@@ -409,6 +409,10 @@ define([
setDocumentTitle();
});
sframeChan.on('EV_SET_HASH', function (hash) {
window.location.hash = hash;
});
Cryptpad.autoStore.onStoreRequest.reg(function (data) {
sframeChan.event("EV_AUTOSTORE_DISPLAY_POPUP", data);
});

View File

@@ -228,6 +228,10 @@ define([
ctx.sframeChan.event('EV_SET_TAB_TITLE', newTitle);
};
funcs.setHash = function (hash) {
ctx.sframeChan.event('EV_SET_HASH', hash);
};
funcs.setLoginRedirect = function (cb) {
cb = cb || $.noop;
ctx.sframeChan.query('Q_SET_LOGIN_REDIRECT', null, cb);