From 5dcc7643da268d70ed7d78a5e37d6e23477cc837 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 8 Nov 2019 12:04:30 +0100 Subject: [PATCH] Fix missing teams in the share modal --- www/common/common-ui-elements.js | 2 +- www/common/drive-ui.js | 12 +++++++++++- www/common/outer/team.js | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 1ee5a9608..34fb16474 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -882,7 +882,7 @@ define([ // config.teamId only exists when we're trying to share a pad from a team drive // In this case, we don't want to share the pad with the current team if (config.teamId && config.teamId === id) { return; } - if (!teamsData[id].secondaryKey) { return; } + if (!teamsData[id].hasSecondaryKey) { return; } var t = teamsData[id]; teams[t.edPublic] = { notifications: true, diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index f3ef49bcc..3b52e3193 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1888,9 +1888,16 @@ define([ var $password = $passwordIcon.clone().appendTo($state); $password.attr('title', Messages.fm_passwordProtected || ''); } + if (hrefData.hashData && hrefData.hashData.mode === 'view') { + var $ro = $readonlyIcon.clone().appendTo($state); + $ro.attr('title', Messages.readonly); + } var $shared = $sharedIcon.clone().appendTo($state); $shared.attr('title', Messages.fm_canBeShared); + } else if ($content.data('readOnlyFolder') || APP.readOnly) { + var $ro = $readonlyIcon.clone().appendTo($state); + $ro.attr('title', Messages.readonly); } var sf = manager.hasSubfolder(element); @@ -2559,6 +2566,10 @@ define([ 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; } modal = UI.dialog.tabs(modal); $shareBlock.click(function () { UI.openCustomModal(modal, { @@ -4079,7 +4090,6 @@ define([ var roParsed = Hash.parsePadUrl(data.roHref); var padType = parsed.type || roParsed.type; var ro = !sf || (folders[el] && folders[el].version >= 2); - console.log(folders[el]); var padData = { teamId: APP.team, origin: APP.origin, diff --git a/www/common/outer/team.js b/www/common/outer/team.js index ada4361c5..caac0704e 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -1309,6 +1309,9 @@ define([ if (safe && ctx.teams[id]) { t[id].secondaryKey = ctx.teams[id].secondaryKey; } + if (ctx.teams[id]) { + t[id].hasSecondaryKey = Boolean(ctx.teams[id].secondaryKey); + } }); return t; };