Merge branch 'communities-allow-list' of github.com:xwiki-labs/cryptpad into communities-allow-list

pull/1/head
ansuz 5 years ago
commit ad7096d754

@ -73,7 +73,7 @@
font: @colortheme_app-font; font: @colortheme_app-font;
.cp-checkmark { .cp-checkmark {
color: #000000; color: @cryptpad_text_col;
} }
.cp-inline-alert-text { .cp-inline-alert-text {

@ -3586,7 +3586,7 @@ define([
}; };
UIElements.onServerError = function (common, err, toolbar, cb) { UIElements.onServerError = function (common, err, toolbar, cb) {
if (["EDELETED", "EEXPIRED"].indexOf(err.type) === -1) { return; } if (["EDELETED", "EEXPIRED", "ERESTRICTED"].indexOf(err.type) === -1) { return; }
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
var msg = err.type; var msg = err.type;
if (err.type === 'EEXPIRED') { if (err.type === 'EEXPIRED') {
@ -3600,11 +3600,13 @@ define([
if (err.loaded) { if (err.loaded) {
msg += Messages.errorCopy; msg += Messages.errorCopy;
} }
} else if (err.type === 'ERESTRICTED') {
msg = Messages.restrictedError || "RESTRICTED"; // XXX
} }
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
sframeChan.event('EV_SHARE_OPEN', {hidden: true}); sframeChan.event('EV_SHARE_OPEN', {hidden: true});
if (toolbar && typeof toolbar.deleted === "function") { toolbar.deleted(); } if (toolbar && typeof toolbar.deleted === "function") { toolbar.deleted(); }
UI.errorLoadingScreen(msg, true, true); UI.errorLoadingScreen(msg, Boolean(err.loaded), Boolean(err.loaded));
(cb || function () {})(); (cb || function () {})();
}; };

@ -167,7 +167,6 @@ define([
delete _friends[curve]; delete _friends[curve];
} }
}); });
// XXX if no more friends, display message...
if (!Object.keys(_friends).length) { if (!Object.keys(_friends).length) {
$div.append(h('div.cp-app-prop', [ $div.append(h('div.cp-app-prop', [
Messages.contacts, Messages.contacts,
@ -417,7 +416,8 @@ define([
} }
}); });
// XXX allow_removeConfirm, allow_checkbox, allow_text // XXX allow_removeConfirm, allow_checkbox, allow_text, allow_addConfirm
Messages.allow_addConfirm = "Are you sure?"; // XXX
Messages.allow_removeConfirm = "Are you sure?"; // XXX Messages.allow_removeConfirm = "Are you sure?"; // XXX
Messages.allow_checkbox = "Enable allow list"; // XXX Messages.allow_checkbox = "Enable allow list"; // XXX
Messages.allow_text = 'Pewpewpew'; // XXX Messages.allow_text = 'Pewpewpew'; // XXX
@ -570,7 +570,7 @@ define([
}).filter(function (x) { return x; }); }).filter(function (x) { return x; });
nThen(function (waitFor) { nThen(function (waitFor) {
var msg = Messages.owner_addConfirm; var msg = Messages.allow_addConfirm;
UI.confirm(msg, waitFor(function (yes) { UI.confirm(msg, waitFor(function (yes) {
if (!yes) { if (!yes) {
waitFor.abort(); waitFor.abort();
@ -896,6 +896,10 @@ define([
})); }));
} }
// Stop here for files: no allow list, no access request
// Also stop for shared folders
if (parsed.hashData.type !== 'pad' || parsed.type === 'drive') { return h('div', content); }
// Request edit access // Request edit access
if (data.roHref && !data.href) { if (data.roHref && !data.href) {
var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right', var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right',
@ -940,7 +944,7 @@ define([
var canMute = data.mailbox && owned === true && ( var canMute = data.mailbox && owned === true && (
(typeof (data.mailbox) === "string" && data.owners[0] === edPublic) || (typeof (data.mailbox) === "string" && data.owners[0] === edPublic) ||
data.mailbox[edPublic]); data.mailbox[edPublic]);
if (owned === true) { // XXX not for files if (owned === true) {
var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute); var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute);
var $cbox = $(cbox); var $cbox = $(cbox);
var spinner = UI.makeSpinner($cbox); var spinner = UI.makeSpinner($cbox);
@ -1038,7 +1042,8 @@ define([
Access.getAccessModal = function (common, opts, cb) { Access.getAccessModal = function (common, opts, cb) {
var data; var data;
var tab1, tab2, tab3; var tab1, tab2, tab3;
var owned = false; var disabled = false;
var allowDisabled = false;
var button = [{ var button = [{
className: 'cancel', className: 'cancel',
name: Messages.filePicker_close, name: Messages.filePicker_close,
@ -1054,7 +1059,10 @@ define([
data = _data; data = _data;
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
owned = isOwned(common, data); var owned = isOwned(common, data);
var parsed = Hash.parsePadUrl(data.href || data.roHref);
disabled = !owned || !parsed.hashData || parsed.hashData.type !== 'pad';
allowDisabled = parsed.type === 'drive';
getAccessTab(common, data, opts, waitFor(function (e, c) { getAccessTab(common, data, opts, waitFor(function (e, c) {
if (e) { if (e) {
@ -1066,18 +1074,19 @@ define([
}); });
})); }));
if (!owned) { return; } if (disabled) { return; }
// XXX if "file" ==> don't show "allow" and "owners"
getAllowTab(common, data, opts, waitFor(function (e, c) { if (!allowDisabled) {
if (e) { getAllowTab(common, data, opts, waitFor(function (e, c) {
waitFor.abort(); if (e) {
return void cb(e); waitFor.abort();
} return void cb(e);
tab2 = UI.dialog.customModal(c, { }
buttons: button tab2 = UI.dialog.customModal(c, {
}); buttons: button
})); });
}));
}
getOwnersTab(common, data, opts, waitFor(function (e, c) { getOwnersTab(common, data, opts, waitFor(function (e, c) {
if (e) { if (e) {
waitFor.abort(); waitFor.abort();
@ -1098,12 +1107,12 @@ define([
content: tab1 content: tab1
}, { }, {
title: Messages.access_allow, title: Messages.access_allow,
disabled: !owned, disabled: disabled || allowDisabled,
icon: "fa fa-list", icon: "fa fa-list",
content: tab2 content: tab2
}, { }, {
title: Messages.creation_owners, title: Messages.creation_owners,
disabled: !owned, disabled: disabled,
icon: "fa fa-id-badge", icon: "fa fa-id-badge",
content: tab3 content: tab3
}]); }]);

@ -900,10 +900,11 @@ define([
cb = cb || function () {}; cb = cb || function () {};
var sfId = Env.user.userObject.getSFIdFromHref(data.href); var sfId = Env.user.userObject.getSFIdFromHref(data.href);
if (sfId) { if (sfId) {
var sfData = Env.user.proxy[UserObject.SHARED_FOLDERS][sfId]; var sfData = getSharedFolderData(Env, sfId);
var sfValue = data.attr ? sfData[data.attr] : JSON.parse(JSON.stringify(sfData));
setTimeout(function () { setTimeout(function () {
cb(null, { cb(null, {
value: sfData[data.attr], value: sfValue,
atime: 1 atime: 1
}); });
}); });

Loading…
Cancel
Save