import { PublicAppInfo , AppNavLinkStatus , AppStatus } from '../../application' ; import { IBasePath } from '../../http' ; import { NavLinkWrapper } from './nav_link' ; import { appendAppPath } from '../../application/utils' ; export function toNavLink ( app , basePath ) { const useAppStatus = app . navLinkStatus === AppNavLinkStatus . default ; const relativeBaseUrl = basePath . prepend ( app . appRoute ! ) ; const url = relativeToAbsolute ( appendAppPath ( relativeBaseUrl , app . defaultPath ) ) ; const baseUrl = relativeToAbsolute ( relativeBaseUrl ) ; return new NavLinkWrapper ( { ... app , hidden : useAppStatus ? app . status === AppStatus . inaccessible : app . navLinkStatus === AppNavLinkStatus . hidden , disabled : useAppStatus ? false : app . navLinkStatus === AppNavLinkStatus . disabled , baseUrl , href : url , url , } ) ; } param { string } url return { string } export function relativeToAbsolute ( url ) { const a = document . createElement ( 'a' ) ; a . setAttribute ( 'href' , url ) ; return a . href ; }