From aecf9499ad6a53823b5d8c628315b1676cc5f91b Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sun, 14 Nov 2021 12:11:20 +0100 Subject: [PATCH] chg: [internal] Check if update is possible --- app/Controller/ServersController.php | 7 +++---- app/Model/Server.php | 9 +++++++++ app/View/Servers/ajax/update.ctp | 15 ++++++++------- app/View/Servers/ajax/zeromqstatus.ctp | 4 ++-- app/webroot/css/main.css | 6 ++++++ app/webroot/js/misp.js | 3 +-- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/Controller/ServersController.php b/app/Controller/ServersController.php index 4b6929273..57ba33dd9 100644 --- a/app/Controller/ServersController.php +++ b/app/Controller/ServersController.php @@ -1824,12 +1824,11 @@ class ServersController extends AppController public function update($branch = false) { if ($this->request->is('post')) { - $branch = false; $filterData = array( 'request' => $this->request, 'named_params' => $this->params['named'], 'paramArray' => ['branch'], - 'ordered_url_params' => @compact($paramArray), + 'ordered_url_params' => [], 'additional_delimiters' => PHP_EOL ); $exception = false; @@ -1852,8 +1851,8 @@ class ServersController extends AppController return new CakeResponse(array('body' => $update, 'type' => 'txt')); } } else { - $branch = $this->Server->getCurrentBranch(); - $this->set('branch', $branch); + $this->set('isUpdatePossible', $this->Server->isUpdatePossible()); + $this->set('branch', $this->Server->getCurrentBranch()); $this->render('ajax/update'); } } diff --git a/app/Model/Server.php b/app/Model/Server.php index b7bfd636b..dabf7c910 100644 --- a/app/Model/Server.php +++ b/app/Model/Server.php @@ -3870,6 +3870,15 @@ class Server extends AppModel } } + /** + * Check if MISP update is possible. + * @return bool + */ + public function isUpdatePossible() + { + return $this->getCurrentBranch() !== false && is_writable(APP); + } + public function checkoutMain() { $mainBranch = '2.4'; diff --git a/app/View/Servers/ajax/update.ctp b/app/View/Servers/ajax/update.ctp index ecedb9c60..58e149b5f 100644 --- a/app/View/Servers/ajax/update.ctp +++ b/app/View/Servers/ajax/update.ctp @@ -1,9 +1,11 @@
- Form->create('Server', array('style' => 'margin:0px;', 'id' => 'PromptForm', 'url' => $baseurl . '/servers/update')); - ?> Update MISP -
+
+ +

Update is not possible because you are not on a branch or MISP folder is not writeable by current user.

+ + + Form->create('Server', array('style' => 'margin:0px;', 'id' => 'PromptForm', 'url' => $baseurl . '/servers/update')); ?>

@@ -17,8 +19,7 @@
+ Form->end(); ?> +
- Form->end(); - ?>
diff --git a/app/View/Servers/ajax/zeromqstatus.ctp b/app/View/Servers/ajax/zeromqstatus.ctp index 4b5ef7a23..68daf8b25 100644 --- a/app/View/Servers/ajax/zeromqstatus.ctp +++ b/app/View/Servers/ajax/zeromqstatus.ctp @@ -1,6 +1,6 @@
- -
+ +

: Time->time($time); ?>
: Time->time($time2); ?>
diff --git a/app/webroot/css/main.css b/app/webroot/css/main.css index 2e992b954..10d4ec1e2 100644 --- a/app/webroot/css/main.css +++ b/app/webroot/css/main.css @@ -885,6 +885,12 @@ a.proposal_link_red:hover { color:white; } +.confirmation .inner { + padding-left:5px; + padding-right:5px; + padding-bottom:5px; +} + .popover-legend { border-radius: 5px 5px 0px 0px; margin-bottom:5px; diff --git a/app/webroot/js/misp.js b/app/webroot/js/misp.js index 5d7367ea1..6b3c36edc 100644 --- a/app/webroot/js/misp.js +++ b/app/webroot/js/misp.js @@ -183,8 +183,7 @@ function cancelPrompt(isolated) { $("#gray_out").fadeOut(); } $("#popover_form").fadeOut(); - $("#confirmation_box").fadeOut(); - $("#confirmation_box").empty(); + $("#confirmation_box").fadeOut().empty(); $('.have-a-popover').popover('destroy'); }