This is an automated email from the ASF dual-hosted git repository.

jpirek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-tools.git


The following commit(s) were added to refs/heads/master by this push:
     new 5c1f830  NETBEANS-3492Allow admins to edit plugins to NetBeans 
versions mapping & verifications
     new 2f02ea0  Merge pull request #22 from jpirek/master
5c1f830 is described below

commit 5c1f830733511008ac3a5bc8cb8093c7eee29656
Author: Jan Pirek <[email protected]>
AuthorDate: Tue Jan 7 12:50:01 2020 +0100

    NETBEANS-3492Allow admins to edit plugins to NetBeans versions mapping & 
verifications
---
 .../src/Application/Controller/PluginVersionController.php   | 12 ++++++++++--
 .../src/Application/Controller/VerificationController.php    |  2 +-
 .../Application/view/application/admin/_plugin-listrow.phtml |  6 ++++++
 .../Application/view/application/plugin-version/edit.phtml   |  2 +-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git 
a/pp3/module/Application/src/Application/Controller/PluginVersionController.php 
b/pp3/module/Application/src/Application/Controller/PluginVersionController.php
index e0c24fa..9d787cd 100644
--- 
a/pp3/module/Application/src/Application/Controller/PluginVersionController.php
+++ 
b/pp3/module/Application/src/Application/Controller/PluginVersionController.php
@@ -41,8 +41,9 @@ class PluginVersionController extends AuthenticatedController 
{
 
     public function editAction() {
         $pvId = $this->params()->fromQuery('id');
+        $search = $this->params()->fromQuery('search');
         $pluginVersion = $this->_pluginVersionRepository->find($pvId);        
-        if (!$pluginVersion || empty($pvId) || 
!$pluginVersion->getPlugin()->isOwnedBy($this->getAuthenticatedUserId())) {
+        if ((!$pluginVersion || empty($pvId) || 
!$pluginVersion->getPlugin()->isOwnedBy($this->getAuthenticatedUserId())) && 
!$this->isAdmin()) {
             return $this->redirect()->toRoute('plugin', array(
                 'action' => 'list'
             ));
@@ -117,18 +118,25 @@ class PluginVersionController extends 
AuthenticatedController {
         foreach($verifiedNbVersions as $v) {
             $verifiedNbVersionIds[]=$v['id'];
         }
+
+        if ($this->isAdmin() && !empty($search)) {
+            $backUrl = $this->url()->fromRoute('admin', array('action' => 
'index'), array('query' => array('search' => $search)));
+        } else {
+            $backUrl = $this->url()->fromRoute('plugin', array('action' => 
'list'));
+        }
         
         return new ViewModel([
             'pluginVersion' => $pluginVersion,
             'nbVersions' => $this->_nbVersionRepository->findAll(),
             'verifiedNbVersionIds' => $verifiedNbVersionIds,
+            'return' => $backUrl, 
         ]);
     }
 
     public function deleteAction() {
         $pId = $this->params()->fromQuery('id');
         $pluginVersion = $this->_pluginVersionRepository->find($pId);        
-        if (!$pluginVersion || empty($pId) || 
!$pluginVersion->getPlugin()->isOwnedBy($this->getAuthenticatedUserId())) {
+        if ((!$pluginVersion || empty($pId) || 
!$pluginVersion->getPlugin()->isOwnedBy($this->getAuthenticatedUserId())) && 
!$this->isAdmin()) {
             return $this->redirect()->toRoute('plugin', array(
                 'action' => 'list'
             ));
diff --git 
a/pp3/module/Application/src/Application/Controller/VerificationController.php 
b/pp3/module/Application/src/Application/Controller/VerificationController.php
index 4f8b49e..ea43a46 100644
--- 
a/pp3/module/Application/src/Application/Controller/VerificationController.php
+++ 
b/pp3/module/Application/src/Application/Controller/VerificationController.php
@@ -171,7 +171,7 @@ class VerificationController extends 
AuthenticatedController {
             $bailOut = true;
         }
         $plugin = $nbVersionPluginVersion->getPluginVersion()->getPlugin();
-        if (!$plugin->isOwnedBy($this->getAuthenticatedUserId())) {
+        if (!$plugin->isOwnedBy($this->getAuthenticatedUserId()) && 
!$this->isAdmin()) {
             $bailOut = true;
         }
         if ($bailOut) {
diff --git 
a/pp3/module/Application/view/application/admin/_plugin-listrow.phtml 
b/pp3/module/Application/view/application/admin/_plugin-listrow.phtml
index 0cf89d9..fbb008f 100644
--- a/pp3/module/Application/view/application/admin/_plugin-listrow.phtml
+++ b/pp3/module/Application/view/application/admin/_plugin-listrow.phtml
@@ -64,6 +64,7 @@ echo '</p>
         <thead>
             <tr>
             <th scope="col" style="width: 170px;">Plugin Version</th>
+            <th scope="col"></th>
             <th scope="col">NB Versions</th>
             <th scope="col">Verifications</th>
             </tr>
@@ -73,6 +74,11 @@ echo '</p>
 foreach ($plugin->getVersions() as $version) {
     echo '<tr>
         <td><span class="badge">'.$version->getVersion().'</span></td>
+        <td>
+            <a class="btn btn-default" 
href="'.$this->url('plugin-version',array('action'=>'edit'),array('query' => 
array('id'=>$version->getId(), 'search'=>$_GET['search']))).'" role="button" 
title="Edit">
+                <i class="fas fa-edit text-primary"></i>
+            </a>
+        </td>
         <td>';
     foreach ($version->getNbVersionsPluginVersions() as $nbvPv) {
             echo '<span class="badge badge-brown">NB 
'.$nbvPv->getNbVersion()->getVersion().'</span>&nbsp; ';
diff --git a/pp3/module/Application/view/application/plugin-version/edit.phtml 
b/pp3/module/Application/view/application/plugin-version/edit.phtml
index e487a04..0e6805c 100644
--- a/pp3/module/Application/view/application/plugin-version/edit.phtml
+++ b/pp3/module/Application/view/application/plugin-version/edit.phtml
@@ -27,7 +27,7 @@
             echo 
$this->partial('application/plugin-version/_pluginVersion-form.phtml', 
             array('pluginVersion' => $this->pluginVersion, 'nbVersions' => 
$this->nbVersions, 'verifiedNbVersionIds' => $this->verifiedNbVersionIds)); 
             ?>
-            <a class="btn btn-secondary" href="../plugin/list" 
role="button">Return</a>
+            <a class="btn btn-secondary" href="<?= $this->return ?>" 
role="button">Return</a>
             <button type="submit" class="btn btn-primary">Save Plugin 
Version</button>
             </form>
             


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to