Skip to content

Commit

Permalink
Merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeissn committed Oct 20, 2017
2 parents d28cece + 0430c54 commit e1f4b0b
Show file tree
Hide file tree
Showing 30 changed files with 203 additions and 480 deletions.
3 changes: 2 additions & 1 deletion actions/contentdiscussion/addComment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UserProfileStore from '../../stores/UserProfileStore';
import serviceUnavailable from '../error/serviceUnavailable';
import addActivity from '../activityfeed/addActivity';
const log = require('../log/clog');
Expand All @@ -16,7 +17,7 @@ export default function addComment(context, payload, done) {
const comment = res.comment;
let activity = {
activity_type: 'comment',
user_id: comment.user_id,
user_id: String(context.getStore(UserProfileStore).userid),
content_id: comment.content_id,
content_kind: comment.content_kind,
comment_info: {
Expand Down
3 changes: 2 additions & 1 deletion actions/contentdiscussion/addReply.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UserProfileStore from '../../stores/UserProfileStore';
import serviceUnavailable from '../error/serviceUnavailable';
import addActivity from '../activityfeed/addActivity';
const log = require('../log/clog');
Expand All @@ -15,7 +16,7 @@ export default function addReply(context, payload, done) {
const comment = res.comment;
let activity = {
activity_type: 'reply',
user_id: comment.user_id,
user_id: String(context.getStore(UserProfileStore).userid),
content_id: comment.content_id,
content_kind: comment.content_kind,
comment_info: {
Expand Down
3 changes: 2 additions & 1 deletion actions/decktree/addTreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export default function addTreeNode(context, payload, done) {
//context.dispatch('ADD_TREE_NODE_FAILURE', err);
} else {
context.dispatch('ADD_TREE_NODE_SUCCESS', res);
let activityType = (payload.attach) ? 'attach' : 'add';
let activity = {
activity_type: 'add',
activity_type: activityType,
user_id: String(userid),
content_owner_id: String(context.getStore(UserProfileStore).userid),
content_name: res.node.title,
Expand Down
5 changes: 3 additions & 2 deletions actions/decktree/addTreeNodeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export default function addTreeNodeList(context, payload, done) {
context.executeAction(serviceUnavailable, payload, done);
} else {
context.dispatch('ADD_TREE_NODELIST_SUCCESS', res);
let activityType = (payload.attach) ? 'attach' : 'add';
if(Array.isArray(res.node)){ //More than one slide/deck was added
let activities = res.node.map((node) => {
return {
activity_type: 'add',
activity_type: activityType,
user_id: String(context.getStore(UserProfileStore).userid),
content_id: String(node.id),
content_kind: node.type
Expand All @@ -29,7 +30,7 @@ export default function addTreeNodeList(context, payload, done) {
context.executeAction(addActivities, {activities: activities});
} else { //Only a slide/deck was added
let activity = {
activity_type: 'add',
activity_type: activityType,
user_id: String(userid),
content_id: String(res.node.id),
content_kind: res.node.type
Expand Down
2 changes: 1 addition & 1 deletion actions/decktree/deleteTreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function deleteTreeNode(context, payload, done) {
//Create a 'delete' activity
let activity = {
activity_type: 'delete',
user_id: String(userid),
user_id: String(context.getStore(UserProfileStore).userid),
content_id: payload.parentId,
content_kind: 'deck',
content_name: payload.parentName,
Expand Down
7 changes: 7 additions & 0 deletions actions/decktree/focusTreeNode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const log = require('../log/clog');

export default function focusTreeNode(context, payload, done) {
log.info(context);
context.dispatch('FOCUS_TREE_NODE', payload);
done();
}
7 changes: 4 additions & 3 deletions actions/decktree/forkDeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ export default function forkDeck(context, payload, done) {
url: newURL
});

userid = String(context.getStore(UserProfileStore).userid);
//create a fork activity for the origin deck
let activity1 = {
activity_type: 'fork',
user_id: String(userid),
user_id: userid,
content_id: selector.id,
content_kind: 'deck',
fork_info: {
Expand All @@ -69,9 +70,9 @@ export default function forkDeck(context, payload, done) {
//create an add activity for the new deck
let activity2 = {
activity_type: 'add',
user_id: String(userid),
user_id: userid,
content_id: newId,
content_owner_id: String(userid),
content_owner_id: userid,
content_kind: 'deck'
};
context.executeAction(addActivity, {activity: activity2});
Expand Down
2 changes: 1 addition & 1 deletion actions/decktree/saveTreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function saveTreeNode(context, payload, done) {
//create new activity
let activity = {
activity_type: 'edit',
user_id: String(userid),
user_id:String(context.getStore(UserProfileStore).userid),
content_id: String(newSid),
content_kind: payload.selector.stype
};
Expand Down
7 changes: 0 additions & 7 deletions actions/socialshare/mailShareShowWrongFields.js

This file was deleted.

2 changes: 0 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import AttachSubdeckModalStore from './stores/AttachSubdeckModalStore';
import ServiceErrorStore from './stores/ServiceErrorStore';
import PermissionsStore from './stores/PermissionsStore';
import ContentLikeStore from './stores/ContentLikeStore';
import SocialShareStore from './stores/SocialShareStore';
import DeckFamilyStore from './stores/DeckFamilyStore';
import UserReviewStore from './stores/UserReviewStore';

Expand Down Expand Up @@ -92,7 +91,6 @@ const app = new Fluxible({
ServiceErrorStore,
PermissionsStore,
ContentLikeStore,
SocialShareStore,
DeckFamilyStore,
UserReviewStore
]
Expand Down
24 changes: 14 additions & 10 deletions components/Deck/ActivityFeedPanel/ActivityItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ActivityItem extends React.Component {
const viewPath = ((node.content_kind === 'slide') ? '/deck/' + this.props.selector.id + '/slide/' : '/deck/') + node.content_id;
const nodeRef = (node.content_kind === this.props.selector.stype && node.content_id.split('-')[0] === this.props.selector.sid.split('-')[0]) ? (<span>{'this ' + node.content_kind}</span>) : (<span>{node.content_kind + ' '}<a href={this.getPath(node)} onClick={this.handleRefClick.bind(this)}>{cheerioContentName}</a></span>);

if (node.user_id === '0') {
if (node.user_id === '0'|| node.user_id === 'undefined') {
node.user_id = undefined;
}
switch (node.activity_type) {
Expand Down Expand Up @@ -142,7 +142,7 @@ class ActivityItem extends React.Component {
);
break;
case 'use':
IconNode = (<i className="ui large attach icon"></i>);
IconNode = (<i className="ui large repeat icon"></i>);
const title = (node.use_info.target_name !== '') ? node.use_info.target_name : node.use_info.target_id;
SummaryNode = (
<div className="summary">
Expand All @@ -155,6 +155,18 @@ class ActivityItem extends React.Component {
</div>
);
break;
case 'attach':
IconNode = (<i className="ui large attach icon"></i>);
SummaryNode = (
<div className="summary">
<a className="user" href={node.user_id ? '/user/' + node.user_id : ''} target="_blank">
{node.author ? node.author.username : 'unknown'}
</a> {'attached '} {nodeRef}
<br/>
{DateDiv}
</div>
);
break;
case 'rate'://TODO modify rate display
IconNode = (<i className="ui large empty star icon"></i>);
SummaryNode = (
Expand Down Expand Up @@ -229,14 +241,6 @@ class ActivityItem extends React.Component {
</div>
);
}
// TODO: Unused (no likes for activities), therefore MetaNode should be removed probably, otherwise it should go below the SummaryNode
const MetaNode = (
<div className="meta">
<a className="like" onClick={this.handleLike.bind(this)}>
<i className="like icon"></i> {node.likesNo} Likes
</a>
</div>
);

return (
<div className="ui feed">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AttachSubdeckModal extends React.Component{
id:slideId
};
});
this.context.executeAction(addTreeNodeListAndNavigate, {selector: this.props.selector, nodeSpec:nodeSpec});
this.context.executeAction(addTreeNodeListAndNavigate, {selector: this.props.selector, nodeSpec:nodeSpec, attach: true});

//find target deck id
let targetDeckId = this.props.selector.sid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class AttachSubdeckModal extends React.Component{
handleAttachButton() {
//selector: Object {id: "56", stype: "deck", sid: 67, spath: "67:2"}
//nodeSec: Object {type: "deck", id: 1245-2}
this.context.executeAction(addTreeNodeAndNavigate, {selector: this.props.selector, nodeSpec: {type:'deck',id:this.state.selectedDeckId}});
this.context.executeAction(addTreeNodeAndNavigate, {selector: this.props.selector, nodeSpec: {type:'deck',id:this.state.selectedDeckId}, attach: true});

//find target deck id
let targetDeckId = this.props.selector.sid;
Expand Down
75 changes: 27 additions & 48 deletions components/Deck/TreePanel/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TreeUtil from './util/TreeUtil';
import TreeNodeList from './TreeNodeList';

class Tree extends React.Component {

getKeyMap() {
const keyMap = {
'moveUp': 'up',
Expand All @@ -19,8 +20,8 @@ class Tree extends React.Component {

getKeyMapHandlers() {
const handlers = {
'moveUp': (event) => this.handleUpKey(this.props.prevSelector, this.props.page, this.props.mode),
'moveDown': (event) => this.handleDownKey(this.props.nextSelector, this.props.page, this.props.mode),
'moveUp': (event) => this.handleUpKey(),
'moveDown': (event) => this.handleDownKey(),
'fastForward': (event) => this.handleForwardClick(),
'fastBackward': (event) => this.handleBackwardClick(),
'expandOrMenu': (event) => this.handleRightKey(),
Expand All @@ -30,7 +31,7 @@ class Tree extends React.Component {
}

handleRightKey() {
let node = TreeUtil.getImmNodeFromPath(this.props.deckTree, this.props.selector.get('spath'));
let node = TreeUtil.getImmNodeFromPath(this.props.deckTree, this.props.focusedSelector.get('spath'));
if (node.get('editable') || this.props.username=== '') {
//disable handler when editing node or when user is not loggedIn
return true;
Expand All @@ -39,32 +40,32 @@ class Tree extends React.Component {
if (!node.get('expanded')) {
this.props.onToggleNode({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
} else {
this.props.onSwitchOnAction({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
}
} else {
this.props.onSwitchOnAction({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
}
return false;
}
}

handleLeftKey() {
let node = TreeUtil.getImmNodeFromPath(this.props.deckTree, this.props.selector.get('spath'));
let node = TreeUtil.getImmNodeFromPath(this.props.deckTree, this.props.focusedSelector.get('spath'));
if (node.get('editable') || this.props.username=== '') {
//disable handler when editing node or when user is not loggedIn
return true;
Expand All @@ -73,27 +74,27 @@ class Tree extends React.Component {
if (node.get('onAction')) {
this.props.onSwitchOnAction({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
} else {
if (node.get('expanded')) {
this.props.onToggleNode({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
}
}
} else {
if (node.get('onAction')) {
this.props.onSwitchOnAction({
id: this.props.rootNode.id,
stype: this.props.selector.get('stype'),
sid: this.props.selector.get('sid'),
spath: this.props.selector.get('spath')
stype: this.props.focusedSelector.get('stype'),
sid: this.props.focusedSelector.get('sid'),
spath: this.props.focusedSelector.get('spath')
});
}
}
Expand Down Expand Up @@ -137,36 +138,14 @@ class Tree extends React.Component {
return false;
}

handleUpKey(prevSelector, page, mode) {
let selector = {
id: prevSelector.get('id'),
stype: prevSelector.get('stype'),
sid: prevSelector.get('sid'),
spath: prevSelector.get('spath')
};
let prevPath = TreeUtil.makeNodeURL(selector, page, mode);
if (prevPath) {
this.context.executeAction(navigateAction, {
url: prevPath
});
}
handleUpKey() {
this.props.onFocusNode(this.props.prevSelector.toJS());
//returning false stops the event and prevents default browser events
return false;
}

handleDownKey(nextSelector, page, mode) {
let selector = {
id: nextSelector.get('id'),
stype: nextSelector.get('stype'),
sid: nextSelector.get('sid'),
spath: nextSelector.get('spath')
};
let nextPath = TreeUtil.makeNodeURL(selector, page, mode);
if (nextPath) {
this.context.executeAction(navigateAction, {
url: nextPath
});
}
handleDownKey() {
this.props.onFocusNode(this.props.nextSelector.toJS());
//returning false stops the event and prevents default browser events
return false;
}
Expand Down
Loading

0 comments on commit e1f4b0b

Please sign in to comment.