Updated groups so that anyone can create

• Updated:
- groups so that anyone can create
This commit is contained in:
mgabdev 2020-12-17 16:07:00 -05:00
parent d5361419d8
commit 47d57960a4
2 changed files with 5 additions and 47 deletions

View File

@ -26,7 +26,6 @@ import {
import { fetchGroup } from '../actions/groups' import { fetchGroup } from '../actions/groups'
import { fetchGroupCategories } from '../actions/group_categories' import { fetchGroupCategories } from '../actions/group_categories'
import { me } from '../initial_state' import { me } from '../initial_state'
import { MODAL_PRO_UPGRADE } from '../constants'
import ColumnIndicator from '../components/column_indicator' import ColumnIndicator from '../components/column_indicator'
import Button from '../components/button' import Button from '../components/button'
import Divider from '../components/divider' import Divider from '../components/divider'
@ -76,13 +75,6 @@ class GroupCreate extends ImmutablePureComponent {
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault() e.preventDefault()
// if not pro and not admin of group show pro upgrade modal
if (!this.props.isPro && !this.props.isAdmin) {
this.props.onOpenProUpgradeModal()
return
}
if (this.props.onClose) this.props.onClose() if (this.props.onClose) this.props.onClose()
this.props.onSubmit(this.context.router.history) this.props.onSubmit(this.context.router.history)
} }
@ -114,25 +106,12 @@ class GroupCreate extends ImmutablePureComponent {
groupId, groupId,
categories, categories,
isAdmin, isAdmin,
isPro,
} = this.props } = this.props
if (!group && groupId) { if (!group && groupId) {
return <ColumnIndicator type='loading' /> return <ColumnIndicator type='loading' />
} else if ((!group && error) || (groupId && !isAdmin)) { } else if ((!group && error) || (groupId && !isAdmin)) {
return <ColumnIndicator type='missing' /> return <ColumnIndicator type='missing' />
} else if (!isPro && !groupId) {
return <ColumnIndicator type='error' message={(
<React.Fragment>
<Text>You must be a GabPRO member to create a group.</Text>
<Button
onClick={this.props.onOpenProUpgradeModal}
className={[_s.mt15, _s.mlAuto, _s.mrAuto].join(' ')}
>
Learn more
</Button>
</React.Fragment>
)} />
} }
const memberCount = group ? group.get('member_count') : 0 const memberCount = group ? group.get('member_count') : 0
@ -357,7 +336,6 @@ const mapStateToProps = (state, { params }) => {
isPrivate: state.getIn(['group_editor', 'isPrivate']), isPrivate: state.getIn(['group_editor', 'isPrivate']),
isVisible: state.getIn(['group_editor', 'isVisible']), isVisible: state.getIn(['group_editor', 'isVisible']),
categories: state.getIn(['group_categories', 'items']), categories: state.getIn(['group_categories', 'items']),
isPro: state.getIn(['accounts', me, 'is_pro']),
} }
} }
@ -405,9 +383,6 @@ const mapDispatchToProps = (dispatch) => ({
onFetchGroupCategories() { onFetchGroupCategories() {
dispatch(fetchGroupCategories()) dispatch(fetchGroupCategories())
}, },
onOpenProUpgradeModal() {
dispatch(openModal(MODAL_PRO_UPGRADE))
},
}) })
GroupCreate.propTypes = { GroupCreate.propTypes = {
@ -429,7 +404,6 @@ GroupCreate.propTypes = {
onResetEditor: PropTypes.func.isRequired, onResetEditor: PropTypes.func.isRequired,
onSetGroup: PropTypes.func.isRequired, onSetGroup: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired,
onOpenProUpgradeModal: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool, isSubmitting: PropTypes.bool,
isAdmin: PropTypes.bool, isAdmin: PropTypes.bool,
onClose: PropTypes.func, onClose: PropTypes.func,

View File

@ -8,8 +8,6 @@ import Text from '../components/text'
import DefaultLayout from '../layouts/default_layout' import DefaultLayout from '../layouts/default_layout'
import GroupsCollection from '../features/groups_collection' import GroupsCollection from '../features/groups_collection'
import WrappedBundle from '../features/ui/util/wrapped_bundle' import WrappedBundle from '../features/ui/util/wrapped_bundle'
import { openModal } from '../actions/modal'
import { MODAL_PRO_UPGRADE } from '../constants'
import { import {
GroupsPanel, GroupsPanel,
LinkFooter, LinkFooter,
@ -17,16 +15,11 @@ import {
class GroupsPage extends React.PureComponent { class GroupsPage extends React.PureComponent {
handleOpenProUpgradeModal = () => {
this.props.dispatch(openModal(MODAL_PRO_UPGRADE))
}
render() { render() {
const { const {
activeTab, activeTab,
intl, intl,
children, children,
isPro,
} = this.props } = this.props
const dontShowChildren = (activeTab === 'timeline' && !me) const dontShowChildren = (activeTab === 'timeline' && !me)
@ -52,14 +45,11 @@ class GroupsPage extends React.PureComponent {
title: intl.formatMessage(messages.categories), title: intl.formatMessage(messages.categories),
to: '/groups/browse/categories', to: '/groups/browse/categories',
}, },
] : [] {
if (isPro) {
tabs.push({
title: intl.formatMessage(messages.admin), title: intl.formatMessage(messages.admin),
to: '/groups/browse/admin', to: '/groups/browse/admin',
}) },
} ] : []
const title = intl.formatMessage(messages.groups) const title = intl.formatMessage(messages.groups)
@ -76,8 +66,7 @@ class GroupsPage extends React.PureComponent {
{ {
attrTitle: 'Create', attrTitle: 'Create',
icon: 'add', icon: 'add',
to: isPro ? '/groups/create' : undefined, to: '/groups/create',
onClick: isPro ? undefined : this.handleOpenProUpgradeModal,
}, },
{ {
icon: 'search', icon: 'search',
@ -114,15 +103,10 @@ const messages = defineMessages({
admin: { id: 'admin', defaultMessage: 'Admin' }, admin: { id: 'admin', defaultMessage: 'Admin' },
}) })
const mapStateToProps = (state) => ({
isPro: state.getIn(['accounts', me, 'is_pro']),
})
GroupsPage.propTypes = { GroupsPage.propTypes = {
activeTab: PropTypes.string.isRequired, activeTab: PropTypes.string.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
isPro: PropTypes.bool,
} }
export default injectIntl(connect(mapStateToProps)(GroupsPage)) export default injectIntl(connect()(GroupsPage))