Skip to content

Commit

Permalink
fix: Enable blocks if user can't manually enable them. (#8354)
Browse files Browse the repository at this point in the history
* fix: Enable blocks if user can't manually enable them.

* Only change the affected test method.
  • Loading branch information
johnnesky authored Jul 22, 2024
1 parent 5cd3188 commit 40c6d9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,25 @@ export class Block implements IASTNodeLocation {
* update whether the block is currently disabled for this reason.
*/
setDisabledReason(disabled: boolean, reason: string): void {
// Workspaces that were serialized before the reason for being disabled
// could be specified may have blocks that are disabled without a known
// reason. On being loaded, these blocks will default to having the manually
// disabled reason. However, if the user isn't allowed to manually disable
// or enable blocks, then this manually disabled reason cannot be removed.
// For backward compatibility with these legacy workspaces, when removing
// any disabled reason and the workspace does not allow manually disabling
// but the block is manually disabled, then remove the manually disabled
// reason in addition to the more specific reason. For example, when an
// orphaned block is no longer orphaned, the block should be enabled again.
if (
!disabled &&
!this.workspace.options.disable &&
this.hasDisabledReason(constants.MANUALLY_DISABLED) &&
reason != constants.MANUALLY_DISABLED
) {
this.setDisabledReason(false, constants.MANUALLY_DISABLED);
}

if (this.disabledReasons.has(reason) !== disabled) {
if (disabled) {
this.disabledReasons.add(reason);
Expand Down
1 change: 1 addition & 0 deletions tests/mocha/blocks/procedures_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ suite('Procedures', function () {
'if a procedure caller block was already disabled before ' +
'its definition was disabled, it is not reenabled',
function () {
this.workspace.options.disable = true;
const defBlock = createProcDefBlock(this.workspace);
const callBlock = createProcCallBlock(this.workspace);
this.clock.runAll();
Expand Down

0 comments on commit 40c6d9c

Please sign in to comment.