diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css
index db8ba7776..4ef7a4567 100644
--- a/customize.dist/toolbar.css
+++ b/customize.dist/toolbar.css
@@ -162,6 +162,7 @@
font-size: 20px;
}
.cryptpad-toolbar .cryptpad-limit span {
+ cursor: pointer;
margin: auto;
}
.cryptpad-toolbar .cryptpad-lag {
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index a826659ca..50a2bf667 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -56,8 +56,10 @@ define(function () {
out.redLight = "Vous êtes déconnectés de la session";
out.pinLimitReached = "Vous avez atteint votre limite de stockage";
- out.pinLimitReachedAlert = "Vous avez atteint votre limite de stockage. Ce pad ne sera pas enregistré dans votre CrypDrive.
" +
+ out.pinLimitReachedAlert = "Vous avez atteint votre limite de stockage. Les nouveaux pads ne seront pas enregistrés dans votre CrypDrive.
" +
"Pour résoudre ce problème, vous pouvez soit supprimer des pads de votre CryptDrive (y compris la corbeille), soit vous abonner à une offre premium pour augmenter la limite maximale.";
+ out.pinLimitNotPinned = "Vous avez atteint votre limite de stockage.
"+
+ "Ce pad n'est pas enregistré dans votre CryptDrive.";
out.importButtonTitle = 'Importer un pad depuis un fichier local';
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index 5e37ffdc6..7c5fd8df5 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -58,8 +58,10 @@ define(function () {
out.redLight = "You are disconnected from the session";
out.pinLimitReached = "You've reached your storage limit";
- out.pinLimitReachedAlert = "You've reached your storage limit. This pad won't be stored in your CryptDrive.
" +
+ out.pinLimitReachedAlert = "You've reached your storage limit. New pads won't be stored in your CryptDrive.
" +
"To fix this problem, you can either remove pads from your CryptDrive (including the trash) or subscribe to a premium offer to increase your limit.";
+ out.pinLimitNotPinned = "You've reached your storage limit.
"+
+ "This pad is not stored in your CryptDrive.";
out.importButtonTitle = 'Import a pad from a local file';
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index 66030927f..0fb7d7ad8 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -570,8 +570,16 @@ define([
if (!contains) {
var data = makePad(href, name);
- getStore().pushData(data);
- getStore().addPad(data, common.initialPath);
+ getStore().pushData(data, function (e, state) {
+ if (e) {
+ if (e === 'E_OVER_LIMIT') {
+ Cryptpad.alert(Messages.pinLimitNotPinned, null, true);
+ return;
+ }
+ else { throw new Error("Cannot push this pad to CryptDrive", e); }
+ }
+ getStore().addPad(data, common.initialPath);
+ });
}
if (updateWeaker.length > 0) {
updateWeaker.forEach(function (obj) {
@@ -709,7 +717,23 @@ define([
};
var getPinLimit = common.getPinLimit = function (cb) {
- cb(void 0, 10);
+ cb(void 0, 1000);
+ };
+
+ var isOverPinLimit = common.isOverPinLimit = function (cb) {
+ var andThen = function (e, limit) {
+ if (e) { return void cb(e); }
+ if (usage > limit) {
+ return void cb (null, true);
+ }
+ return void cb (null, false);
+ };
+ var todo = function (e, used) {
+ usage = common.bytesToMegabytes(used);
+ if (e) { return void cb(e); }
+ common.getPinLimit(andThen);
+ };
+ common.getPinnedUsage(todo);
};
var createButton = common.createButton = function (type, rightside, data, callback) {
diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index ed7b88459..23de3262d 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -497,19 +497,15 @@ define([
'class': LIMIT_ELEM_CLS,
'title': Messages.pinLimitReached
}).append($limitIcon).hide().appendTo($userContainer);
- var andThen = function (e, limit) {
- if (usage > limit) {
+ var todo = function (e, overLimit) {
+ if (e) { return void console.error("Unable tog et the pinned usage"); }
+ if (overLimit) {
$limit.show().click(function () {
Cryptpad.alert(Messages.pinLimitReachedAlert, null, true);
});
}
};
- var todo = function (e, used) {
- usage = Cryptpad.bytesToMegabytes(used);
- if (e) { console.error("Unable tog et the pinned usage"); return; }
- Cryptpad.getPinLimit(andThen);
- };
- Cryptpad.getPinnedUsage(todo);
+ Cryptpad.isOverPinLimit(todo);
}
if (config.displayed.indexOf('newpad') !== -1) {
diff --git a/www/common/userObject.js b/www/common/userObject.js
index 9ea1af726..6757e7cd7 100644
--- a/www/common/userObject.js
+++ b/www/common/userObject.js
@@ -1,6 +1,7 @@
define([
'jquery',
-], function ($) {
+ '/customize/application_config.js'
+], function ($, AppConfig) {
var module = {};
var ROOT = module.ROOT = "root";
@@ -427,19 +428,25 @@ define([
};
// FILES DATA
- var pushFileData = exp.pushData = function (data) {
+ var pushFileData = exp.pushData = function (data, cb) {
+ if (typeof cb !== "function") { cb = function () {}; }
+ var todo = function () {
+ files[FILES_DATA].push(data);
+ cb();
+ };
+ if (!Cryptpad.isLoggedIn() || !AppConfig.enablePinning) { todo(); }
Cryptpad.pinPads([Cryptpad.hrefToHexChannelId(data.href)], function (e, hash) {
- if (e) { console.log(e); return; }
- console.log(hash);
+ if (e) { return void cb(e); }
+ cb('E_OVER_LIMIT'); return; //TODO
+ todo();
});
- files[FILES_DATA].push(data);
};
var spliceFileData = exp.removeData = function (idx) {
var data = files[FILES_DATA][idx];
- if (typeof data === "object") {
+ if (typeof data === "object" && Cryptpad.isLoggedIn() && AppConfig.enablePinning) {
Cryptpad.unpinPads([Cryptpad.hrefToHexChannelId(data.href)], function (e, hash) {
- if (e) { console.log(e); return; }
- console.log(hash);
+ if (e) { return void logError(e); }
+ debug('UNPIN', hash);
});
}
files[FILES_DATA].splice(idx, 1);
diff --git a/www/drive/main.js b/www/drive/main.js
index 057a0a8ee..e05772676 100644
--- a/www/drive/main.js
+++ b/www/drive/main.js
@@ -2392,7 +2392,7 @@ define([
var userList = APP.userList = info.userList;
var config = {
- displayed: ['useradmin', 'spinner', 'lag', 'state'],
+ displayed: ['useradmin', 'spinner', 'lag', 'state', 'limit'],
readOnly: readOnly,
ifrw: window,
common: Cryptpad,
diff --git a/www/pad/main.js b/www/pad/main.js
index c2bbdc5d2..e1b552a48 100644
--- a/www/pad/main.js
+++ b/www/pad/main.js
@@ -578,7 +578,7 @@ define([
userList = info.userList;
var configTb = {
- displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
+ displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
userData: userData,
readOnly: readOnly,
ifrw: ifrw,
diff --git a/www/poll/main.js b/www/poll/main.js
index 5aa3e4ee2..1d6a151e5 100644
--- a/www/poll/main.js
+++ b/www/poll/main.js
@@ -733,7 +733,7 @@ define([
userList = APP.userList = info.userList;
var config = {
- displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
+ displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
userData: userData,
readOnly: readOnly,
share: {
diff --git a/www/slide/main.js b/www/slide/main.js
index bef2a4e52..eb9919abc 100644
--- a/www/slide/main.js
+++ b/www/slide/main.js
@@ -513,7 +513,7 @@ define([
userList = info.userList;
var configTb = {
- displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
+ displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
userData: userData,
readOnly: readOnly,
ifrw: ifrw,
diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js
index 6cadfc487..b35ae705d 100644
--- a/www/whiteboard/main.js
+++ b/www/whiteboard/main.js
@@ -334,7 +334,7 @@ window.canvas = canvas;
var onInit = config.onInit = function (info) {
userList = info.userList;
var config = {
- displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'],
+ displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
userData: userData,
readOnly: readOnly,
share: {