@@ -26,7 +26,7 @@ export type SchemaExportState = {
2626 abortController ?: AbortController ;
2727 isOpen : boolean ;
2828 isLegacyBannerOpen : boolean ;
29- dontShowLegacyBanner : boolean ;
29+ legacyBannerChoice ?: 'legacy' | 'export' ;
3030 exportedSchema ?: string ;
3131 exportFormat : SchemaFormat ;
3232 errorMessage ?: string ;
@@ -42,15 +42,15 @@ const getInitialState = (): SchemaExportState => ({
4242 exportedSchema : undefined ,
4343 isOpen : false ,
4444 isLegacyBannerOpen : false ,
45- dontShowLegacyBanner : localStorage . getItem ( 'dontShowLegacyBanner' ) === 'true' ,
45+ legacyBannerChoice : undefined ,
4646} ) ;
4747
4848export const enum SchemaExportActions {
4949 openExportSchema = 'schema-service/schema-export/openExportSchema' ,
5050 closeExportSchema = 'schema-service/schema-export/closeExportSchema' ,
5151 openLegacyBanner = 'schema-service/schema-export/openLegacyBanner' ,
5252 closeLegacyBanner = 'schema-service/schema-export/closeLegacyBanner' ,
53- dontShowLegacyBanner = 'schema-service/schema-export/dontShowLegacyBanner ' ,
53+ setLegacyBannerChoice = 'schema-service/schema-export/setLegacyBannerChoice ' ,
5454 changeExportSchemaStatus = 'schema-service/schema-export/changeExportSchemaStatus' ,
5555 changeExportSchemaFormatStarted = 'schema-service/schema-export/changeExportSchemaFormatStarted' ,
5656 changeExportSchemaFormatComplete = 'schema-service/schema-export/changeExportSchemaFormatComplete' ,
@@ -300,14 +300,14 @@ export const schemaExportReducer: Reducer<SchemaExportState, Action> = (
300300 }
301301
302302 if (
303- isAction < dontShowLegacyBannerAction > (
303+ isAction < setLegacyBannerChoiceAction > (
304304 action ,
305- SchemaExportActions . dontShowLegacyBanner
305+ SchemaExportActions . setLegacyBannerChoice
306306 )
307307 ) {
308308 return {
309309 ...state ,
310- isLegacyBannerOpen : false ,
310+ legacyBannerChoice : action . choice ,
311311 } ;
312312 }
313313
@@ -373,14 +373,41 @@ export type openLegacyBannerAction = {
373373 type : SchemaExportActions . openLegacyBanner ;
374374} ;
375375
376+ export const openLegacyBanner = ( ) : SchemaThunkAction < void > => {
377+ return ( dispatch , getState ) => {
378+ const choiceInState = getState ( ) . schemaExport . legacyBannerChoice ;
379+ const savedChoice = choiceInState || localStorage . getItem ( localStorageId ) ;
380+ if ( savedChoice ) {
381+ if ( savedChoice !== choiceInState ) {
382+ dispatch ( {
383+ type : SchemaExportActions . setLegacyBannerChoice ,
384+ choice : savedChoice ,
385+ } ) ;
386+ }
387+ if ( savedChoice === 'legacy' ) {
388+ dispatch ( confirmedLegacySchemaShare ( ) ) ;
389+ return ;
390+ }
391+ if ( savedChoice === 'export' ) {
392+ dispatch ( openExportSchema ( ) ) ;
393+ return ;
394+ }
395+ }
396+ dispatch ( { type : SchemaExportActions . openLegacyBanner } ) ;
397+ } ;
398+ } ;
399+
376400export type closeLegacyBannerAction = {
377401 type : SchemaExportActions . closeLegacyBanner ;
378402} ;
379403
380- export type dontShowLegacyBannerAction = {
381- type : SchemaExportActions . dontShowLegacyBanner ;
404+ export type setLegacyBannerChoiceAction = {
405+ type : SchemaExportActions . setLegacyBannerChoice ;
406+ choice : 'legacy' | 'export' ;
382407} ;
383408
409+ const localStorageId = 'schemaExportLegacyBannerChoice' ;
410+
384411export const switchToSchemaExport = ( ) : SchemaThunkAction < void > => {
385412 return ( dispatch ) => {
386413 dispatch ( { type : SchemaExportActions . closeLegacyBanner } ) ;
@@ -439,9 +466,11 @@ export const _trackSchemaShared = (
439466 } ;
440467} ;
441468
442- export const stopShowingLegacyBanner = ( ) : SchemaThunkAction < void > => {
469+ export const stopShowingLegacyBanner = (
470+ choice : 'legacy' | 'export'
471+ ) : SchemaThunkAction < void > => {
443472 return ( dispatch ) => {
444- localStorage . setItem ( 'dontShowLegacyBanner' , 'true' ) ;
445- dispatch ( { type : SchemaExportActions . dontShowLegacyBanner } ) ;
473+ localStorage . setItem ( localStorageId , choice ) ;
474+ dispatch ( { type : SchemaExportActions . setLegacyBannerChoice , choice } ) ;
446475 } ;
447476} ;
0 commit comments