Added restriction to group policy. Create link hidden for non-pro.
This commit is contained in:
parent
8c837a0c36
commit
3fa8eb1bac
|
@ -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';
|
||||||
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({
|
||||||
|
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create?
|
||||||
|
admin? or current_account.is_pro
|
||||||
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
if admin?
|
if admin?
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in New Issue