Skip to content

Commit

Permalink
Make dfd output port edit ui work without label feature
Browse files Browse the repository at this point in the history
For gdpr-editor where the label feature is disabled.
  • Loading branch information
hlxid committed Jan 28, 2024
1 parent 4c01a61 commit 15a2e7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/features/dfdElements/outputPortEditUi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inject, injectable } from "inversify";
import { inject, injectable, optional } from "inversify";
import {
AbstractUIExtension,
ActionDispatcher,
Expand Down Expand Up @@ -132,7 +132,7 @@ const dfdBehaviorLanguageMonarchDefinition: monaco.languages.IMonarchLanguage =
class MonacoEditorDfdBehaviorCompletionProvider implements monaco.languages.CompletionItemProvider {
constructor(
private readonly ui: OutputPortEditUI,
private readonly labelTypeRegistry: LabelTypeRegistry,
private readonly labelTypeRegistry?: LabelTypeRegistry,
) {}

// Auto open completions after typing a dot. Useful for the set statement where
Expand Down Expand Up @@ -290,7 +290,7 @@ class MonacoEditorDfdBehaviorCompletionProvider implements monaco.languages.Comp
model: monaco.editor.ITextModel,
position: monaco.Position,
): monaco.languages.CompletionItem[] {
const availableLabelTypes = this.labelTypeRegistry.getLabelTypes();
const availableLabelTypes = this.labelTypeRegistry?.getLabelTypes() ?? [];
const currentWord = model.getWordUntilPosition(position);

return availableLabelTypes.map((labelType) => ({
Expand All @@ -312,7 +312,7 @@ class MonacoEditorDfdBehaviorCompletionProvider implements monaco.languages.Comp
labelTypeName: string,
): monaco.languages.CompletionItem[] {
const labelType = this.labelTypeRegistry
.getLabelTypes()
?.getLabelTypes()
.find((labelType) => labelType.name === labelTypeName.trim());
if (!labelType) {
return [];
Expand Down Expand Up @@ -353,7 +353,7 @@ export class OutputPortEditUI extends AbstractUIExtension {
@inject(TYPES.ViewerOptions) private viewerOptions: ViewerOptions,
@inject(TYPES.DOMHelper) private domHelper: DOMHelper,
@inject(PortBehaviorValidator) private validator: PortBehaviorValidator,
@inject(LabelTypeRegistry) private labelTypeRegistry: LabelTypeRegistry,
@inject(LabelTypeRegistry) @optional() private labelTypeRegistry?: LabelTypeRegistry,
) {
super();
}
Expand Down

0 comments on commit 15a2e7a

Please sign in to comment.