diff options
author | Dessalines <happydooby@gmail.com> | 2019-05-08 09:07:34 -0700 |
---|---|---|
committer | Dessalines <happydooby@gmail.com> | 2019-05-08 09:07:34 -0700 |
commit | a96eb1ddc21a2199b510eb207a11d81960859603 (patch) | |
tree | 1545acb6d5371ea67e60438dccf1fc00459acd98 /ui | |
parent | 8f4ad8eb292ae74fcac50aa7830b8d5eae281703 (diff) |
Adding create community and post buttons from sidebar.
- Fixes #148
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/create-post.tsx | 4 | ||||
-rw-r--r-- | ui/src/components/main.tsx | 2 | ||||
-rw-r--r-- | ui/src/components/sidebar.tsx | 6 | ||||
-rw-r--r-- | ui/src/index.tsx | 1 |
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} /> |