@@ -59,6 +59,8 @@ export class AddDataStateManager {
5959 private onStepChange : ( ( step : AddDataStep ) => void ) | undefined = undefined ;
6060 private config : AddDataConfig | undefined = undefined ;
6161
62+ private lastTransitionTime : number = 0 ;
63+
6264 public setCallbacks (
6365 onDone : ( ( ) => void ) | undefined ,
6466 onClose : ( ( ) => void ) | undefined ,
@@ -98,7 +100,7 @@ export class AddDataStateManager {
98100 case AddDataStep . SelectConnector : {
99101 if ( event . type === TransitionEventType . Back ) {
100102 this . popState ( ) ;
101- return ;
103+ break ;
102104 }
103105 if ( event . type !== TransitionEventType . SchemaSelected ) return ;
104106 const newState = getStepForSchema ( event . schema , event . driver ) ;
@@ -115,7 +117,7 @@ export class AddDataStateManager {
115117 { step : AddDataStep . CreateConnector , schema : this . state . schema } ,
116118 ) ;
117119 this . popState ( ) ;
118- return ;
120+ break ;
119121 }
120122 if ( event . type !== TransitionEventType . ConnectorSelected ) return ;
121123 const newState = getStepForConnector (
@@ -144,7 +146,7 @@ export class AddDataStateManager {
144146 } ,
145147 ) ;
146148 this . popState ( ) ;
147- return ;
149+ break ;
148150
149151 // CreateModel/ExploreConnector =={ImportConfigured event}=> Import
150152 case TransitionEventType . ImportConfigured :
@@ -190,7 +192,7 @@ export class AddDataStateManager {
190192 } ) ;
191193 // Can be back to Init/CreateModel/ExploreConnector
192194 this . popState ( ) ;
193- return ;
195+ break ;
194196 }
195197 if ( event . type !== TransitionEventType . Imported ) return ;
196198 this . pushState ( {
@@ -199,44 +201,51 @@ export class AddDataStateManager {
199201 break ;
200202 }
201203
202- switch ( this . state . step ) {
203- case AddDataStep . CreateConnector :
204- this . fireBehaviourEvent (
205- BehaviourEventAction . ConnectorConfigurationStarted ,
206- {
207- step : AddDataStep . CreateConnector ,
208- schema : this . state . schema ,
209- } ,
210- ) ;
211- break ;
204+ if ( event . type !== TransitionEventType . Back ) {
205+ switch ( this . state . step ) {
206+ case AddDataStep . CreateConnector :
207+ this . fireBehaviourEvent (
208+ BehaviourEventAction . ConnectorConfigurationStarted ,
209+ {
210+ step : AddDataStep . CreateConnector ,
211+ schema : this . state . schema ,
212+ } ,
213+ ) ;
214+ break ;
212215
213- case AddDataStep . CreateModel :
214- this . fireBehaviourEvent (
215- BehaviourEventAction . ModelConfigurationStarted ,
216- {
217- step : AddDataStep . CreateModel ,
218- schema : this . state . schema ,
219- connector : this . state . connector ,
220- } ,
221- ) ;
222- break ;
216+ case AddDataStep . CreateModel :
217+ this . fireBehaviourEvent (
218+ BehaviourEventAction . ModelConfigurationStarted ,
219+ {
220+ step : AddDataStep . CreateModel ,
221+ schema : this . state . schema ,
222+ connector : this . state . connector ,
223+ } ,
224+ ) ;
225+ break ;
223226
224- case AddDataStep . ExploreConnector :
225- this . fireBehaviourEvent ( BehaviourEventAction . ConnectorExploreStarted , {
226- step : AddDataStep . Import ,
227- schema : this . state . schema ,
228- connector : this . state . connector ,
229- } ) ;
230- break ;
227+ case AddDataStep . ExploreConnector :
228+ this . fireBehaviourEvent (
229+ BehaviourEventAction . ConnectorExploreStarted ,
230+ {
231+ step : AddDataStep . Import ,
232+ schema : this . state . schema ,
233+ connector : this . state . connector ,
234+ } ,
235+ ) ;
236+ break ;
231237
232- case AddDataStep . Import :
233- this . fireBehaviourEvent ( BehaviourEventAction . ImportStarted , {
234- step : AddDataStep . Import ,
235- schema : this . state . schema ,
236- connector : this . state . config . connector ,
237- } ) ;
238- break ;
238+ case AddDataStep . Import :
239+ this . fireBehaviourEvent ( BehaviourEventAction . ImportStarted , {
240+ step : AddDataStep . Import ,
241+ schema : this . state . schema ,
242+ connector : this . state . config . connector ,
243+ } ) ;
244+ break ;
245+ }
239246 }
247+
248+ this . lastTransitionTime = Date . now ( ) ;
240249 }
241250
242251 private pushState ( state : AddDataState ) {
@@ -252,6 +261,8 @@ export class AddDataStateManager {
252261 this . state = this . stateStack . pop ( ) ?? { step : AddDataStep . Init } ;
253262 if ( this . stateStack . length === 0 ) this . onClose ?.( ) ;
254263 this . onStepChange ?.( this . state . step ) ;
264+
265+ this . lastTransitionTime = Date . now ( ) ;
255266 }
256267
257268 // For lateral state change, going back is not supported.
@@ -265,12 +276,15 @@ export class AddDataStateManager {
265276 fields : AddDataBehaviourEventFields ,
266277 ) {
267278 if ( ! this . config ) return ;
279+ const duration = this . lastTransitionTime
280+ ? Date . now ( ) - this . lastTransitionTime
281+ : 0 ;
268282 void behaviourEvent ?. fireAddDataStepEvent (
269283 action ,
270284 this . config . medium ,
271285 this . config . space ,
272286 this . config . screen ,
273- fields ,
287+ { ... fields , duration } ,
274288 ) ;
275289 }
276290}
0 commit comments