@@ -19,14 +19,18 @@ import { IntlProvider } from 'react-intl';
19
19
import { connect , Provider } from 'react-redux' ;
20
20
import axios from 'axios' ;
21
21
import shortUUID from 'short-uuid' ;
22
- import { CommonCanvas , CanvasController , CommonProperties } from '@elyra/canvas' ;
22
+ import {
23
+ CommonCanvas ,
24
+ CanvasController ,
25
+ CommonProperties ,
26
+ } from '@elyra/canvas' ;
23
27
import { Button , Loading , Modal , Select } from 'carbon-components-react' ;
24
28
import {
25
29
Play32 ,
26
30
WarningAlt24 ,
27
31
DocumentDownload32 ,
28
32
Upload16 ,
29
- SettingsAdjust32
33
+ SettingsAdjust32 ,
30
34
} from '@carbon/icons-react' ;
31
35
import nlpPalette from '../config/nlpPalette.json' ;
32
36
import RHSPanel from './components/rhs-panel' ;
@@ -53,7 +57,7 @@ import {
53
57
setShowRightPanel ,
54
58
setShowDocumentViewer ,
55
59
setDirty ,
56
- setModuleName
60
+ setModuleName ,
57
61
} from '../redux/slice' ;
58
62
59
63
const TIMER_TICK = 250 ; // 1/4 second
@@ -100,13 +104,15 @@ class VisualEditor extends React.Component {
100
104
errorMessage : undefined ,
101
105
languageSelectModal : false ,
102
106
showSettings : false ,
103
- editorSettings : localStorage . getItem ( 'nlpEditorSettings' ) ? JSON . parse ( localStorage . getItem ( 'nlpEditorSettings' ) ) : {
104
- moduleName : 'elyraNLPCanvas' ,
105
- language : 'en'
106
- }
107
+ editorSettings : localStorage . getItem ( 'nlpEditorSettings' )
108
+ ? JSON . parse ( localStorage . getItem ( 'nlpEditorSettings' ) )
109
+ : {
110
+ moduleName : 'elyraNLPCanvas' ,
111
+ language : 'en' ,
112
+ } ,
107
113
} ;
108
114
109
- this . props . setModuleName ( this . state . editorSettings . moduleName ) ;
115
+ this . props . setModuleName ( this . state . editorSettings . moduleName ) ;
110
116
111
117
this . canvasController = new CanvasController ( ) ;
112
118
this . canvasController . openPalette ( ) ;
@@ -414,8 +420,8 @@ class VisualEditor extends React.Component {
414
420
this . props . setShowRightPanel ( { showPanel : true } ) ;
415
421
this . props . setShowDocumentViewer ( { showViewer : false } ) ;
416
422
this . setState ( {
417
- showSettings : true
418
- } )
423
+ showSettings : true ,
424
+ } ) ;
419
425
}
420
426
421
427
getToolbar = ( ) => {
@@ -522,12 +528,7 @@ class VisualEditor extends React.Component {
522
528
tooltip : 'Select Language' ,
523
529
jsx : (
524
530
< >
525
- < Button
526
- id = { 'btn-language' }
527
- size = "field"
528
- kind = "ghost"
529
- disabled
530
- >
531
+ < Button id = { 'btn-language' } size = "field" kind = "ghost" disabled >
531
532
Language ({ languages [ this . getCurrentLanguage ( ) ] } )
532
533
</ Button >
533
534
</ >
@@ -665,61 +666,67 @@ class VisualEditor extends React.Component {
665
666
parameterDef : {
666
667
titleDefinition : {
667
668
title : 'NLP Settings' ,
668
- editable : false
669
+ editable : false ,
669
670
} ,
670
671
current_parameters : {
671
672
moduleName : this . state . editorSettings . moduleName ,
672
- language : this . getCurrentLanguage ( )
673
+ language : this . getCurrentLanguage ( ) ,
673
674
} ,
674
- parameters : [ {
675
- id : 'moduleName' ,
676
- type : 'string' ,
677
- default : ''
678
- } , {
679
- id : 'language' ,
680
- type : 'string'
681
- } ] ,
675
+ parameters : [
676
+ {
677
+ id : 'moduleName' ,
678
+ type : 'string' ,
679
+ default : '' ,
680
+ } ,
681
+ {
682
+ id : 'language' ,
683
+ type : 'string' ,
684
+ } ,
685
+ ] ,
682
686
uihints : {
683
687
id : 'Settings' ,
684
688
editor_size : 'medium' ,
685
689
label : {
686
- default : 'General Settings'
690
+ default : 'General Settings' ,
687
691
} ,
688
- parameter_info : [ {
689
- parameter_ref : 'moduleName' ,
690
- label : {
691
- default : 'Module Name'
692
+ parameter_info : [
693
+ {
694
+ parameter_ref : 'moduleName' ,
695
+ label : {
696
+ default : 'Module Name' ,
697
+ } ,
698
+ description : {
699
+ default : 'Module Name' ,
700
+ } ,
692
701
} ,
693
- description : {
694
- default : 'Module Name'
695
- }
696
- } ] ,
697
- action_info : [ {
698
- id : 'language ' ,
699
- label : {
700
- default : 'Select Language'
702
+ ] ,
703
+ action_info : [
704
+ {
705
+ id : 'language' ,
706
+ label : {
707
+ default : 'Select Language ' ,
708
+ } ,
709
+ control : 'button' ,
701
710
} ,
702
- control : 'button'
703
- } ] ,
704
- group_info : [ {
705
- id : 'settings' ,
706
- label : {
707
- default : 'Settings'
711
+ ] ,
712
+ group_info : [
713
+ {
714
+ id : 'settings' ,
715
+ label : {
716
+ default : 'Settings' ,
717
+ } ,
718
+ parameter_refs : [ 'moduleName' ] ,
708
719
} ,
709
- parameter_refs : [
710
- 'moduleName'
711
- ] ,
712
- } , {
713
- id : 'lang' ,
714
- label : {
715
- default : 'Language'
720
+ {
721
+ id : 'lang' ,
722
+ label : {
723
+ default : 'Language' ,
724
+ } ,
725
+ type : 'actionPanel' ,
726
+ action_refs : [ 'language' ] ,
716
727
} ,
717
- type : 'actionPanel' ,
718
- action_refs : [
719
- 'language'
720
- ] ,
721
- } ]
722
- }
728
+ ] ,
729
+ } ,
723
730
} ,
724
731
} ;
725
732
}
@@ -740,35 +747,41 @@ class VisualEditor extends React.Component {
740
747
ref = { ( instance ) => {
741
748
this . CommonProperties = instance ;
742
749
} }
743
- propertiesConfig = { { containerType : " Custom" , rightFlyout : true } }
750
+ propertiesConfig = { { containerType : ' Custom' , rightFlyout : true } }
744
751
propertiesInfo = { this . getPropertiesInfo ( ) } // required
745
752
callbacks = { {
746
753
applyPropertyChanges : ( propertySet ) => {
747
754
this . setState ( {
748
755
editorSettings : {
749
- moduleName : propertySet . moduleName
750
- }
756
+ moduleName : propertySet . moduleName ,
757
+ } ,
751
758
} ) ;
752
- this . props . setModuleName ( propertySet . moduleName ) ;
753
- localStorage . setItem ( 'nlpEditorSettings' , JSON . stringify ( { ...this . state . editorSettings , ...propertySet } ) ) ;
759
+ this . props . setModuleName ( propertySet . moduleName ) ;
760
+ localStorage . setItem (
761
+ 'nlpEditorSettings' ,
762
+ JSON . stringify ( {
763
+ ...this . state . editorSettings ,
764
+ ...propertySet ,
765
+ } ) ,
766
+ ) ;
754
767
} ,
755
768
closePropertiesDialog : ( ) => {
756
769
this . props . setShowRightPanel ( { showPanel : false } ) ;
757
770
this . setState ( {
758
- showSettings : false
771
+ showSettings : false ,
759
772
} ) ;
760
773
} ,
761
774
actionHandler : ( id , appData , data ) => {
762
- switch ( id ) {
775
+ switch ( id ) {
763
776
case 'language' :
764
777
this . setState ( { languageSelectModal : true } ) ;
765
778
break ;
766
779
}
767
- }
780
+ } ,
768
781
} } // required
769
782
light // optional
770
783
> </ CommonProperties >
771
- )
784
+ ) ;
772
785
}
773
786
return (
774
787
< Provider store = { store } >
@@ -790,10 +803,16 @@ class VisualEditor extends React.Component {
790
803
this . setCurrentLanguage ( language ) ;
791
804
const editorSettings = {
792
805
...this . state . editorSettings ,
793
- ...{ language : language }
806
+ ...{ language : language } ,
794
807
} ;
795
- this . setState ( { languageSelectModal : false , editorSettings : editorSettings } ) ;
796
- localStorage . setItem ( 'nlpEditorSettings' , JSON . stringify ( editorSettings ) ) ;
808
+ this . setState ( {
809
+ languageSelectModal : false ,
810
+ editorSettings : editorSettings ,
811
+ } ) ;
812
+ localStorage . setItem (
813
+ 'nlpEditorSettings' ,
814
+ JSON . stringify ( editorSettings ) ,
815
+ ) ;
797
816
} }
798
817
onRequestClose = { ( ) => {
799
818
this . setState ( { languageSelectModal : false } ) ;
@@ -897,7 +916,7 @@ const mapDispatchToProps = (dispatch) => ({
897
916
setShowRightPanel : ( doShow ) => dispatch ( setShowRightPanel ( doShow ) ) ,
898
917
setShowDocumentViewer : ( doShow ) => dispatch ( setShowDocumentViewer ( doShow ) ) ,
899
918
setDirty : ( dirty ) => dispatch ( setDirty ( dirty ) ) ,
900
- setModuleName : ( name ) => dispatch ( setModuleName ( name ) )
919
+ setModuleName : ( name ) => dispatch ( setModuleName ( name ) ) ,
901
920
} ) ;
902
921
903
922
export default connect ( mapStateToProps , mapDispatchToProps ) ( VisualEditor ) ;
0 commit comments