Redirect back to the license page after installing a package
authorAlexander Ebert <ebert@woltlab.com>
Tue, 19 Sep 2023 15:23:04 +0000 (17:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 19 Sep 2023 15:23:04 +0000 (17:23 +0200)
See https://www.woltlab.com/community/thread/301678-acp-lizenzierte-produkte-plugins-installieren/

ts/WoltLabSuite/Core/Acp/Component/License.ts
ts/WoltLabSuite/Core/Acp/Ui/Package/PrepareInstallation.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Component/License.js
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Package/PrepareInstallation.js
wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php

index 718d4e59fcefbc2057f99758c51fc073c3be8a2c..6a4c61c1df63af7161a46c9d7ed737855454e2f1 100644 (file)
@@ -12,7 +12,7 @@ import AcpUiPackagePrepareInstallation from "../Ui/Package/PrepareInstallation";
 
 function installPackage(button: HTMLButtonElement): Promise<void> {
   const installation = new AcpUiPackagePrepareInstallation();
-  return installation.start(button.dataset.package!, button.dataset.packageVersion!);
+  return installation.start(button.dataset.package!, button.dataset.packageVersion!, "license");
 }
 
 export function setup(): void {
index 5fcf8530ba175a880d628073ea2a64a4f5a7e2fb..6c3ea631c1ff41a7acb7c22c87a4a5288cd34b60 100644 (file)
@@ -21,18 +21,22 @@ interface AjaxResponse {
   };
 }
 
+type RedirectLocation = "license";
+
 class AcpUiPackagePrepareInstallation {
   private identifier = "";
   private version = "";
   #resolve?: () => void;
+  #redirectLocation?: RedirectLocation;
 
-  start(identifier: string, version: string): Promise<void> {
+  start(identifier: string, version: string, redirectLocation?: RedirectLocation): Promise<void> {
     if (this.#resolve !== undefined) {
       throw new Error("There is already a pending installation.");
     }
 
     this.identifier = identifier;
     this.version = version;
+    this.#redirectLocation = redirectLocation;
 
     return new Promise<void>((resolve) => {
       this.#resolve = resolve;
@@ -86,7 +90,9 @@ class AcpUiPackagePrepareInstallation {
         UiDialog.close(this);
       }
 
-      const installation = new window.WCF.ACP.Package.Installation(data.returnValues.queueID, undefined, false);
+      const installation = new window.WCF.ACP.Package.Installation(data.returnValues.queueID, undefined, false, false, {
+        redirectLocation: this.#redirectLocation,
+      });
       installation.prepareInstallation();
     } else if (data.returnValues.template) {
       UiDialog.open(this, data.returnValues.template);
index 7663b1bbd84f95db16827ce2b9a6440fec4a9876..b6204053f3eaa8e20e342bb6d4423ac4ccc483a7 100644 (file)
@@ -13,7 +13,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/PromiseMutex",
     PrepareInstallation_1 = tslib_1.__importDefault(PrepareInstallation_1);
     function installPackage(button) {
         const installation = new PrepareInstallation_1.default();
-        return installation.start(button.dataset.package, button.dataset.packageVersion);
+        return installation.start(button.dataset.package, button.dataset.packageVersion, "license");
     }
     function setup() {
         const callback = (0, PromiseMutex_1.promiseMutex)((button) => installPackage(button));
index 97f0da58bac3b9363db2c4d1879662196fab0bb6..96c7082313a49ea64b5abf718bc333df0410d50e 100644 (file)
@@ -16,12 +16,14 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Language", "..
         identifier = "";
         version = "";
         #resolve;
-        start(identifier, version) {
+        #redirectLocation;
+        start(identifier, version, redirectLocation) {
             if (this.#resolve !== undefined) {
                 throw new Error("There is already a pending installation.");
             }
             this.identifier = identifier;
             this.version = version;
+            this.#redirectLocation = redirectLocation;
             return new Promise((resolve) => {
                 this.#resolve = resolve;
                 this.prepare({});
@@ -67,7 +69,9 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Language", "..
                 if (Dialog_1.default.isOpen(this)) {
                     Dialog_1.default.close(this);
                 }
-                const installation = new window.WCF.ACP.Package.Installation(data.returnValues.queueID, undefined, false);
+                const installation = new window.WCF.ACP.Package.Installation(data.returnValues.queueID, undefined, false, false, {
+                    redirectLocation: this.#redirectLocation,
+                });
                 installation.prepareInstallation();
             }
             else if (data.returnValues.template) {
index 72460a67661de5e130af59b91c8580eb623b4dac..f8dd8f7f61a04c82cb8c29e308235e5982f72e41 100755 (executable)
@@ -29,6 +29,8 @@ class InstallPackageAction extends AbstractSecureAction
 
     public PackageInstallationQueue $queue;
 
+    private string $redirectLocation = '';
+
     /**
      * @inheritDoc
      */
@@ -63,6 +65,11 @@ class InstallPackageAction extends AbstractSecureAction
             throw new IllegalLinkException();
         }
 
+        $redirectLocation = $_REQUEST['redirectLocation'] ?? '';
+        if ($redirectLocation === 'license') {
+            $this->redirectLocation = $redirectLocation;
+        }
+
         $this->installation = new PackageInstallationDispatcher($this->queue);
     }
 
@@ -182,6 +189,8 @@ class InstallPackageAction extends AbstractSecureAction
             $controller = 'first-time-setup';
 
             WCF::getSession()->unregister('__wcfSetup_completed');
+        } else if ($this->redirectLocation === 'license') {
+            $controller = 'license';
         }
 
         // Do not use the LinkHandler here as it is sort of unreliable during WCFSetup.