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 c01be70 commit 946b851
Show file tree
Hide file tree
Showing 15 changed files with 381 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/components/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// modules
@import './modules/LoginForm.scss';
@import './modules/CreateGroup.scss';
@import './modules/groups/MyGroups.scss';
@import './modules/Modals.scss';

@import "./pages/Messages";
24 changes: 19 additions & 5 deletions src/components/dialogs/LoginDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Input from 'app/components/elements/common/Input';
import keyCodes from 'app/utils/keyCodes';
import { pageSession } from 'app/redux/UserSaga'

export function showLoginDialog(username, onClose, authType = 'active', saveLogin = false) {
export function showLoginDialog(username, onClose, authType = 'active', saveLogin = false, hint = '') {
let dm, oldZ = ''

DialogManager.showDialog({
Expand All @@ -18,6 +18,7 @@ export function showLoginDialog(username, onClose, authType = 'active', saveLogi
props: {
username,
authType,
hint,
},
onClose: (data) => {
if (dm) dm.style.zIndex = oldZ
Expand All @@ -44,7 +45,7 @@ export default class LoginDialog extends React.PureComponent {
}

componentDidMount() {
let { saveLogin } = this.props
let { saveLogin, hint } = this.props
const session = pageSession.load()
if (session) {
this.setState({
Expand All @@ -58,6 +59,11 @@ export default class LoginDialog extends React.PureComponent {
const linkInput = document.getElementsByClassName('AddImageDialog__link-input')[0];
if (linkInput)
linkInput.focus();
setTimeout(() => {
this.setState({
enabled: true
})
}, hint ? 1500 : 0)
}

onPasswordChange = (e) => {
Expand Down Expand Up @@ -122,7 +128,13 @@ export default class LoginDialog extends React.PureComponent {
}

render() {
const { password, error, saveLogin } = this.state
const { password, error, saveLogin, enabled } = this.state

let hint
if (this.props.hint) {
hint = <b style={{ color: 'red' }}>&nbsp;{this.props.hint}</b>
}

return (
<DialogFrame
className='LoginDialog'
Expand All @@ -132,6 +144,8 @@ export default class LoginDialog extends React.PureComponent {
<div>
<div className="AddImageDialog__link-text">
{tt('loginform_jsx.is_is_for_operation')}
{hint}
.
</div>
<Input
block
Expand Down Expand Up @@ -159,8 +173,8 @@ export default class LoginDialog extends React.PureComponent {
</div>
<div style={{ marginTop: '1rem' }}>
<center>
<button className='button' onClick={this.onLogin}>
{tt('g.login')}
<button disabled={!enabled} className='button' onClick={this.onLogin}>
{enabled ? tt('g.login') : tt('g.wait')}
</button>
<button className='button hollow' onClick={this.onCancel}>
{tt('g.cancel')}
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/messages/StartPanel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default connect(
},
dispatch => ({
showCreateGroup() {
dispatch(user.actions.showCreateGroup())
dispatch(user.actions.showCreateGroup({ redirectAfter: true }))
},
})
)(StartPanel)
11 changes: 9 additions & 2 deletions src/components/modules/CreateGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CreateGroup extends React.Component {
}

_onSubmit = (data, actions) => {
const { currentUser } = this.props
const { currentUser, redirectAfter } = this.props
const creator = currentUser.get('username')
data.creator = creator

Expand All @@ -132,8 +132,13 @@ class CreateGroup extends React.Component {
password,
...data,
onSuccess: () => {
alert('success')
actions.setSubmitting(false)
const { closeMe } = this.props
if (closeMe) closeMe()
if (redirectAfter) {
window.location.href = '/' + data.name
return
}
},
onError: (err, errStr) => {
this.setState({ submitError: errStr })
Expand Down Expand Up @@ -188,6 +193,7 @@ class CreateGroup extends React.Component {
initialValues={this.state.initialValues}
enableReinitialize={true}
validateOnMount={true}
validateOnBlur={false}
validate={this.validate}
onSubmit={this._onSubmit}
>
Expand Down Expand Up @@ -234,6 +240,7 @@ export default connect(
return { ...ownProps,
currentUser,
currentAccount,
redirectAfter: state.user.get('create_group_redirect_after'),
}
},
dispatch => ({
Expand Down
15 changes: 14 additions & 1 deletion 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 MyGroups from 'app/components/modules/groups/MyGroups'
import Donate from 'app/components/modules/Donate'
import LoginForm from 'app/components/modules/LoginForm';
import AppDownload from 'app/components/modules/app/AppDownload'
Expand All @@ -19,6 +20,7 @@ class Modals extends React.Component {
show_login_modal: PropTypes.bool,
show_donate_modal: PropTypes.bool,
show_create_group_modal: PropTypes.bool,
show_my_groups_modal: PropTypes.bool,
show_app_download_modal: PropTypes.bool,
hideDonate: PropTypes.func.isRequired,
hideAppDownload: PropTypes.func.isRequired,
Expand All @@ -41,10 +43,12 @@ class Modals extends React.Component {
show_login_modal,
show_donate_modal,
show_create_group_modal,
show_my_groups_modal,
show_app_download_modal,
hideLogin,
hideDonate,
hideCreateGroup,
hideMyGroups,
hideAppDownload,
notifications,
removeNotification,
Expand All @@ -70,7 +74,11 @@ class Modals extends React.Component {
</Reveal>}
{show_create_group_modal && <Reveal enforceFocus={false} onBackdropClick={this.onUnclosableClick} revealStyle={{ overflow: 'hidden' }} onHide={hideCreateGroup} show={show_create_group_modal}>
<CloseButton onClick={hideCreateGroup} />
<CreateGroup />
<CreateGroup closeMe={hideCreateGroup} />
</Reveal>}
{show_my_groups_modal && <Reveal enforceFocus={false} revealStyle={{ overflow: 'hidden' }} onHide={hideMyGroups} show={show_my_groups_modal}>
<CloseButton onClick={hideMyGroups} />
<MyGroups />
</Reveal>}
{show_app_download_modal && <Reveal onHide={hideAppDownload} show={show_app_download_modal}>
<CloseButton onClick={hideAppDownload} />
Expand All @@ -94,6 +102,7 @@ export default connect(
show_login_modal: state.user.get('show_login_modal'),
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_app_download_modal: state.user.get('show_app_download_modal'),
loginUnclosable,
notifications: state.app.get('notifications'),
Expand All @@ -112,6 +121,10 @@ export default connect(
if (e) e.preventDefault()
dispatch(user.actions.hideCreateGroup())
},
hideMyGroups: e => {
if (e) e.preventDefault()
dispatch(user.actions.hideMyGroups())
},
hideAppDownload: e => {
if (e) e.preventDefault()
dispatch(user.actions.hideAppDownload())
Expand Down
1 change: 1 addition & 0 deletions src/components/modules/groups/GroupName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default class GroupName extends React.Component {
maxLength='48'
onChange={e => this.onTitleChange(e)}
autoFocus
validateOnBlur={false}
/>
<ErrorMessage name='title' component='div' className='error' />
</div>
Expand Down
Loading

0 comments on commit 946b851

Please sign in to comment.