From d61df6e2ae26a6ffd5105b0504960e794288a8c7 Mon Sep 17 00:00:00 2001
From: mgabdev <>
Date: Thu, 10 Sep 2020 17:15:35 -0500
Subject: [PATCH] Added GroupCategories page
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
• Added:
- GroupCategories page for selecting groups based on category
---
.../gabsocial/features/groups_categories.js | 51 +++++++++++++++++++
app/javascript/gabsocial/features/ui/ui.js | 2 +
.../features/ui/util/async_components.js | 2 +-
app/javascript/gabsocial/pages/groups_page.js | 5 ++
4 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 app/javascript/gabsocial/features/groups_categories.js
diff --git a/app/javascript/gabsocial/features/groups_categories.js b/app/javascript/gabsocial/features/groups_categories.js
new file mode 100644
index 00000000..5817ad27
--- /dev/null
+++ b/app/javascript/gabsocial/features/groups_categories.js
@@ -0,0 +1,51 @@
+import React from 'react'
+import PropTypes from 'prop-types'
+import ImmutablePropTypes from 'react-immutable-proptypes'
+import ImmutablePureComponent from 'react-immutable-pure-component'
+import { connect } from 'react-redux'
+import { fetchGroupCategories } from '../actions/group_categories'
+import slugify from '../utils/slugify'
+import Block from '../components/block'
+import BlockHeading from '../components/block_heading'
+import List from '../components/list'
+
+class GroupCategories extends ImmutablePureComponent {
+
+ componentDidMount() {
+ this.props.dispatch(fetchGroupCategories())
+ }
+
+ render() {
+ const { categories } = this.props
+
+ let categoriesOptions = []
+ if (categories) {
+ for (let i = 0; i < categories.count(); i++) {
+ const c = categories.get(i)
+ const title = c.get('text')
+ categoriesOptions.push({
+ title,
+ to: `/groups/browse/categories/${slugify(title)}`,
+ })
+ }
+ }
+
+ return (
+
+
+
+
+ )
+ }
+
+}
+
+const mapStateToProps = (state) => ({
+ categories: state.getIn(['group_categories', 'items']),
+})
+
+GroupCategories.propTypes = {
+ categories: ImmutablePropTypes.list.isRequired,
+}
+
+export default connect(mapStateToProps)(GroupCategories)
\ No newline at end of file
diff --git a/app/javascript/gabsocial/features/ui/ui.js b/app/javascript/gabsocial/features/ui/ui.js
index b7fe266a..56402eb8 100644
--- a/app/javascript/gabsocial/features/ui/ui.js
+++ b/app/javascript/gabsocial/features/ui/ui.js
@@ -68,6 +68,7 @@ import {
GroupMembers,
GroupRemovedAccounts,
GroupTimeline,
+ GroupsCategories,
HashtagTimeline,
HomeTimeline,
Investors,
@@ -191,6 +192,7 @@ class SwitchingArea extends React.PureComponent {
+
diff --git a/app/javascript/gabsocial/features/ui/util/async_components.js b/app/javascript/gabsocial/features/ui/util/async_components.js
index e67a56c0..220f2801 100644
--- a/app/javascript/gabsocial/features/ui/util/async_components.js
+++ b/app/javascript/gabsocial/features/ui/util/async_components.js
@@ -47,8 +47,8 @@ export function GroupRemovedAccounts() { return import(/* webpackChunkName: "fea
export function GroupTimeline() { return import(/* webpackChunkName: "features/group_timeline" */'../../group_timeline') }
export function GroupTimelineSortOptionsPopover() { return import(/* webpackChunkName: "components/group_timeline_sort_options_popover" */'../../../components/popover/group_timeline_sort_options_popover') }
export function GroupTimelineSortTopOptionsPopover() { return import(/* webpackChunkName: "components/group_timeline_sort_top_options_popover" */'../../../components/popover/group_timeline_sort_top_options_popover') }
-// export function GroupsCategories() { return import(/* webpackChunkName: "features/groups_categories" */'../../groups_categories.js') }
// export function GroupCategory() { return import(/* webpackChunkName: "features/group_category" */'../../group_category') }
+export function GroupsCategories() { return import(/* webpackChunkName: "features/groups_categories" */'../../groups_categories') }
export function HashtagTimeline() { return import(/* webpackChunkName: "features/hashtag_timeline" */'../../hashtag_timeline') }
export function HashtagTimelineSettingsModal() { return import(/* webpackChunkName: "components/hashtag_timeline_settings_modal" */'../../../components/modal/hashtag_timeline_settings_modal') }
export function HomeTimeline() { return import(/* webpackChunkName: "features/home_timeline" */'../../home_timeline') }
diff --git a/app/javascript/gabsocial/pages/groups_page.js b/app/javascript/gabsocial/pages/groups_page.js
index 3f3379ac..d2da2155 100644
--- a/app/javascript/gabsocial/pages/groups_page.js
+++ b/app/javascript/gabsocial/pages/groups_page.js
@@ -48,6 +48,10 @@ class GroupsPage extends React.PureComponent {
title: intl.formatMessage(messages.new),
to: '/groups/browse/new',
},
+ {
+ title: intl.formatMessage(messages.categories),
+ to: '/groups/browse/categories',
+ },
] : []
if (isPro) {
@@ -102,6 +106,7 @@ const messages = defineMessages({
featured: { id: 'featured', defaultMessage: 'Featured Groups' },
myGroupsTimeline: { id: 'my_groups_timeline', defaultMessage: 'Timeline' },
myGroups: { id: 'my_groups', defaultMessage: 'My Groups' },
+ categories: { id: 'categories', defaultMessage: 'Categories' },
admin: { id: 'admin', defaultMessage: 'Admin' },
})