From 91e860a67bf9514d40e18f891c9005ffc33c933c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 23 Aug 2020 21:35:33 -0500 Subject: [PATCH] SoapboxConfig: Actually upload the logo and banner files --- app/soapbox/features/soapbox_config/index.js | 19 +++++++++++++++---- app/styles/forms.scss | 4 ++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/soapbox/features/soapbox_config/index.js b/app/soapbox/features/soapbox_config/index.js index 30c3e958d..a6f853069 100644 --- a/app/soapbox/features/soapbox_config/index.js +++ b/app/soapbox/features/soapbox_config/index.js @@ -18,6 +18,7 @@ import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { updateAdminConfig } from 'soapbox/actions/admin'; import Icon from 'soapbox/components/icon'; import { defaultConfig } from 'soapbox/actions/soapbox'; +import { uploadMedia } from 'soapbox/actions/media'; const messages = defineMessages({ heading: { id: 'column.soapbox_config', defaultMessage: 'Soapbox config' }, @@ -90,6 +91,16 @@ class SoapboxConfig extends ImmutablePureComponent { }; }; + handleFileChange = path => { + return e => { + const data = new FormData(); + data.append('file', e.target.files[0]); + this.props.dispatch(uploadMedia(data)).then(({ data }) => { + this.handleChange(path, e => data.url)(e); + }).catch(() => {}); + }; + }; + handleAddItem = (path, template) => { return e => { this.setConfig( @@ -139,7 +150,7 @@ class SoapboxConfig extends ImmutablePureComponent {
-
+
@@ -148,11 +159,11 @@ class SoapboxConfig extends ImmutablePureComponent { label={} name='logo' hint={
-
+
@@ -161,7 +172,7 @@ class SoapboxConfig extends ImmutablePureComponent { label={} name='banner' hint={} - // onChange={this.handleFileChange} + onChange={this.handleFileChange(['banner'])} />
diff --git a/app/styles/forms.scss b/app/styles/forms.scss index 92c1c3fe2..eee0feb4b 100644 --- a/app/styles/forms.scss +++ b/app/styles/forms.scss @@ -984,3 +984,7 @@ code { margin-top: 10px; } } + +.file-picker img { + max-width: 100px; +}