import { SampleDataRegistrySetup } from '../../../../../src/plugins/home/server' ; import { registerLogsSampleData , registerLogsSampleDataLink } from './logs' ; import { registerEcommerceSampleData , registerEcommerceSampleDataLink } from './ecommerce' ; import { registerFlightsSampleData , registerFlightsSampleDataLink } from './flights' ; import { LicenseState } from '../lib/license_state' ; export function registerSampleData ( sampleDataRegistry , licenseState ) { registerEcommerceSampleData ( sampleDataRegistry ) ; registerFlightsSampleData ( sampleDataRegistry ) ; registerLogsSampleData ( sampleDataRegistry ) ; const licenseUpdates = licenseState . getLicenseInformation$ ( ) ; if ( licenseUpdates === null ) { throw new Error ( 'License state has to be initialized before registering sample data' ) ; } let registered = false ; licenseUpdates . subscribe ( ( licenseInformation ) => { if ( ! registered && licenseInformation . showAppLink ) { registered = true ; registerEcommerceSampleDataLink ( sampleDataRegistry ) ; registerFlightsSampleDataLink ( sampleDataRegistry ) ; registerLogsSampleDataLink ( sampleDataRegistry ) ; } } ) ; }