Skip to content

Commit

Permalink
use beta editor flag to switch variable editor as well
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 7, 2023
1 parent 1a437d0 commit 85807ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
[tabSize]="tabSize"
[showVariableDialog]="showVariableDialog"
[enableExperimental]="enableExperimental"
[betaDisableNewEditor]="betaDisableNewEditor"
(variablesChange)="variablesChange.emit($event)"
></app-variables-editor>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<app-codemirror
*ngIf="enableExperimental"
*ngIf="!betaDisableNewEditor"
#newEditor
class="set-variable-textarea mousetrap"
[extensions]="editorExtensions"
[ngModel]="variables"
(ngModelChange)="variablesChange.emit($event)"
></app-codemirror>
<ngx-codemirror
*ngIf="!enableExperimental"
*ngIf="betaDisableNewEditor"
#editor
class="set-variable-textarea mousetrap"
[options]="variableEditorConfig"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class VariablesEditorComponent implements AfterViewInit, OnChanges {
@Input() tabSize = 4;
@Input() showVariableDialog = false;
@Input() enableExperimental = false;
@Input() betaDisableNewEditor = true;

@Output() variablesChange = new EventEmitter();

Expand Down Expand Up @@ -115,6 +116,19 @@ export class VariablesEditorComponent implements AfterViewInit, OnChanges {
) {
handleEditorRefresh(this.editor?.codeMirror);
}

if (changes?.betaDisableNewEditor) {
// Using timeout to wait for editor to be initialized.
// This is hacky but should be fine since the beta should be temporary
setTimeout(() => {
if (this.newEditor?.view) {
updateSchema(
this.newEditor.view,
vttToJsonSchema(this.variableToType)
);
}
}, 10);
}
}

onKeyUp(cm: CodeMirror.Editor, event: KeyboardEvent) {
Expand Down

0 comments on commit 85807ef

Please sign in to comment.