@@ -364,6 +364,7 @@ QueryCompTmp = class extends QueryCompTmp {
364
364
if ( action . type === CompActionTypes . EXECUTE_QUERY ) {
365
365
if ( getReduceContext ( ) . disableUpdateState ) return this ;
366
366
if ( ! action . args ) action . args = this . children . variables . children . variables . toJsonValue ( ) . reduce ( ( acc , curr ) => Object . assign ( acc , { [ curr . key as string ] :curr . value } ) , { } ) ;
367
+ action . args . $queryName = this . children . name . getView ( ) ;
367
368
368
369
return this . executeQuery ( action ) ;
369
370
}
@@ -673,8 +674,8 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
673
674
return undefined ;
674
675
}
675
676
const newNode = Object . values ( input . data )
676
- . filter ( ( kvNode : any ) => kvNode . key . value )
677
- . map ( ( kvNode : any ) => ( { [ kvNode . key . value ] : kvNode . value . value } ) )
677
+ . filter ( ( kvNode : any ) => kvNode . key )
678
+ . map ( ( kvNode : any ) => ( { [ kvNode . key ] : kvNode . value } ) )
678
679
. reduce ( ( prev , obj ) => ( { ...prev , ...obj } ) , { } ) ;
679
680
return newNode ;
680
681
} ,
@@ -773,12 +774,24 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
773
774
if ( ! originQuery ) {
774
775
return ;
775
776
}
777
+
778
+ const jsonData = originQuery . toJsonValue ( ) ;
779
+ //Regenerate variable header
780
+ jsonData . variables ?. variables ?. forEach ( kv => {
781
+ const [ prefix , _ ] = ( kv . key as string ) . split ( / (? = \d + $ ) / ) ;
782
+ let i = 1 , newName = "" ;
783
+ do {
784
+ newName = prefix + ( i ++ ) ;
785
+ } while ( editorState . checkRename ( "" , newName ) ) ;
786
+ kv . key = newName ;
787
+ } )
788
+
776
789
const newQueryName = this . genNewName ( editorState ) ;
777
790
const id = genQueryId ( ) ;
778
791
this . dispatch (
779
792
wrapActionExtraInfo (
780
793
this . pushAction ( {
781
- ...originQuery . toJsonValue ( ) ,
794
+ ...jsonData ,
782
795
id : id ,
783
796
name : newQueryName ,
784
797
isNewCreate : true ,
@@ -789,7 +802,7 @@ class QueryListComp extends QueryListTmpComp implements BottomResListComp {
789
802
{
790
803
type : "add" ,
791
804
compName : name ,
792
- compType : originQuery . children . compType . getView ( ) ,
805
+ compType : jsonData . compType ,
793
806
} ,
794
807
] ,
795
808
}
0 commit comments