import React from 'react' ; import { Switch , Route , useRouteMatch } from 'react-router-dom' ; import { QueriesPage } from './list' ; import { NewSavedQueryPage } from './new' ; import { EditSavedQueryPage } from './edit' ; import { useBreadcrumbs } from '../../common/hooks/use_breadcrumbs' ; import { MissingPrivileges } from '../components' ; import { useKibana } from '../../common/lib/kibana' ; const SavedQueriesComponent = ( ) => { const permissions = useKibana ( ) . services . application . capabilities . osquery ; useBreadcrumbs ( 'saved_queries' ) ; const match = useRouteMatch ( ) ; if ( ! permissions . readSavedQueries ) { return < MissingPrivileges />; } return ( < Switch > < Route path = { `${ match . url }/new` } > { permissions . writeSavedQueries ? < NewSavedQueryPage /> : <MissingPrivileges / > } < /Route> < Route path = { `${ match . url }/:savedQueryId` } > < EditSavedQueryPage /> < /Route> < Route path = { `${ match . url }` } > < QueriesPage /> < /Route> < /Switch>); } ; export const SavedQueries = React . memo ( SavedQueriesComponent ) ;