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

pull/1/head
ansuz 7 years ago
commit 5b4e5480cb

@ -36,7 +36,10 @@ var nt = nThen(function (waitFor) {
}).nThen; }).nThen;
[ [
// login test must happen after register test
['/register/', {}], ['/register/', {}],
['/login/', {}],
['/assert/', {}], ['/assert/', {}],
['/auth/', {}], ['/auth/', {}],

@ -14,7 +14,6 @@
} }
.cke_toolbox_main { .cke_toolbox_main {
display: inline-block; display: inline-block;
margin-bottom: -3px;
} }
#cke_1_contents { #cke_1_contents {
flex: 1; flex: 1;

@ -0,0 +1,40 @@
.icons_main() {
li {
display: inline-block;
margin: 10px 10px;
width: 140px;
height: 140px;
text-align: center;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
padding-top: 5px;
padding-bottom: 5px;
border: 1px solid white;
.cp-icons-name {
width: 100%;
height: 24px;
margin: 0;
display: inline-block;
font-size: 14px;
//align-items: center;
//justify-content: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
word-wrap: break-word;
}
.fa {
display: block;
margin: auto;
font-size: 64px;
margin: 18px 0;
text-align: center;
&.listonly {
display: none;
}
}
}
}

@ -6,6 +6,8 @@
@import (once) "./toolbar-history.less"; @import (once) "./toolbar-history.less";
@import (once) "./icon-colors.less"; @import (once) "./icon-colors.less";
@import (once) "./tools.less"; @import (once) "./tools.less";
@import (once) "./icons.less";
@import (once) "./modal.less";
.toolbar_main ( .toolbar_main (
@color: @colortheme_default-color, // Color of the text for the toolbar @color: @colortheme_default-color, // Color of the text for the toolbar
@ -173,6 +175,68 @@
} }
} }
#cp-app-toolbar-creation-dialog.cp-modal-container {
.icons_main();
li:hover {
border: 1px solid white;
}
.cp-modal {
display: flex;
flex-flow: column;
li, li .fa {
cursor: pointer;
}
&> p {
margin: 50px;
}
&> div {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
overflow-y: auto;
}
}
.cp-creation-icons-name {
white-space: nowrap;
}
#cp-app-toolbar-creation-advanced {
width: auto;
margin: 0;
padding: 0;
}
label[for="cp-app-toolbar-creation-advanced"] {
margin: 0;
margin-left: 5px;
}
@media screen and (max-height: @browser_media-not-big) {
.cp-modal {
& > p {
display: none;
}
& > div {
align-content: unset;
li {
height: 40px;
width: 200px;
display: flex;
align-items: center;
.fa {
font-size: 32px;
}
.cp-icons-name {
height: auto;
}
}
}
}
}
}
// TODO(cjd) This ought to be in a less file for markdown-based editors // TODO(cjd) This ought to be in a less file for markdown-based editors
.cp-markdown-toolbar { .cp-markdown-toolbar {
height: @toolbar_line-height; height: @toolbar_line-height;

@ -803,9 +803,12 @@ define(function () {
// Properties about creation data // Properties about creation data
out.creation_owners = "Propriétaires"; out.creation_owners = "Propriétaires";
out.creation_ownedByOther = "Possédé par un autre utilisateur"; out.creation_ownedByOther = "Possédé par un autre utilisateur";
out.creation_noOwner = "Pad de propriétaire"; out.creation_noOwner = "Pas de propriétaire";
out.creation_expiration = "Date d'expiration"; out.creation_expiration = "Date d'expiration";
out.creation_propertiesTitle = "Disponibilité"; out.creation_propertiesTitle = "Disponibilité";
out.creation_appMenuName = "Mode avancé (Ctrl + E)";
out.creation_newPadModalDescription = "Cliquez sur un type de pad pour le créer. Vous pouvez cocher la case pour afficher l'écran de création de pads";
out.creation_newPadModalAdvanced = "Afficher l'écran de création de pads";
return out; return out;
}); });

@ -839,6 +839,9 @@ define(function () {
out.creation_noOwner = "No owner"; out.creation_noOwner = "No owner";
out.creation_expiration = "Expiration time"; out.creation_expiration = "Expiration time";
out.creation_propertiesTitle = "Availability"; out.creation_propertiesTitle = "Availability";
out.creation_appMenuName = "Advanced mode (Ctrl + E)";
out.creation_newPadModalDescription = "Click on a pad type to create it. You can check the box if you want to display the pad creation screen (for owned pad, expiration pad, etc.).";
out.creation_newPadModalAdvanced = "Display the pad creation screen";
return out; return out;
}); });

