From e09265279d6a39229ac350879d59def397f57e55 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 10 Jun 2020 22:16:23 -0400 Subject: [PATCH] Fixed group editing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed: - group editing dialog • Updated: - FileInput to take in file from props to state - GroupCreateModal, GroupCreate to take in groupId --- app/javascript/gabsocial/components/file_input.js | 2 +- .../components/modal/group_create_modal.js | 13 ++++++++----- .../components/popover/group_options_popover.js | 6 +++--- app/javascript/gabsocial/features/group_create.js | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/javascript/gabsocial/components/file_input.js b/app/javascript/gabsocial/components/file_input.js index 356f19a8..9385254f 100644 --- a/app/javascript/gabsocial/components/file_input.js +++ b/app/javascript/gabsocial/components/file_input.js @@ -20,7 +20,7 @@ export default class FileInput extends PureComponent { } state = { - file: null, + file: this.props.file, } handleOnChange = (e) => { diff --git a/app/javascript/gabsocial/components/modal/group_create_modal.js b/app/javascript/gabsocial/components/modal/group_create_modal.js index c7f1f159..8e43314a 100644 --- a/app/javascript/gabsocial/components/modal/group_create_modal.js +++ b/app/javascript/gabsocial/components/modal/group_create_modal.js @@ -1,31 +1,34 @@ import { defineMessages, injectIntl } from 'react-intl' -import ImmutablePureComponent from 'react-immutable-pure-component' import ModalLayout from './modal_layout' import GroupCreate from '../../features/group_create' const messages = defineMessages({ title: { id: 'create_group', defaultMessage: 'Create group' }, + update: { id: 'groups.form.update', defaultMessage: 'Update group' }, }) export default @injectIntl -class GroupCreateModal extends ImmutablePureComponent { +class GroupCreateModal extends PureComponent { static propTypes = { intl: PropTypes.object.isRequired, onClose: PropTypes.func.isRequired, + groupId: PropTypes.string, } render() { - const { intl, onClose } = this.props + const { intl, onClose, groupId } = this.props + + const title = intl.formatMessage(groupId ? messages.update : messages.title) return ( - + ) } diff --git a/app/javascript/gabsocial/components/popover/group_options_popover.js b/app/javascript/gabsocial/components/popover/group_options_popover.js index db91ddf7..4637b106 100644 --- a/app/javascript/gabsocial/components/popover/group_options_popover.js +++ b/app/javascript/gabsocial/components/popover/group_options_popover.js @@ -20,9 +20,9 @@ const messages = defineMessages({ const mapDispatchToProps = (dispatch) => ({ - onOpenEditGroup(group) { + onOpenEditGroup(groupId) { dispatch(closePopover()) - dispatch(openModal(MODAL_GROUP_CREATE, { group })) + dispatch(openModal(MODAL_GROUP_CREATE, { groupId })) }, onOpenRemovedMembers(groupId) { @@ -54,7 +54,7 @@ class GroupOptionsPopover extends ImmutablePureComponent { updateOnProps = ['group'] handleEditGroup = () => { - this.props.onOpenEditGroup(this.props.group) + this.props.onOpenEditGroup(this.props.group.get('id')) } handleOnOpenRemovedMembers = () => { diff --git a/app/javascript/gabsocial/features/group_create.js b/app/javascript/gabsocial/features/group_create.js index fb253b97..ca8c2672 100644 --- a/app/javascript/gabsocial/features/group_create.js +++ b/app/javascript/gabsocial/features/group_create.js @@ -167,6 +167,7 @@ class GroupCreate extends ImmutablePureComponent { disabled={isSubmitting} title={intl.formatMessage(coverImage === null ? messages.coverImage : messages.coverImageChange)} onChange={this.handleCoverImageChange} + file={group ? group.get('cover_image_url') : undefined} width='340px' height='145px' />