add notes from our review

pull/1/head
ansuz 4 years ago
parent 67af5c220c
commit 4e3a7fef24

@ -27,6 +27,7 @@ DISABLE_INTEGRATED_EVICTION
// BROADCAST // BROADCAST
SET_LAST_BROADCAST_HASH SET_LAST_BROADCAST_HASH
SET_SURVEY_URL SET_SURVEY_URL
SET_MAINTENANCE
NOT IMPLEMENTED: NOT IMPLEMENTED:
@ -129,10 +130,10 @@ var args_isString = function (args) {
return Array.isArray(args) && typeof(args[0]) === "string"; return Array.isArray(args) && typeof(args[0]) === "string";
}; };
var args_isMaintenance = function (args) { var args_isMaintenance = function (args) {
return Array.isArray(args) && args[0] && args[0].end && args[0].start; return Array.isArray(args) && args[0] && args[0].end && args[0].start; // XXX we could validate that these are numbers && !isNaN
}; };
var makeBroadcastSetter = function (attr) { var makeBroadcastSetter = function (attr) { // XXX could pass extra validation here?
return function (Env, args) { return function (Env, args) {
if (!args_isString(args) && !args_isMaintenance(args)) { if (!args_isString(args) && !args_isMaintenance(args)) {
throw new Error('INVALID_ARGS'); throw new Error('INVALID_ARGS');
@ -149,7 +150,7 @@ var makeBroadcastSetter = function (attr) {
commands.SET_LAST_BROADCAST_HASH = makeBroadcastSetter('lastBroadcastHash'); commands.SET_LAST_BROADCAST_HASH = makeBroadcastSetter('lastBroadcastHash');
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_SURVEY_URL', [url]]], console.log) // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_SURVEY_URL', [url]]], console.log)
commands.SET_SURVEY_URL = makeBroadcastSetter('surveyURL'); commands.SET_SURVEY_URL = makeBroadcastSetter('surveyURL'); // XXX anticipate language-specific surveys
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [{start: +Date, end: +Date}]]], console.log) // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [{start: +Date, end: +Date}]]], console.log)
// CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [""]]], console.log) // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['SET_MAINTENANCE', [""]]], console.log)

@ -113,8 +113,7 @@ var setHeaders = (function () {
// Don't set CSP headers on /api/config because they aren't necessary and they cause problems // Don't set CSP headers on /api/config because they aren't necessary and they cause problems
// when duplicated by NGINX in production environments // when duplicated by NGINX in production environments
// XXX /api/broadcast too? if (/^\/api\/(broadcast|config)/.test(req.url)) { return; }
if (/^\/api\/config/.test(req.url)) { return; }
// targeted CSP, generic policies, maybe custom headers // targeted CSP, generic policies, maybe custom headers
const h = [ const h = [
/^\/common\/onlyoffice\/.*\/index\.html.*/, /^\/common\/onlyoffice\/.*\/index\.html.*/,
@ -273,7 +272,7 @@ var serveConfig = (function () {
}; };
}()); }());
var serveBroadcast = (function () { var serveBroadcast = (function () { // XXX deduplicate
var cacheString = function () { var cacheString = function () {
return (Env.FRESH_KEY? '-' + Env.FRESH_KEY: '') + (Env.DEV_MODE? '-' + (+new Date()): ''); return (Env.FRESH_KEY? '-' + Env.FRESH_KEY: '') + (Env.DEV_MODE? '-' + (+new Date()): '');
}; };
@ -284,7 +283,7 @@ var serveBroadcast = (function () {
maintenance = undefined; maintenance = undefined;
} }
return [ return [
'define(function(){', 'define(function(){', // XXX maybe this could just be JSON
'return ' + JSON.stringify({ 'return ' + JSON.stringify({
lastBroadcastHash: Env.lastBroadcastHash, lastBroadcastHash: Env.lastBroadcastHash,
surveyURL: Env.surveyURL, surveyURL: Env.surveyURL,

@ -14,6 +14,10 @@
display: flex; display: flex;
flex-flow: column; flex-flow: column;
a {
color: @cryptpad_color_link;
text-decoration: underline;
}
.cp-admin-setlimit-form, .cp-admin-broadcast-form { .cp-admin-setlimit-form, .cp-admin-broadcast-form {
label { label {

@ -970,6 +970,7 @@ define([
var getApi = function (cb) { var getApi = function (cb) {
return function () { return function () {
require(['/api/broadcast?'+ (+new Date())], function (Broadcast) { require(['/api/broadcast?'+ (+new Date())], function (Broadcast) {
// XXX require.s.contexts._ can be used to erase old loaded objects
cb(Broadcast); cb(Broadcast);
}); });
}; };
@ -1219,7 +1220,7 @@ define([
} }
if (error) { if (error) {
console.error('One of the selected languages has no data'); console.error('One of the selected languages has no data');
return false; return false; // XXX better error handling?
} }
return { return {
defaultLanguage: defaultLanguage, defaultLanguage: defaultLanguage,
@ -1229,7 +1230,7 @@ define([
var send = function (data) { var send = function (data) {
$button.prop('disabled', 'disabled'); $button.prop('disabled', 'disabled');
data.time = +new Date(); data.time = +new Date(); // XXX not used anymore?
common.mailbox.sendTo('BROADCAST_CUSTOM', data, {}, function (err /*, data */) { // XXX unused argument common.mailbox.sendTo('BROADCAST_CUSTOM', data, {}, function (err /*, data */) { // XXX unused argument
if (err) { if (err) {
$button.prop('disabled', ''); $button.prop('disabled', '');
@ -1249,7 +1250,7 @@ define([
send(data); send(data);
}); });
UI.confirmButton(removeButton, { UI.confirmButton(removeButton, { // XXX table jank
classes: 'btn-danger', classes: 'btn-danger',
}, function () { }, function () {
if (!activeUid) { return; } if (!activeUid) { return; }
@ -1311,7 +1312,8 @@ define([
var end = h('input'); var end = h('input');
var $start = $(start); var $start = $(start);
var $end = $(end); var $end = $(end);
var endPickr = Flatpickr(end, { // XXX new Date().toLocaleString('fr-fr', {month: 'long'}).replace(/./, c => c.toUpperCase())
var endPickr = Flatpickr(end, { // XXX translations?
enableTime: true, enableTime: true,
minDate: new Date() minDate: new Date()
}); });
@ -1411,7 +1413,7 @@ define([
common.openUnsafeURL(Broadcast.surveyURL); common.openUnsafeURL(Broadcast.surveyURL);
}); });
active = h('div.cp-broadcast-active', [ active = h('div.cp-broadcast-active', [
h('p', a), h('p', a), // XXX spacing around this element is really cramped
removeButton removeButton
]); ]);
} }

@ -162,7 +162,7 @@ define(function() {
// making it much faster to open new tabs. // making it much faster to open new tabs.
config.disableWorkers = false; config.disableWorkers = false;
//config.surveyURL = ""; //config.surveyURL = ""; // XXX remove this?
// Teams are always loaded during the initial loading screen (for the first tab only if // Teams are always loaded during the initial loading screen (for the first tab only if
// SharedWorkers are available). Allowing users to be members of multiple teams can // SharedWorkers are available). Allowing users to be members of multiple teams can

@ -466,7 +466,7 @@ define([
return { return {
add: function(common, data) { add: function(common, data) {
console.log(data); console.log(data); // XXX noise?
var type = data.content.msg.type; var type = data.content.msg.type;
if (handlers[type]) { if (handlers[type]) {

@ -3156,7 +3156,7 @@ define([
}); });
}; };
Store.newVersionReload = function () { Store.newVersionReload = function () { // XXX not used anymore?
broadcast([], "NETWORK_RECONNECT"); broadcast([], "NETWORK_RECONNECT");
}; };
Store.disconnect = function () { Store.disconnect = function () {

@ -341,7 +341,7 @@ proxy.mailboxes = {
}; };
var notify = box.ready; var notify = box.ready;
Handlers.add(ctx, box, message, function (dismissed, toDismiss, setAsLKH) { Handlers.add(ctx, box, message, function (dismissed, toDismiss, setAsLKH) {
if (setAsLKH) { if (setAsLKH) { // XXX confirm whether this if is used?
// Update LKH // Update LKH
box.data.lastKnownHash = hash; box.data.lastKnownHash = hash;
box.data.viewed = []; box.data.viewed = [];

@ -1032,7 +1032,7 @@ MessengerUI, Messages) {
Messages.broadcast_maintenance = "A maintenance is planned between <b>{0}</b> and <b>{1}</b>"; // XXX Messages.broadcast_maintenance = "A maintenance is planned between <b>{0}</b> and <b>{1}</b>"; // XXX
var createMaintenance = function (toolbar, config) { var createMaintenance = function (toolbar, config) {
var $notif = toolbar.$top.find('.'+MAINTENANCE_CLS); var $notif = toolbar.$top.find('.'+MAINTENANCE_CLS);
var button = h('button.cp-maintenance-wrench.fa.fa-wrench'); var button = h('button.cp-maintenance-wrench.fa.fa-wrench'); // XXX might need some color contrast
$notif.append(button); $notif.append(button);

@ -445,7 +445,7 @@ define([
}; };
ctx.FM = common.createFileManager(fmConfig); ctx.FM = common.createFileManager(fmConfig);
ui.send = function (id, type, data, dest) { ui.send = function (id, type, data, dest) { // XXX confirm that this is actually used
return send(ctx, id, type, data, dest); return send(ctx, id, type, data, dest);
}; };
ui.sendForm = function (id, form, dest) { ui.sendForm = function (id, form, dest) {

Loading…
Cancel
Save