From ee30913246b5426ee427c0a8a0d2e47fb2cf56be Mon Sep 17 00:00:00 2001 From: zhaoke Date: Wed, 2 Aug 2023 14:45:45 +0800 Subject: [PATCH] * Fix error of edit instance. --- module/gitea/control.php | 5 +++-- module/gitlab/control.php | 9 +++++---- module/gogs/control.php | 5 +++-- module/jenkins/control.php | 2 +- module/sonarqube/control.php | 6 +++--- module/space/js/browse.ui.js | 3 ++- module/space/ui/browse.html.php | 2 ++ 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/module/gitea/control.php b/module/gitea/control.php index 286475f283..73c3a73d99 100644 --- a/module/gitea/control.php +++ b/module/gitea/control.php @@ -121,7 +121,8 @@ class gitea extends control if($_POST) { - $this->checkToken(); + $gitea = fixer::input('post')->trim('url,token')->get(); + $this->checkToken($gitea); $this->gitea->update($giteaID); $gitea = $this->gitea->getByID($giteaID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -130,7 +131,7 @@ class gitea extends control $actionID = $this->action->create('gitea', $giteaID, 'edited'); $changes = common::createChanges($oldGitea, $gitea); $this->action->logHistory($actionID, $changes); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->title = $this->lang->gitea->common . $this->lang->colon . $this->lang->gitea->edit; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 92a6f4aed5..8f94d273d0 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -116,7 +116,8 @@ class gitlab extends control if($_POST) { - $this->checkToken(); + $gitlab = fixer::input('post')->trim('url,token')->get(); + $this->checkToken($gitlab, $id); $this->gitlab->update($id); $gitLab = $this->gitlab->getByID($id); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -125,7 +126,7 @@ class gitlab extends control $actionID = $this->action->create('gitlab', $id, 'edited'); $changes = common::createChanges($oldGitLab, $gitLab); $this->action->logHistory($actionID, $changes); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->edit; @@ -292,9 +293,9 @@ class gitlab extends control * @access protected * @return void */ - protected function checkToken(object $gitlab) + protected function checkToken(object $gitlab, int $gitlabID = 0) { - $this->dao->update('gitlab')->data($gitlab)->batchCheck($this->config->gitlab->create->requiredFields, 'notempty'); + $this->dao->update('gitlab')->data($gitlab)->batchCheck($gitlabID ? $this->config->gitlab->edit->requiredFields : $this->config->gitlab->create->requiredFields, 'notempty'); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); if(strpos($gitlab->url, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array(sprintf($this->lang->gitlab->hostError, $this->config->gitlab->minCompatibleVersion))))); diff --git a/module/gogs/control.php b/module/gogs/control.php index d819d9e5b5..ca82ec2fb7 100644 --- a/module/gogs/control.php +++ b/module/gogs/control.php @@ -120,7 +120,8 @@ class gogs extends control if($_POST) { - $this->checkToken(); + $gogs = fixer::input('post')->trim('url,token')->get(); + $this->checkToken($gogs); $this->gogs->update($gogsID); $gogs = $this->gogs->getByID($gogsID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -129,7 +130,7 @@ class gogs extends control $actionID = $this->action->create('gogs', $gogsID, 'edited'); $changes = common::createChanges($oldGogs, $gogs); $this->action->logHistory($actionID, $changes); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->title = $this->lang->gogs->common . $this->lang->colon . $this->lang->gogs->edit; diff --git a/module/jenkins/control.php b/module/jenkins/control.php index acb2a538c2..939b10ced8 100644 --- a/module/jenkins/control.php +++ b/module/jenkins/control.php @@ -92,7 +92,7 @@ class jenkins extends control { $this->jenkins->update($id); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->title = $this->lang->jenkins->common . $this->lang->colon . $this->lang->jenkins->edit; diff --git a/module/sonarqube/control.php b/module/sonarqube/control.php index e3494a03d6..3dcb9b5d4a 100644 --- a/module/sonarqube/control.php +++ b/module/sonarqube/control.php @@ -156,11 +156,11 @@ class sonarqube extends control /** * Check post info. * - * @param object $sonarqube + * @param int $sonarqubeID * @access protected * @return void */ - protected function checkToken(object $sonarqube) + protected function checkToken(int $sonarqubeID) { $sonarqube = fixer::input('post')->trim('url,token,account,password')->get(); $this->dao->update('sonarqube')->data($sonarqube) @@ -207,7 +207,7 @@ class sonarqube extends control $actionID = $this->action->create('sonarqube', $sonarqubeID, 'edited'); $changes = common::createChanges($oldSonarQube, $sonarqube); $this->action->logHistory($actionID, $changes); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->editServer; diff --git a/module/space/js/browse.ui.js b/module/space/js/browse.ui.js index d23c2a16b7..563a69aa6a 100644 --- a/module/space/js/browse.ui.js +++ b/module/space/js/browse.ui.js @@ -77,5 +77,6 @@ window.bindUser = function(externalID, appName) window.editApp = function(externalID, appName) { - openUrl($.createLink(appName.toLowerCase(), 'edit', 'id=' + externalID)); + $('#editLinkContainer').attr('href', $.createLink(appName.toLowerCase(), 'edit', 'id=' + externalID)); + $('#editLinkContainer').trigger('click'); } diff --git a/module/space/ui/browse.html.php b/module/space/ui/browse.html.php index 2fd86ac3ea..f3f5073f53 100644 --- a/module/space/ui/browse.html.php +++ b/module/space/ui/browse.html.php @@ -42,5 +42,7 @@ dtable set::footPager(usePager()), ); +a(setStyle('display', 'none'), setID('editLinkContainer'), setData('toggle', 'modal')); + render();