Skip to content

Commit

Permalink
[SWIK-1524_refactor_components_made_by_Kurt] Merged from master
Browse files Browse the repository at this point in the history
  • Loading branch information
TBoonX committed Aug 23, 2017
2 parents c20596f + 03b5eb7 commit d144e20
Show file tree
Hide file tree
Showing 84 changed files with 1,883 additions and 672 deletions.
8 changes: 8 additions & 0 deletions actions/activityfeed/incrementDeckViewCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import log from '../log/clog';

export default function incrementDeckViewCounter(context,payload,done){
log.info(context);
context.dispatch('INCREMENT_DECK_VIEW_COUNTER', payload);

done();
}
12 changes: 12 additions & 0 deletions actions/loadDeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import resetPermissions from './permissions/resetPermissions';
import loadLikes from './activityfeed/loadLikes';
import PermissionsStore from '../stores/PermissionsStore';
import loadContributors from './loadContributors';
import loadForks from './permissions/loadForks';

const log = require('./log/clog');

Expand Down Expand Up @@ -153,6 +154,17 @@ export default function loadDeck(context, payload, done) {
}else{
callback();
}
},
(callback) => {
//if user is logged is and root deck changed load forks of this deck owned by the user
if(payload.params.jwt && currentState.selector.id !== payloadCustom.params.id){
context.executeAction(loadForks, {
selector: payload.params,
user: context.getStore(UserProfileStore).getState().userid
}, callback);
}else{
callback();
}
}
],
// final callback
Expand Down
2 changes: 1 addition & 1 deletion actions/loadLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function loadLegacy(context, payload, done) {
context.executeAction(serviceUnavailable, payload, done);
//context.dispatch('LOAD_FEATURED_FAILURE', err);
} else {
done(null, res.new_id);
done({'statusCode':'301','redirectURL': '/deck/' + res.new_id});
}
});
}
42 changes: 36 additions & 6 deletions actions/log/clog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
exports.error = function(context, message='') {
if (!isAllowedLogLevel('error'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -14,7 +17,10 @@ exports.error = function(context, message='') {
return;
};

exports.warning = function(context, msg='') {
exports.warning = function(context, message='') {
if (!isAllowedLogLevel('warning'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -31,6 +37,9 @@ exports.warning = function(context, msg='') {
};

exports.info = function(context, message='') {
if (!isAllowedLogLevel('info'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -46,7 +55,10 @@ exports.info = function(context, message='') {
return;
};

exports.crit = function(context, msg='') {
exports.crit = function(context, message='') {
if (!isAllowedLogLevel('crit'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -62,7 +74,10 @@ exports.crit = function(context, msg='') {
return;
};

exports.debug = function(context, msg='') {
exports.debug = function(context, message='') {
if (!isAllowedLogLevel('debug'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -78,7 +93,10 @@ exports.debug = function(context, msg='') {
return;
};

exports.notice = function(context, msg='') {
exports.notice = function(context, message='') {
if (!isAllowedLogLevel('notice'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -94,7 +112,10 @@ exports.notice = function(context, msg='') {
return;
};

exports.emerg = function(context, msg='') {
exports.emerg = function(context, message='') {
if (!isAllowedLogLevel('emerg'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -110,7 +131,10 @@ exports.emerg = function(context, msg='') {
return;
};

exports.alert = function(context, msg='') {
exports.alert = function(context, message='') {
if (!isAllowedLogLevel('alert'))
return;

let logFields = {};
logFields.Actions = context.stack.slice();
if (context.getUser() !== undefined)
Expand All @@ -125,3 +149,9 @@ exports.alert = function(context, msg='') {
});
return;
};

function isAllowedLogLevel(level) {
const allLevel = ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
const allowed = require('../../configs/general.js').loglevel;
return allLevel.indexOf(level) <= allLevel.indexOf(allowed);
}
16 changes: 16 additions & 0 deletions actions/permissions/loadForks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';

export default function loadForks(context, payload, done) {
log.info(context);
let {selector, user} = payload;
context.service.read('deck.forks', {params: {id: selector.id, user: user}}, {}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename});
context.executeAction(serviceUnavailable, payload, done);
} else {
context.dispatch('LOAD_FORKS_SUCCESS', {ownedForks: res});
done();
}
});
}
18 changes: 1 addition & 17 deletions actions/permissions/showNoPermissionsModal.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';

export default function showNoPermissionsModal(context, payload, done) {
let {selector, user, permissions} = payload;
if (!permissions.edit){
context.service.read('deck.forks', {params:{id: selector.id, user: user}}, {}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename});
context.executeAction(serviceUnavailable, payload, done);
} else {
context.dispatch('SHOW_NO_PERMISSIONS_MODAL', {ownedForks: res});
}
done();
});
} else {
context.dispatch('SHOW_NO_PERMISSIONS_MODAL');
done();
}

context.dispatch('SHOW_NO_PERMISSIONS_MODAL');
}
1 change: 1 addition & 0 deletions actions/user/resetPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const log = require('../log/clog');

export default function resetPassword(context, payload, done) {
log.info(context);
context.dispatch('RESET_PASSWORD_START', {});
context.service.update('user.resetPassword', payload, { timeout: 20 * 1000 }, (err, res) => {
if (err) {
switch (err.statusCode) {
Expand Down
1 change: 1 addition & 0 deletions actions/user/userprofile/changeUserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const log = require('../../log/clog');

export default function changeUserData(context, payload, done) {
log.info(context);
context.dispatch('SAVE_USERPROFILE_START', {});
payload.params = {};
payload.params.id = context.getStore(UserProfileStore).userid;
payload.params.jwt = context.getStore(UserProfileStore).jwt;
Expand Down
Binary file added assets/images/carousel/OER-Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carousel/SW-logo-squ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carousel/globe-squ-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carousel/hands-1926704_640.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/carousel/slide1.png
Binary file not shown.
Binary file removed assets/images/carousel/slide2.png
Binary file not shown.
Binary file removed assets/images/carousel/slide3.png
Binary file not shown.
Binary file removed assets/images/carousel/slide4.png
Binary file not shown.
Binary file added assets/images/carousel/slidewiki 500x200px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/features/slide-edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion client.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,23 @@ function loadLocaleData(locale) {

};


//removing hash, for redirects
function removeHash () {
let scrollV, scrollH, loc = window.location;
if ('pushState' in history)
history.pushState('', document.title, loc.pathname + loc.search);
else {
// Prevent scrolling by storing the page's current scroll offset
scrollV = document.body.scrollTop;
scrollH = document.body.scrollLeft;

loc.hash = '';

// Restore the scroll offset, should be flicker free
document.body.scrollTop = scrollV;
document.body.scrollLeft = scrollH;
}
}



Expand All @@ -320,6 +336,7 @@ function renderApp(locale) {
throw err;
}
window.context = context;
removeHash();
const mountNode = document.getElementById('app');

const Root = app.getComponent();
Expand Down
4 changes: 2 additions & 2 deletions components/Deck/ActivityFeedPanel/ActivityItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {navigateAction} from 'fluxible-router';
import {connectToStores} from 'fluxible-addons-react';
import cheerio from 'cheerio';
import DeckTreeStore from '../../../stores/DeckTreeStore';
import TreeUtil from '../../../components/Deck/TreePanel/util/TreeUtil';
import TreeUtil from '../TreePanel/util/TreeUtil';

class ActivityItem extends React.Component {
handleLike() {
Expand Down Expand Up @@ -53,7 +53,7 @@ class ActivityItem extends React.Component {
fontStyle: 'italic',
fontWeight: 400
};
const cheerioContentName = (node.content_name !== undefined) ? cheerio.load(node.content_name).text() : '';
const cheerioContentName = (node.content_name) ? cheerio.load(node.content_name).text() : '';
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>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class AddComment extends React.Component {
return (
<form className="ui form comment">
<div className="ui seven wide required field">
<label>Comment title</label>
<input type="text" ref="title" id="title" name="title" placeholder="Title" autoFocus required />
<label htmlFor="title">Comment title</label>
<input type="text" ref="title" id="title" name="title" placeholder="Title" aria-required="true" autoFocus required />
</div>
<div className="ui field">
<label>Comment text</label>
<label htmlFor="text">Comment text</label>
<textarea ref="text" id="text" name="text" style={{minHeight: '6em', height: '6em'}} placeholder="Text" ></textarea>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class AddReply extends React.Component {
return (
<form className="ui form reply">
<div className="ui seven wide required field">
<label>Reply title</label>
<input type="text" ref="replytitle" id="replytitle" name="replytitle" defaultValue={replyTitle} required/>
<label htmlFor="replytitle">Reply title</label>
<input type="text" ref="replytitle" id="replytitle" name="replytitle" defaultValue={replyTitle} aria-required="true" required/>
</div>
<div className="ui field">
<label>Reply text</label>
<label htmlFor="replytext">Reply text</label>
<textarea ref="replytext" id="replytext" name="replytext" style={{minHeight: '6em', height: '6em'}} placeholder="Text" autoFocus></textarea>
</div>
<button tabIndex="0" type="submit" className="ui blue labeled submit icon button" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,43 @@ import {connectToStores} from 'fluxible-addons-react';
import invertReplyBoxFlag from '../../../../actions/contentdiscussion/invertReplyBoxFlag';
import ActivityFeedUtil from '../util/ActivityFeedUtil';
import AddReply from './AddReply';
import {navigateAction} from 'fluxible-router';
import cheerio from 'cheerio';
import DeckTreeStore from '../../../../stores/DeckTreeStore';
import TreeUtil from '../../TreePanel/util/TreeUtil';

class Comment extends React.Component {
handleReply() {
this.context.executeAction(invertReplyBoxFlag, {comment: this.props.comment});
}

//return the position of the node in the deck
getPath(node){
const savedDeckTreeStore = (this.props.DeckTreeStore) ? this.props.DeckTreeStore : this.props.savedDeckTreeStore;

const flatTree = savedDeckTreeStore.flatTree;
let path = '';
for (let i=0; i < flatTree.size; i++) {
if (flatTree.get(i).get('type') === node.content_kind && flatTree.get(i).get('id') === node.content_id) {
path = flatTree.get(i).get('path');
let nodeSelector = {id: this.props.selector.id, stype: node.content_kind, sid: node.content_id, spath: path};
let nodeURL = TreeUtil.makeNodeURL(nodeSelector, 'deck', 'view');

return nodeURL;
}
}
return path;
}

handleRefClick(e) {
e.preventDefault();

this.context.executeAction(navigateAction, {
url: this.getPath(this.props.comment)
});
// return false;
}

render() {
const comment = this.props.comment;
const replyLink = (
Expand All @@ -17,6 +48,10 @@ class Comment extends React.Component {
</div>
);

const cheerioContentName = (comment.content_name) ? cheerio.load(comment.content_name).text() : '';
const nodeRef = (comment.content_kind !== this.props.selector.stype || comment.content_id.split('-')[0] !== this.props.selector.sid.split('-')[0]) ? (<span>{' (from ' + comment.content_kind + ' '}<a href={this.getPath(comment)} onClick={this.handleRefClick.bind(this)}>{cheerioContentName}</a>)</span>) : '';

const savedDeckTreeStore = (this.props.DeckTreeStore) ? this.props.DeckTreeStore : this.props.savedDeckTreeStore;
return (
<div className="comment">
<a className="avatar">
Expand All @@ -26,6 +61,7 @@ class Comment extends React.Component {
<a className="author" href={'/user/' + comment.author.username}>{comment.author.username}</a>
<div className="metadata">
<span className="date">{ActivityFeedUtil.formatDate(comment.timestamp)}</span>
{nodeRef}
</div>
<div className="text">
<strong>{comment.title}</strong><br/>
Expand All @@ -34,7 +70,7 @@ class Comment extends React.Component {
{ (String(this.props.userid) !== '') ? replyLink : ''}
{ comment.replyBoxOpened ? (<AddReply comment={comment} userid={this.props.userid}/>) : '' }
</div>
{comment.replies ? <div className="comments">{comment.replies.map((reply, index) => { return (<Comment key={index} comment={reply} userid={this.props.userid}/>); })}</div> : ''}
{comment.replies ? <div className="comments">{comment.replies.map((reply, index) => { return (<Comment key={index} comment={reply} userid={this.props.userid} selector={this.props.selector} savedDeckTreeStore={savedDeckTreeStore}/>); })}</div> : ''}
</div>
);
}
Expand All @@ -43,5 +79,9 @@ class Comment extends React.Component {
Comment.contextTypes = {
executeAction: React.PropTypes.func.isRequired
};

Comment = connectToStores(Comment, [DeckTreeStore], (context, props) => {
return {
DeckTreeStore: context.getStore(DeckTreeStore).getState()
};
});
export default Comment;
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ContentDiscussionPanel extends React.Component {
<div>There are currently no comments for this {selector.stype}.</div>
:
<div style={{ maxHeight: '600px', overflowY: 'auto' }}>
{this.props.ContentDiscussionStore.discussion.map((comment, index) => { return (<Comment key={index} comment={comment} userid={this.props.UserProfileStore.userid} />); })}
{this.props.ContentDiscussionStore.discussion.map((comment, index) => { return (<Comment key={index} comment={comment} userid={this.props.UserProfileStore.userid} selector={selector}/>); })}
</div>
}
</div>
Expand Down
Loading

0 comments on commit d144e20

Please sign in to comment.