Enable properties modal when the pad is not stored

pull/1/head
yflory 4 years ago
parent a69fb1fae9
commit e7a72896d5

@ -836,12 +836,7 @@ define([
.text(Messages.propertiesButton)) .text(Messages.propertiesButton))
.click(common.prepareFeedback(type)) .click(common.prepareFeedback(type))
.click(function () { .click(function () {
common.isPadStored(function (err, data) { sframeChan.event('EV_PROPERTIES_OPEN');
if (!data) {
return void UI.alert(Messages.autostore_notAvailable);
}
sframeChan.event('EV_PROPERTIES_OPEN');
});
}); });
break; break;
case 'save': // OnlyOffice save case 'save': // OnlyOffice save

@ -18,6 +18,16 @@ define([
opts = opts || {}; opts = opts || {};
var $d = $('<div>'); var $d = $('<div>');
if (!data) { return void cb(void 0, $d); } if (!data) { return void cb(void 0, $d); }
data = Util.clone(data);
var privateData = common.getMetadataMgr().getPrivateData();
if (privateData.propChannels) {
var p = privateData.propChannels;
data.channel = data.channel || p.channel;
data.rtChannel = data.rtChannel || p.rtChannel;
data.lastVersion = data.lastVersion || p.lastVersion;
data.lastCpHash = data.lastCpHash || p.lastCpHash;
}
if (data.channel) { if (data.channel) {
$('<label>', { 'for': 'cp-app-prop-id'}).text(Messages.documentID).appendTo($d); $('<label>', { 'for': 'cp-app-prop-id'}).text(Messages.documentID).appendTo($d);
@ -26,18 +36,20 @@ define([
})); }));
} }
if (data.href) { if (!data.fakeHref) {
$('<label>', {'for': 'cp-app-prop-link'}).text(Messages.editShare).appendTo($d); if (data.href) {
$d.append(UI.dialog.selectable(data.href, { $('<label>', {'for': 'cp-app-prop-link'}).text(Messages.editShare).appendTo($d);
id: 'cp-app-prop-link', $d.append(UI.dialog.selectable(data.href, {
})); id: 'cp-app-prop-link',
} }));
}
if (data.roHref && !opts.noReadOnly) { if (data.roHref && !opts.noReadOnly) {
$('<label>', {'for': 'cp-app-prop-rolink'}).text(Messages.viewShare).appendTo($d); $('<label>', {'for': 'cp-app-prop-rolink'}).text(Messages.viewShare).appendTo($d);
$d.append(UI.dialog.selectable(data.roHref, { $d.append(UI.dialog.selectable(data.roHref, {
id: 'cp-app-prop-rolink', id: 'cp-app-prop-rolink',
})); }));
}
} }
if (data.tags && Array.isArray(data.tags)) { if (data.tags && Array.isArray(data.tags)) {
@ -54,7 +66,6 @@ define([
if (!common.isLoggedIn()) { return void cb(void 0, $d); } if (!common.isLoggedIn()) { return void cb(void 0, $d); }
var privateData = common.getMetadataMgr().getPrivateData();
if (privateData.offline) { return void cb(void 0, $d); } if (privateData.offline) { return void cb(void 0, $d); }
// File and history size... // File and history size...
@ -179,6 +190,7 @@ define([
Properties.getPropertiesModal = function (common, opts, cb) { Properties.getPropertiesModal = function (common, opts, cb) {
cb = cb || function () {}; cb = cb || function () {};
opts = opts || {}; opts = opts || {};
opts.access = true;
var tabs = [{ var tabs = [{
getTab: getPadProperties, getTab: getPadProperties,
title: Messages.fc_prop, title: Messages.fc_prop,

@ -26,6 +26,10 @@ define([
obj.ooVersionHash = version; obj.ooVersionHash = version;
obj.ooForceVersion = localStorage.CryptPad_ooVersion || ""; obj.ooForceVersion = localStorage.CryptPad_ooVersion || "";
}; };
var channels = {};
var getPropChannels = function () {
return channels;
};
var addRpc = function (sframeChan, Cryptpad, Utils) { var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('Q_OO_SAVE', function (data, cb) { sframeChan.on('Q_OO_SAVE', function (data, cb) {
var chanId = Utils.Hash.hrefToHexChannelId(data.url); var chanId = Utils.Hash.hrefToHexChannelId(data.url);
@ -38,14 +42,17 @@ define([
Cryptpad.pinPads([chanId], function (e) { Cryptpad.pinPads([chanId], function (e) {
if (e) { return void cb(e); } if (e) { return void cb(e); }
Cryptpad.setPadAttribute('lastVersion', data.url, cb); Cryptpad.setPadAttribute('lastVersion', data.url, cb);
channels.lastVersion = data.url;
}); });
Cryptpad.setPadAttribute('lastCpHash', data.hash, cb); Cryptpad.setPadAttribute('lastCpHash', data.hash, cb);
channels.lastCpHash = data.hash;
}); });
sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) { sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) {
Cryptpad.getPadAttribute('rtChannel', function (err, res) { Cryptpad.getPadAttribute('rtChannel', function (err, res) {
// If already stored, don't pin it again // If already stored, don't pin it again
if (res && res === data.channel) { return; } if (res && res === data.channel) { return; }
Cryptpad.pinPads([data.channel], function () { Cryptpad.pinPads([data.channel], function () {
channels.rtChannel = data.channel;
Cryptpad.setPadAttribute('rtChannel', data.channel, function () {}); Cryptpad.setPadAttribute('rtChannel', data.channel, function () {});
}); });
}); });
@ -144,6 +151,7 @@ define([
useCreationScreen: true, useCreationScreen: true,
addData: addData, addData: addData,
addRpc: addRpc, addRpc: addRpc,
getPropChannels: getPropChannels,
messaging: true messaging: true
}); });
}); });

@ -1378,6 +1378,14 @@ define([
// Secure modal // Secure modal
var SecureModal = {}; var SecureModal = {};
// Create or display the iframe and modal // Create or display the iframe and modal
var getPropChannels = function () {
var channels = {};
if (cfg.getPropChannels) {
channels = Utils.Util.clone(cfg.getPropChannels());
}
channels.channel = secret.channel;
return channels;
};
var initSecureModal = function (type, cfg, cb) { var initSecureModal = function (type, cfg, cb) {
cfg.modal = type; cfg.modal = type;
SecureModal.cb = cb; SecureModal.cb = cb;
@ -1397,7 +1405,8 @@ define([
app: parsed.type, app: parsed.type,
hashes: hashes, hashes: hashes,
password: password, password: password,
isTemplate: isTemplate isTemplate: isTemplate,
getPropChannels: getPropChannels
}; };
config.addCommonRpc = addCommonRpc; config.addCommonRpc = addCommonRpc;
config.modules = { config.modules = {

@ -33,7 +33,7 @@ define([
var metadataMgr = common.getMetadataMgr(); var metadataMgr = common.getMetadataMgr();
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var $body = $('body'); var $body = $('body');
var displayed; var displayed;
var hideIframe = function () { var hideIframe = function () {
if (!displayed) { return; } if (!displayed) { return; }

@ -103,6 +103,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,
propChannels: config.data.getPropChannels(),
isTemplate: isTemplate, isTemplate: isTemplate,
file: config.data.file, file: config.data.file,
secureIframe: true, secureIframe: true,

Loading…
Cancel
Save