Skip to content

Commit 52bbb2c

Browse files
authored
Merge pull request #4200 from LLK/develop
Merge develop into release
2 parents 164e58e + fb640fa commit 52bbb2c

File tree

10 files changed

+248
-120
lines changed

10 files changed

+248
-120
lines changed

package-lock.json

Lines changed: 162 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"redux-mock-store": "^1.2.3",
129129
"redux-thunk": "2.0.1",
130130
"sass-loader": "6.0.6",
131-
"scratch-gui": "0.1.0-prerelease.20200708034512",
131+
"scratch-gui": "0.1.0-prerelease.20200715032543",
132132
"scratch-l10n": "latest",
133133
"selenium-webdriver": "3.6.0",
134134
"slick-carousel": "1.6.0",

src/components/footer/www/footer.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ const FormattedMessage = require('react-intl').FormattedMessage;
22
const injectIntl = require('react-intl').injectIntl;
33
const intlShape = require('react-intl').intlShape;
44
const MediaQuery = require('react-responsive').default;
5+
const connect = require('react-redux').connect;
6+
const PropTypes = require('prop-types');
57
const React = require('react');
68

79
const FooterBox = require('../container/footer.jsx');
810
const LanguageChooser = require('../../languagechooser/languagechooser.jsx');
911

1012
const frameless = require('../../../lib/frameless');
13+
const getScratchWikiLink = require('../../../lib/scratch-wiki');
1114

1215
require('./footer.scss');
1316

@@ -108,7 +111,7 @@ const Footer = props => (
108111
</a>
109112
</dd>
110113
<dd>
111-
<a href="https://en.scratch-wiki.info/">
114+
<a href={props.scratchWikiLink}>
112115
<FormattedMessage id="general.wiki" />
113116
</a>
114117
</dd>
@@ -213,7 +216,13 @@ const Footer = props => (
213216
);
214217

215218
Footer.propTypes = {
216-
intl: intlShape.isRequired
219+
intl: intlShape.isRequired,
220+
scratchWikiLink: PropTypes.string
217221
};
218222

219-
module.exports = injectIntl(Footer);
223+
const mapStateToProps = (state, ownProps) => ({
224+
scratchWikiLink: getScratchWikiLink(ownProps.intl.locale)
225+
});
226+
227+
const ConnectedFooter = connect(mapStateToProps)(Footer);
228+
module.exports = injectIntl(ConnectedFooter);

src/components/welcome/welcome.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
content: "";
3636
}
3737

38+
img {
39+
display: block;
40+
max-width: 133px;
41+
max-height: 100px;
42+
}
43+
3844
&.blue {
3945
#{$color-bars} {
4046
background-color: $ui-blue;
@@ -43,6 +49,10 @@
4349
a {
4450
color: $ui-blue;
4551
}
52+
53+
img {
54+
margin-left: 4px;
55+
}
4656
}
4757

4858
&.green {

src/lib/scratch-wiki.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This list has to be updated when a new Scratch Wiki is made.
2+
// Note that wikis under testwiki are not included.
3+
const wwwLocaleToScratchWikiLocale = {
4+
en: 'en',
5+
ja: 'ja',
6+
fr: 'fr',
7+
de: 'de',
8+
ru: 'ru',
9+
hu: 'hu',
10+
nl: 'nl',
11+
id: 'id'
12+
};
13+
14+
const getScratchWikiLink = locale => {
15+
if (!wwwLocaleToScratchWikiLocale.hasOwnProperty(locale)) {
16+
locale = locale.split('-')[0];
17+
if (!wwwLocaleToScratchWikiLocale.hasOwnProperty(locale)) {
18+
locale = 'en';
19+
}
20+
}
21+
return `https://${wwwLocaleToScratchWikiLocale[locale]}.scratch-wiki.info/`;
22+
};
23+
24+
module.exports = getScratchWikiLink;

src/views/preview/meta.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
const React = require('react');
22
const Helmet = require('react-helmet').default;
3+
const PropTypes = require('prop-types');
34

45
const projectShape = require('./projectshape.jsx').projectShape;
56

67
const Meta = props => {
78
const {id, title, instructions, author} = props.projectInfo;
89

9-
// Do not want to render any meta tags unless all the info is loaded
10-
// Check only author (object) because it is ok to have empty string instructions
11-
if (!author) return null;
10+
if (!author) {
11+
// Project info is not ready. It's either fetching state, or logged-out users creating project.
12+
if (!props.userPresent) {
13+
return (
14+
<Helmet>
15+
<title>Scratch - Imagine, Program, Share</title>
16+
</Helmet>
17+
);
18+
}
19+
return null;
20+
}
1221

1322
const truncatedInstructions = instructions.split(' ')
1423
.slice(0, 50)
@@ -38,7 +47,8 @@ const Meta = props => {
3847
};
3948

4049
Meta.propTypes = {
41-
projectInfo: projectShape
50+
projectInfo: projectShape,
51+
userPresent: PropTypes.bool
4252
};
4353

4454
module.exports = Meta;

src/views/preview/preview.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ $stage-width: 480px;
444444
font-size: .875rem;
445445
flex-shrink: 1;
446446
text-align: left;
447+
overflow: auto;
448+
overflow-wrap: break-word;
447449
}
448450

449451
.description-block {

src/views/preview/project-view.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,10 @@ class Preview extends React.Component {
700700

701701
return (
702702
<React.Fragment>
703-
<Meta projectInfo={this.props.projectInfo} />
703+
<Meta
704+
projectInfo={this.props.projectInfo}
705+
userPresent={this.props.userPresent}
706+
/>
704707
{this.props.playerMode ?
705708
<Page
706709
className={classNames({

static/images/welcome-learn.png

-6.07 KB
Loading

test/unit/lib/scratch-wiki.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const getScratchWikiLink = require('../../../src/lib/scratch-wiki');
2+
3+
describe('unit test lib/scratch-wiki.js', () => {
4+
test('getScratchWikiLink exists', () => {
5+
expect(typeof getScratchWikiLink).toBe('function');
6+
});
7+
8+
test('it returns link to jawiki when ja is given', () => {
9+
expect(getScratchWikiLink('ja')).toBe('https://ja.scratch-wiki.info/');
10+
});
11+
12+
test('it returns link to jawiki when ja-Hira is given', () => {
13+
expect(getScratchWikiLink('ja-Hira')).toBe('https://ja.scratch-wiki.info/');
14+
});
15+
16+
test('it returns link to enwiki when invalid locale is given', () => {
17+
expect(getScratchWikiLink('test')).toBe('https://en.scratch-wiki.info/');
18+
});
19+
});

0 commit comments

Comments
 (0)