mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-02 11:59:07 -05:00
Set up studios view with 404 page
This commit is contained in:
parent
dbec1c7a97
commit
040350314b
2 changed files with 61 additions and 33 deletions
|
@ -26,7 +26,9 @@ const getInitialState = () => ({
|
||||||
manager: false,
|
manager: false,
|
||||||
curator: false,
|
curator: false,
|
||||||
following: false,
|
following: false,
|
||||||
invited: false
|
invited: false,
|
||||||
|
|
||||||
|
studioNotAvailable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const studioReducer = (state, action) => {
|
const studioReducer = (state, action) => {
|
||||||
|
@ -51,6 +53,13 @@ const studioReducer = (state, action) => {
|
||||||
if (action.error) {
|
if (action.error) {
|
||||||
log.error(action.error);
|
log.error(action.error);
|
||||||
}
|
}
|
||||||
|
if (action.fetchType === 'infoStatus' && action.fetchStatus === Status.ERROR) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
[action.fetchType]: action.fetchStatus,
|
||||||
|
studioNotAvailable: true
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
[action.fetchType]: action.fetchStatus
|
[action.fetchType]: action.fetchStatus
|
||||||
|
@ -94,6 +103,7 @@ const selectStudioCommentsAllowed = state => state.studio.commentsAllowed;
|
||||||
const selectIsFetchingInfo = state => state.studio.infoStatus === Status.FETCHING;
|
const selectIsFetchingInfo = state => state.studio.infoStatus === Status.FETCHING;
|
||||||
const selectIsFollowing = state => state.studio.following;
|
const selectIsFollowing = state => state.studio.following;
|
||||||
const selectIsFetchingRoles = state => state.studio.rolesStatus === Status.FETCHING;
|
const selectIsFetchingRoles = state => state.studio.rolesStatus === Status.FETCHING;
|
||||||
|
const selectIsStudioAvailable = state => !state.studio.studioNotAvailable;
|
||||||
|
|
||||||
// Thunks
|
// Thunks
|
||||||
const getInfo = () => ((dispatch, getState) => {
|
const getInfo = () => ((dispatch, getState) => {
|
||||||
|
@ -159,5 +169,6 @@ module.exports = {
|
||||||
selectStudioCommentsAllowed,
|
selectStudioCommentsAllowed,
|
||||||
selectIsFetchingInfo,
|
selectIsFetchingInfo,
|
||||||
selectIsFetchingRoles,
|
selectIsFetchingRoles,
|
||||||
selectIsFollowing
|
selectIsFollowing,
|
||||||
|
selectIsStudioAvailable
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,9 +6,14 @@ import {
|
||||||
Redirect,
|
Redirect,
|
||||||
useRouteMatch
|
useRouteMatch
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
|
|
||||||
|
|
||||||
import Page from '../../components/page/www/page.jsx';
|
import Page from '../../components/page/www/page.jsx';
|
||||||
import render from '../../lib/render.jsx';
|
import render from '../../lib/render.jsx';
|
||||||
|
import NotAvailable from '../../components/not-available/not-available.jsx';
|
||||||
|
|
||||||
|
|
||||||
import StudioTabNav from './studio-tab-nav.jsx';
|
import StudioTabNav from './studio-tab-nav.jsx';
|
||||||
import StudioProjects from './studio-projects.jsx';
|
import StudioProjects from './studio-projects.jsx';
|
||||||
|
@ -25,17 +30,18 @@ import {
|
||||||
activity
|
activity
|
||||||
} from './lib/redux-modules';
|
} from './lib/redux-modules';
|
||||||
|
|
||||||
const {getInitialState, studioReducer} = require('../../redux/studio');
|
const {getInitialState, studioReducer, selectIsStudioAvailable} = require('../../redux/studio');
|
||||||
const {studioReportReducer} = require('../../redux/studio-report');
|
const {studioReportReducer} = require('../../redux/studio-report');
|
||||||
const {commentsReducer} = require('../../redux/comments');
|
const {commentsReducer} = require('../../redux/comments');
|
||||||
const {studioMutationsReducer} = require('../../redux/studio-mutations');
|
const {studioMutationsReducer} = require('../../redux/studio-mutations');
|
||||||
|
|
||||||
import './studio.scss';
|
import './studio.scss';
|
||||||
|
|
||||||
const StudioShell = () => {
|
const StudioShell = ({isStudioAvailable}) => {
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
isStudioAvailable ?
|
||||||
<div className="studio-shell">
|
<div className="studio-shell">
|
||||||
<div className="studio-info">
|
<div className="studio-info">
|
||||||
<StudioInfo />
|
<StudioInfo />
|
||||||
|
@ -64,17 +70,28 @@ const StudioShell = () => {
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> :
|
||||||
|
<NotAvailable />
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StudioShell.propTypes = {
|
||||||
|
isStudioAvailable: PropTypes.bool
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConnectedStudioShell = connect(
|
||||||
|
state => ({
|
||||||
|
isStudioAvailable: selectIsStudioAvailable(state)
|
||||||
|
}),
|
||||||
|
)(StudioShell);
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<Page className="studio-page">
|
<Page className="studio-page">
|
||||||
<Router>
|
<Router>
|
||||||
<Switch>
|
<Switch>
|
||||||
{/* Use variable studioPath to support /studio-playground/ or future route */}
|
{/* Use variable studioPath to support /studio-playground/ or future route */}
|
||||||
<Route path="/:studioPath/:studioId">
|
<Route path="/:studioPath/:studioId">
|
||||||
<StudioShell />
|
<ConnectedStudioShell />
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
Loading…
Reference in a new issue