]> Untitled Git - lemmy.git/commitdiff
Adding create community and post buttons from sidebar.
authorDessalines <tyhou13@gmx.com>
Wed, 8 May 2019 16:07:34 +0000 (09:07 -0700)
committerDessalines <tyhou13@gmx.com>
Wed, 8 May 2019 16:07:34 +0000 (09:07 -0700)
- Fixes #148

ui/src/components/create-post.tsx
ui/src/components/main.tsx
ui/src/components/sidebar.tsx
ui/src/index.tsx

index 1958be72d2e1cb9004ab985959f9a1f92dac36e2..fdee01f66c16565ca48aac9bb341651570c252d5 100644 (file)
@@ -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];
index 1ec016ea67fae220e0915306cd488c6e9f8c8a6c..ac43b1d9f88b5f3e41b5a7bfbcc2eb20a21b8c2d 100644 (file)
@@ -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>
             }
index d14ad68cc444e47e1619e2c40247015b1d174e72..8d1459d569e55b0105f1de50e123e4c2c53cd18b 100644 (file)
@@ -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 />
index b744ac7d2963d138dd8220813b24fd7a49cc80c8..04160a9fabb98544f666e73651c435f2ece2917d 100644 (file)
@@ -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} />