Bläddra i källkod

Allow to force the display of update output with a shift-click on the update button

Jordi Boggiano 9 år sedan
förälder
incheckning
1b205e477e

+ 11 - 2
src/Packagist/WebBundle/Controller/PackageController.php

@@ -519,6 +519,7 @@ class PackageController extends Controller
         $update = $req->request->get('update', $req->query->get('update'));
         $autoUpdated = $req->request->get('autoUpdated', $req->query->get('autoUpdated'));
         $updateEqualRefs = $req->request->get('updateAll', $req->query->get('updateAll'));
+        $showOutput = $req->request->get('showOutput', $req->query->get('showOutput', false));
 
         $user = $this->getUser() ?: $doctrine
             ->getRepository('PackagistWebBundle:User')
@@ -550,11 +551,19 @@ class PackageController extends Controller
                 try {
                     $updater->update($io, $config, $package, $repository, $updateEqualRefs ? Updater::UPDATE_EQUAL_REFS : 0);
                 } catch (\Exception $e) {
-                    return new Response(json_encode(array(
+                    return new JsonResponse([
                         'status' => 'error',
                         'message' => '['.get_class($e).'] '.$e->getMessage(),
                         'details' => '<pre>'.$io->getOutput().'</pre>',
-                    )), 400);
+                    ], 400);
+                }
+
+                if ($showOutput) {
+                    return new JsonResponse([
+                        'status' => 'error',
+                        'message' => 'Update successful',
+                        'details' => '<pre>'.$io->getOutput().'</pre>',
+                    ], 400);
                 }
             }
 

+ 4 - 0
src/Packagist/WebBundle/Resources/public/js/view.js

@@ -80,6 +80,9 @@
         if (updateAll) {
             data.push({name: 'updateAll', value: '1'});
         }
+        if (e && e.shiftKey) {
+            data.push({name: 'showOutput', value: '1'});
+        }
         $.ajax({
             url: $('.package .force-update').attr('action'),
             dataType: 'json',
@@ -94,6 +97,7 @@
         submit.addClass('loading');
     }
     $('.package .force-update').on('submit', forceUpdatePackage);
+    $('.package .force-update').on('click', forceUpdatePackage);
     $('.package .mark-favorite').on('click', function (e) {
         var options = {
             dataType: 'json',