From 550498bfc081ccd24630a8b70d10b74c8e6302bd Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Thu, 10 Dec 2020 13:13:35 +0100 Subject: [PATCH] MM-30858 fix: follow config to show the option to copy file public link (#5011) (#5016) (cherry picked from commit 5874e58dd13736d282f7598a5c5cb10edda1c505) Co-authored-by: Elias Nahum --- app/screens/gallery/footer/index.tsx | 2 +- app/screens/gallery/footer/summary/actions/actions.tsx | 2 +- app/screens/gallery/footer/summary/actions/index.ts | 5 ++++- types/screens/gallery.d.ts | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/screens/gallery/footer/index.tsx b/app/screens/gallery/footer/index.tsx index 40d4ba59e..4997de166 100644 --- a/app/screens/gallery/footer/index.tsx +++ b/app/screens/gallery/footer/index.tsx @@ -50,7 +50,7 @@ const Footer = forwardRef((props: FooterProps, ref) => { const message = formatMessage({id: 'mobile.public_link.copied', defaultMessage: 'Public link copied'}); const res = await Client4.getFilePublicLink(props.file.id); Clipboard.setString(res.link); - showToast(message, undefined, callback); + showToast(message, 100, callback); } catch (e) { // eslint-disable-next-line no-console console.log('An error occurred, we should show a different toast', e); diff --git a/app/screens/gallery/footer/summary/actions/actions.tsx b/app/screens/gallery/footer/summary/actions/actions.tsx index 22f3872b6..f4f08d52a 100644 --- a/app/screens/gallery/footer/summary/actions/actions.tsx +++ b/app/screens/gallery/footer/summary/actions/actions.tsx @@ -40,7 +40,7 @@ const Actions = (props: ActionsProps) => { }; }, []); - let linkActionVisible = !props.file.id.startsWith('uid'); + let linkActionVisible = !props.file.id.startsWith('uid') && props.enablePublicLink; if (managedConfig?.copyPasteProtection === 'true') { linkActionVisible = false; } diff --git a/app/screens/gallery/footer/summary/actions/index.ts b/app/screens/gallery/footer/summary/actions/index.ts index d48e33985..30aec0a9b 100644 --- a/app/screens/gallery/footer/summary/actions/index.ts +++ b/app/screens/gallery/footer/summary/actions/index.ts @@ -3,15 +3,18 @@ import {connect} from 'react-redux'; -import {canDownloadFilesOnMobile} from '@mm-redux/selectors/entities/general'; +import {canDownloadFilesOnMobile, getConfig} from '@mm-redux/selectors/entities/general'; import type {GlobalState} from '@mm-redux/types/store'; import Actions from './actions'; function mapStateToProps(state: GlobalState) { + const config = getConfig(state); + return { canDownloadFiles: canDownloadFilesOnMobile(state), + enablePublicLink: config?.EnablePublicLink === 'true', }; } diff --git a/types/screens/gallery.d.ts b/types/screens/gallery.d.ts index c8eeb59a2..a8dc1d430 100644 --- a/types/screens/gallery.d.ts +++ b/types/screens/gallery.d.ts @@ -21,6 +21,7 @@ export interface ActionProps { export interface ActionsProps { canDownloadFiles: boolean; + enablePublicLink: boolean; downloadAction: ActionCallback; file: FileInfo; linkAction: ActionCallback;