Skip to content

Commit

Permalink
adds my links
Browse files Browse the repository at this point in the history
  • Loading branch information
walidvb committed Feb 9, 2020
1 parent f0e0502 commit 20ebb33
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
9 changes: 9 additions & 0 deletions app/controllers/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def link_form_details
}
end

def my_links
@current_page = params[:page].to_i
@page_size = 25
@links = current_user.links.page(@current_page).per(@page_size)
@pages_count = @links.total_pages
render :index
end

# GET /links
# GET /links.json
def index
Expand Down Expand Up @@ -72,6 +80,7 @@ def index
# new_c_ids = c_ids.select{|c_id| clique_ids.include?(c_id)}
@link_assignments = @link_assignments.where(clique_id: c_ids)
end

if p_ids = params[:playlists].presence
@link_assignments = PlaylistAssignment
.where(playlist_id: p_ids)
Expand Down
6 changes: 3 additions & 3 deletions client/src/actions/linkActions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as types from './actionTypes';
import { request, routes } from '../request';

export const getLinks = ({ filters, page }) => {
console.log(filters);
export const getLinks = ({ filters, page, }) => {
return {
type: types.GET_LINKS,
payload: new Promise(resolve => {
request(routes.api.links.explore, { qs: {
const url = filters.mineOnly ? routes.api.links.myLinks : routes.api.links.explore
request(url, { qs: {
...filters,
users: filters.users.map(u=>u.id),
cliques: filters.cliques.map(c => c.id),
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/DDMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import PlaylistList from './playlists/PlaylistList';
import LinkUI from './links/LinkUI';

import styles from './DDMenu.scss';
import MyLinks from './ui_components/MyLinks';
import { Link } from 'react-router-dom';

class DDMenu extends Component {
static propTypes = {
Expand All @@ -29,10 +31,11 @@ class DDMenu extends Component {
disabledTabClassName={styles.disabled}
>
<TabList className={styles.menuWrapper} style={{ borderBottom: `1px solid ${panelsOn ? '#f2f2f2' : 'transparent'}` }}>
{['explore', 'playlists', 'player'].map( menu => <Tab
key={menu}
className={styles.menuItem}
>{menu}</Tab>)}
<Link to="/me" className={styles.menuItem}>My Digs</Link>
<Tab className={styles.menuItem} ><Link style={{textDecoration: 'none'}} to='/explore'>explore</Link></Tab>
<Tab className={styles.menuItem} >playlists</Tab>
<Tab className={styles.menuItem} >player</Tab>

</TabList>
<div style={panelsStyles} className={styles.tabsWrapper}>
<TabPanel>
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/DDMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $background: $background-grey;
}
.menuItem{
padding: .5rem 1rem;
cursor: pointer;
text-decoration: none;
}
.tabsWrapper{
max-height: 360px;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/cliques/CliquesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function CliquesList(props) {
].join(' ')} key={user.id}
onClick={() => hasLinks && clickUser(user)}>
{user.name}
<span class={styles.badge}>{user.link_clique_assignments_count}</span>
<span className={styles.badge}>{user.link_clique_assignments_count}</span>
</div>
}
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/links/LinksContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LinksContainer extends Component {
resetFilters(props = this.props){
this.props.resetFilters({
users: props.displayMine ? [{id:props.user.id}] : [],
mineOnly: props.displayMine,
});
}
componentDidMount() {
Expand Down Expand Up @@ -102,7 +103,7 @@ class LinksContainer extends Component {
return <h1 className={styles.pageTitle} key="title">{name}</h1>
}
renderIsWalid(){
const total = this.props.pagination.total * this.props.pagination.page_size
const total = this.props.pagination.total * this.props.pagination.page_size
return this.props.isWalid ? <div key="isWalid" style={{flexBasis: '100%', paddingLeft: '15px'}}>
Oops! No one digged tracks to this clique yet. When this happens, we show you all {total} founder's digs.
<br />
Expand Down
7 changes: 7 additions & 0 deletions client/src/components/ui_components/MyLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const MyLinks = ({ className }) => {
return <div className={className}>My Digs</div>
}

export default MyLinks
1 change: 1 addition & 0 deletions client/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const routes = {
covers: '/api/covers',
links: {
explore: '/api/links.json',
myLinks: '/api/links/my_links.json',
filters: '/api/filters.json',
formDetails: url => `/api/link_form_details.json?url=${encodeURIComponent(url)}`,
create: '/api/links.json',
Expand Down

0 comments on commit 20ebb33

Please sign in to comment.