Merge branch 'staging' into editable-metadata
This commit is contained in:
commit
9f959eccea
@ -119,15 +119,32 @@ define([
|
|||||||
$('<label>', {'for': 'cp-app-prop-owners'}).text(Messages.creation_owners)
|
$('<label>', {'for': 'cp-app-prop-owners'}).text(Messages.creation_owners)
|
||||||
.appendTo($d);
|
.appendTo($d);
|
||||||
var owners = Messages.creation_noOwner;
|
var owners = Messages.creation_noOwner;
|
||||||
var edPublic = common.getMetadataMgr().getPrivateData().edPublic;
|
var priv = common.getMetadataMgr().getPrivateData();
|
||||||
|
var edPublic = priv.edPublic;
|
||||||
var owned = false;
|
var owned = false;
|
||||||
if (data.owners && data.owners.length) {
|
if (data.owners && data.owners.length) {
|
||||||
if (data.owners.indexOf(edPublic) !== -1) {
|
if (data.owners.indexOf(edPublic) !== -1) {
|
||||||
owners = Messages.yourself;
|
|
||||||
owned = true;
|
owned = true;
|
||||||
} else {
|
|
||||||
owners = Messages.creation_ownedByOther;
|
|
||||||
}
|
}
|
||||||
|
var names = [];
|
||||||
|
var strangers = 0;
|
||||||
|
data.owners.forEach(function (ed) {
|
||||||
|
// If a friend is an owner, add their name to the list
|
||||||
|
// otherwise, increment the list of strangers
|
||||||
|
if (!Object.keys(priv.friends || {}).some(function (c) {
|
||||||
|
var friend = priv.friends[c] || {};
|
||||||
|
if (friend.edPublic !== ed) { return; }
|
||||||
|
var name = c === 'me' ? Messages.yourself : friend.displayName;
|
||||||
|
names.push(name);
|
||||||
|
return true;
|
||||||
|
})) {
|
||||||
|
strangers++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (strangers) {
|
||||||
|
names.push(Messages._getKey('properties_unknownUser', [strangers]));
|
||||||
|
}
|
||||||
|
owners = names.join(', ');
|
||||||
}
|
}
|
||||||
$d.append(UI.dialog.selectable(owners, {
|
$d.append(UI.dialog.selectable(owners, {
|
||||||
id: 'cp-app-prop-owners',
|
id: 'cp-app-prop-owners',
|
||||||
@ -325,7 +342,7 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var getFriendsList = function (config) {
|
var getFriendsList = function (config, onShare) {
|
||||||
var common = config.common;
|
var common = config.common;
|
||||||
var title = config.title;
|
var title = config.title;
|
||||||
var friends = config.friends;
|
var friends = config.friends;
|
||||||
@ -413,6 +430,7 @@ define([
|
|||||||
common.mailbox.sendTo("SHARE_PAD", {
|
common.mailbox.sendTo("SHARE_PAD", {
|
||||||
href: href,
|
href: href,
|
||||||
password: config.password,
|
password: config.password,
|
||||||
|
isTemplate: config.isTemplate,
|
||||||
name: myName,
|
name: myName,
|
||||||
title: title
|
title: title
|
||||||
}, {
|
}, {
|
||||||
@ -436,6 +454,9 @@ define([
|
|||||||
return smallCurves.indexOf(curve) !== -1;
|
return smallCurves.indexOf(curve) !== -1;
|
||||||
});
|
});
|
||||||
common.setAttribute(['general', 'share-friends'], order);
|
common.setAttribute(['general', 'share-friends'], order);
|
||||||
|
if (onShare) {
|
||||||
|
onShare.fire();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$nav.append(button);
|
$nav.append(button);
|
||||||
}
|
}
|
||||||
@ -512,8 +533,10 @@ define([
|
|||||||
|
|
||||||
// Share link tab
|
// Share link tab
|
||||||
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
var hasFriends = Object.keys(config.friends || {}).length !== 0;
|
||||||
var friendsList = hasFriends ? getFriendsList(config) : undefined;
|
var onFriendShare = Util.mkEvent();
|
||||||
|
var friendsList = hasFriends ? getFriendsList(config, onFriendShare) : undefined;
|
||||||
var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
|
var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
|
||||||
|
|
||||||
var link = h('div.cp-share-modal' + friendsUIClass, [
|
var link = h('div.cp-share-modal' + friendsUIClass, [
|
||||||
h('div.cp-share-column', [
|
h('div.cp-share-column', [
|
||||||
hasFriends ? h('p', Messages.share_description) : undefined,
|
hasFriends ? h('p', Messages.share_description) : undefined,
|
||||||
@ -547,6 +570,7 @@ define([
|
|||||||
present: present
|
present: present
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
onFriendShare.reg(saveValue);
|
||||||
var getLinkValue = function (initValue) {
|
var getLinkValue = function (initValue) {
|
||||||
var val = initValue || {};
|
var val = initValue || {};
|
||||||
var edit = initValue ? val.edit : Util.isChecked($(link).find('#cp-share-editable-true'));
|
var edit = initValue ? val.edit : Util.isChecked($(link).find('#cp-share-editable-true'));
|
||||||
|
|||||||
@ -4,8 +4,10 @@ define([
|
|||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
'/common/common-ui-elements.js',
|
'/common/common-ui-elements.js',
|
||||||
|
'/common/common-constants.js',
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
], function ($, h, Hash, UI, UIElements, Messages) {
|
'/bower_components/nthen/index.js'
|
||||||
|
], function ($, h, Hash, UI, UIElements, Constants, Messages, nThen) {
|
||||||
|
|
||||||
var handlers = {};
|
var handlers = {};
|
||||||
|
|
||||||
@ -83,11 +85,16 @@ define([
|
|||||||
common.openURL(msg.content.href);
|
common.openURL(msg.content.href);
|
||||||
defaultDismiss(common, data)();
|
defaultDismiss(common, data)();
|
||||||
};
|
};
|
||||||
if (!msg.content.password) { return void todo(); }
|
nThen(function (waitFor) {
|
||||||
common.getSframeChannel().query('Q_SESSIONSTORAGE_PUT', {
|
if (msg.content.isTemplate) {
|
||||||
key: 'newPadPassword',
|
common.sessionStorage.put(Constants.newPadPathKey, ['template'], waitFor());
|
||||||
value: msg.content.password
|
}
|
||||||
}, todo);
|
if (msg.content.password) {
|
||||||
|
common.sessionStorage.put('newPadPassword', msg.content.password, waitFor());
|
||||||
|
}
|
||||||
|
}).nThen(function () {
|
||||||
|
todo();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
if (!content.archived) {
|
if (!content.archived) {
|
||||||
content.dismissHandler = defaultDismiss(common, data);
|
content.dismissHandler = defaultDismiss(common, data);
|
||||||
@ -126,17 +133,18 @@ define([
|
|||||||
var link = h('a', {
|
var link = h('a', {
|
||||||
href: '#'
|
href: '#'
|
||||||
}, Messages.requestEdit_viewPad);
|
}, Messages.requestEdit_viewPad);
|
||||||
var verified = h('p.cp-notifications-requestedit-verified');
|
var verified = h('p');
|
||||||
var $verified = $(verified);
|
var $verified = $(verified);
|
||||||
|
|
||||||
if (priv.friends && priv.friends[msg.author]) {
|
if (priv.friends && priv.friends[msg.author]) {
|
||||||
|
$verified.addClass('cp-notifications-requestedit-verified');
|
||||||
var f = priv.friends[msg.author];
|
var f = priv.friends[msg.author];
|
||||||
$verified.append(h('span.fa.fa-certificate'));
|
$verified.append(h('span.fa.fa-certificate'));
|
||||||
var $avatar = $(h('span.cp-avatar')).appendTo($verified);
|
var $avatar = $(h('span.cp-avatar')).appendTo($verified);
|
||||||
$verified.append(h('p', Messages._getKey('requestEdit_fromFriend', [f.displayName])));
|
$verified.append(h('p', Messages._getKey('requestEdit_fromFriend', [f.displayName])));
|
||||||
common.displayAvatar($avatar, f.avatar, f.displayName);
|
common.displayAvatar($avatar, f.avatar, f.displayName);
|
||||||
} else {
|
} else {
|
||||||
$verified.append(Messages.requestEdit_fromStranger);
|
$verified.append(Messages._getKey('requestEdit_fromStranger', [msg.content.user.displayName]));
|
||||||
}
|
}
|
||||||
|
|
||||||
var div = h('div', [
|
var div = h('div', [
|
||||||
|
|||||||
@ -272,23 +272,25 @@ define([
|
|||||||
var parsed = Utils.Hash.parsePadUrl(window.location.href);
|
var parsed = Utils.Hash.parsePadUrl(window.location.href);
|
||||||
if (!parsed.type) { throw new Error(); }
|
if (!parsed.type) { throw new Error(); }
|
||||||
var defaultTitle = Utils.Hash.getDefaultName(parsed);
|
var defaultTitle = Utils.Hash.getDefaultName(parsed);
|
||||||
var edPublic;
|
var edPublic, isTemplate;
|
||||||
var forceCreationScreen = cfg.useCreationScreen &&
|
var forceCreationScreen = cfg.useCreationScreen &&
|
||||||
sessionStorage[Utils.Constants.displayPadCreationScreen];
|
sessionStorage[Utils.Constants.displayPadCreationScreen];
|
||||||
delete sessionStorage[Utils.Constants.displayPadCreationScreen];
|
delete sessionStorage[Utils.Constants.displayPadCreationScreen];
|
||||||
var updateMeta = function () {
|
var updateMeta = function () {
|
||||||
//console.log('EV_METADATA_UPDATE');
|
//console.log('EV_METADATA_UPDATE');
|
||||||
var metaObj, isTemplate;
|
var metaObj;
|
||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
Cryptpad.getMetadata(waitFor(function (err, m) {
|
Cryptpad.getMetadata(waitFor(function (err, m) {
|
||||||
if (err) { console.log(err); }
|
if (err) { console.log(err); }
|
||||||
metaObj = m;
|
metaObj = m;
|
||||||
edPublic = metaObj.priv.edPublic; // needed to create an owned pad
|
edPublic = metaObj.priv.edPublic; // needed to create an owned pad
|
||||||
}));
|
}));
|
||||||
|
if (typeof(isTemplate) === "undefined") {
|
||||||
Cryptpad.isTemplate(window.location.href, waitFor(function (err, t) {
|
Cryptpad.isTemplate(window.location.href, waitFor(function (err, t) {
|
||||||
if (err) { console.log(err); }
|
if (err) { console.log(err); }
|
||||||
isTemplate = t;
|
isTemplate = t;
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
}).nThen(function (/*waitFor*/) {
|
}).nThen(function (/*waitFor*/) {
|
||||||
metaObj.doc = {
|
metaObj.doc = {
|
||||||
defaultTitle: defaultTitle,
|
defaultTitle: defaultTitle,
|
||||||
@ -735,6 +737,7 @@ define([
|
|||||||
var initShareModal = function (cfg) {
|
var initShareModal = function (cfg) {
|
||||||
cfg.hashes = hashes;
|
cfg.hashes = hashes;
|
||||||
cfg.password = password;
|
cfg.password = password;
|
||||||
|
cfg.isTemplate = isTemplate;
|
||||||
// cfg.hidden means pre-loading the filepicker while keeping it hidden.
|
// cfg.hidden means pre-loading the filepicker while keeping it hidden.
|
||||||
// if cfg.hidden is true and the iframe already exists, do nothing
|
// if cfg.hidden is true and the iframe already exists, do nothing
|
||||||
if (!ShareModal.$iframe) {
|
if (!ShareModal.$iframe) {
|
||||||
|
|||||||
@ -1111,5 +1111,17 @@
|
|||||||
"notifications_cat_friends": "Freundschaftsanfragen",
|
"notifications_cat_friends": "Freundschaftsanfragen",
|
||||||
"notifications_cat_pads": "Mit mir geteilt",
|
"notifications_cat_pads": "Mit mir geteilt",
|
||||||
"notifications_cat_archived": "Verlauf",
|
"notifications_cat_archived": "Verlauf",
|
||||||
"notifications_dismissAll": "Alle verbergen"
|
"notifications_dismissAll": "Alle verbergen",
|
||||||
|
"support_notification": "",
|
||||||
|
"requestEdit_button": "",
|
||||||
|
"requestEdit_dialog": "",
|
||||||
|
"requestEdit_confirm": "",
|
||||||
|
"requestEdit_fromFriend": "",
|
||||||
|
"requestEdit_fromStranger": "",
|
||||||
|
"requestEdit_viewPad": "",
|
||||||
|
"later": "",
|
||||||
|
"requestEdit_request": "",
|
||||||
|
"requestEdit_accepted": "",
|
||||||
|
"requestEdit_sent": "",
|
||||||
|
"uploadFolderButton": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1123,5 +1123,6 @@
|
|||||||
"requestEdit_request": "{1} wants to edit the pad <b>{0}</b>",
|
"requestEdit_request": "{1} wants to edit the pad <b>{0}</b>",
|
||||||
"requestEdit_accepted": "{1} granted you edit rights for the pad <b>{0}</b>",
|
"requestEdit_accepted": "{1} granted you edit rights for the pad <b>{0}</b>",
|
||||||
"requestEdit_sent": "Request sent",
|
"requestEdit_sent": "Request sent",
|
||||||
"uploadFolderButton": "Upload folder"
|
"uploadFolderButton": "Upload folder",
|
||||||
|
"properties_unknownUser": "{0} unknown user(s)"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3601,6 +3601,7 @@ define([
|
|||||||
hash: parsed.hash,
|
hash: parsed.hash,
|
||||||
password: data.password
|
password: data.password
|
||||||
},
|
},
|
||||||
|
isTemplate: paths[0].path[0] === 'template',
|
||||||
title: data.title,
|
title: data.title,
|
||||||
common: common
|
common: common
|
||||||
};
|
};
|
||||||
|
|||||||
@ -43,6 +43,7 @@ define([
|
|||||||
origin: origin,
|
origin: origin,
|
||||||
pathname: pathname,
|
pathname: pathname,
|
||||||
password: priv.password,
|
password: priv.password,
|
||||||
|
isTemplate: priv.isTemplate,
|
||||||
hashes: hashes,
|
hashes: hashes,
|
||||||
common: common,
|
common: common,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
|
|||||||
@ -91,6 +91,7 @@ define([
|
|||||||
feedbackAllowed: Utils.Feedback.state,
|
feedbackAllowed: Utils.Feedback.state,
|
||||||
hashes: config.data.hashes,
|
hashes: config.data.hashes,
|
||||||
password: config.data.password,
|
password: config.data.password,
|
||||||
|
isTemplate: config.data.isTemplate,
|
||||||
file: config.data.file,
|
file: config.data.file,
|
||||||
};
|
};
|
||||||
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
|
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user