You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conststopGraph=useCallback(async()=>{// this may await forever, if some component have process that haven't call `output.done()` or return without calling `this.deactivate(context)`.awaitcurrentNetworkReference.current?.stop();setGraphIsRunning(false);},[]);
/* eslint-disable @typescript-eslint/strict-boolean-expressions *//* eslint-disable unicorn/no-null, @typescript-eslint/require-await */// Load the NoFlo interfaceimport{getDataOrDefault}from'@/pages/Workflow/GraphEditor/utils/getDataOrDefault';import{Component}from'noflo';importtype{ITextFieldProps,UIEffectsContext}from'../types/UIEffectsContext';exportconstgetComponent=()=>newTextField();classTextFieldextendsComponent{description='Wait for user input some text.';icon='commenting-o';uiElementID?: string;uiEffects?: UIEffectsContext;defaultValues: Record<string,string>={};constructor(){super();// Define the component's inportsthis.inPorts.add('control',{datatype: 'bang',description: 'Trigger the input box to show.',});this.inPorts.add('label',{datatype: 'string',description: 'Name of this input, should be a short text.',required: true,});this.inPorts.add('desc',{datatype: 'string',description: 'Description text show on the input box. Can be a one line long text.',});this.inPorts.add('intro',{datatype: 'string',description: 'Introduction text show before the input box. Can be a multiple line long text.',});this.inPorts.add('placeholder',{datatype: 'string',description: 'Text to display when the input box is empty.',});this.inPorts.add('ui_effects',{datatype: 'object',description: 'Used by system, inject UI related methods.',required: true,});this.outPorts.add('out',{datatype: 'string',});// Register a process handler for incoming datathis.process((input,output,context)=>{this.uiEffects??=input.getData('ui_effects')asUIEffectsContext|undefined;if(this.uiEffects===undefined){this.deactivate(context);return;}// If 'in' port is not triggered, returnif(!input.hasData('control')){this.deactivate(context);return;}constcontrol=input.getData('control')asundefined|null|true;// rapidly receive null here, still stuckif(control!==true){this.deactivate(context);return;}constprops: ITextFieldProps={label: getDataOrDefault('label',input,this.defaultValues),description: getDataOrDefault('desc',input,this.defaultValues),introduction: getDataOrDefault('intro',input,this.defaultValues),placeholder: getDataOrDefault('placeholder',input,this.defaultValues),};// If we already have an UI element created, update it. Otherwise, create a new one.if(this.uiElementID===undefined){this.uiElementID=this.uiEffects.addElement({type: 'textField', props });// wait for result, and sent to outPort// TODO: change to async await when https://github.com/noflo/noflo/issues/1047 is fixed.voidthis.uiEffects.onSubmit(this.uiElementID).then(resultText=>{this.uiElementID=undefined;output.sendDone({out: resultText});});}else{this.uiEffects.updateElementProps({id: this.uiElementID, props });this.deactivate(context);}});}asynctearDown(){if(this.uiElementID!==undefined){// set to submit statethis.uiEffects?.submitElement?.(this.uiElementID,null);}}}
I found:
So in my component I have to write alog of
for example:
This is annoying. Combine with #1047 , I think process API need some upgrade @bergie @trustmaster @jonnor what do you think?
The text was updated successfully, but these errors were encountered: