mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-16 16:19:48 -05:00
Add "project not available" view for when project body cannot be loaded
This happens when the project id does not exist, or is not visible to the given user.
This commit is contained in:
parent
7721418165
commit
315c8b78fc
7 changed files with 51 additions and 2 deletions
24
src/components/not-available/not-available.jsx
Normal file
24
src/components/not-available/not-available.jsx
Normal file
|
@ -0,0 +1,24 @@
|
|||
const React = require('react');
|
||||
const FormattedMessage = require('react-intl').FormattedMessage;
|
||||
const FlexRow = require('../../components/flex-row/flex-row.jsx');
|
||||
|
||||
require('./not-available.scss');
|
||||
|
||||
const ProjectNotAvailable = () => (
|
||||
<div className="not-available-outer">
|
||||
<FlexRow className="inner">
|
||||
<img
|
||||
className="not-available-image"
|
||||
src="/images/404-giga.png"
|
||||
/>
|
||||
<h1>
|
||||
<FormattedMessage id="general.notAvailableHeadline" />
|
||||
</h1>
|
||||
<p>
|
||||
<FormattedMessage id="general.notAvailableSubtitle" />
|
||||
</p>
|
||||
</FlexRow>
|
||||
</div>
|
||||
);
|
||||
|
||||
module.exports = ProjectNotAvailable;
|
5
src/components/not-available/not-available.scss
Normal file
5
src/components/not-available/not-available.scss
Normal file
|
@ -0,0 +1,5 @@
|
|||
@import "../../colors";
|
||||
|
||||
.not-available-image {
|
||||
padding: 5rem 0 2rem;
|
||||
}
|
|
@ -86,6 +86,8 @@
|
|||
"general.wiki": "Scratch Wiki",
|
||||
"general.copyLink": "Copy Link",
|
||||
"general.report": "Report",
|
||||
"general.notAvailableHeadline": "Whoops! Our server is Scratch'ing its head",
|
||||
"general.notAvailableSubtitle": "We couldn't find the page you're looking for. Check to make sure you've typed the url correctly.",
|
||||
|
||||
"general.all": "All",
|
||||
"general.animations": "Animations",
|
||||
|
|
|
@ -38,7 +38,8 @@ module.exports.getInitialState = () => ({
|
|||
projectStudios: [],
|
||||
curatedStudios: [],
|
||||
currentStudioIds: [],
|
||||
moreCommentsToLoad: false
|
||||
moreCommentsToLoad: false,
|
||||
projectNotAvailable: false
|
||||
});
|
||||
|
||||
module.exports.previewReducer = (state, action) => {
|
||||
|
@ -51,7 +52,8 @@ module.exports.previewReducer = (state, action) => {
|
|||
return module.exports.getInitialState();
|
||||
case 'SET_PROJECT_INFO':
|
||||
return Object.assign({}, state, {
|
||||
projectInfo: action.info
|
||||
projectInfo: action.info ? action.info : {},
|
||||
projectNotAvailable: !!action.info
|
||||
});
|
||||
case 'SET_REMIXES':
|
||||
return Object.assign({}, state, {
|
||||
|
@ -318,6 +320,7 @@ module.exports.getProjectInfo = (id, token) => (dispatch => {
|
|||
if (typeof body === 'undefined') {
|
||||
dispatch(module.exports.setFetchStatus('project', module.exports.Status.ERROR));
|
||||
dispatch(module.exports.setError('No project info'));
|
||||
dispatch(module.exports.setProjectInfo(null));
|
||||
return;
|
||||
}
|
||||
dispatch(module.exports.setFetchStatus('project', module.exports.Status.FETCHED));
|
||||
|
|
|
@ -25,6 +25,7 @@ const InplaceInput = require('../../components/forms/inplace-input.jsx');
|
|||
const TopLevelComment = require('./comment/top-level-comment.jsx');
|
||||
const ComposeComment = require('./comment/compose-comment.jsx');
|
||||
const ExtensionChip = require('./extension-chip.jsx');
|
||||
const NotAvailable = require('../../components/not-available/not-available.jsx');
|
||||
|
||||
const projectShape = require('./projectshape.jsx').projectShape;
|
||||
require('./preview.scss');
|
||||
|
@ -67,6 +68,7 @@ const PreviewPresentation = ({
|
|||
projectHost,
|
||||
projectId,
|
||||
projectInfo,
|
||||
projectNotAvailable,
|
||||
remixes,
|
||||
reportOpen,
|
||||
replies,
|
||||
|
@ -93,6 +95,15 @@ const PreviewPresentation = ({
|
|||
onUpdate
|
||||
}) => {
|
||||
const shareDate = ((projectInfo.history && projectInfo.history.shared)) ? projectInfo.history.shared : '';
|
||||
|
||||
if (projectNotAvailable) {
|
||||
return (
|
||||
<div className="preview">
|
||||
<NotAvailable />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="preview">
|
||||
{canShare && !isShared && (
|
||||
|
@ -477,6 +488,7 @@ PreviewPresentation.propTypes = {
|
|||
projectHost: PropTypes.string,
|
||||
projectId: PropTypes.string,
|
||||
projectInfo: projectShape,
|
||||
projectNotAvailable: PropTypes.bool,
|
||||
projectStudios: PropTypes.arrayOf(PropTypes.object),
|
||||
remixes: PropTypes.arrayOf(PropTypes.object),
|
||||
replies: PropTypes.objectOf(PropTypes.array),
|
||||
|
|
|
@ -423,6 +423,7 @@ class Preview extends React.Component {
|
|||
projectHost={this.props.projectHost}
|
||||
projectId={this.state.projectId}
|
||||
projectInfo={this.props.projectInfo}
|
||||
projectNotAvailable={this.props.projectNotAvailable}
|
||||
projectStudios={this.props.projectStudios}
|
||||
remixes={this.props.remixes}
|
||||
replies={this.props.replies}
|
||||
|
@ -530,6 +531,7 @@ Preview.propTypes = {
|
|||
playerMode: PropTypes.bool,
|
||||
projectHost: PropTypes.string.isRequired,
|
||||
projectInfo: projectShape,
|
||||
projectNotAvailable: PropTypes.bool,
|
||||
projectStudios: PropTypes.arrayOf(PropTypes.object),
|
||||
remixes: PropTypes.arrayOf(PropTypes.object),
|
||||
replies: PropTypes.objectOf(PropTypes.array),
|
||||
|
@ -610,6 +612,7 @@ const mapStateToProps = state => {
|
|||
parent: state.preview.parent,
|
||||
playerMode: state.scratchGui.mode.isPlayerOnly,
|
||||
projectInfo: state.preview.projectInfo,
|
||||
projectNotAvailable: state.preview.projectNotAvailable,
|
||||
projectStudios: state.preview.projectStudios,
|
||||
remixes: state.preview.remixes,
|
||||
replies: state.preview.replies,
|
||||
|
|
BIN
static/images/404-giga.png
Normal file
BIN
static/images/404-giga.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
Loading…
Reference in a new issue