-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redo the way exported projects are initialized #12623
Conversation
Hopefully this will fix a whole slew of bugs.
import applabCommands from './commands'; | ||
import {injectErrorHandler} from '../javascriptMode'; | ||
import JavaScriptModeErrorHandler from '../JavaScriptModeErrorHandler'; | ||
//import applabCommands from './commands'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code?
"codeStudioLogo":false, | ||
"hasI18n":false, | ||
"callouts":[], | ||
"channel":"Wc1JaBxTP04gGolQ9xuhNw", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a channel ID hard-coded into this object?
"hasContainedLevels":false, | ||
"hideSource":true, | ||
"share":true, | ||
"labUserId":"x+OhD4/hmGgtPrHVlrC32TFHAdo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whose user ID is this?
"labUserId":"x+OhD4/hmGgtPrHVlrC32TFHAdo", | ||
"firebaseName":"cdo-v3-dev", | ||
"firebaseAuthToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2IjowLCJpYXQiOjE0ODM5OTg4MjksImQiOnsidWlkIjoiOTIiLCJpc19kYXNoYm9hcmRfdXNlciI6dHJ1ZX19.DX8PP0Q8EDGg7UtMbhT2sT-h39LvDsuuPbA6YesXLG8", | ||
"firebaseChannelIdSuffix":"-DEVELOPMENT-pcardune", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh... auth token?
"level":"custom", | ||
"shouldShowDialog":true | ||
}, | ||
"locale":"en_us" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded locale?
"level":"custom", | ||
"shouldShowDialog":true | ||
}, | ||
"locale":"en_us" | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to be a lot pickier about what gets included in this object...
"art_from_html":"Minecraft\u0026%238482;%20\u0026copy;%202017%20Microsoft.%20All%20Rights%20Reserved.%3Cbr%20/%3EStar%20Wars\u0026%238482;%20\u0026copy;%202017%20Disney%20and%20Lucasfilm.%20All%20Rights%20Reserved.%3Cbr%20/%3EFrozen\u0026%238482;%20\u0026copy;%202017%20Disney.%20All%20Rights%20Reserved.%3Cbr%20/%3EIce%20Age\u0026%238482;%20\u0026copy;%202017%2020th%20Century%20Fox.%20All%20Rights%20Reserved.%3Cbr%20/%3EAngry%20Birds\u0026%238482;%20\u0026copy;%202009-2017%20Rovio%20Entertainment%20Ltd.%20All%20Rights%20Reserved.%3Cbr%20/%3EPlants%20vs.%20Zombies\u0026%238482;%20\u0026copy;%202017%20Electronic%20Arts%20Inc.%20All%20Rights%20Reserved.%3Cbr%20/%3EThe%20Amazing%20World%20of%20Gumball%20is%20trademark%20and%20\u0026copy;%202017%20Cartoon%20Network.", | ||
"code_from_html":"Code.org%20uses%20p5.play,%20which%20is%20licensed%20under%20%3Ca%20href=%22http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html%22%3Ethe%20GNU%20LGPL%202.1%3C/a%3E.", | ||
"powered_by_aws":"Powered by Amazon Web Services", | ||
"trademark":"\u0026copy;%20Code.org,%202017.%20Code.org\u0026reg;,%20the%20CODE%20logo%20and%20Hour%20of%20Code\u0026reg;%20are%20trademarks%20of%20Code.org." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get these localizations from someplace?
const APP_OPTIONS = { | ||
"levelGameName":"Applab", | ||
"skinId":"applab", | ||
"baseUrl":"/blockly/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely we can get this URL in a DRY fashion?
"postFinalMilestone":true, | ||
"puzzleRatingsUrl":"/puzzle_ratings", | ||
"authoredHintViewRequestsUrl":"/authored_hint_view_requests.json", | ||
"serverLevelId":2176, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I. CAN'T. EVEN.
"callback":null, | ||
"sublevelCallback":null}, | ||
"sendToPhone":true, | ||
"send_to_phone_url":"http://localhost-studio.code.org:3000/sms/send", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should sendToPhone be a thing for exported projects?
"app":"applab", | ||
"droplet":true, | ||
"pretty":"", | ||
"level":{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how much of the level
object could be imported from applab/levels.js
}; | ||
|
||
Applab.render = function (){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not going to get solved here, but this indicates a need for a better division between App Lab the execution environment (interpreter, commands, student assets, etc) and App Lab the development environment (UI, editors, debugging, save/load, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
const options = getAppOptionsAtPath(APP_OPTIONS_WHITELIST, getAppOptions()); | ||
return `window.APP_OPTIONS = ${JSON.stringify(options)};`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could use a unit test, should document the expected format of the whitelist
argument, and could probably be simplified - especially if we can assume the whitelist grammar is strict (if you'll forgive the pseudo-BNF):
<whitelist> ::= Object.<string, value>
<value> ::= true | <whitelist>
Couldn't the inner method reduce to something like this?
function getAppOptionsAtPath(whitelist, sourceOptions) {
if (!whitelist || !sourceOptions) {
return null;
}
return _.reduce(whitelist, (memo, value, key) => {
if (value === true) {
memo[key] = sourceOptions[key];
} else if (typeof value === 'object' && typeof sourceOptions[key] === 'object') {
memo[key] = getAppOptionsAtPath(value, sourceOptions[key]);
}
return memo;
}, {});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if there was something like that in underscore. I like your version better :)
return; | ||
} | ||
if (typeof whitelist[key] === 'object') { | ||
const subOptions = getAppOptionsAtPath(whitelist[key], sourceOptions[key]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to pass null
into the recursive call here, which doesn't get caught before a sourceOptions[key]
call the next level down, which would cause a TypeError
.
"isLegacyShare": true, | ||
"postMilestone": true, | ||
"postFinalMilestone": true, | ||
"puzzleRatingsUrl": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a glance, things I'd try pulling from the whitelist:
- puzzleRatingsUrl
- authoredHintViewRequestsUrl
- serverLevelId
- labUserId
- firebaseName
- firebaseAuthToken
- firebaseChannelIdSuffix
- teacherMarkdown
This helps avoid log spew in exported projects that don't use the data apis anyway.
…cardune-export-screen-switch-bug
@@ -1,14 +1,138 @@ | |||
/* global dashboard */ | |||
import $ from 'jquery'; | |||
|
|||
import _ from 'underscore'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you mean lodash
?
"locale": true, | ||
}; | ||
|
||
export function getAppOptionsFile() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could still use a comment describing the correct whitelist format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after import change. 👍
Hopefully this will fix a whole slew of bugs.