Share a pad, a file or a folder with friends

This commit is contained in:
yflory 2019-06-04 16:19:47 +02:00
parent c154d020b2
commit a3a2c92c0c
3 changed files with 35 additions and 11 deletions

View File

@ -316,7 +316,7 @@ define([
}); });
}; };
var getFriendsList = function (config) { // XXX test from the drive and don't forget to pass the title var getFriendsList = function (config) {
var common = config.common; var common = config.common;
var title = config.title; var title = config.title;
var friends = config.friends; var friends = config.friends;
@ -374,6 +374,7 @@ define([
}; };
addFake(others); addFake(others);
// Hide friends when they are filtered using the text input
var redraw = function () { var redraw = function () {
var name = $(inputFilter).val().trim().replace(/"/g, ''); var name = $(inputFilter).val().trim().replace(/"/g, '');
$div.find('.cp-share-friend').show(); $div.find('.cp-share-friend').show();
@ -394,8 +395,10 @@ define([
redraw(); redraw();
}); });
// Replace "copy link" by "share with friends" if at least one friedn is selected
// Also create the "share with friends" button if it doesn't exist
var refreshButtons = function () { var refreshButtons = function () {
var $nav = $div.parents('.alertify-tabs-content').find('nav'); var $nav = $div.parents('.alertify').find('nav');
if (!$nav.find('.cp-share-with-friends').length) { if (!$nav.find('.cp-share-with-friends').length) {
var button = h('button.primary.cp-share-with-friends', { var button = h('button.primary.cp-share-with-friends', {
'data-keys': '[13]' 'data-keys': '[13]'
@ -418,7 +421,6 @@ define([
}); });
}); });
console.log(UI.findCancelButton());
UI.findCancelButton().click(); UI.findCancelButton().click();
// Update the "recently shared with" array: // Update the "recently shared with" array:
@ -659,8 +661,15 @@ define([
// Share link tab // Share link tab
var link = h('div.cp-share-modal', [ var hasFriends = Object.keys(config.friends || {}).length !== 0;
UI.dialog.selectable('', { id: 'cp-share-link-preview' }) var friendsList = hasFriends ? getFriendsList(config) : undefined;
var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
var link = h('div.cp-share-modal' + friendsUIClass, [
h('div.cp-share-column', [
hasFriends ? h('p', Messages.share_description) : undefined,
UI.dialog.selectable('', { id: 'cp-share-link-preview' }),
]),
friendsList
]); ]);
var getLinkValue = function () { return url; }; var getLinkValue = function () { return url; };
$(link).find('#cp-share-link-preview').val(getLinkValue()); $(link).find('#cp-share-link-preview').val(getLinkValue());
@ -734,10 +743,17 @@ define([
var url = origin + pathname + '#' + hashes.editHash; var url = origin + pathname + '#' + hashes.editHash;
// Share link tab // Share link tab
var link = h('div.cp-share-modal', [ var hasFriends = Object.keys(config.friends || {}).length !== 0;
h('label', Messages.sharedFolders_share), var friendsList = hasFriends ? getFriendsList(config) : undefined;
h('br'), var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
UI.dialog.selectable(url, { id: 'cp-share-link-preview', tabindex: 1 }) var link = h('div.cp-share-modal' + friendsUIClass, [
h('div.cp-share-column', [
h('label', Messages.sharedFolders_share),
h('br'),
hasFriends ? h('p', Messages.share_description) : undefined,
UI.dialog.selectable(url, { id: 'cp-share-link-preview', tabindex: 1 })
]),
friendsList
]); ]);
var linkButtons = [{ var linkButtons = [{
name: Messages.cancel, name: Messages.cancel,

View File

@ -1,9 +1,10 @@
define([ define([
'jquery', 'jquery',
'/common/hyperscript.js', '/common/hyperscript.js',
'/common/common-hash.js',
'/common/common-ui-elements.js', '/common/common-ui-elements.js',
'/customize/messages.js', '/customize/messages.js',
], function ($, h, UIElements, Messages) { ], function ($, h, Hash, UIElements, Messages) {
var handlers = {}; var handlers = {};
@ -49,8 +50,12 @@ define([
var content = data.content; var content = data.content;
var msg = content.msg; var msg = content.msg;
$(el).find('.cp-notification-content').addClass("cp-clickable"); $(el).find('.cp-notification-content').addClass("cp-clickable");
var type = Hash.parsePadUrl(msg.content.href).type;
var key = type === 'drive' ? 'notification_folderShared' :
(type === 'file' ? 'notification_fileShared' :
'notification_padShared');
$(el).find('.cp-notification-content p') $(el).find('.cp-notification-content p')
.html(Messages._getKey('notification_padShared', [msg.content.name || Messages.anonymous, msg.content.title])) .html(Messages._getKey(key, [msg.content.name || Messages.anonymous, msg.content.title]))
.click(function () { .click(function () {
common.openURL(msg.content.href); common.openURL(msg.content.href);
}); });

View File

@ -3245,6 +3245,9 @@ define([
modal = UIElements.createSFShareModal({ modal = UIElements.createSFShareModal({
origin: APP.origin, origin: APP.origin,
pathname: "/drive/", pathname: "/drive/",
friends: friends,
title: data.title,
common: common,
hashes: { hashes: {
editHash: parsed.hash editHash: parsed.hash
} }