Skip to content

Commit

Permalink
HF 30 - Private message groups
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Jun 22, 2024
1 parent 946b851 commit 50cbc0b
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 48 deletions.
1 change: 1 addition & 0 deletions src/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@import './modules/LoginForm.scss';
@import './modules/CreateGroup.scss';
@import './modules/groups/MyGroups.scss';
@import './modules/groups/GroupSettings.scss';
@import './modules/Modals.scss';

@import "./pages/Messages";
72 changes: 36 additions & 36 deletions src/components/modules/CreateGroup.scss
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
.CreateGroup {
h3 {
padding-left: 0.75rem;
}
.next-button {
width: 48px;
height: 48px;
padding-left: 13px !important;
color: white;
position: absolute;
bottom: 0.4rem;
right: 0.5rem;
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.4);
}
.Stepper {
width: 85%;
margin-left: 1rem;
}
.icon-hint {
margin-left: 0.25rem;
}
.column {
padding-right: 0.5rem !important;
}
.error {
margin-bottom: 0px !important;
margin-top: 0.5rem;
}
.submit-error {
margin-left: 1rem;
max-width: 83%;
}
h3 {
padding-left: 0.75rem;
}
.next-button {
width: 48px;
height: 48px;
padding-left: 13px !important;
color: white;
position: absolute;
bottom: 0.4rem;
right: 0.5rem;
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.4);
}
.Stepper {
width: 85%;
margin-left: 1rem;
}
.icon-hint {
margin-left: 0.25rem;
}
.column {
padding-right: 0.5rem !important;
}
.error {
margin-bottom: 0px !important;
margin-top: 0.5rem;
}
.submit-error {
margin-left: 1rem;
max-width: 83%;
}

.image-loader {
margin-top: 14px;
}
.image-loader {
margin-top: 14px;
}

.image-preview {
max-width: 75px;
Expand All @@ -42,7 +42,7 @@
border: none;
}
.submit-loader {
margin-left: 0.5rem;
margin-top: 0.5rem;
margin-left: 0.5rem;
margin-top: 0.5rem;
}
}
13 changes: 13 additions & 0 deletions src/components/modules/Modals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CloseButton from 'react-foundation-components/lib/global/close-button';
import Reveal from 'react-foundation-components/lib/global/reveal';