@ -11,5 +11,6 @@ define(function () {
oldStorageKey: 'CryptPad_RECENTPADS', oldStorageKey: 'CryptPad_RECENTPADS',
storageKey: 'filesData', storageKey: 'filesData',
tokenKey: 'loginToken', tokenKey: 'loginToken',
displayPadCreationScreen: 'displayPadCreationScreen'
}; };
}); });

@ -5,6 +5,7 @@ define([
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-language.js', '/common/common-language.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-constants.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/common/media-tag.js', '/common/media-tag.js',
@ -13,8 +14,8 @@ define([
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'css!/common/tippy.css', 'css!/common/tippy.css',
], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages, AppConfig, ], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Messages,
NThen) { AppConfig, NThen) {
var UIElements = {}; var UIElements = {};
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
@ -1263,6 +1264,64 @@ define([
return $blockContainer; return $blockContainer;
}; };
UIElements.createNewPadModal = function (common) {
var $modal = UIElements.createModal({
id: 'cp-app-toolbar-creation-dialog',
$body: $('body')
});
var $title = $('<h3>').text(Messages.fm_newFile);
var $description = $('<p>').text(Messages.creation_newPadModalDescription);
$modal.find('.cp-modal').append($title);
$modal.find('.cp-modal').append($description);
var $advanced;
var $advancedContainer = $('<div>');
if (common.isLoggedIn()) {
$advanced = $('<input>', {
type: 'checkbox',
checked: 'checked',
id: 'cp-app-toolbar-creation-advanced'
}).appendTo($advancedContainer);
$('<label>', {
for: 'cp-app-toolbar-creation-advanced'
}).text(Messages.creation_newPadModalAdvanced).appendTo($advancedContainer);
}
var $container = $('<div>');
AppConfig.availablePadTypes.forEach(function (p) {
if (p === 'drive') { return; }
if (p === 'contacts') { return; }
if (p === 'todo') { return; }
if (p === 'file') { return; }
if (!common.isLoggedIn() && AppConfig.registeredOnlyTypes &&
AppConfig.registeredOnlyTypes.indexOf(p) !== -1) { return; }
var $element = $('<li>', {
'class': 'cp-icons-element'
}).prepend(UI.getIcon(p)).appendTo($container);
$element.append($('<span>', {'class': 'cp-icons-name'})
.text(Messages.type[p]));
$element.attr('data-type', p);
$element.click(function () {
$modal.hide();
if ($advanced && $advanced.is(':checked')) {
common.sessionStorage.put(Constants.displayPadCreationScreen, true, function () {
common.openURL('/' + p + '/');
});
return;
}
common.sessionStorage.put(Constants.displayPadCreationScreen, "", function () {
common.openURL('/' + p + '/');
});
});
});
/*var $content = createNewPadIcons($modal, isInRoot);*/
$modal.find('.cp-modal').append($container).append($advancedContainer);
window.setTimeout(function () { $modal.show(); });
//addNewPadHandlers($modal, isInRoot);
};
UIElements.initFilePicker = function (common, cfg) { UIElements.initFilePicker = function (common, cfg) {
var onSelect = cfg.onSelect || $.noop; var onSelect = cfg.onSelect || $.noop;

@ -407,7 +407,7 @@ define([
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
if (priv.isNewFile) { if (priv.isNewFile) {
var c = (priv.settings.general && priv.settings.general.creation) || {}; var c = (priv.settings.general && priv.settings.general.creation) || {};
if (c.skip) { return void common.createPad(c, waitFor()); } if (c.skip && !priv.forceCreationScreen) { return void common.createPad(c, waitFor()); }
common.getPadCreationScreen(c, waitFor()); common.getPadCreationScreen(c, waitFor());
} }
}).nThen(function (waitFor) { }).nThen(function (waitFor) {

@ -148,6 +148,9 @@ define([
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;
var forceCreationScreen = cfg.useCreationScreen &&
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, isTemplate;
@ -182,7 +185,8 @@ define([
upgradeURL: Cryptpad.upgradeURL upgradeURL: Cryptpad.upgradeURL
}, },
isNewFile: isNewFile, isNewFile: isNewFile,
isDeleted: window.location.hash.length > 0 isDeleted: window.location.hash.length > 0,
forceCreationScreen: forceCreationScreen
}; };
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; } for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }

@ -91,6 +91,7 @@ define([
funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector); funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector);
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar); funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen); funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal);
// Thumb // Thumb
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail); funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);

