From 7733a714de70425eadd71664fd308703b7ed6fad Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Thu, 9 Jan 2020 03:31:28 -0700 Subject: [PATCH] Show alert when not a member of a team (#3784) --- assets/base/i18n/en.json | 1 + ios/MattermostShare/ShareViewController.swift | 2 ++ .../android/extension_post/extension_post.js | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 9db09cdb2..65fd2ab22 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -252,6 +252,7 @@ "mobile.extension.file_limit": "Sharing is limited to a maximum of 5 files.", "mobile.extension.max_file_size": "File attachments shared in Mattermost must be less than {size}.", "mobile.extension.permission": "Mattermost needs access to the device storage to share files.", + "mobile.extension.team_required": "You must belong to a team before you can share files.", "mobile.extension.title": "Share in Mattermost", "mobile.failed_network_action.retry": "try again", "mobile.failed_network_action.shortDescription": "Messages will load when you have an internet connection or {tryAgainAction}.", diff --git a/ios/MattermostShare/ShareViewController.swift b/ios/MattermostShare/ShareViewController.swift index 9f7d2e2b9..8d2dc9c8b 100644 --- a/ios/MattermostShare/ShareViewController.swift +++ b/ios/MattermostShare/ShareViewController.swift @@ -90,6 +90,8 @@ class ShareViewController: SLComposeServiceViewController { if sessionToken == nil || serverURL == nil { showErrorMessage(title: "", message: "Authentication required: Please first login using the app.", VC: self) + } else if store.getCurrentTeamId() == "" { + showErrorMessage(title: "", message: "You must belong to a team before you can share files.", VC: self) } } diff --git a/share_extension/android/extension_post/extension_post.js b/share_extension/android/extension_post/extension_post.js index 9efbb9293..a5f2eee65 100644 --- a/share_extension/android/extension_post/extension_post.js +++ b/share_extension/android/extension_post/extension_post.js @@ -608,7 +608,7 @@ export default class ExtensionPost extends PureComponent { render() { const {formatMessage} = this.context.intl; const {maxFileSize} = this.props; - const {error, hasPermission, files, totalSize, loaded} = this.state; + const {error, hasPermission, files, totalSize, loaded, teamId} = this.state; if (!loaded) { return ( @@ -620,6 +620,15 @@ export default class ExtensionPost extends PureComponent { return this.renderErrorMessage(error); } + if (!teamId) { + const teamRequired = formatMessage({ + id: 'mobile.extension.team_required', + defaultMessage: 'You must belong to a team before you can share files.', + }); + + return this.renderErrorMessage(teamRequired); + } + if (this.token && this.url) { if (hasPermission === false) { const storage = formatMessage({