summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-05-08 09:07:34 -0700
committerDessalines <tyhou13@gmx.com>2019-05-08 09:07:34 -0700
commit73a129a24d846b387357336bec7b5c8b09c5a6ba (patch)
tree993120477c3eee8269ecdd52f8f6ab121f4c24f8
parent780817840f718500063579056081cfc1526f16bb (diff)
Adding create community and post buttons from sidebar.
- Fixes #148
-rw-r--r--ui/src/components/create-post.tsx4
-rw-r--r--ui/src/components/main.tsx2
-rw-r--r--ui/src/components/sidebar.tsx6
-rw-r--r--ui/src/index.tsx1
4 files changed, 10 insertions, 3 deletions
diff --git a/ui/src/components/create-post.tsx b/ui/src/components/create-post.tsx
index 1958be72..fdee01f6 100644
--- a/ui/src/components/create-post.tsx
+++ b/ui/src/components/create-post.tsx
@@ -26,7 +26,9 @@ export class CreatePost extends Component<any, any> {
}
get prevCommunityName(): string {
- if (this.props.location.state) {
+ if (this.props.match.params.name) {
+ return this.props.match.params.name;
+ } else if (this.props.location.state) {
let lastLocation = this.props.location.state.prevPath;
if (lastLocation.includes("/c/")) {
return lastLocation.split("/c/")[1];
diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx
index 1ec016ea..ac43b1d9 100644
--- a/ui/src/components/main.tsx
+++ b/ui/src/components/main.tsx
@@ -136,6 +136,8 @@ export class Main extends Component<any, MainState> {
</ul>
</div>
}
+ <Link class="btn btn-sm btn-secondary btn-block mb-3"
+ to="/create_community">Create a Community</Link>
{this.sidebar()}
</div>
}
diff --git a/ui/src/components/sidebar.tsx b/ui/src/components/sidebar.tsx
index d14ad68c..8d1459d5 100644
--- a/ui/src/components/sidebar.tsx
+++ b/ui/src/components/sidebar.tsx
@@ -117,10 +117,12 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
</ul>
<div>
{community.subscribed
- ? <button class="btn btn-sm btn-secondary" onClick={linkEvent(community.id, this.handleUnsubscribe)}>Unsubscribe</button>
- : <button class="btn btn-sm btn-secondary" onClick={linkEvent(community.id, this.handleSubscribe)}>Subscribe</button>
+ ? <button class="btn btn-sm btn-secondary btn-block mb-3" onClick={linkEvent(community.id, this.handleUnsubscribe)}>Unsubscribe</button>
+ : <button class="btn btn-sm btn-secondary btn-block mb-3" onClick={linkEvent(community.id, this.handleSubscribe)}>Subscribe</button>
}
</div>
+ <Link class="btn btn-sm btn-secondary btn-block mb-3"
+ to={`/create_post/c/${community.name}`}>Create a Post</Link>
{community.description &&
<div>
<hr />
diff --git a/ui/src/index.tsx b/ui/src/index.tsx
index b744ac7d..04160a9f 100644
--- a/ui/src/index.tsx
+++ b/ui/src/index.tsx
@@ -41,6 +41,7 @@ class Index extends Component<any, any> {
<Route path={`/home/type/:type/sort/:sort/page/:page`} component={Main} />
<Route exact path={`/`} component={Main} />
<Route path={`/login`} component={Login} />
+ <Route path={`/create_post/c/:name`} component={CreatePost} />
<Route path={`/create_post`} component={CreatePost} />
<Route path={`/create_community`} component={CreateCommunity} />
<Route path={`/communities/page/:page`} component={Communities} />