import * as t from 'io-ts' ; import React from 'react' ; import { casesPath } from '../../common' ; import { CasesPage } from '../pages/cases' ; import { AlertsPage } from '../pages/alerts/containers/alerts_page' ; import { HomePage } from '../pages/home' ; import { LandingPage } from '../pages/landing' ; import { OverviewPage } from '../pages/overview' ; import { jsonRt } from './json_rt' ; import { ObservabilityExploratoryView } from '../components/shared/exploratory_view/obsv_exploratory_view' ; export type RouteParams < T extends keyof typeof routes > = DecodeParams < typeof routes [ T ] [ 'params' ] > ; type DecodeParams < TParams extends Params | undefined > = { [ key in keyof TParams ] : TParams [ key ] extends t . Any ? t . TypeOf < TParams [ key ] > : never ; } ; export interface Params { query ? : t . HasProps ; path ? : t . HasProps ; } export const routes = { '/' : { handler : ( ) => { return < HomePage />; } , params : { } , exact : true , } , '/landing' : { handler : ( ) => { return < LandingPage />; } , params : { } , exact : true , } , '/overview' : { handler : ( { query } ) => { return < OverviewPage routeParams = { { query } } />; } , params : { query : t . partial ( { rangeFrom : t . string , rangeTo : t . string , refreshPaused : jsonRt . pipe ( t . boolean ) , refreshInterval : jsonRt . pipe ( t . number ) , } ) , } , exact : true , } , [ casesPath ] : { handler : ( ) => { return < CasesPage />; } , params : { } , exact : false , } , '/alerts' : { handler : ( ) => { return < AlertsPage />; } , params : { } , exact : true , } , '/exploratory-view/' : { handler : ( ) => { return < ObservabilityExploratoryView />; } , params : { query : t . partial ( { rangeFrom : t . string , rangeTo : t . string , refreshPaused : jsonRt . pipe ( t . boolean ) , refreshInterval : jsonRt . pipe ( t . number ) , } ) , } , exact : true , } , } ;