diff --git a/legacy/src/app/entry.js b/legacy/src/app/entry.js index 214ee0ea9d..dcfb51a9dc 100644 --- a/legacy/src/app/entry.js +++ b/legacy/src/app/entry.js @@ -253,7 +253,7 @@ function configureMaas( $locationProvider, $compileProvider, tagsInputConfigProvider, - $urlRouterProvider + $urlRouterProvider, ) { // Disable debugInfo unless in a Jest context. // Re-enable debugInfo in development by running diff --git a/legacy/src/app/routes.js b/legacy/src/app/routes.js index 1d0ea86fa7..790e3b2c5b 100644 --- a/legacy/src/app/routes.js +++ b/legacy/src/app/routes.js @@ -148,8 +148,14 @@ const configureRoutes = ($stateProvider, $urlRouterProvider) => { template: podDetailsTmpl, controller: "PodDetailsController", }) - .state("pods", { url: prefixRoute("/pods"), redirectTo: prefixRoute("/kvm") }) - .state("podDetails", { url: prefixRoute("/pod/:id"), redirectTo: prefixRoute("/kvm/:id") }) + .state("pods", { + url: prefixRoute("/pods"), + redirectTo: prefixRoute("/kvm"), + }) + .state("podDetails", { + url: prefixRoute("/pod/:id"), + redirectTo: prefixRoute("/kvm/:id"), + }) .state("master.rsd", { url: prefixRoute("/rsd"), template: podsListTmpl, @@ -227,6 +233,26 @@ const configureRoutes = ($stateProvider, $urlRouterProvider) => { template: dashboardTmpl, controller: "DashboardController", }); + + $urlRouterProvider.otherwise(($injector, $location) => { + // Redirect old hash routes to new routes + if ($location.hash()) { + window.history.pushState( + null, + null, + `${process.env.BASENAME}${ + process.env.ANGULAR_BASENAME + }${$location.hash()}` + ); + } else { + // fallthrough redirect machine listing + window.history.pushState( + null, + null, + `${process.env.BASENAME}${process.env.REACT_BASENAME}/machines` + ); + } + }); }; export default configureRoutes; diff --git a/legacy/src/app/services/tests/test_region.js b/legacy/src/app/services/tests/test_region.js index 4f2b09a107..522d8bb633 100644 --- a/legacy/src/app/services/tests/test_region.js +++ b/legacy/src/app/services/tests/test_region.js @@ -10,7 +10,11 @@ import MockWebSocket from "testing/websocket"; describe("RegionConnection", function() { // Load the MAAS module to test. - beforeEach(angular.mock.module("MAAS")); + beforeEach( + angular.mock.module("MAAS", ($urlRouterProvider) => + $urlRouterProvider.deferIntercept() + ) + ); // Grab the needed angular pieces. var $timeout, $rootScope, $q, $cookies, $window; diff --git a/root/src/root-application.js b/root/src/root-application.js index 592db598bf..592d66e701 100644 --- a/root/src/root-application.js +++ b/root/src/root-application.js @@ -15,7 +15,10 @@ registerApplication({ showLoading(); return import("@maas-ui/maas-ui-legacy"); }, - activeWhen: `${process.env.BASENAME}${process.env.ANGULAR_BASENAME}`, + activeWhen: (location) => + location.pathname.startsWith( + `${process.env.BASENAME}${process.env.ANGULAR_BASENAME}` + ) || location.hash.startsWith("#"), }); registerApplication({