github.com/GoogleCloudPlatform/testgrid@v0.0.174/web/src/utils/navigation.ts (about) 1 /** 2 * Navigates application to a specified page. 3 * @fires location-changed 4 * @param {string} path 5 */ 6 export function navigate(name: string){ 7 const url = new URL(location.href); 8 url.pathname = name; 9 history.pushState(null, '', url); 10 window.dispatchEvent(new CustomEvent('location-changed')); 11 } 12 13 /** 14 * Changes the URL without reloading 15 * @param {string} dashboard 16 * @param {string} tab 17 */ 18 export function navigateTab(dashboard: string, tab: string){ 19 const url = new URL(location.href) 20 if (tab === 'Summary' || tab === undefined){ 21 url.pathname = `${dashboard}` 22 } else { 23 url.pathname = `${dashboard}/${tab}` 24 } 25 history.pushState(null, '', url); 26 }