Add a share icon in the drive when displaying a shared folder
This commit is contained in:
parent
6143bceabb
commit
08005a709e
@ -1210,6 +1210,7 @@ define(function () {
|
|||||||
out.sharedFolders_create_name = "Folder name";
|
out.sharedFolders_create_name = "Folder name";
|
||||||
out.sharedFolders_create_owned = "Owned folder";
|
out.sharedFolders_create_owned = "Owned folder";
|
||||||
out.sharedFolders_create_password = "Folder password";
|
out.sharedFolders_create_password = "Folder password";
|
||||||
|
out.sharedFolders_share = "Share this URL with other registered users to give them access to the shared folder. Once they open this URL, the shared folder will be added to the root directory of their CryptDrive.";
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -517,6 +517,35 @@ define([
|
|||||||
}
|
}
|
||||||
return tabs;
|
return tabs;
|
||||||
};
|
};
|
||||||
|
UIElements.createSFShareModal = function (config) {
|
||||||
|
var origin = config.origin;
|
||||||
|
var pathname = config.pathname;
|
||||||
|
var hashes = config.hashes;
|
||||||
|
|
||||||
|
if (!hashes.editHash) { throw new Error("You must provide a valid hash"); }
|
||||||
|
var url = origin + pathname + '#' + hashes.editHash;
|
||||||
|
|
||||||
|
// Share link tab
|
||||||
|
var link = h('div.cp-share-modal', [
|
||||||
|
h('label', Messages.sharedFolders_share),
|
||||||
|
h('br'),
|
||||||
|
UI.dialog.selectable(url, { id: 'cp-share-link-preview', tabindex: 1 })
|
||||||
|
]);
|
||||||
|
var linkButtons = [{
|
||||||
|
name: Messages.cancel,
|
||||||
|
onClick: function () {},
|
||||||
|
keys: [27]
|
||||||
|
}, {
|
||||||
|
className: 'primary',
|
||||||
|
name: Messages.share_linkCopy,
|
||||||
|
onClick: function () {
|
||||||
|
var success = Clipboard.copy(url);
|
||||||
|
if (success) { UI.log(Messages.shareSuccess); }
|
||||||
|
},
|
||||||
|
keys: [13]
|
||||||
|
}];
|
||||||
|
return UI.dialog.customModal(link, {buttons: linkButtons});
|
||||||
|
};
|
||||||
|
|
||||||
UIElements.createButton = function (common, type, rightside, data, callback) {
|
UIElements.createButton = function (common, type, rightside, data, callback) {
|
||||||
var AppConfig = common.getAppConfig();
|
var AppConfig = common.getAppConfig();
|
||||||
|
|||||||
@ -866,7 +866,7 @@ define([
|
|||||||
|
|
||||||
var isInSharedFolder = function (Env, path) {
|
var isInSharedFolder = function (Env, path) {
|
||||||
var resolved = _resolvePath(Env, path);
|
var resolved = _resolvePath(Env, path);
|
||||||
return typeof resolved.id === "number";
|
return typeof resolved.id === "number" ? resolved.id : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generic: doesn't need access to a proxy */
|
/* Generic: doesn't need access to a proxy */
|
||||||
|
|||||||
@ -1864,6 +1864,27 @@ define([
|
|||||||
$container.append($block);
|
$container.append($block);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var createShareButton = function (id, $container) {
|
||||||
|
var $shareBlock = $('<button>', {
|
||||||
|
'class': 'fa fa-shhare-alt cp-toolbar-share-button',
|
||||||
|
title: Messages.shareButton
|
||||||
|
});
|
||||||
|
var data = manager.getSharedFolderData(id);
|
||||||
|
var parsed = Hash.parsePadUrl(data.href);
|
||||||
|
if (!parsed || !parsed.hash) { return void console.error("Invalid href: "+data.href); }
|
||||||
|
var modal = UIElements.createSFShareModal({
|
||||||
|
origin: APP.origin,
|
||||||
|
pathname: "/drive/",
|
||||||
|
hashes: {
|
||||||
|
editHash: parsed.hash
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$shareBlock.click(function () {
|
||||||
|
UI.openCustomModal(modal);
|
||||||
|
});
|
||||||
|
$container.append($shareBlock);
|
||||||
|
};
|
||||||
|
|
||||||
var hideNewButton = function () {
|
var hideNewButton = function () {
|
||||||
$('.cp-dropdown-content').hide();
|
$('.cp-dropdown-content').hide();
|
||||||
};
|
};
|
||||||
@ -2527,6 +2548,10 @@ define([
|
|||||||
|
|
||||||
// NewButton can be undefined if we're in read only mode
|
// NewButton can be undefined if we're in read only mode
|
||||||
createNewButton(isInRoot, $toolbar.find('.cp-app-drive-toolbar-leftside'));
|
createNewButton(isInRoot, $toolbar.find('.cp-app-drive-toolbar-leftside'));
|
||||||
|
var sfId = manager.isInSharedFolder(currentPath);
|
||||||
|
if (sfId) {
|
||||||
|
createShareButton(sfId, $toolbar.find('.cp-app-drive-toolbar-leftside'));
|
||||||
|
}
|
||||||
|
|
||||||
createTitle($toolbar.find('.cp-app-drive-path'), path);
|
createTitle($toolbar.find('.cp-app-drive-path'), path);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user