Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
remove icon to add post if not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
KrNel committed Feb 13, 2019
1 parent 423dc13 commit 72b90e4
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 86 deletions.
5 changes: 5 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ hr {
clear:both;
}

.disabled {
pointer-events:none;
opacity:0.6;
}

/*#wrapper {
width:922px;
margin: 0 auto;
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Modal/ModalGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ModalGroup extends Component {
<Dimmer inverted active={addPostLoading}><Loader /></Dimmer>
}
<Modal.Header>
{'Add to Group'}
{'Add to Community Group'}
</Modal.Header>
<Modal.Content>
<div>
Expand All @@ -65,6 +65,7 @@ class ModalGroup extends Component {
options={groups}
label=''
addErrorPost={addErrorPost}
type='community'
/>
</Form.Group>
</Form>
Expand Down
51 changes: 35 additions & 16 deletions client/src/components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,41 @@ import { Form, Select, Label } from "semantic-ui-react";
* @param {function} props.onChange Function to set state when choice is made
* @returns {Component} Displays a dropdown menu to choose a user role.
*/
const Picker = ({ options, onChange, onClick, addErrorPost, label = '' }) => (
<React.Fragment>
{
(label) ? <Label size='large' color='blue'>{label}</Label> : ''
}
<Form.Field
control={Select}
placeholder='Select group'
options={options}
onChange={onChange}
onClick={onClick}
/>
{addErrorPost}
{/*defaultValue={options[0].value}*/}
</React.Fragment>
)
const Picker = ({ options, onChange, onClick, addErrorPost, label, type }) => {
let controlContent;
if (type) {
controlContent =
(
<Form.Field
control={Select}
placeholder={`Select ${type}`}
options={options}
onChange={onChange}
onClick={onClick}
/>
);
}else {
controlContent =
(
<Form.Field
control={Select}
defaultValue={options[0].value}
options={options}
onChange={onChange}
onClick={onClick}
/>
);
}
return (
<React.Fragment>
{
(label) ? <Label size='large' color='blue'>{label}</Label> : ''
}
{controlContent}
{addErrorPost}
</React.Fragment>
)
}

Picker.propTypes = {
options: PropTypes.arrayOf(PropTypes.object.isRequired).isRequired,
Expand Down
1 change: 1 addition & 0 deletions client/src/components/pages/Kurate/Kurate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

90 changes: 64 additions & 26 deletions client/src/components/pages/Kurate/Kurate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Client } from 'dsteem';
import { Button } from "semantic-ui-react";
import { Form, Button } from "semantic-ui-react";

import PostsSummary from './PostsSummary';
import PostDetails from './PostDetails';
import { getUserGroups, addPost } from '../Manage/fetchFunctions';
import ModalGroup from '../../Modal/ModalGroup';
import ErrorLabel from '../../ErrorLabel/ErrorLabel';
import Picker from '../../Picker/Picker';

const client = new Client('https://hive.anyx.io/');

Expand All @@ -17,6 +19,11 @@ const client = new Client('https://hive.anyx.io/');
* to which the user belongs.
*/
class Kurate extends Component {

static propTypes = {
user: PropTypes.string.isRequired,
};

constructor(props) {
super(props);
this.state = {
Expand All @@ -31,16 +38,19 @@ class Kurate extends Component {
newPost: '',
postExists: false,
addPostLoading: false,
tag: '',
selectedFilter: 'created',
}
this.existPost = "Post already in group.";
this.steemPostData = '';
}

componentDidMount() {
this.getPosts();
const {user} = this.props;
//this.getGroupsFetch(user);
this.getGroupsFetch('krnel');
this.getGroupsFetch(user);
}

/*shouldComponentUpdate(np, ns) {
const {posts} = this.state;
//if (ns.selectedGroup !== this.state.selectedGroup) return false;
Expand Down Expand Up @@ -230,31 +240,30 @@ class Kurate extends Component {
this.setState({postsListShow: 'block'})
}

/*openPost = (author, permlink) => {
client.database.call('get_content', [author, permlink]).then(result => {
this.setState({
post: result
});
this.onPostOpen();
});
}
onPostOpen = () => {
/**
* Set state values for when tag input text changes.
*
* @param {event} e Event triggered by element to handle
* @param {string} name Name of the element triggering the event
* @param {string} value Value of the element triggering the event
*/
handleChange = (e, { name, value }) => {
this.setState({
postsListShow: 'none',
postShow: 'block',
})
[name]: value,
});
}

onPostClose = () => {
/**
* Set state values for when filter option changes.
*
* @param {event} e Event triggered by element to handle
* @param {string} value Value of the role selected
*/
handleFilterSelect = (e, {value}) => {
this.setState({
postsListShow: 'block',
postShow: 'none',
post: {}
})
}*/


selectedFilter: value
});
}

