From 6dcab2606473fccd3c6cc2eb509f83eb8edc3f8f Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 4 Aug 2022 23:30:09 +0000 Subject: [PATCH 1/3] feat: make isMutator public --- core/workspace.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/workspace.ts b/core/workspace.ts index 0782c0fe611..c1631d8991e 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -66,7 +66,6 @@ export class Workspace implements IASTNodeLocation { /** * Is this workspace the surface for a mutator? - * @internal */ isMutator = false; From 07522bf86461138442dfac75df21ecdf75251ffe Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 5 Aug 2022 16:13:31 +0000 Subject: [PATCH 2/3] fix: move isFlyout and isMutator to getters --- core/flyout_base.ts | 2 +- core/mutator.ts | 2 +- core/workspace.ts | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/flyout_base.ts b/core/flyout_base.ts index 547dac15ed8..94657ade3ec 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -255,7 +255,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.workspace_.setMetricsManager( new FlyoutMetricsManager(this.workspace_, this)); - this.workspace_.isFlyout = true; + this.workspace_.internalIsFlyout = true; // Keep the workspace visibility consistent with the flyout's visibility. this.workspace_.setVisible(this.isVisible_); diff --git a/core/mutator.ts b/core/mutator.ts index de85081c488..1d0ad364b85 100644 --- a/core/mutator.ts +++ b/core/mutator.ts @@ -191,7 +191,7 @@ export class Mutator extends Icon { workspaceOptions.languageTree = toolbox.convertToolboxDefToJson(quarkXml); } this.workspace_ = this.newWorkspaceSvg(workspaceOptions); - this.workspace_.isMutator = true; + this.workspace_.internalIsMutator = true; this.workspace_.addChangeListener(eventUtils.disableOrphans); // Mutator flyouts go inside the mutator workspace's rather than in diff --git a/core/workspace.ts b/core/workspace.ts index c1631d8991e..fca1ce771b6 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -61,13 +61,27 @@ export class Workspace implements IASTNodeLocation { */ rendered = false; + /** + * Is this workspace the surface for a flyout? + * @internal + */ + internalIsFlyout = false; + /** Is this workspace the surface for a flyout? */ - isFlyout = false; + get isFlyout(): boolean { + return this.internalIsFlyout; + } /** * Is this workspace the surface for a mutator? + * @internal */ - isMutator = false; + internalIsMutator = false; + + /** Is this workspace the surface for a mutator? */ + get isMutator(): boolean { + return this.internalIsMutator; + } /** * Returns `true` if the workspace is currently in the process of a bulk From a9038540d13dea8bca6f09cd3b01616c3157feaa Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 5 Aug 2022 22:12:28 +0000 Subject: [PATCH 3/3] chore: delete change detector test --- tests/mocha/workspace_svg_test.js | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/tests/mocha/workspace_svg_test.js b/tests/mocha/workspace_svg_test.js index 568b2d2adfe..d30374c10c0 100644 --- a/tests/mocha/workspace_svg_test.js +++ b/tests/mocha/workspace_svg_test.js @@ -124,48 +124,6 @@ suite('WorkspaceSvg', function() { }); }); - suite('addTopBlock', function() { - setup(function() { - this.targetWorkspace = new Blockly.Workspace(); - this.workspace.isFlyout = true; - this.workspace.targetWorkspace = this.targetWorkspace; - Blockly.defineBlocksWithJsonArray([{ - "type": "get_var_block", - "message0": "%1", - "args0": [ - { - "type": "field_variable", - "name": "VAR", - "variableTypes": ["", "type1", "type2"], - }, - ], - }]); - }); - - teardown(function() { - // Have to dispose of the main workspace after the flyout workspace - // because it holds the variable map. - // Normally the main workspace disposes of the flyout workspace. - workspaceTeardown.call(this, this.targetWorkspace); - }); - - test('Trivial Flyout is True', function() { - this.targetWorkspace.createVariable('name1', '', '1'); - - // Flyout.init usually does this binding. - this.workspace.variableMap_ = this.targetWorkspace.getVariableMap(); - - Blockly.Events.disable(); - const block = new Blockly.Block(this.workspace, 'get_var_block'); - block.inputList[0].fieldRow[0].setValue('1'); - Blockly.Events.enable(); - - this.workspace.removeTopBlock(block); - this.workspace.addTopBlock(block); - assertVariableValues(this.workspace, 'name1', '', '1'); - }); - }); - suite('Viewport change events', function() { function resetEventHistory(eventsFireStub, changeListenerSpy) { eventsFireStub.resetHistory();