From 7bb358888980bdcd8d605214b611ba7bd22c0712 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 16 Jan 2019 23:53:10 +1100 Subject: [PATCH] Adds the whole package definition to the scope model for devs to use, adds a custom query string parameter when redirecting to the angular view after install (so devs know its a new install) --- .../src/views/packages/edit.controller.js | 2 +- .../src/views/packages/options.controller.js | 6 +++++- .../src/views/packages/overview.controller.js | 14 +++++++------- .../packages/views/install-local.controller.js | 10 ++-------- .../views/packages/views/installed.controller.js | 5 +++-- .../src/views/packages/views/repo.controller.js | 6 ++---- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js index ca20b33a3e..bed3341c6b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js @@ -130,7 +130,7 @@ } function back() { - $location.path("packages/packages/created").search("create", null); + $location.path("packages/packages/created").search("create", null).search("packageId", null); } function createOrUpdatePackage(editPackageForm) { diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/options.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/options.controller.js index 8ffd282e0d..4fdf6488a0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/options.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/options.controller.js @@ -15,6 +15,10 @@ packageResource.getInstalledById(packageId).then(pck => { vm.package = pck; + + //set the $scope too, packages can then access this if they wanted from their own scope or parent scope + $scope.package = pck; + vm.loading = false; //make sure the packageView is formatted as a virtual path @@ -30,7 +34,7 @@ } function back() { - $location.path("packages/packages/installed"); + $location.path("packages/packages/installed").search("packageId", null); } diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/overview.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/overview.controller.js index f4c1ab9de4..e48271aa23 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/overview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/overview.controller.js @@ -4,26 +4,26 @@ function PackagesOverviewController($scope, $location, $routeParams, localStorageService) { //Hack! - // if there is a cookie value for packageInstallUri then we need to redirect there, + // if there is a local storage value for packageInstallData then we need to redirect there, // the issue is that we still have webforms and we cannot go to a hash location and then window.reload // because it will double load it. // we will refresh and then navigate there. - let installPackageUri = localStorageService.get("packageInstallUri"); + let packageInstallData = localStorageService.get("packageInstallData"); let packageUri = $routeParams.method; - if (installPackageUri) { - localStorageService.remove("packageInstallUri"); + if (packageInstallData) { + localStorageService.remove("packageInstallData"); } - if (installPackageUri && installPackageUri !== "installed") { + if (packageInstallData && packageInstallData !== "installed" && packageInstallData.postInstallationPath) { //navigate to the custom installer screen, if it is just "installed" it means there is no custom installer screen - $location.path(installPackageUri).search(""); + $location.path(packageInstallData.postInstallationPath).search("packageId", packageInstallData.id); } else { var vm = this; - packageUri = installPackageUri ? installPackageUri : packageUri; //use the path stored in storage over the one in the current path + packageUri = packageInstallData ? packageInstallData : packageUri; //use the path stored in storage over the one in the current path vm.page = {}; vm.page.name = "Packages"; diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/views/install-local.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/views/install-local.controller.js index 17b417de48..0d9341243b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/views/install-local.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/views/install-local.controller.js @@ -184,14 +184,8 @@ installError) .then(function (result) { - if (result.postInstallationPath) { - //Put the redirect Uri in a cookie so we can use after reloading - localStorageService.set("packageInstallUri", result.postInstallationPath); - } - else { - //set to a constant value so it knows to just go to the installed view - localStorageService.set("packageInstallUri", "installed"); - } + //Put the package data in local storage so we can use after reloading + localStorageService.set("packageInstallData", result); vm.installState.status = labels.installStateCompleted; vm.installCompleted = true; diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/views/installed.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/views/installed.controller.js index 3b6422ace4..ddfee19ac1 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/views/installed.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/views/installed.controller.js @@ -36,7 +36,8 @@ } function packageOptions(pck) { - $location.path("packages/packages/options/" + pck.id); + $location.path("packages/packages/options/" + pck.id) + .search("packageId", null); //ensure the installId flag is gone, it's only available on first install } function confirmUninstall(pck) { @@ -56,7 +57,7 @@ vm.installState.progress = "100"; //set this flag so that on refresh it shows the installed packages list - localStorageService.set("packageInstallUri", "installed"); + localStorageService.set("packageInstallData", "installed"); //reload on next digest (after cookie) $timeout(function () { diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/views/repo.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/views/repo.controller.js index b77326d2fc..dc3e67db15 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/views/repo.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/packages/views/repo.controller.js @@ -257,10 +257,8 @@ error) .then(function (result) { - if (result.postInstallationPath) { - //Put the redirect Uri in a cookie so we can use after reloading - localStorageService.set("packageInstallUri", result.postInstallationPath); - } + //Put the package data in local storage so we can use after reloading + localStorageService.set("packageInstallData", result); vm.installState.status = labels.installStateCompleted; vm.installCompleted = true;