render() {
const {
Expand All @@ -268,15 +277,27 @@ class Kurate extends Component {
groups,
postExists,
addPostLoading,
tag,
selectedFilter,
},
props: {
user
}
} = this;
let addErrorPost = '';

if (postExists) addErrorPost = <ErrorLabel position='left' text={this.existPost} />;

const filters = [
{key: 0, value: 'created', text: 'New'},
{key: 1, value: 'hot', text: 'Hot'},
{key: 2, value: 'promoted', text: 'Promoted'},
{key: 3, value: 'trending', text: 'Trending'}
];

return (
<React.Fragment>
<div>
<div className='controlContent'>
<ModalGroup
modalOpen={modalOpen}
onModalClose={this.onModalClose}
Expand All @@ -287,7 +308,23 @@ class Kurate extends Component {
addErrorPost={addErrorPost}
addPostLoading={addPostLoading}
/>
<Button id='init' color='blue' onClick={() => this.getPosts('init')}>Refresh Posts</Button>

<Form>
<Form.Group>
<Button id='init' color='blue' onClick={() => this.getPosts('init')}>Refresh Posts</Button>
<Picker
onChange={this.handleFilterSelect}
options={filters}
label=''
/>
<Form.Input
placeholder='Search a tag'
name='tag'
value={tag}
onChange={this.handleChange}
/>
</Form.Group>
</Form>
</div>
<hr />
<div>
Expand All @@ -298,6 +335,7 @@ class Kurate extends Component {
nextPost={nextPost}
showModal={this.showModal}
handleGroupSelect={this.handleGroupSelect}
user={user}
/>
</div>

Expand Down
41 changes: 13 additions & 28 deletions client/src/components/pages/Kurate/PostActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import React from 'react';
import './PostActions.css';
import { Icon } from "semantic-ui-react";

const like = (e) => {
e.preventDefault();
}

const vote = (e) => {
e.preventDefault();
}
Expand All @@ -18,10 +14,6 @@ const resteem = (e) => {
e.preventDefault();
}

const dislike = (e) => {
e.preventDefault();
}

const flag = (e) => {
e.preventDefault();
}
Expand All @@ -39,22 +31,14 @@ const flag = (e) => {
* @param {string} title Post's title
* @param {function} showModal Parent function to show the add post modal
*/
const PostActions = ({activeVotesCount, commentCount, author, category, permlink, title, showModal}) => (
const PostActions = ({activeVotesCount, commentCount, author, category, permlink, title, showModal, user}) => (
<div>
<ul className="meta">
<ul className="meta disabled">
<li className="item">
<a href="/like" onClick={(e) => like(e)} title='Like this post on KURE'>
<Icon name='thumbs up outline' size='large' />
</a>
<strong>
{'0'}
</strong>
</li>
<li className="item">
<a href="/vote" onClick={(e) => vote(e)} title={`${activeVotesCount.length} upvotes on Steem`}>
<a href="/vote" onClick={(e) => vote(e)} title={`${activeVotesCount} upvotes on Steem`}>
<Icon name='chevron up' size='large' />
</a>
<strong>{activeVotesCount.length}</strong>
<strong>{activeVotesCount}</strong>
</li>
<li className="item">
<a href="/comment" onClick={(e) => comment(e)} title={`${commentCount} comments`}>
Expand All @@ -67,21 +51,22 @@ const PostActions = ({activeVotesCount, commentCount, author, category, permlink
<Icon name='retweet' size='large' />
</a>
</li>
<li className="item">
<a href="/dislike" onClick={(e) => dislike(e)} title="Dislike this post on KURE">
<Icon name='thumbs down outline' size='large' />
</a>
</li>
<li className="item">
<a href="/flag" onClick={(e) => flag(e)} title="Flag this post on Steem">
<Icon name='flag outline' size='large' />
</a>
</li>
</ul>
<div className='right'>
<a href="/group/add" onClick={(e) => showModal(e, {author, category, permlink, title})} title="Add to a community">
<Icon name='plus circle' size='large' />
</a>
{
(user)
? (
<a href="/group/add" onClick={(e) => showModal(e, {author, category, permlink, title})} title="Add to a community">
<Icon name='plus circle' size='large' />
</a>
)
: ''
}
</div>
</div>
)
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/pages/Kurate/PostsSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const repLog10 = rep2 => {
* @param {array} nextPost Whether to skip the first post, dupe of prev last post
* @param {function} showModal Parent function to show the add post modal
*/
const PostsSummary = ({posts, openPost, nextPost, showModal}) => {
const PostsSummary = ({posts, openPost, nextPost, showModal, user}) => {
//const postsExtracts = extractContent(posts);

//var posts = [];
Expand Down Expand Up @@ -122,6 +122,7 @@ const PostsSummary = ({posts, openPost, nextPost, showModal}) => {
permlink={permlink}
title={title}
showModal={showModal}
user={user}
/>
</div>
</div>
Expand Down
14 changes: 1 addition & 13 deletions client/src/components/pages/Manage/GroupManage.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ class GroupManage extends Component {
this.steemPostData = {};
}

/**
* Prevent updates for simply selecting a different User Access/Role
*
* @param {object} nextProps Next props before it becomes current props
* @param {object} nextState Next state before it becomes current state
*/
shouldComponentUpdate(nextProps, nextState) {
const {selectedAccess} = this.state;
if(selectedAccess !== nextState.selectedAccess) {
return false
}
return true
}

/**
* Need to populate state from props updates passed down from parents comp.
Expand Down Expand Up @@ -500,6 +487,7 @@ class GroupManage extends Component {
{key: 2, text: 'Admin', value: '1'}
]}
label='Role: '
type='role'
/>
</Form.Group>
</Form>
Expand Down
1 change: 0 additions & 1 deletion client/src/components/pages/Manage/GroupsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const GroupsList = (props) => {
{
groups.map((g, i) => {
const key = g._id || i;
console.log('g: ', g)
const date = moment(g.created).format("ddd MMM DD, YYYY");
return (
<Grid.Column key={key+1} width={4}>
Expand Down

0 comments on commit 72b90e4

Please sign in to comment.