Skip to content

Commit

Permalink
Merge pull request #1128 from slidewiki/SWIK-555_Fix_deck_not_found_h…
Browse files Browse the repository at this point in the history
…andling_page

Swik 555 fix deck not found handling page
  • Loading branch information
kprist authored Dec 14, 2018
2 parents 70903da + bd5da8f commit ec682bc
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 48 deletions.
31 changes: 21 additions & 10 deletions actions/loadDeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ import log from './log/clog';
export default function loadDeck(context, payload, done) {
log.info(context); // do not remove such log messages. If you don't want to see them, change log level in config
context.dispatch('UPDATE_MODE', {mode: 'loading'});

// resets the deck view store
// TODO (what other store to reset ???)
context.dispatch('LOAD_DECK_PAGE_START');

if (!(AllowedPattern.DECK_ID.test(payload.params.id))) {
context.executeAction(deckIdTypeError, payload, done);
return;
Expand Down Expand Up @@ -102,16 +107,6 @@ export default function loadDeck(context, payload, done) {

payload.params.jwt = context.getStore(UserProfileStore).getState().jwt;

let permissionsPromise;
//if user is not logged in, only allow view mode and reset permissions, else load this user's permissions on the selected root deck
if (!payload.params.jwt){
if (!payload.query.interestedUser) //NOTE should not be changed in the special case: Link from email for deck owner to add new editor
payloadCustom.params.mode = 'view';
permissionsPromise = context.executeAction(resetPermissions, payloadCustom);
} else {
permissionsPromise = context.executeAction(loadPermissions, payloadCustom);
}

context.dispatch('UPDATE_DECK_PAGE_CONTENT', payloadCustom);
pageTitle = pageTitle + ' | ' + payloadCustom.params.stype + ' | ' + payloadCustom.params.sid + ' | ' + payloadCustom.params.mode;
if((currentState.selector.id === payloadCustom.params.id) && (currentState.selector.spath === payloadCustom.params.spath)){
Expand All @@ -131,6 +126,12 @@ export default function loadDeck(context, payload, done) {

// load translation stuff
context.executeAction(loadNodeTranslations, payload.params, (err, results) => {
if (err) {
// log the error and return!!!
log.error(context, {filepath: __filename, message: err.message});
return done(err);
}

//load all required actions in parallel
async.parallel([
(callback) => {
Expand All @@ -141,6 +142,16 @@ export default function loadDeck(context, payload, done) {
}, callback);
},
(callback) => {
let permissionsPromise;
//if user is not logged in, only allow view mode and reset permissions, else load this user's permissions on the selected root deck
if (!payload.params.jwt){
if (!payload.query.interestedUser) //NOTE should not be changed in the special case: Link from email for deck owner to add new editor
payloadCustom.params.mode = 'view';
permissionsPromise = context.executeAction(resetPermissions, payloadCustom);
} else {
permissionsPromise = context.executeAction(loadPermissions, payloadCustom);
}

permissionsPromise.then(() => {
let permissions = context.getStore(PermissionsStore).getState().permissions;
//special handling for special case: Link from email for deck owner to add new editor
Expand Down
3 changes: 1 addition & 2 deletions actions/loadDeckView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default function loadDeckView(context, payload, done) {

context.service.read('deck.content', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {
console.log(err);
log.error(context, {filepath: __filename});
log.error(context, {filepath: __filename, message: err.message });
context.executeAction(serviceUnavailable, payload, done);
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion actions/loadLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function loadLegacy(context, payload, done) {
context.executeAction(serviceUnavailable, payload, done);
//context.dispatch('LOAD_FEATURED_FAILURE', err);
} else {
done({'statusCode':'301','redirectURL': '/deck/' + res.new_id});
done({'statusCode': 301,'redirectURL': '/deck/' + res.new_id});
}
});
}
4 changes: 2 additions & 2 deletions actions/translation/loadNodeTranslations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default function loadNodeTranslations(context, payload, done) {

context.service.read('decktree.nodetranslation', payload, {timeout: 20 * 1000}, (err, res) => {
if (err) {
log.error(context, {filepath: __filename});
context.executeAction(serviceUnavailable, payload, done);
log.error(context, {filepath: __filename, message: err.message});
done(err);
} else {
context.dispatch('LOAD_TRANSLATIONS_SUCCESS', res);
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SlideViewPanel extends React.Component {
deckTheme = this.props.DeckTreeStore.theme;
}
}
if (this.currentID === selector.sid){
if (this.currentID === selector.sid && this.props.SlideViewStore.slideId) {
let hideSpeakerNotes = true;
if (this.props.SlideViewStore.speakernotes !== '' && this.props.SlideViewStore.speakernotes !== ' '){hideSpeakerNotes = false;}

Expand All @@ -73,8 +73,7 @@ class SlideViewPanel extends React.Component {
};
return (
<div className="ui bottom attached segment">
{(this.currentID !== selector.sid) ? <div style={loadStyle} className="ui active dimmer"><div className="ui text loader">Loading</div></div> : ''}
{this.slideContentView}
{this.slideContentView || <div style={loadStyle} className="ui active dimmer"><div className="ui text loader">Loading</div></div>}
</div>
);
}
Expand Down
174 changes: 173 additions & 1 deletion components/Deck/DeckLandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NavLink } from 'fluxible-router';
import { Grid, Divider, Button, Header, Image, Icon, Item, Label, Menu, Segment, Container } from 'semantic-ui-react';

import { connectToStores } from 'fluxible-addons-react';
import ContentStore from '../../stores/ContentStore';
import DeckPageStore from '../../stores/DeckPageStore';
import DeckViewStore from '../../stores/DeckViewStore';
import ContentLikeStore from '../../stores/ContentLikeStore';
Expand Down Expand Up @@ -55,8 +56,170 @@ class DeckLandingPage extends React.Component {
return presLocation;
}

getPlaceholder() {
return (
<Container fluid>
<Divider hidden/>
<Grid padded='vertically' divided='vertically' stackable>
<Grid.Column only="tablet computer" tablet={1} computer={2}>
</Grid.Column>

<Grid.Column mobile={16} tablet={14} computer={12}>
<Grid.Row>
<Segment>
<Grid stackable>
<Grid.Column width={4}>
<div className="ui placeholder">
<div className="rectangular image"></div>
</div>
</Grid.Column>
<Grid.Column width={12}>
<Grid.Row>
<div className="ui placeholder">
<div className="header">
<div className="long line"></div>
<div className="long line"></div>
</div>
</div>
</Grid.Row>
<Divider hidden />
<Grid stackable>
<Grid.Row columns={2}>
<Grid.Column>
<div className="ui placeholder">
<div className="line"></div>
<div className="line"></div>
<div className="line"></div>
</div>
</Grid.Column>
<Grid.Column>
<div className="ui placeholder">
<div className="line"></div>
<div className="line"></div>
</div>
</Grid.Column>
</Grid.Row>
<Divider hidden />
<Grid.Row>
<Grid.Column>
<div className="ui placeholder">
<div className="header">
<div className="line"></div>
</div>
<div className="paragraph">
<div className="line"></div>
<div className="line"></div>
</div>
</div>
</Grid.Column>
</Grid.Row>
<Divider hidden />
<Grid.Row>
<Grid.Column>
<div className="ui placeholder">
<div className="header">
<div className="line"></div>
</div>
<div className="paragraph">
<div className="line"></div>
</div>
</div>
</Grid.Column>
</Grid.Row>
</Grid>
</Grid.Column>
</Grid>
</Segment>
</Grid.Row>
<Grid.Row>
<div className="ui bottom attached tabular menu" style={{'background': '#e0e1e2'}}>
<div className="ui icon buttons huge attached">
<Button icon size="huge">
<Icon name="line graph" />
</Button>
<Button icon size="huge">
<Icon name="warning circle" />
</Button>
</div>

<div className="right inverted menu">
<div className="ui icon buttons huge attached">
<Button icon size="huge">
<Icon name="open folder" />
</Button>
<Button icon size="huge">
<Icon name="play circle" />
</Button>
<Button icon size="huge">
<Icon name="record" />
</Button>
</div>
</div>
</div>
</Grid.Row>

<Divider hidden />

<Grid divided='vertically' stackable>
<Grid.Column only="tablet computer" width={12}>
<Segment attached='top' >
<div className="ui placeholder">
<div className="header">
<div className="line"></div>
</div>
<div className="paragraph">
<div className="long line"></div>
</div>
</div>
</Segment>
<Segment attached>
<div className="ui placeholder">
<div className="header">
<div className="line"></div>
</div>
<div className="paragraph">
<div className="long line"></div>
</div>
</div>
</Segment>
<Segment attached='bottom'>
<div className="ui placeholder">
<div className="header">
<div className="line"></div>
</div>
<div className="paragraph">
<div className="long line"></div>
</div>
</div>
</Segment>
</Grid.Column>
<Grid.Column only="tablet computer" width={4}>
<Segment>
<div className="ui fluid placeholder">
</div>
</Segment>
<Segment attached='bottom'>
<a href='https://creativecommons.org/licenses/by-sa/4.0/' target='_blank'>
<CCBYSA size='small' />
</a>
This work is licensed under <a href='https://creativecommons.org/licenses/by-sa/4.0/' target='_blank'>Creative Commons Attribution-ShareAlike 4.0 International License</a>
</Segment>
</Grid.Column>
</Grid>

</Grid.Column>

<Grid.Column only="tablet computer" tablet={1} computer={2}>
</Grid.Column>

</Grid>
</Container>
);
}

render() {
let deckData = this.props.DeckViewStore.deckData;
if (lodash.isEmpty(deckData)) return this.getPlaceholder();

let firstSlide = (this.props.DeckViewStore.slidesData && this.props.DeckViewStore.slidesData.children && this.props.DeckViewStore.slidesData.children[0]);
const totalSlides = lodash.get(this.props.DeckViewStore.slidesData, 'children.length', undefined);
Expand Down Expand Up @@ -296,8 +459,17 @@ class DeckLandingPage extends React.Component {
}
}

DeckLandingPage = connectToStores(DeckLandingPage, [ContentLikeStore, DeckPageStore, DeckViewStore, TranslationStore, ContentModulesStore, SimilarContentStore], (context, props) => {
DeckLandingPage = connectToStores(DeckLandingPage, [
ContentStore,
ContentLikeStore,
DeckPageStore,
DeckViewStore,
TranslationStore,
ContentModulesStore,
SimilarContentStore,
], (context, props) => {
return {
ContentStore: context.getStore(ContentStore).getState(),
ContentLikeStore: context.getStore(ContentLikeStore).getState(),
DeckPageStore: context.getStore(DeckPageStore).getState(),
DeckViewStore: context.getStore(DeckViewStore).getState(),
Expand Down
Loading

0 comments on commit ec682bc

Please sign in to comment.