Disable some toolbar features not available if the pad is not stored
parent
9ebb598467
commit
d201e9a0cd
|
@ -1242,6 +1242,7 @@ define(function () {
|
|||
out.autostore_error = "Unexpected error: we were unable to store this pad, please try again.";
|
||||
out.autostore_saved = "The pad was successfully stored in your CryptDrive!";
|
||||
out.autostore_forceSave = "Store the file in CryptDrive"; // File upload modal
|
||||
out.autostore_notAvailable = "You must store this pad in your CryptDrive before being able to use this feature."; // Properties/tags/move to trash
|
||||
|
||||
return out;
|
||||
});
|
||||
|
|
|
@ -722,27 +722,32 @@ define([
|
|||
button
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function() {
|
||||
sframeChan.query('Q_IS_ONLY_IN_SHARED_FOLDER', null, function (err, res) {
|
||||
if (err || res.error) { return void console.log(err || res.error); }
|
||||
var msg = Messages.forgetPrompt;
|
||||
if (res) {
|
||||
UI.alert(Messages.sharedFolders_forget);
|
||||
return;
|
||||
} else if (!common.isLoggedIn()) {
|
||||
msg = Messages.fm_removePermanentlyDialog;
|
||||
common.isPadStored(function (err, data) {
|
||||
if (!data) {
|
||||
return void UI.alert(Messages.autostore_notAvailable);
|
||||
}
|
||||
UI.confirm(msg, function (yes) {
|
||||
if (!yes) { return; }
|
||||
sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) {
|
||||
if (err) { return void callback(err); }
|
||||
var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
|
||||
var msg = common.fixLinks($('<div>').html(cMsg));
|
||||
UI.alert(msg);
|
||||
callback();
|
||||
sframeChan.query('Q_IS_ONLY_IN_SHARED_FOLDER', null, function (err, res) {
|
||||
if (err || res.error) { return void console.log(err || res.error); }
|
||||
var msg = Messages.forgetPrompt;
|
||||
if (res) {
|
||||
UI.alert(Messages.sharedFolders_forget);
|
||||
return;
|
||||
} else if (!common.isLoggedIn()) {
|
||||
msg = Messages.fm_removePermanentlyDialog;
|
||||
}
|
||||
UI.confirm(msg, function (yes) {
|
||||
if (!yes) { return; }
|
||||
sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) {
|
||||
if (err) { return void callback(err); }
|
||||
var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
|
||||
var msg = common.fixLinks($('<div>').html(cMsg));
|
||||
UI.alert(msg);
|
||||
callback();
|
||||
return;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
@ -807,7 +812,14 @@ define([
|
|||
title: Messages.tags_title,
|
||||
})
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function () { UIElements.updateTags(common, null); });
|
||||
.click(function () {
|
||||
common.isPadStored(function (err, data) {
|
||||
if (!data) {
|
||||
return void UI.alert(Messages.autostore_notAvailable);
|
||||
}
|
||||
UIElements.updateTags(common, null);
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'toggle':
|
||||
button = $('<button>', {
|
||||
|
@ -844,11 +856,16 @@ define([
|
|||
.text(Messages.propertiesButton))
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function () {
|
||||
getPropertiesData(common, function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
UIElements.getProperties(common, data, function (e, $prop) {
|
||||
common.isPadStored(function (err, data) {
|
||||
if (!data) {
|
||||
return void UI.alert(Messages.autostore_notAvailable);
|
||||
}
|
||||
getPropertiesData(common, function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
UI.alert($prop[0], undefined, true);
|
||||
UIElements.getProperties(common, data, function (e, $prop) {
|
||||
if (e) { return void console.error(e); }
|
||||
UI.alert($prop[0], undefined, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -766,7 +766,8 @@ define([
|
|||
// Add the pad if it does not exist in our drive
|
||||
if (!contains) {
|
||||
var autoStore = Util.find(store.proxy, ['settings', 'general', 'autostore']);
|
||||
if (autoStore !== 1 && !data.forceSave && !data.path) {
|
||||
var ownedByMe = Array.isArray(owners) && owners.indexOf(store.proxy.edPublic) !== -1;
|
||||
if (autoStore !== 1 && !data.forceSave && !data.path && !ownedByMe) {
|
||||
// send event to inner to display the corner popup
|
||||
postMessage(clientId, "AUTOSTORE_DISPLAY_POPUP", {
|
||||
autoStore: autoStore
|
||||
|
|
|
@ -373,6 +373,11 @@ define([
|
|||
cb(err);
|
||||
});
|
||||
});
|
||||
sframeChan.on('Q_IS_PAD_STORED', function (data, cb) {
|
||||
Cryptpad.getPadAttribute('title', function (err, data) {
|
||||
cb (!err && typeof (data) === "string");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) {
|
||||
|
|
|
@ -206,6 +206,12 @@ define([
|
|||
}, cb);
|
||||
};
|
||||
|
||||
funcs.isPadStored = function (cb) {
|
||||
ctx.sframeChan.query("Q_IS_PAD_STORED", null, function (err, obj) {
|
||||
cb (err || (obj && obj.error), obj);
|
||||
});
|
||||
};
|
||||
|
||||
funcs.sendAnonRpcMsg = function (msg, content, cb) {
|
||||
ctx.sframeChan.query('Q_ANON_RPC_MESSAGE', {
|
||||
msg: msg,
|
||||
|
|
|
@ -257,4 +257,5 @@ define({
|
|||
// Store pads in the drive
|
||||
'EV_AUTOSTORE_DISPLAY_POPUP': true,
|
||||
'Q_AUTOSTORE_STORE': true,
|
||||
'Q_IS_PAD_STORED': true,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue