Merge branch 'group-widgets' into 'develop'
Add MyGroupsPanel, improve layout on various group pages See merge request soapbox-pub/soapbox!2374
This commit is contained in:
commit
71c7c4adc7
4 changed files with 63 additions and 3 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Widget } from 'soapbox/components/ui';
|
||||||
|
import GroupListItem from 'soapbox/features/groups/components/discover/group-list-item';
|
||||||
|
import PlaceholderGroupSearch from 'soapbox/features/placeholder/components/placeholder-group-search';
|
||||||
|
import { useGroups } from 'soapbox/hooks';
|
||||||
|
|
||||||
|
const MyGroupsPanel = () => {
|
||||||
|
const { groups, isFetching, isFetched, isError } = useGroups();
|
||||||
|
const isEmpty = (isFetched && groups.length === 0) || isError;
|
||||||
|
|
||||||
|
if (isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Widget
|
||||||
|
title='My Groups'
|
||||||
|
>
|
||||||
|
{isFetching ? (
|
||||||
|
new Array(3).fill(0).map((_, idx) => (
|
||||||
|
<PlaceholderGroupSearch key={idx} />
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
groups.slice(0, 3).map((group) => (
|
||||||
|
<GroupListItem group={group} withJoinAction={false} key={group.id} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MyGroupsPanel;
|
|
@ -590,6 +590,10 @@ export function NewGroupPanel() {
|
||||||
return import(/* webpackChunkName: "features/groups" */'../components/panels/new-group-panel');
|
return import(/* webpackChunkName: "features/groups" */'../components/panels/new-group-panel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function MyGroupsPanel() {
|
||||||
|
return import(/* webpackChunkName: "features/groups" */'../components/panels/my-groups-panel');
|
||||||
|
}
|
||||||
|
|
||||||
export function SuggestedGroupsPanel() {
|
export function SuggestedGroupsPanel() {
|
||||||
return import(/* webpackChunkName: "features/groups" */'../components/panels/suggested-groups-panel');
|
return import(/* webpackChunkName: "features/groups" */'../components/panels/suggested-groups-panel');
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
CtaBanner,
|
CtaBanner,
|
||||||
GroupMediaPanel,
|
GroupMediaPanel,
|
||||||
SignUpPanel,
|
SignUpPanel,
|
||||||
|
SuggestedGroupsPanel,
|
||||||
} from 'soapbox/features/ui/util/async-components';
|
} from 'soapbox/features/ui/util/async-components';
|
||||||
import { useGroup, useOwnAccount } from 'soapbox/hooks';
|
import { useGroup, useOwnAccount } from 'soapbox/hooks';
|
||||||
import { Group } from 'soapbox/schemas';
|
import { Group } from 'soapbox/schemas';
|
||||||
|
@ -127,6 +128,9 @@ const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
|
||||||
<BundleContainer fetchComponent={GroupMediaPanel}>
|
<BundleContainer fetchComponent={GroupMediaPanel}>
|
||||||
{Component => <Component group={group} />}
|
{Component => <Component group={group} />}
|
||||||
</BundleContainer>
|
</BundleContainer>
|
||||||
|
<BundleContainer fetchComponent={SuggestedGroupsPanel}>
|
||||||
|
{Component => <Component />}
|
||||||
|
</BundleContainer>
|
||||||
<LinkFooter key='link-footer' />
|
<LinkFooter key='link-footer' />
|
||||||
</Layout.Aside>
|
</Layout.Aside>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Route, Routes } from 'react-router-dom-v5-compat';
|
||||||
|
|
||||||
import { Column, Layout } from 'soapbox/components/ui';
|
import { Column, Layout } from 'soapbox/components/ui';
|
||||||
import LinkFooter from 'soapbox/features/ui/components/link-footer';
|
import LinkFooter from 'soapbox/features/ui/components/link-footer';
|
||||||
import BundleContainer from 'soapbox/features/ui/containers/bundle-container';
|
import BundleContainer from 'soapbox/features/ui/containers/bundle-container';
|
||||||
import { NewGroupPanel } from 'soapbox/features/ui/util/async-components';
|
import { MyGroupsPanel, NewGroupPanel, SuggestedGroupsPanel } from 'soapbox/features/ui/util/async-components';
|
||||||
|
|
||||||
interface IGroupsPage {
|
interface IGroupsPage {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
|
@ -22,10 +23,28 @@ const GroupsPage: React.FC<IGroupsPage> = ({ children }) => (
|
||||||
|
|
||||||
<Layout.Aside>
|
<Layout.Aside>
|
||||||
<BundleContainer fetchComponent={NewGroupPanel}>
|
<BundleContainer fetchComponent={NewGroupPanel}>
|
||||||
{Component => <Component key='new-group-panel' />}
|
{Component => <Component />}
|
||||||
</BundleContainer>
|
</BundleContainer>
|
||||||
|
<Routes>
|
||||||
|
<Route
|
||||||
|
path='/groups'
|
||||||
|
element={(
|
||||||
|
<BundleContainer fetchComponent={SuggestedGroupsPanel}>
|
||||||
|
{Component => <Component />}
|
||||||
|
</BundleContainer>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path='/groups/discover'
|
||||||
|
element={(
|
||||||
|
<BundleContainer fetchComponent={MyGroupsPanel}>
|
||||||
|
{Component => <Component />}
|
||||||
|
</BundleContainer>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Routes>
|
||||||
|
|
||||||
<LinkFooter key='link-footer' />
|
<LinkFooter />
|
||||||
</Layout.Aside>
|
</Layout.Aside>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue