Display the share modal after folder conversion to sf
This commit is contained in:
parent
830c401f50
commit
b69261d119
2 changed files with 59 additions and 40 deletions
|
@ -1936,6 +1936,44 @@ define([
|
|||
};
|
||||
var getIcon = UI.getIcon;
|
||||
|
||||
var createShareButton = function (id, $container) {
|
||||
var $shareBlock = $('<button>', {
|
||||
'class': 'cp-toolbar-share-button',
|
||||
title: Messages.shareButton
|
||||
});
|
||||
$sharedIcon.clone().appendTo($shareBlock);
|
||||
$('<span>').text(Messages.shareButton).appendTo($shareBlock);
|
||||
var data = manager.getSharedFolderData(id);
|
||||
var parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
|
||||
var roParsed = Hash.parsePadUrl(data.roHref) || {};
|
||||
if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); }
|
||||
var friends = common.getFriends();
|
||||
var ro = folders[id] && folders[id].version >= 2;
|
||||
var modal = UIElements.createShareModal({
|
||||
teamId: APP.team,
|
||||
origin: APP.origin,
|
||||
pathname: "/drive/",
|
||||
friends: friends,
|
||||
title: data.title,
|
||||
password: data.password,
|
||||
sharedFolder: true,
|
||||
common: common,
|
||||
hashes: {
|
||||
editHash: parsed.hash,
|
||||
viewHash: ro && roParsed.hash,
|
||||
}
|
||||
});
|
||||
// If we're a viewer and this is an old shared folder (no read-only mode), we
|
||||
// can't share the read-only URL and we don't have access to the edit one.
|
||||
// We should hide the share button.
|
||||
if (!modal) { return; }
|
||||
$shareBlock.click(function () {
|
||||
UI.openCustomModal(modal);
|
||||
});
|
||||
$container.append($shareBlock);
|
||||
return $shareBlock;
|
||||
};
|
||||
|
||||
// Create the "li" element corresponding to the file/folder located in "path"
|
||||
var createElement = function (path, elPath, root, isFolder) {
|
||||
// Forbid drag&drop inside the trash
|
||||
|
@ -2016,6 +2054,15 @@ define([
|
|||
});
|
||||
delete APP.newFolder;
|
||||
}
|
||||
|
||||
if (isSharedFolder && APP.convertedFolder === element) {
|
||||
setTimeout(function () {
|
||||
var $fakeButton = createShareButton(element, $('<div>'));
|
||||
if (!$fakeButton) { return; }
|
||||
$fakeButton.click();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
return $element;
|
||||
};
|
||||
|
||||
|
@ -2553,43 +2600,6 @@ define([
|
|||
$container.append($block);
|
||||
};
|
||||
|
||||
var createShareButton = function (id, $container) {
|
||||
var $shareBlock = $('<button>', {
|
||||
'class': 'cp-toolbar-share-button',
|
||||
title: Messages.shareButton
|
||||
});
|
||||
$sharedIcon.clone().appendTo($shareBlock);
|
||||
$('<span>').text(Messages.shareButton).appendTo($shareBlock);
|
||||
var data = manager.getSharedFolderData(id);
|
||||
var parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
|
||||
var roParsed = Hash.parsePadUrl(data.roHref) || {};
|
||||
if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); }
|
||||
var friends = common.getFriends();
|
||||
var ro = folders[id] && folders[id].version >= 2;
|
||||
var modal = UIElements.createShareModal({
|
||||
teamId: APP.team,
|
||||
origin: APP.origin,
|
||||
pathname: "/drive/",
|
||||
friends: friends,
|
||||
title: data.title,
|
||||
password: data.password,
|
||||
sharedFolder: true,
|
||||
common: common,
|
||||
hashes: {
|
||||
editHash: parsed.hash,
|
||||
viewHash: ro && roParsed.hash,
|
||||
}
|
||||
});
|
||||
// If we're a viewer and this is an old shared folder (no read-only mode), we
|
||||
// can't share the read-only URL and we don't have access to the edit one.
|
||||
// We should hide the share button.
|
||||
if (!modal) { return; }
|
||||
$shareBlock.click(function () {
|
||||
UI.openCustomModal(modal);
|
||||
});
|
||||
$container.append($shareBlock);
|
||||
};
|
||||
|
||||
var SORT_FOLDER_DESC = 'sortFoldersDesc';
|
||||
var SORT_FILE_BY = 'sortFilesBy';
|
||||
var SORT_FILE_DESC = 'sortFilesDesc';
|
||||
|
@ -3485,6 +3495,9 @@ define([
|
|||
} else {
|
||||
$content.scrollTop(s);
|
||||
}
|
||||
|
||||
delete APP.convertedFolder;
|
||||
|
||||
appStatus.ready(true);
|
||||
};
|
||||
var displayDirectory = APP.displayDirectory = function (path, force) {
|
||||
|
@ -4087,10 +4100,14 @@ define([
|
|||
if (!res) { return; }
|
||||
var password = $(convertContent).find('#cp-upload-password').val() || undefined;
|
||||
var owned = Util.isChecked($(convertContent).find('#cp-upload-owned'));
|
||||
manager.convertFolderToSharedFolder(paths[0].path, owned, password, refresh);
|
||||
manager.convertFolderToSharedFolder(paths[0].path, owned, password, function (err, obj) {
|
||||
if (err || obj && obj.error) { return void console.error(err || obj.error); }
|
||||
if (obj && obj.fId) { APP.convertedFolder = obj.fId; }
|
||||
refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
} else { // File
|
||||
} else { // File or shared folder
|
||||
var sf = manager.isSharedFolder(el);
|
||||
data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el);
|
||||
parsed = (data.href && data.href.indexOf('#') !== -1) ? Hash.parsePadUrl(data.href) : {};
|
||||
|
|
|
@ -689,7 +689,9 @@ define([
|
|||
|
||||
// remove folder
|
||||
Env.user.userObject.delete([path], function () {
|
||||
cb();
|
||||
cb({
|
||||
fId: SFId
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue