-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36401 from code-dot-org/test
Test
- Loading branch information
Showing
47 changed files
with
2,089 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Removes the parent email from the student's account. | ||
*/ | ||
export default class RemoveParentEmailController { | ||
/** | ||
* @param {jQuery} form The form which sets the parent email to nil. | ||
* @param {jQuery} link The link the student clicks in order to remove the parent email address from their account. | ||
*/ | ||
constructor({form, link}) { | ||
this.form = form; | ||
link.click(event => { | ||
event.preventDefault(); | ||
form.submit(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Blockly from '@code-dot-org/blockly'; | ||
import CDOBlockly from '@code-dot-org/blockly'; | ||
import initializeCdoBlocklyWrapper from './cdoBlocklyWrapper'; | ||
|
||
window.Blockly = initializeCdoBlocklyWrapper(Blockly); | ||
window.Blockly = initializeCdoBlocklyWrapper(CDOBlockly); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
import {BlocklyVersion} from '@cdo/apps/constants'; | ||
/** | ||
* Wrapper class for https://github.com/google/blockly | ||
* This wrapper will facilitate migrating from CDO Blockly to Google Blockly | ||
* by allowing us to unify the APIs so that we can switch out the underlying Blockly | ||
* object without affecting apps code. | ||
* This wrapper will contain all of our customizations to Google Blockly. | ||
* See also ./cdoBlocklyWrapper.js | ||
*/ | ||
const BlocklyWrapper = function(blocklyInstance) { | ||
this.version = BlocklyVersion.GOOGLE; | ||
this.blockly_ = blocklyInstance; | ||
this.wrapReadOnlyProperty = function(propertyName) { | ||
Object.defineProperty(this, propertyName, { | ||
get: function() { | ||
return this.blockly_[propertyName]; | ||
} | ||
}); | ||
}; | ||
this.wrapSettableProperty = function(propertyName) { | ||
Object.defineProperty(this, propertyName, { | ||
get: function() { | ||
return this.blockly_[propertyName]; | ||
}, | ||
set: function(newValue) { | ||
this.blockly_[propertyName] = newValue; | ||
} | ||
}); | ||
}; | ||
}; | ||
|
||
function initializeBlocklyWrapper(blocklyInstance) { | ||
const blocklyWrapper = new BlocklyWrapper(blocklyInstance); | ||
|
||
blocklyWrapper.wrapReadOnlyProperty('ALIGN_CENTRE'); | ||
blocklyWrapper.wrapReadOnlyProperty('ALIGN_LEFT'); | ||
blocklyWrapper.wrapReadOnlyProperty('ALIGN_RIGHT'); | ||
blocklyWrapper.wrapReadOnlyProperty('applab_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('bindEvent_'); | ||
blocklyWrapper.wrapReadOnlyProperty('Block'); | ||
blocklyWrapper.wrapReadOnlyProperty('BlockFieldHelper'); | ||
blocklyWrapper.wrapReadOnlyProperty('Blocks'); | ||
blocklyWrapper.wrapReadOnlyProperty('BlockSvg'); | ||
blocklyWrapper.wrapReadOnlyProperty('BlockValueType'); | ||
blocklyWrapper.wrapReadOnlyProperty('common_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('Connection'); | ||
blocklyWrapper.wrapReadOnlyProperty('contractEditor'); | ||
blocklyWrapper.wrapReadOnlyProperty('createSvgElement'); | ||
blocklyWrapper.wrapReadOnlyProperty('Css'); | ||
blocklyWrapper.wrapReadOnlyProperty('disableVariableEditing'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldAngleDropdown'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldAngleInput'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldAngleTextInput'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldButton'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldColour'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldColourDropdown'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldDropdown'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldIcon'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldImage'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldImageDropdown'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldLabel'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldParameter'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldRectangularDropdown'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldTextInput'); | ||
blocklyWrapper.wrapReadOnlyProperty('FieldVariable'); | ||
blocklyWrapper.wrapReadOnlyProperty('fireUiEvent'); | ||
blocklyWrapper.wrapReadOnlyProperty('fish_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('Flyout'); | ||
blocklyWrapper.wrapReadOnlyProperty('FunctionalBlockUtils'); | ||
blocklyWrapper.wrapReadOnlyProperty('FunctionalTypeColors'); | ||
blocklyWrapper.wrapReadOnlyProperty('FunctionEditor'); | ||
blocklyWrapper.wrapReadOnlyProperty('functionEditor'); | ||
blocklyWrapper.wrapReadOnlyProperty('gamelab_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('Generator'); | ||
blocklyWrapper.wrapReadOnlyProperty('getRelativeXY'); | ||
blocklyWrapper.wrapReadOnlyProperty('googlecode'); | ||
blocklyWrapper.wrapReadOnlyProperty('hasCategories'); | ||
blocklyWrapper.wrapReadOnlyProperty('html'); | ||
blocklyWrapper.wrapReadOnlyProperty('inject'); | ||
blocklyWrapper.wrapReadOnlyProperty('Input'); | ||
blocklyWrapper.wrapReadOnlyProperty('INPUT_VALUE'); | ||
blocklyWrapper.wrapReadOnlyProperty('js'); | ||
blocklyWrapper.wrapReadOnlyProperty('modalBlockSpace'); | ||
blocklyWrapper.wrapReadOnlyProperty('Msg'); | ||
blocklyWrapper.wrapReadOnlyProperty('Names'); | ||
blocklyWrapper.wrapReadOnlyProperty('netsim_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('Procedures'); | ||
blocklyWrapper.wrapReadOnlyProperty('removeChangeListener'); | ||
blocklyWrapper.wrapReadOnlyProperty('RTL'); | ||
blocklyWrapper.wrapReadOnlyProperty('tutorialExplorer_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('useContractEditor'); | ||
blocklyWrapper.wrapReadOnlyProperty('useModalFunctionEditor'); | ||
blocklyWrapper.wrapReadOnlyProperty('Variables'); | ||
blocklyWrapper.wrapReadOnlyProperty('weblab_locale'); | ||
blocklyWrapper.wrapReadOnlyProperty('Workspace'); | ||
|
||
// These are also wrapping read only properties, but can't use wrapReadOnlyProperty | ||
// because the alias name is not the same as the underlying property name. | ||
Object.defineProperty(blocklyWrapper, 'mainBlockSpace', { | ||
get: function() { | ||
return this.blockly_.mainWorkspace; | ||
} | ||
}); | ||
Object.defineProperty(blocklyWrapper, 'mainBlockSpaceEditor', { | ||
get: function() { | ||
return this.blockly_.mainWorkspace; | ||
} | ||
}); | ||
Object.defineProperty(blocklyWrapper, 'SVG_NS', { | ||
get: function() { | ||
return this.blockly_.utils.dom.SVG_NS; | ||
} | ||
}); | ||
|
||
blocklyWrapper.wrapSettableProperty('assetUrl'); | ||
blocklyWrapper.wrapSettableProperty('behaviorEditor'); | ||
blocklyWrapper.wrapSettableProperty('BROKEN_CONTROL_POINTS'); | ||
blocklyWrapper.wrapSettableProperty('BUMP_UNCONNECTED'); | ||
blocklyWrapper.wrapSettableProperty('HSV_SATURATION'); | ||
blocklyWrapper.wrapSettableProperty('JavaScript'); | ||
blocklyWrapper.wrapSettableProperty('readOnly'); | ||
blocklyWrapper.wrapSettableProperty('showUnusedBlocks'); | ||
blocklyWrapper.wrapSettableProperty('SNAP_RADIUS'); | ||
blocklyWrapper.wrapSettableProperty('typeHints'); | ||
blocklyWrapper.wrapSettableProperty('valueTypeTabShapeMap'); | ||
blocklyWrapper.wrapSettableProperty('Xml'); | ||
|
||
blocklyWrapper.getGenerator = function() { | ||
return this.JavaScript; | ||
}; | ||
blocklyWrapper.findEmptyContainerBlock = function() {}; // TODO | ||
blocklyWrapper.BlockSpace = { | ||
EVENTS: { | ||
MAIN_BLOCK_SPACE_CREATED: 'mainBlockSpaceCreated', | ||
EVENT_BLOCKS_IMPORTED: 'blocksImported', | ||
BLOCK_SPACE_CHANGE: 'blockSpaceChange', | ||
BLOCK_SPACE_SCROLLED: 'blockSpaceScrolled', | ||
RUN_BUTTON_CLICKED: 'runButtonClicked' | ||
}, | ||
onMainBlockSpaceCreated: () => {}, // TODO | ||
createReadOnlyBlockSpace: () => {} // TODO | ||
}; | ||
|
||
// CDO Blockly titles are equivalent to Google Blockly fields. | ||
blocklyWrapper.Block.prototype.getTitles = function() { | ||
let fields = []; | ||
this.inputList.forEach(input => { | ||
input.fieldRow.forEach(field => { | ||
fields.push(field); | ||
}); | ||
}); | ||
return fields; | ||
}; | ||
blocklyWrapper.Block.prototype.getTitleValue = | ||
blocklyWrapper.Block.prototype.getFieldValue; | ||
blocklyWrapper.Block.prototype.isUserVisible = () => false; // TODO | ||
// Google Blockly only allows you to set the hue, not saturation or value. | ||
// TODO: determine if this will work for us, or if there's a workaround to | ||
// allow us to keep our colors the same | ||
blocklyWrapper.Block.prototype.setHSV = function(h, s, v) { | ||
return this.setColour(h); | ||
}; | ||
|
||
// This function was a custom addition in CDO Blockly, so we need to add it here | ||
// so that our code generation logic still works with Google Blockly | ||
blocklyWrapper.Generator.blockSpaceToCode = function(name, opt_typeFilter) { | ||
let blocksToGenerate = blocklyWrapper.mainBlockSpace.getTopBlocks( | ||
true /* ordered */ | ||
); | ||
if (opt_typeFilter) { | ||
if (typeof opt_typeFilter === 'string') { | ||
opt_typeFilter = [opt_typeFilter]; | ||
} | ||
blocksToGenerate = blocksToGenerate.filter(block => | ||
opt_typeFilter.includes(block.type) | ||
); | ||
} | ||
let code = []; | ||
blocksToGenerate.forEach(block => { | ||
code.push(blocklyWrapper.JavaScript.blockToCode(block)); | ||
}); | ||
return code.join('\n'); | ||
}; | ||
|
||
blocklyWrapper.Input.prototype.appendTitle = function(a, b) { | ||
return this.appendField(a, b); | ||
}; | ||
|
||
blocklyWrapper.Workspace.prototype.getToolboxWidth = function() { | ||
return blocklyWrapper.mainBlockSpace.getMetrics().toolboxWidth; | ||
}; | ||
blocklyWrapper.Workspace.prototype.addUnusedBlocksHelpListener = () => {}; // TODO | ||
blocklyWrapper.Workspace.prototype.getAllUsedBlocks = | ||
blocklyWrapper.Workspace.prototype.getAllBlocks; // TODO | ||
blocklyWrapper.Workspace.prototype.isReadOnly = () => false; // TODO | ||
blocklyWrapper.Workspace.prototype.setEnableToolbox = () => {}; // TODO | ||
blocklyWrapper.Workspace.prototype.blockSpaceEditor = { | ||
blockLimits: { | ||
blockLimitExceeded: () => false, // TODO | ||
getLimit: () => {} // TODO | ||
} | ||
}; | ||
|
||
// Aliasing Google's blockToDom() so that we can override it, but still be able | ||
// to call Google's blockToDom() in the override function. | ||
blocklyWrapper.Xml.originalBlockToDom = blocklyWrapper.Xml.blockToDom; | ||
blocklyWrapper.Xml.blockToDom = function(block, ignoreChildBlocks) { | ||
const blockXml = blocklyWrapper.Xml.originalBlockToDom(block); | ||
if (ignoreChildBlocks) { | ||
Blockly.Xml.deleteNext(blockXml); | ||
} | ||
return blockXml; | ||
}; | ||
|
||
blocklyWrapper.Xml = { | ||
...blocklyWrapper.Xml, | ||
domToBlockSpace: blocklyWrapper.Xml.domToWorkspace, | ||
blockSpaceToDom: blocklyWrapper.Xml.workspaceToDom | ||
}; | ||
|
||
return blocklyWrapper; | ||
} | ||
|
||
module.exports = initializeBlocklyWrapper; |
Oops, something went wrong.