From 3c0f082506a68240abd1960cbd0fda22679e12c2 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 28 Jul 2017 13:52:31 -0400 Subject: PLT-6924 Added config options to disable file uploads/downloads on mobile (#7049) --- config/config.json | 25 +++++++----- model/config.go | 12 ++++++ utils/config.go | 2 + .../components/admin_console/storage_settings.jsx | 44 +++++++++++++++++++++- webapp/i18n/en.json | 8 +++- 5 files changed, 77 insertions(+), 14 deletions(-) diff --git a/config/config.json b/config/config.json index 35747cefd..0c7144f1a 100644 --- a/config/config.json +++ b/config/config.json @@ -46,18 +46,10 @@ "TimeBetweenUserTypingUpdatesMilliseconds": 5000, "EnablePostSearch": true, "EnableUserTypingMessages": true, - "EnableUserStatuses": true, "EnableChannelViewedMessages": true, + "EnableUserStatuses": true, "ClusterLogTimeoutMilliseconds": 2000 }, - "ElasticsearchSettings": { - "ConnectionUrl": "http://dockerhost:9200", - "Username": "elastic", - "Password": "changeme", - "EnableIndexing": false, - "EnableSearching": false, - "Sniff": true - }, "TeamSettings": { "SiteName": "Mattermost", "MaxUsersPerTeam": 50, @@ -112,6 +104,8 @@ }, "FileSettings": { "EnableFileAttachments": true, + "EnableMobileUpload": true, + "EnableMobileDownload": true, "MaxFileSize": 52428800, "DriverName": "local", "Directory": "./data/", @@ -167,6 +161,9 @@ "AboutLink": "https://about.mattermost.com/default-about/", "HelpLink": "https://about.mattermost.com/default-help/", "ReportAProblemLink": "https://about.mattermost.com/default-report-a-problem/", + "AdministratorsGuideLink": "https://about.mattermost.com/administrators-guide/", + "TroubleshootingForumLink": "https://about.mattermost.com/troubleshooting-forum/", + "CommercialSupportLink": "https://about.mattermost.com/commercial-support/", "SupportEmail": "feedback@mattermost.com" }, "AnnouncementSettings": { @@ -287,6 +284,14 @@ "TurnUsername": "", "TurnSharedKey": "" }, + "ElasticsearchSettings": { + "ConnectionUrl": "http://dockerhost:9200", + "Username": "elastic", + "Password": "changeme", + "EnableIndexing": false, + "EnableSearching": false, + "Sniff": true + }, "DataRetentionSettings": { "Enable": false }, @@ -294,4 +299,4 @@ "RunJobs": true, "RunScheduler": true } -} +} \ No newline at end of file diff --git a/model/config.go b/model/config.go index 9daee78c8..a1af59185 100644 --- a/model/config.go +++ b/model/config.go @@ -236,6 +236,8 @@ type PasswordSettings struct { type FileSettings struct { EnableFileAttachments *bool + EnableMobileUpload *bool + EnableMobileDownload *bool MaxFileSize *int64 DriverName string Directory string @@ -539,6 +541,16 @@ func (o *Config) SetDefaults() { *o.FileSettings.EnableFileAttachments = true } + if o.FileSettings.EnableMobileUpload == nil { + o.FileSettings.EnableMobileUpload = new(bool) + *o.FileSettings.EnableMobileUpload = true + } + + if o.FileSettings.EnableMobileDownload == nil { + o.FileSettings.EnableMobileDownload = new(bool) + *o.FileSettings.EnableMobileDownload = true + } + if o.FileSettings.MaxFileSize == nil { o.FileSettings.MaxFileSize = new(int64) *o.FileSettings.MaxFileSize = 52428800 // 50 MB diff --git a/utils/config.go b/utils/config.go index 3e5edbdcc..e008377d3 100644 --- a/utils/config.go +++ b/utils/config.go @@ -452,6 +452,8 @@ func getClientConfig(c *model.Config) map[string]string { props["SupportEmail"] = *c.SupportSettings.SupportEmail props["EnableFileAttachments"] = strconv.FormatBool(*c.FileSettings.EnableFileAttachments) + props["EnableMobileFileUpload"] = strconv.FormatBool(*c.FileSettings.EnableMobileUpload) + props["EnableMobileFileDownload"] = strconv.FormatBool(*c.FileSettings.EnableMobileDownload) props["EnablePublicLink"] = strconv.FormatBool(c.FileSettings.EnablePublicLink) props["WebsocketPort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketPort) diff --git a/webapp/components/admin_console/storage_settings.jsx b/webapp/components/admin_console/storage_settings.jsx index 1400b673c..934a82f8f 100644 --- a/webapp/components/admin_console/storage_settings.jsx +++ b/webapp/components/admin_console/storage_settings.jsx @@ -26,6 +26,8 @@ export default class StorageSettings extends AdminSettings { getConfigFromState(config) { config.FileSettings.EnableFileAttachments = this.state.enableFileAttachments; + config.FileSettings.EnableMobileUpload = this.state.enableMobileUpload; + config.FileSettings.EnableMobileDownload = this.state.enableMobileDownload; config.FileSettings.MaxFileSize = this.parseInt(this.state.maxFileSize) * 1024 * 1024; config.FileSettings.DriverName = this.state.driverName; config.FileSettings.Directory = this.state.directory; @@ -41,6 +43,8 @@ export default class StorageSettings extends AdminSettings { getStateFromConfig(config) { return { enableFileAttachments: config.FileSettings.EnableFileAttachments, + enableMobileUpload: config.FileSettings.EnableMobileUpload, + enableMobileDownload: config.FileSettings.EnableMobileDownload, maxFileSize: config.FileSettings.MaxFileSize / 1024 / 1024, driverName: config.FileSettings.DriverName, directory: config.FileSettings.Directory, @@ -206,18 +210,54 @@ export default class StorageSettings extends AdminSettings { label={ } helpText={ } value={this.state.enableFileAttachments} onChange={this.handleChange} /> + + } + helpText={ + + } + value={this.state.enableMobileUpload} + onChange={this.handleChange} + disabled={!this.state.enableFileAttachments} + /> + + } + helpText={ + + } + value={this.state.enableMobileDownload} + onChange={this.handleChange} + disabled={!this.state.enableFileAttachments} + />