From 64cb88dea1ce9fdcfa390632d9539180fc5a94af Mon Sep 17 00:00:00 2001 From: zenggang Date: Fri, 28 Jul 2023 06:05:10 +0000 Subject: [PATCH] * Adjust app list edit,binduser. --- module/common/lang/menu.php | 2 +- module/gitlab/ui/view.html.php | 38 ++++++++++++++++++++++++++++++++++ module/instance/model.php | 12 +++++------ module/space/config/dtable.php | 4 ++-- module/space/control.php | 17 ++++++++++++++- module/space/js/browse.ui.js | 14 +++++++++++-- 6 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 module/gitlab/ui/view.html.php diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index 37f4d4c390..5165de77f7 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -486,7 +486,7 @@ $lang->devops->homeMenu = new stdclass(); //$lang->devops->homeMenu->dashboard = array('link' => "{$lang->dashboard}|system|dashboard"); $lang->devops->homeMenu->repos = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit,import'); $lang->devops->homeMenu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job'); -$lang->devops->homeMenu->WIPs = array('link' => "{$lang->app->common}|space|browse", 'subModule' => 'instance,store', 'alias' => 'createapplication'); +$lang->devops->homeMenu->WIPs = array('link' => "{$lang->app->common}|space|browse", 'subModule' => 'instance,store,gitlab,gitea,gogs', 'alias' => 'createapplication,binduser,edit'); //$lang->devops->homeMenu->environment = array('link' => "{$lang->devops->environment}|gitlab|browse", 'subModule' => 'gitlab,jenkins,sonarqube,gitea,gogs', 'alias' => 'setrules,create,edit,import'); //$lang->devops->homeMenu->app = array('link' => "{$lang->app->common}|app|serverlink|%s"); diff --git a/module/gitlab/ui/view.html.php b/module/gitlab/ui/view.html.php new file mode 100644 index 0000000000..f5829a6664 --- /dev/null +++ b/module/gitlab/ui/view.html.php @@ -0,0 +1,38 @@ + + * @package gitlab + * @link https://www.zentao.net + */ +namespace zin; +global $lang; + +detailHeader +( + isAjaxRequest('modal') ? to::prefix() : '', + to::title( + entityLabel( + set(array('entityID' => $gitlab->id, 'level' => 1, 'text' => $gitlab->name)) + ) + ), +); + +detailBody +( + sectionList + ( + section + ( + set::title($lang->gitlab->url), + set::content("{$gitlab->url}"), + set::useHtml(true) + ), + ), + history(), +); + +render(); diff --git a/module/instance/model.php b/module/instance/model.php index be189ddcb3..04dceb99a2 100644 --- a/module/instance/model.php +++ b/module/instance/model.php @@ -2045,13 +2045,13 @@ class InstanceModel extends model */ public function isClickable(object $instance, string $action): bool { - if($action == 'start') return empty($instance->type) ? $this->canDo('start', $instance) : false; - if($action == 'stop') return empty($instance->type) ? $this->canDo('stop', $instance) : false; - if($action == 'uninstall') return empty($instance->solution) && $this->canDo('uninstall', $instance); - if($action == 'visit') return empty($instance->type) ? ($instance->domain && $this->canDo('visit', $instance)) : true; + if($action == 'start') return $instance->type == 'app' ? $this->canDo('start', $instance) : false; + if($action == 'stop') return $instance->type == 'app' ? $this->canDo('stop', $instance) : false; + if($action == 'uninstall') return $instance->type == 'app' && $this->canDo('uninstall', $instance); + if($action == 'visit') return $instance->type == 'app' ? ($instance->domain && $this->canDo('visit', $instance)) : true; if($action == 'upgrade') return !empty($instance->latestVersion); - if($action == 'bindUser') return empty($instance->type) ? false : true; - if($action == 'edit') return empty($instance->type) ? false : true; + if($action == 'bindUser') return ($instance->type == 'external' && in_array($instance->appName, array('Gitlab', 'Gitea', 'Gogs'))) ? true : false; + if($action == 'edit') return $instance->type == 'app' ? false : true; return true; } diff --git a/module/space/config/dtable.php b/module/space/config/dtable.php index 6b9f78cac5..8d93784afe 100644 --- a/module/space/config/dtable.php +++ b/module/space/config/dtable.php @@ -68,8 +68,8 @@ $config->space->dtable->fieldList['actions']['list']['upgrade']['url'] = $config->space->dtable->fieldList['actions']['list']['edit']['icon'] = 'edit'; $config->space->dtable->fieldList['actions']['list']['edit']['hint'] = $lang->edit; -$config->space->dtable->fieldList['actions']['list']['edit']['url'] = array('module' => 'space', 'method' => 'edit', 'params' => 'id={orgID}&type={type}'); +$config->space->dtable->fieldList['actions']['list']['edit']['url'] = 'javascript:editApp({orgID}, "{appName}")'; $config->space->dtable->fieldList['actions']['list']['bindUser']['icon'] = 'lock'; $config->space->dtable->fieldList['actions']['list']['bindUser']['hint'] = $lang->gitlab->bindUser; -$config->space->dtable->fieldList['actions']['list']['bindUser']['url'] = array('module' => 'space', 'method' => 'bindUser', 'id={id}'); +$config->space->dtable->fieldList['actions']['list']['bindUser']['url'] = 'javascript:bindUser({orgID}, "{appName}")'; diff --git a/module/space/control.php b/module/space/control.php index 3ebb7a9480..6134e4d290 100644 --- a/module/space/control.php +++ b/module/space/control.php @@ -90,6 +90,13 @@ class space extends control $this->display(); } + /** + * 创建一个应用。 + * Create a application. + * + * @access public + * @return viod + */ public function createApplication() { $this->app->loadLang('sonarqube'); @@ -112,7 +119,15 @@ class space extends control $this->display(); } - public function getStoreAppInfo($appID) + /** + * 获取应用商店app信息。 + * Get a store app info. + * + * @param int $appID + * @access public + * @return viod + */ + public function getStoreAppInfo(int $appID) { $cloudApp = $this->loadModel('store')->getAppInfo($appID); diff --git a/module/space/js/browse.ui.js b/module/space/js/browse.ui.js index 425c2c5524..4b55dfa35c 100644 --- a/module/space/js/browse.ui.js +++ b/module/space/js/browse.ui.js @@ -20,7 +20,7 @@ window.renderInstanceList = function (result, {col, row, value}) { if(row.data.externalID) { - if(row.data.appName == 'Gitea') result[0] = {html: '' + result[0] + ''}; + if(row.data.appName == 'Gitea' || row.data.appName == 'Gitlab') result[0] = {html: '' + result[0] + ''}; } else { @@ -68,4 +68,14 @@ window.onPageUnmount = function() { if(timer == null) return; clearInterval(timer); -} \ No newline at end of file +} + +window.bindUser = function(externalID, appName) +{ + openUrl($.createLink(appName.toLowerCase(), 'bindUser', 'id=' + externalID)); +} + +window.editApp = function(externalID, appName) +{ + openUrl($.createLink(appName.toLowerCase(), 'edit', 'id=' + externalID)); +}