Access modal for calendars

pull/1/head
yflory 4 years ago
parent 547b0c1d3e
commit 09b229203c

@ -133,6 +133,9 @@
&:hover { &:hover {
background: fade(@cryptpad_text_col, 10%); background: fade(@cryptpad_text_col, 10%);
} }
&.cp-restricted {
color: @cp_drive-header-fg;
}
&.cp-active { &.cp-active {
background: @cp_sidebar-left-active; background: @cp_sidebar-left-active;
} }

@ -390,6 +390,36 @@ Messages.calendar_import = "Import to my calendars";
return true; return true;
} }
}); });
options.push({
tag: 'a',
attributes: {
'class': 'fa fa-lock',
},
content: h('span', Messages.accessButton),
action: function (e) {
e.stopPropagation();
var friends = common.getFriends();
var cal = APP.calendars[id];
var title = Util.find(cal, ['content', 'metadata', 'title']);
var color = Util.find(cal, ['content', 'metadata', 'color']);
var h = cal.hashes || {};
var href = Hash.hashToHref(h.editHash || h.viewHash, 'calendar');
Access.getAccessModal(common, {
title: title,
password: cal.password, // XXX support passwords
calendar: {
title: title,
color: color,
channel: id,
},
common: common,
noExpiration: true,
channel: id,
href: href
});
return true;
}
});
} }
if (!cantRemove) { if (!cantRemove) {
options.push({ options.push({
@ -443,14 +473,16 @@ Messages.calendar_import = "Import to my calendars";
var md = Util.find(data, ['content', 'metadata']); var md = Util.find(data, ['content', 'metadata']);
if (!md) { return; } if (!md) { return; }
var active = data.hidden ? '' : '.cp-active'; var active = data.hidden ? '' : '.cp-active';
var calendar = h('div.cp-calendar-entry'+active, { var restricted = data.restricted ? '.cp-restricted' : '';
var calendar = h('div.cp-calendar-entry'+active+restricted, {
'data-uid': id 'data-uid': id
}, [ }, [
h('span.cp-calendar-color', { h('span.cp-calendar-color', {
style: 'background-color: '+md.color+';' style: 'background-color: '+md.color+';'
}), }),
h('span.cp-calendar-title', md.title), h('span.cp-calendar-title', md.title),
isReadOnly(id, teamId) ? h('i.fa.fa-eye', {title: Messages.readonly}) : undefined, data.restricted ? h('i.fa.fa-ban', {title: Messages.fm_restricted}) :
(isReadOnly(id, teamId) ? h('i.fa.fa-eye', {title: Messages.readonly}) : undefined),
edit edit
]); ]);
$(calendar).click(function () { $(calendar).click(function () {

@ -2921,7 +2921,7 @@ define([
var dismiss = function () { var dismiss = function () {
common.mailbox.dismiss(data, function (err) { common.mailbox.dismiss(data, function (err) {
console.log(err); if (err) { console.log(err); }
}); });
}; };
var answer = function (yes) { var answer = function (yes) {
@ -2930,6 +2930,7 @@ define([
href: msg.content.href, href: msg.content.href,
password: msg.content.password, password: msg.content.password,
title: msg.content.title, title: msg.content.title,
calendar: msg.content.calendar,
answer: yes answer: yes
}, { }, {
channel: msg.content.user.notifications, channel: msg.content.user.notifications,
@ -2965,16 +2966,29 @@ define([
// Add the pad to your drive // Add the pad to your drive
// This command will also add your mailbox to the metadata log // This command will also add your mailbox to the metadata log
// The callback is called when the pad is stored, independantly of the metadata command // The callback is called when the pad is stored, independantly of the metadata command
sframeChan.query('Q_ACCEPT_OWNERSHIP', data, function (err, res) { if (data.calendar) {
if (err || (res && res.error)) { var calendarModule = common.makeUniversal('calendar');
return void console.error(err | res.error); var calendarData = data.calendar;
} calendarData.href = data.href;
UI.log(Messages.saved); calendarData.teamId = 1;
if (autoStoreModal[data.channel]) { calendarModule.execCommand('ADD', calendarData, function (obj) {
autoStoreModal[data.channel].delete(); if (obj && obj.error) {
delete autoStoreModal[data.channel]; console.error(obj.error);
} return void UI.warn(Messages.error);
}); }
});
} else {
sframeChan.query('Q_ACCEPT_OWNERSHIP', data, function (err, res) {
if (err || (res && res.error)) {
return void console.error(err | res.error);
}
UI.log(Messages.saved);
if (autoStoreModal[data.channel]) {
autoStoreModal[data.channel].delete();
delete autoStoreModal[data.channel];
}
});
}
// Remove yourself from the pending owners // Remove yourself from the pending owners
sframeChan.query('Q_SET_PAD_METADATA', { sframeChan.query('Q_SET_PAD_METADATA', {

@ -336,6 +336,7 @@ define([
common.mailbox.sendTo("ADD_OWNER", { common.mailbox.sendTo("ADD_OWNER", {
channel: channel, channel: channel,
href: href, href: href,
calendar: opts.calendar,
password: data.password || priv.password, password: data.password || priv.password,
title: data.title || title title: data.title || title
}, { }, {
@ -1016,7 +1017,7 @@ define([
var owned = Modal.isOwned(Env, data); var owned = Modal.isOwned(Env, data);
// Request edit access // Request edit access
if (common.isLoggedIn() && ((data.roHref && !data.href) || data.fakeHref) && !owned) { if (common.isLoggedIn() && ((data.roHref && !data.href) || data.fakeHref) && !owned && !opts.calendar) {
var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right', var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right',
Messages.requestEdit_button); Messages.requestEdit_button);
var requestBlock = h('p', requestButton); var requestBlock = h('p', requestButton);
@ -1054,7 +1055,7 @@ define([
var canMute = data.mailbox && owned === true && ( var canMute = data.mailbox && owned === true && (
(typeof (data.mailbox) === "string" && data.owners[0] === edPublic) || (typeof (data.mailbox) === "string" && data.owners[0] === edPublic) ||
data.mailbox[edPublic]); data.mailbox[edPublic]);
if (owned === true) { if (owned === true && !opts.calendar) {
var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute); var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute);
var $cbox = $(cbox); var $cbox = $(cbox);
var spinner = UI.makeSpinner($cbox); var spinner = UI.makeSpinner($cbox);

Loading…
Cancel
Save