@ -933,6 +933,21 @@ define([
content: $('<div>').append(UI.getIcon(p)).html() + Messages.type[p] content: $('<div>').append(UI.getIcon(p)).html() + Messages.type[p]
}); });
}); });
if (Config.displayCreationScreen) {
pads_options.push({
tag: 'a',
attributes: {
id: 'cp-app-toolbar-creation-advanced',
href: origin
},
content: '<span class="fa fa-plus-circle"></span> ' + Messages.creation_appMenuName
});
$(window).keydown(function (e) {
if (e.which === 69 && e.ctrlKey) {
Common.createNewPadModal();
}
});
}
var dropdownConfig = { var dropdownConfig = {
text: '', // Button initial text text: '', // Button initial text
options: pads_options, // Entries displayed in the menu options: pads_options, // Entries displayed in the menu
@ -945,6 +960,10 @@ define([
var $newPadBlock = UIElements.createDropdown(dropdownConfig); var $newPadBlock = UIElements.createDropdown(dropdownConfig);
$newPadBlock.find('button').attr('title', Messages.newButtonTitle); $newPadBlock.find('button').attr('title', Messages.newButtonTitle);
$newPadBlock.find('button').addClass('fa fa-th'); $newPadBlock.find('button').addClass('fa fa-th');
$newPadBlock.find('#cp-app-toolbar-creation-advanced').click(function (e) {
e.preventDefault();
Common.createNewPadModal();
});
return $newPadBlock; return $newPadBlock;
}; };

@ -664,6 +664,10 @@ span {
} }
} }
.cp-app-drive-new-name {
white-space: nowrap;
}
@media screen and (max-height: @browser_media-not-big) { @media screen and (max-height: @browser_media-not-big) {
.cp-modal { .cp-modal {
& > p { & > p {

@ -6,9 +6,10 @@ define([
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/outer/local-store.js', '/common/outer/local-store.js',
'/common/test.js',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
], function ($, Cryptpad, Login, UI, Realtime, Feedback, LocalStore) { ], function ($, Cryptpad, Login, UI, Realtime, Feedback, LocalStore, Test) {
$(function () { $(function () {
var $main = $('#mainBlock'); var $main = $('#mainBlock');
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
@ -53,6 +54,7 @@ define([
}); });
var hashing = false; var hashing = false;
var test;
$('button.login').click(function () { $('button.login').click(function () {
if (hashing) { return void console.log("hashing is already in progress"); } if (hashing) { return void console.log("hashing is already in progress"); }
@ -89,6 +91,11 @@ define([
Realtime.whenRealtimeSyncs(result.realtime, function() { Realtime.whenRealtimeSyncs(result.realtime, function() {
LocalStore.login(result.userHash, result.userName, function () { LocalStore.login(result.userHash, result.userName, function () {
hashing = false; hashing = false;
if (test) {
localStorage.clear();
test.pass();
return;
}
if (sessionStorage.redirectTo) { if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo; var h = sessionStorage.redirectTo;
var parser = document.createElement('a'); var parser = document.createElement('a');
@ -145,5 +152,12 @@ define([
} }
window.location.href = '/register/'; window.location.href = '/register/';
}); });
Test(function (t) {
$uname.val('testuser');
$passwd.val('testtest');
test = t;
$('button.login').click();
});
}); });
}); });

@ -16,8 +16,9 @@
display: flex; display: flex;
} }
#cke_1_toolbox { #cke_1_toolbox {
display: inline-block; display: inline-flex;
width: 100%; width: 100%;
flex-flow: column;
background-color: @colortheme_pad-toolbar-bg; background-color: @colortheme_pad-toolbar-bg;
} }
#cke_1_toolbox .cke_toolbar { #cke_1_toolbox .cke_toolbar {

@ -13,7 +13,6 @@ define([
'/common/diffMarked.js', '/common/diffMarked.js',
'/common/sframe-common-codemirror.js', '/common/sframe-common-codemirror.js',
'/common/common-thumbnail.js', '/common/common-thumbnail.js',
'/bower_components/chainpad/chainpad.dist.js',
'/common/common-interface.js', '/common/common-interface.js',
'/customize/messages.js', '/customize/messages.js',
'cm/lib/codemirror', 'cm/lib/codemirror',
@ -43,7 +42,6 @@ define([
DiffMd, DiffMd,
SframeCM, SframeCM,
Thumb, Thumb,
ChainPad,
UI, UI,
Messages, Messages,
CMeditor, CMeditor,
@ -1110,6 +1108,8 @@ define([
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
$('#cp-app-poll-create-user').click(); $('#cp-app-poll-create-user').click();
setTimeout(waitFor()); setTimeout(waitFor());
}).nThen(function (waitFor) {
APP.rt.realtime.onSettle(waitFor());
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
passIfOk(t); passIfOk(t);
}); });

@ -54,11 +54,8 @@ define([
var $register = $('button#register'); var $register = $('button#register');
var registering = false; var registering = false;
var test;
var logMeIn = function (result) { var logMeIn = function (result) {
if (Test.testing) {
Test.passed();
return;
}
LocalStore.setUserHash(result.userHash); LocalStore.setUserHash(result.userHash);
var proxy = result.proxy; var proxy = result.proxy;
@ -72,6 +69,11 @@ define([
Realtime.whenRealtimeSyncs(result.realtime, function () { Realtime.whenRealtimeSyncs(result.realtime, function () {
LocalStore.login(result.userHash, result.userName, function () { LocalStore.login(result.userHash, result.userName, function () {
registering = false; registering = false;
if (test) {
localStorage.clear();
test.pass();
return;
}
if (sessionStorage.redirectTo) { if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo; var h = sessionStorage.redirectTo;
var parser = document.createElement('a'); var parser = document.createElement('a');
@ -236,8 +238,9 @@ define([
} }
}); });
Test(function () { Test(function (t) {
$uname.val('test' + Math.random()); test = t;
$uname.val('testuser');
$passwd.val('testtest'); $passwd.val('testtest');
$confirm.val('testtest'); $confirm.val('testtest');
$checkImport[0].checked = true; $checkImport[0].checked = true;

@ -98,7 +98,6 @@
} }
} }
.fa { .fa {
display: none;
margin-left: 50px; margin-left: 50px;
} }
} }

@ -9,6 +9,7 @@ define([
'/common/common-hash.js', '/common/common-hash.js',
'/customize/messages.js', '/customize/messages.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/customize/application_config.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
@ -24,7 +25,8 @@ define([
Util, Util,
Hash, Hash,
Messages, Messages,
h h,
AppConfig
) )
{ {
var saveAs = window.saveAs; var saveAs = window.saveAs;
@ -65,6 +67,10 @@ define([
] ]
}; };
if (!AppConfig.dislayCreationScreen) {
delete categories.creation;
}
var create = {}; var create = {};
// Account settings // Account settings
@ -326,8 +332,8 @@ define([
var $owned = $(owned); var $owned = $(owned);
var $ok = $owned.find('.fa-check'); var $ok = $owned.find('.fa-check').hide();
var $spinner = $owned.find('.fa-spinner'); var $spinner = $owned.find('.fa-spinner').hide();
$owned.find('input').change(function () { $owned.find('input').change(function () {
$spinner.show(); $spinner.show();
@ -392,8 +398,8 @@ define([
var $expire = $(expire); var $expire = $(expire);
var $ok = $expire.find('.fa-check'); var $ok = $expire.find('.fa-check').hide();
var $spinner = $expire.find('.fa-spinner'); var $spinner = $expire.find('.fa-spinner').hide();
var getValue = function () { var getValue = function () {
if(!parseInt($expire.find('[name="cp-creation-expire"]:checked').val())) { return 0; } if(!parseInt($expire.find('[name="cp-creation-expire"]:checked').val())) { return 0; }
@ -447,8 +453,8 @@ define([
var $div = $(skip); var $div = $(skip);
var $ok = $div.find('.fa-check'); var $ok = $div.find('.fa-check').hide();
var $spinner = $div.find('.fa-spinner'); var $spinner = $div.find('.fa-spinner').hide();
$div.find('input').change(function () { $div.find('input').change(function () {
$spinner.show(); $spinner.show();
@ -504,8 +510,8 @@ define([
var $div = $(skip); var $div = $(skip);
var $ok = $div.find('.fa-check'); var $ok = $div.find('.fa-check').hide();
var $spinner = $div.find('.fa-spinner'); var $spinner = $div.find('.fa-spinner').hide();
$div.find('input').change(function () { $div.find('input').change(function () {
$spinner.show(); $spinner.show();

Loading…
Cancel
Save