From 92a729e9c8794d1a521335d59fcd1bbd45a8738a Mon Sep 17 00:00:00 2001 From: Chris Garrity Date: Wed, 22 Jan 2020 15:54:05 -0500 Subject: [PATCH 01/15] Set language cookie domain to allow for cross-domain cookies Add leading `.` to the current hostname for the language cookie domain. --- src/components/languagechooser/languagechooser.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/languagechooser/languagechooser.jsx b/src/components/languagechooser/languagechooser.jsx index 66e4a4262..be6f78881 100644 --- a/src/components/languagechooser/languagechooser.jsx +++ b/src/components/languagechooser/languagechooser.jsx @@ -21,7 +21,7 @@ class LanguageChooser extends React.Component { ]); } handleSetLanguage (name, value) { - jar.set('scratchlanguage', value); + jar.set('scratchlanguage', value, {domain: `.${window.location.hostname}`}); window.location.reload(); } render () { From a4764e0581f1925dfc5613e87f6aba0a9ea703a0 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Thu, 23 Jan 2020 12:36:47 -0500 Subject: [PATCH 02/15] attempt to get travis cron job to only run translations --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e462cd16..1a7f868f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -122,6 +122,7 @@ jobs: script: npm run deploy on: repo: LLK/scratch-www + condition: $TRAVIS_EVENT_TYPE != cron branch: - develop - hotfix/* @@ -135,13 +136,10 @@ jobs: - master - stage: smoke script: npm run test:integration:remote + - stage: update translations + script: npm run i18n:push + if: branch == develop AND type == cron stages: - test - name: smoke if: type != pull_request -- provider: script - on: - branch: develop - condition: $TRAVIS_EVENT_TYPE == cron - skip_cleanup: true - script: npm run i18n:push From ad2f0fa4e2a78c9be072f775eb7f323705fa76c2 Mon Sep 17 00:00:00 2001 From: Chris Garrity Date: Thu, 23 Jan 2020 16:56:12 -0500 Subject: [PATCH 03/15] =?UTF-8?q?Don=E2=80=99t=20prefix=20`localhost`=20wi?= =?UTF-8?q?th=20`.`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Need to special case localhost so that changing language works when running locally. --- src/components/languagechooser/languagechooser.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/languagechooser/languagechooser.jsx b/src/components/languagechooser/languagechooser.jsx index be6f78881..77f4fed72 100644 --- a/src/components/languagechooser/languagechooser.jsx +++ b/src/components/languagechooser/languagechooser.jsx @@ -21,7 +21,11 @@ class LanguageChooser extends React.Component { ]); } handleSetLanguage (name, value) { - jar.set('scratchlanguage', value, {domain: `.${window.location.hostname}`}); + let opts = {}; + if (window.location.hostname !== 'localhost') { + opts = {domain: `.${window.location.hostname}`}; + } + jar.set('scratchlanguage', value, opts); window.location.reload(); } render () { From 725740293a264185d9d8af09b020c31748d42e03 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Fri, 24 Jan 2020 10:39:32 -0500 Subject: [PATCH 04/15] revised travis yml to move condition to stage section --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a7f868f7..0534c56ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -122,7 +122,6 @@ jobs: script: npm run deploy on: repo: LLK/scratch-www - condition: $TRAVIS_EVENT_TYPE != cron branch: - develop - hotfix/* @@ -138,8 +137,10 @@ jobs: script: npm run test:integration:remote - stage: update translations script: npm run i18n:push - if: branch == develop AND type == cron stages: - test + if: type != cron - name: smoke - if: type != pull_request + if: type NOT IN (cron, pull_request) +- name: update translations + if: branch == develop AND type == cron From 24fa082c1925c1386f74630b00334fb7ba034382 Mon Sep 17 00:00:00 2001 From: Benjamin Wheeler Date: Tue, 28 Jan 2020 10:52:45 -0500 Subject: [PATCH 05/15] Revert "attempt to get travis cron job to only run translations" --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0534c56ab..2e462cd16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,12 +135,13 @@ jobs: - master - stage: smoke script: npm run test:integration:remote - - stage: update translations - script: npm run i18n:push stages: - test - if: type != cron - name: smoke - if: type NOT IN (cron, pull_request) -- name: update translations - if: branch == develop AND type == cron + if: type != pull_request +- provider: script + on: + branch: develop + condition: $TRAVIS_EVENT_TYPE == cron + skip_cleanup: true + script: npm run i18n:push From bbae4570e0d3b0642ef1bd6712a4c9444cd257b0 Mon Sep 17 00:00:00 2001 From: Benjamin Wheeler Date: Tue, 28 Jan 2020 11:12:18 -0500 Subject: [PATCH 06/15] Revert "Revert "attempt to get travis cron job to only run translations"" --- .travis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e462cd16..0534c56ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,13 +135,12 @@ jobs: - master - stage: smoke script: npm run test:integration:remote + - stage: update translations + script: npm run i18n:push stages: - test + if: type != cron - name: smoke - if: type != pull_request -- provider: script - on: - branch: develop - condition: $TRAVIS_EVENT_TYPE == cron - skip_cleanup: true - script: npm run i18n:push + if: type NOT IN (cron, pull_request) +- name: update translations + if: branch == develop AND type == cron From 5122922e36f7d5c1ccccac2c58ac1e3664ab1c0f Mon Sep 17 00:00:00 2001 From: Benjamin Wheeler Date: Tue, 28 Jan 2020 11:14:16 -0500 Subject: [PATCH 07/15] use name in test stage --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0534c56ab..7671f53c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -138,7 +138,7 @@ jobs: - stage: update translations script: npm run i18n:push stages: -- test +- name: test if: type != cron - name: smoke if: type NOT IN (cron, pull_request) From 5328ddbaaf853ec6480983b2b67d96a65fb519ee Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Tue, 28 Jan 2020 11:43:39 -0500 Subject: [PATCH 08/15] correct file location of tx-push-www script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c823874af..ff8a8cd72 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "deploy:s3:all": "npm run deploy:s3cmd -- --exclude '.DS_Store' --exclude '*.svg' --exclude '*.js' ./build/ s3://$S3_BUCKET_NAME/", "deploy:s3:svg": "npm run deploy:s3cmd -- --exclude '*' --include '*.svg' --mime-type 'image/svg+xml' ./build/ s3://$S3_BUCKET_NAME/", "deploy:s3:js": "npm run deploy:s3cmd -- --exclude '*' --include '*.js' --mime-type 'application/javascript' ./build/ s3://$S3_BUCKET_NAME/", - "i18n:push": "tx-push-www --execute", + "i18n:push": "./bin/tx-push-www --execute", "translate:urls": "node ./bin/get-localized-urls localized-urls.json", "translate:files": "node ./bin/build-locales node_modules/scratch-l10n/www intl", "translate": "npm run translate:urls && npm run translate:files" From 3c913cba9943ad6671c3a1db9baafd9703d2d015 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2020 19:48:55 +0000 Subject: [PATCH 09/15] chore(package): update scratch-gui to version 0.1.0-prerelease.20200128191437 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff8a8cd72..69cc0bd7f 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "redux-mock-store": "^1.2.3", "redux-thunk": "2.0.1", "sass-loader": "6.0.6", - "scratch-gui": "0.1.0-prerelease.20200127164821", + "scratch-gui": "0.1.0-prerelease.20200128191437", "scratch-l10n": "latest", "selenium-webdriver": "3.6.0", "slick-carousel": "1.6.0", From 497ea533c45d2ea384340cdc2e08ddc8c32138a2 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2020 19:48:59 +0000 Subject: [PATCH 10/15] chore(package): update lockfile package-lock.json --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb8f3c104..22f1a6626 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15756,9 +15756,9 @@ } }, "scratch-gui": { - "version": "0.1.0-prerelease.20200127164821", - "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200127164821.tgz", - "integrity": "sha512-LyNzqx6wLxINFo74kcLtDumKV5MxsOQiqHSywEFESciUbScktCDp0UrYk7eu9b8A8/e3gUa/v4RM5Aqf5WPH7Q==", + "version": "0.1.0-prerelease.20200128191437", + "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200128191437.tgz", + "integrity": "sha512-eYScTW+Zwvm8TdWEbJAgFv4azxsqH8CrJ9MTrz5qIea/sDbjr1e6F5OBo8B5kaRiYe4F/sqUnUXCXskoo393mQ==", "dev": true }, "scratch-l10n": { From 4add7b8fb561bd4aefc736343844a7d8178d9331 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 13:59:51 +0000 Subject: [PATCH 11/15] chore(package): update scratch-gui to version 0.1.0-prerelease.20200129134710 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69cc0bd7f..8723f2d8e 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "redux-mock-store": "^1.2.3", "redux-thunk": "2.0.1", "sass-loader": "6.0.6", - "scratch-gui": "0.1.0-prerelease.20200128191437", + "scratch-gui": "0.1.0-prerelease.20200129134710", "scratch-l10n": "latest", "selenium-webdriver": "3.6.0", "slick-carousel": "1.6.0", From 6ebe876f60fc15b51f6020086fef255008e663f6 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 13:59:55 +0000 Subject: [PATCH 12/15] chore(package): update lockfile package-lock.json --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 22f1a6626..823f14fb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15756,15 +15756,15 @@ } }, "scratch-gui": { - "version": "0.1.0-prerelease.20200128191437", - "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200128191437.tgz", - "integrity": "sha512-eYScTW+Zwvm8TdWEbJAgFv4azxsqH8CrJ9MTrz5qIea/sDbjr1e6F5OBo8B5kaRiYe4F/sqUnUXCXskoo393mQ==", + "version": "0.1.0-prerelease.20200129134710", + "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200129134710.tgz", + "integrity": "sha512-Qm5HHzRDT/f6pbNSl3SxiVziHCvNYPdtgq0mKQw6u8iZu3Auuo62G9WqWy6kmiEmUdPaEcsULHrSvwhw6EnZQg==", "dev": true }, "scratch-l10n": { - "version": "3.7.20200121224403", - "resolved": "https://registry.npmjs.org/scratch-l10n/-/scratch-l10n-3.7.20200121224403.tgz", - "integrity": "sha512-IAg8e5GtD6dduQaV2CRkA4qXGxYQn62IzBBOSTukS4UqphfotsAAg9Qkykg+KbuCxET+v7ZEBu27yNjyG2p+ew==", + "version": "3.7.20200128224436", + "resolved": "https://registry.npmjs.org/scratch-l10n/-/scratch-l10n-3.7.20200128224436.tgz", + "integrity": "sha512-ha/bTXYz8ke33leQRlraUB3n9qHneldoGdw66AN/Yho6b3uhq6qz89zditiTSv7LiGDIYpuXzBCEuiRDImK9DA==", "dev": true, "requires": { "@babel/cli": "^7.1.2", From 78749fcda7b959e155400bd8c5cf0037572faa08 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 18:56:40 +0000 Subject: [PATCH 13/15] chore(package): update scratch-gui to version 0.1.0-prerelease.20200129184440 Closes #3661 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8723f2d8e..5e3001466 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "redux-mock-store": "^1.2.3", "redux-thunk": "2.0.1", "sass-loader": "6.0.6", - "scratch-gui": "0.1.0-prerelease.20200129134710", + "scratch-gui": "0.1.0-prerelease.20200129184440", "scratch-l10n": "latest", "selenium-webdriver": "3.6.0", "slick-carousel": "1.6.0", From a5f9fc5271f08bf7b27fb35e269d820443fd67a5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 18:56:46 +0000 Subject: [PATCH 14/15] chore(package): update lockfile package-lock.json --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 823f14fb3..f3937498f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15756,9 +15756,9 @@ } }, "scratch-gui": { - "version": "0.1.0-prerelease.20200129134710", - "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200129134710.tgz", - "integrity": "sha512-Qm5HHzRDT/f6pbNSl3SxiVziHCvNYPdtgq0mKQw6u8iZu3Auuo62G9WqWy6kmiEmUdPaEcsULHrSvwhw6EnZQg==", + "version": "0.1.0-prerelease.20200129184440", + "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200129184440.tgz", + "integrity": "sha512-92BXenpNk6C87NNFfBbhdpJ08HFwUD3ySXtx31sGH+uTeyOs2s8Uzk7VsKqL0OiS0keAFtjzmFmF+rfMUQolVg==", "dev": true }, "scratch-l10n": { From c95d087289375f8bd5bc61727c2c84e4abea8aaa Mon Sep 17 00:00:00 2001 From: Chris Garrity Date: Wed, 29 Jan 2020 16:11:58 -0500 Subject: [PATCH 15/15] Ensure that the old scratchlanguage cookie is removed if it exists. On init, remove the old cookie if it exists. On the project page, make sure `handleSetLanguage` also sets the domain. --- src/init.js | 11 +++++++++++ src/views/preview/project-view.jsx | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/init.js b/src/init.js index d7f9984bb..bf798094a 100644 --- a/src/init.js +++ b/src/init.js @@ -18,6 +18,17 @@ const jar = require('./lib/jar'); if (['pt', 'pt-pt', 'PT', 'PT-PT'].indexOf(obj) !== -1) { obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5. } + } else { + // delete the old cookie (just hostname) by setting it to null and expiring in the past + /* eslint-disable max-len */ + document.cookie = `scratchlanguage=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${window.location.hostname}`; + /* eslint-enable max-len */ + // create the new cookie + let opts = {}; + if (window.location.hostname !== 'localhost') { + opts = {domain: `.${window.location.hostname}`}; + } + jar.set('scratchlanguage', obj, opts); } return obj; }; diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index b9471eeaf..676e1b897 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -626,7 +626,11 @@ class Preview extends React.Component { ); } handleSetLanguage (locale) { - jar.set('scratchlanguage', locale); + let opts = {}; + if (window.location.hostname !== 'localhost') { + opts = {domain: `.${window.location.hostname}`}; + } + jar.set('scratchlanguage', locale, opts); } handleUpdateProjectId (projectId, callback) { this.setState({projectId: projectId}, () => {