Commit bc20f0e1 authored by Rob Colbert's avatar Rob Colbert

Merge branch 'feature/restrict-group-creation-to-pros' into 'develop'

Added restriction to group policy. Create link hidden for non-pro.

See merge request gab/social/gab-social!29
parents 8c837a0c 3fa8eb1b
...@@ -33,6 +33,8 @@ class Api::V1::GroupsController < Api::BaseController ...@@ -33,6 +33,8 @@ class Api::V1::GroupsController < Api::BaseController
end end
def create def create
authorize :group, :create?
@group = Group.create!(group_params.merge(account: current_account)) @group = Group.create!(group_params.merge(account: current_account))
render json: @group, serializer: REST::GroupSerializer render json: @group, serializer: REST::GroupSerializer
end end
......
...@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom'; ...@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom';
import classNames from 'classnames'; import classNames from 'classnames';
import GroupCard from './card'; import GroupCard from './card';
import GroupCreate from '../create'; import GroupCreate from '../create';
import { me } from 'gabsocial/initial_state';
const messages = defineMessages({ const messages = defineMessages({
heading: { id: 'column.groups', defaultMessage: 'Groups' }, heading: { id: 'column.groups', defaultMessage: 'Groups' },
...@@ -20,6 +21,7 @@ const messages = defineMessages({ ...@@ -20,6 +21,7 @@ const messages = defineMessages({
const mapStateToProps = (state, { activeTab }) => ({ const mapStateToProps = (state, { activeTab }) => ({
groupIds: state.getIn(['group_lists', activeTab]), groupIds: state.getIn(['group_lists', activeTab]),
account: state.getIn(['accounts', me]),
}); });
export default @connect(mapStateToProps) export default @connect(mapStateToProps)
...@@ -46,11 +48,11 @@ class Groups extends ImmutablePureComponent { ...@@ -46,11 +48,11 @@ class Groups extends ImmutablePureComponent {
} }
renderHeader() { renderHeader() {
const { intl, activeTab } = this.props; const { intl, activeTab, account } = this.props;
return ( return (
<div className="group-column-header"> <div className="group-column-header">
<div className="group-column-header__cta"><Link to="/groups/create" className="button standard-small">{intl.formatMessage(messages.create)}</Link></div> {account && account.get('is_pro') && <div className="group-column-header__cta"><Link to="/groups/create" className="button standard-small">{intl.formatMessage(messages.create)}</Link></div>}
<div className="group-column-header__title">{intl.formatMessage(messages.heading)}</div> <div className="group-column-header__title">{intl.formatMessage(messages.heading)}</div>
<div className="column-header__wrapper"> <div className="column-header__wrapper">
......
...@@ -5,6 +5,10 @@ class GroupPolicy < ApplicationPolicy ...@@ -5,6 +5,10 @@ class GroupPolicy < ApplicationPolicy
true true
end end
def create?
admin? or current_account.is_pro
end
def update? def update?
if admin? if admin?
true true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment