Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show a message for empty feeds #213

Merged
merged 8 commits into from Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/feed/Page.js
Expand Up @@ -22,6 +22,7 @@ import { toggleBookmark } from '../bookmarks/bookmarksActions';
import Loading from '../widgets/Loading';
import FavoriteCategoryButton from '../favorites/FavoriteCategoryButton';
import * as favoriteActions from '../favorites/favoritesActions';
import EmptyFeed from '../statics/EmptyFeed';

@PageHOC
@connect(
Expand Down Expand Up @@ -111,6 +112,10 @@ export default class Page extends React.Component {
route={this.props.route}
/>
}

{ (content.length === 0 && !isFetching) &&
<EmptyFeed />
}
</div>
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/statics/EmptyFeed.js
@@ -0,0 +1,15 @@
import React from 'react';
import { Link } from 'react-router';
import Icon from '../widgets/Icon';

const EmptyFeed = () => (
<div className="ptl text-xs-center">
<Icon name="info" xl />
<h1>Empty Feed</h1>
<p>
This feed is still empty, please try another feed from the menu or <Link to="/">home page</Link>
</p>
</div>
);

export default EmptyFeed;
15 changes: 15 additions & 0 deletions src/statics/EmptyUserOwnProfile.js
@@ -0,0 +1,15 @@
import React from 'react';
import { Link } from 'react-router';
import Icon from '../widgets/Icon';

const EmptyUserProfile = () => (
<div className="ptl text-xs-center">
<Icon name="info" xl />
<h1>Your Profile is Empty!</h1>
<p>
You didn't publish any stories yet. <Link to="/write">Start now</Link>
</p>
</div>
);

export default EmptyUserProfile;
14 changes: 14 additions & 0 deletions src/statics/EmptyUserProfile.js
@@ -0,0 +1,14 @@
import React from 'react';
import Icon from '../widgets/Icon';

const EmptyUserProfile = () => (
<div className="ptl text-xs-center">
<Icon name="info" xl />
<h1>User Profile is Empty</h1>
<p>
This user doesn't have any story published yet!
</p>
</div>
);

export default EmptyUserProfile;
23 changes: 15 additions & 8 deletions src/user/UserFeed.js
Expand Up @@ -5,6 +5,7 @@ import {
getFeedLoadingFromState,
getFeedHasMoreFromState
} from '../helpers/stateHelpers';
import EmptyFeed from '../statics/EmptyFeed';

export default class UserProfileFeed extends Component {
constructor(props) {
Expand All @@ -30,14 +31,20 @@ export default class UserProfileFeed extends Component {
});

return (
<Feed
content={content}
isFetching={isFetching}
hasMore={hasMore}
loadContent={loadContentAction}
loadMoreContent={loadMoreContentAction}
route={this.props.route}
/>
<div>
<Feed
content={content}
isFetching={isFetching}
hasMore={hasMore}
loadContent={loadContentAction}
loadMoreContent={loadMoreContentAction}
route={this.props.route}
/>

{ (content.length === 0 && !isFetching) &&
<EmptyFeed />
}
</div>
);
}
}
16 changes: 11 additions & 5 deletions src/user/UserProfile.js
Expand Up @@ -22,6 +22,8 @@ import Avatar from '../widgets/Avatar';
import Badge from '../widgets/Badge';
import Donor from '../widgets/Donor';
import donors from '../helpers/donors';
import EmptyUserProfile from '../statics/EmptyUserProfile';
import EmptyUserOwnProfile from '../statics/EmptyUserOwnProfile';

class Profile extends Component {
constructor(props) {
Expand Down Expand Up @@ -79,12 +81,9 @@ class Profile extends Component {
}

render() {
const { feed, posts, getFeedContent, getMoreFeedContent, limit } = this.props;
const { feed, posts, getFeedContent, getMoreFeedContent, limit, auth } = this.props;
const username = this.props.params.name;
const edit = (
this.props.auth.isAuthenticated
&& username === this.props.auth.user.name
);
const isOwnProfile = auth.isAuthenticated && username === auth.user.name;

const content = getFeedContentFromState('blog', username, feed, posts);
const isFetching = getFeedLoadingFromState('blog', username, feed);
Expand Down Expand Up @@ -204,6 +203,13 @@ class Profile extends Component {
loadMoreContent={loadMoreContentAction}
route={this.props.route}
/>

{ (content.length === 0 && !isFetching) &&
isOwnProfile ?
<EmptyUserOwnProfile />
:
<EmptyUserProfile />
}
</div>
</div>
);
Expand Down