import CreateGroup from 'app/components/modules/CreateGroup'
import GroupSettings from 'app/components/modules/groups/GroupSettings'
import MyGroups from 'app/components/modules/groups/MyGroups'
import Donate from 'app/components/modules/Donate'
import LoginForm from 'app/components/modules/LoginForm';
Expand All @@ -21,6 +22,7 @@ class Modals extends React.Component {
show_donate_modal: PropTypes.bool,
show_create_group_modal: PropTypes.bool,
show_my_groups_modal: PropTypes.bool,
show_group_settings_modal: PropTypes.bool,
show_app_download_modal: PropTypes.bool,
hideDonate: PropTypes.func.isRequired,
hideAppDownload: PropTypes.func.isRequired,
Expand All @@ -44,11 +46,13 @@ class Modals extends React.Component {
show_donate_modal,
show_create_group_modal,
show_my_groups_modal,
show_group_settings_modal,
show_app_download_modal,
hideLogin,
hideDonate,
hideCreateGroup,
hideMyGroups,
hideGroupSettings,
hideAppDownload,
notifications,
removeNotification,
Expand Down Expand Up @@ -80,6 +84,10 @@ class Modals extends React.Component {
<CloseButton onClick={hideMyGroups} />
<MyGroups />
</Reveal>}
{show_group_settings_modal && <Reveal enforceFocus={false} revealStyle={{ overflow: 'hidden' }} onHide={hideGroupSettings} show={show_group_settings_modal}>
<CloseButton onClick={hideGroupSettings} />
<GroupSettings closeMe={hideGroupSettings} />
</Reveal>}
{show_app_download_modal && <Reveal onHide={hideAppDownload} show={show_app_download_modal}>
<CloseButton onClick={hideAppDownload} />
<AppDownload />
Expand All @@ -103,6 +111,7 @@ export default connect(
show_donate_modal: state.user.get('show_donate_modal'),
show_create_group_modal: state.user.get('show_create_group_modal'),
show_my_groups_modal: state.user.get('show_my_groups_modal'),
show_group_settings_modal: state.user.get('show_group_settings_modal'),
show_app_download_modal: state.user.get('show_app_download_modal'),
loginUnclosable,
notifications: state.app.get('notifications'),
Expand All @@ -125,6 +134,10 @@ export default connect(
if (e) e.preventDefault()
dispatch(user.actions.hideMyGroups())
},
hideGroupSettings: e => {
if (e) e.preventDefault()
dispatch(user.actions.hideGroupSettings())
},
hideAppDownload: e => {
if (e) e.preventDefault()
dispatch(user.actions.hideAppDownload())
Expand Down
194 changes: 194 additions & 0 deletions src/components/modules/groups/GroupSettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import React from 'react'
import {connect} from 'react-redux'
import { Formik, Form, Field, ErrorMessage, } from 'formik'
import { Map } from 'immutable'
import { api, formatter } from 'golos-lib-js'
import tt from 'counterpart'

import g from 'app/redux/GlobalReducer'
import transaction from 'app/redux/TransactionReducer'
import user from 'app/redux/UserReducer'
import { session } from 'app/redux/UserSaga'
import DropdownMenu from 'app/components/elements/DropdownMenu'
import ExtLink from 'app/components/elements/ExtLink'
import Icon from 'app/components/elements/Icon'
import LoadingIndicator from 'app/components/elements/LoadingIndicator'
import DialogManager from 'app/components/elements/common/DialogManager'
import { showLoginDialog } from 'app/components/dialogs/LoginDialog'
import { getGroupLogo, getGroupMeta, getGroupTitle } from 'app/utils/groups'

class GroupSettings extends React.Component {
constructor(props) {
super(props)
this.state = {
loaded: false
}
}

componentDidMount() {
const { currentGroup } = this.props
const group = currentGroup.toJS()
const { name, member_list, privacy, json_metadata } = group
const meta = getGroupMeta(json_metadata)
let admin
for (const mem of member_list) {
if (mem.member_type === 'admin') {
admin = mem.account
}
break
}
const initialValues = {
title: meta.title,
logo: meta.logo,
admin,
privacy
}
this.setState({
initialValues
})
}

onTitleChange = (e, { applyFieldValue }) => {
const { value } = e.target
if (value.trimLeft() !== value) {
return
}
applyFieldValue('title', value)
}

onLogoChange = (e, { applyFieldValue }) => {
const { value } = e.target
applyFieldValue('logo', value)
}

onAdminChange = (e, { applyFieldValue }) => {
const { value } = e.target
applyFieldValue('admin', value)
}

validate = async () => {

}

onSubmit = async () => {

}

closeMe = (e) => {
e.preventDefault()
this.props.closeMe()
}

render() {
const { currentGroup } = this.props
const group = currentGroup.toJS()
const { name, json_metadata } = group

const meta = getGroupMeta(json_metadata)
const title = getGroupTitle(meta, name)

const { initialValues } = this.state

let form
if (!initialValues) {
form = <LoadingIndicator type='circle' />
} else {
form = <Formik
initialValues={initialValues}
enableReinitialize={true}
validateOnMount={true}
validateOnBlur={false}
validate={this.validate}
onSubmit={this._onSubmit}
>
{({
handleSubmit, isSubmitting, isValid, values, errors, setFieldValue, applyFieldValue, setFieldTouched, handleChange,
}) => {
const disabled = !isValid
return (
<Form>
<div className='row'>
<div className='column small-6'>
{tt('create_group_jsx.title')}
<Field
type='text'
name='title'
maxLength='48'
onChange={e => this.onTitleChange(e, { applyFieldValue })}
autoFocus
validateOnBlur={false}
/>
</div>
<div className='column small-6'>
{tt('create_group_jsx.name2')}<br/>
<div style={{ marginTop: '0.5rem' }}>
{tt('create_group_jsx.name3')}{name}
</div>
</div>
</div>
<div className='row' style={{ marginTop: '1rem' }}>
<div className='column small-12'>
{tt('create_group_jsx.logo')}
<div className="input-group">
<Field
type='text'
name='logo'
className="input-group-field"
maxLength='1024'
placeholder='https://'
onChange={e => this.onLogoChange(e, { applyFieldValue })}
validateOnBlur={false}
/>
<span className="input-group-label">{tt('group_settings_jsx.upload')}</span>
</div>
</div>
</div>
<div className='row' style={{ marginTop: '0rem' }}>
<div className='column small-12'>
{tt('create_group_jsx.admin')}
<Field
type='text'
name='admin'
maxLength='16'
onChange={e => this.onAdminChange(e, { applyFieldValue })}
validateOnBlur={false}
/>
</div>
</div>
<div style={{ marginTop: '1rem' }}>
<button className='button hollow float-right' onClick={this.closeMe}>
{tt('g.cancel')}
</button>
<button type='submit' className='button float-right'>
{tt('group_settings_jsx.submit')}
</button>
</div>
</Form>
)}}</Formik>
}

return <div className='GroupSettings'>
<div className='row'>
<h3>{tt('group_settings_jsx.title_GROUP', {
GROUP: title
})}</h3>
</div>
{form}
</div>
}
}

export default connect(
(state, ownProps) => {
const currentUser = state.user.getIn(['current'])
const currentAccount = currentUser && state.global.getIn(['accounts', currentUser.get('username')])

return { ...ownProps,
currentUser,
currentAccount,
currentGroup: state.user.get('current_group'),
}
},
dispatch => ({
})
)(GroupSettings)
5 changes: 5 additions & 0 deletions src/components/modules/groups/GroupSettings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.GroupSettings {
h3 {
padding-left: 0.75rem;
}
}
Loading

0 comments on commit 50cbc0b

Please sign in to comment.