diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less
index 5e4f74dcf..f67e2ee96 100644
--- a/customize.dist/src/less/toolbar.less
+++ b/customize.dist/src/less/toolbar.less
@@ -79,6 +79,22 @@
}
}
+ .cryptpad-limit {
+ color: red;
+ box-sizing: content-box;
+ height: 16px;
+ width: 16px;
+ display: inline-block;
+ padding: 3px;
+ margin: 3px;
+ margin-right: 6px;
+ font-size: 20px;
+ span {
+ cursor: pointer;
+ margin: auto;
+ }
+ }
+
.cryptpad-lag {
box-sizing: content-box;
height: 16px;
diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css
index 1165c6df4..db8ba7776 100644
--- a/customize.dist/toolbar.css
+++ b/customize.dist/toolbar.css
@@ -150,6 +150,20 @@
.cryptpad-toolbar button.hidden {
display: none;
}
+.cryptpad-toolbar .cryptpad-limit {
+ color: red;
+ box-sizing: content-box;
+ height: 16px;
+ width: 16px;
+ display: inline-block;
+ padding: 3px;
+ margin: 3px;
+ margin-right: 6px;
+ font-size: 20px;
+}
+.cryptpad-toolbar .cryptpad-limit span {
+ margin: auto;
+}
.cryptpad-toolbar .cryptpad-lag {
box-sizing: content-box;
height: 16px;
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index 2b50a088d..a826659ca 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -55,6 +55,10 @@ define(function () {
out.orangeLight = "Votre connexion est lente, ce qui réduit la qualité de l'éditeur";
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.
" +
+ "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.importButtonTitle = 'Importer un pad depuis un fichier local';
out.exportButtonTitle = 'Exporter ce pad vers un fichier local';
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index 6c3ec7c4d..5e37ffdc6 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -57,6 +57,10 @@ define(function () {
out.orangeLight = "Your slow connection may impact your experience";
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.
" +
+ "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.importButtonTitle = 'Import a pad from a local file';
out.exportButtonTitle = 'Export this pad to a local file';
diff --git a/www/code/main.js b/www/code/main.js
index 4f12d0926..35bcd90d4 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -382,7 +382,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/common/cryptpad-common.js b/www/common/cryptpad-common.js
index 4c119654e..66030927f 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -708,6 +708,10 @@ define([
});
};
+ var getPinLimit = common.getPinLimit = function (cb) {
+ cb(void 0, 10);
+ };
+
var createButton = common.createButton = function (type, rightside, data, callback) {
var button;
var size = "17px";
diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index 7ff4f2b51..ed7b88459 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -16,6 +16,8 @@ define([
/** Id of the div containing the lag info. */
var LAG_ELEM_CLS = Bar.constants.lag = 'cryptpad-lag';
+ var LIMIT_ELEM_CLS = Bar.constants.lag = 'cryptpad-limit';
+
/** The toolbar class which contains the user list, debug link and lag. */
var TOOLBAR_CLS = Bar.constants.toolbar = 'cryptpad-toolbar';
@@ -488,6 +490,28 @@ define([
$userContainer.append($lag);
}
+ if (config.displayed.indexOf('limit') !== -1 && Config.enablePinning) {
+ var usage;
+ var $limitIcon = $('', {'class': 'fa fa-exclamation-triangle'});
+ var $limit = $('', {
+ 'class': LIMIT_ELEM_CLS,
+ 'title': Messages.pinLimitReached
+ }).append($limitIcon).hide().appendTo($userContainer);
+ var andThen = function (e, limit) {
+ if (usage > limit) {
+ $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);
+ }
+
if (config.displayed.indexOf('newpad') !== -1) {
var pads_options = [];
Config.availablePadTypes.forEach(function (p) {