diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 0193f67792..d5d3e7ceef 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -29,8 +29,15 @@ class gitlab extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); + $gitlabList = $this->gitlab->getList($orderBy, $pager); + foreach($gitlabList as $gitlab) + { + $token = $this->gitlab->apiGetCurrentUser($gitlab->url,$gitlab->token); + $gitlab->isAdminToken = $token->is_admin; + } + $this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browse; - $this->view->gitlabList = $this->gitlab->getList($orderBy, $pager); + $this->view->gitlabList = $gitlabList; $this->view->orderBy = $orderBy; $this->view->pager = $pager; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 9cc0439aa1..4b91dbc2d4 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -34,34 +34,9 @@ class gitlabModel extends model */ public function getList($orderBy = 'id_desc', $pager = null) { - $pipeline = $this->loadModel('pipeline')->getList('gitlab', $orderBy, $pager); + $gitlabList = $this->loadModel('pipeline')->getList('gitlab', $orderBy, $pager); - $lists = array(); - foreach ($pipeline as $pipelineGitlab) - { - $token = $this->apiGetCurrentUser($pipelineGitlab->url,$pipelineGitlab->token); - - $list = new stdclass; - - $list->id = $pipelineGitlab->id; - $list->type = $pipelineGitlab->type; - $list->name = $pipelineGitlab->name; - $list->url = $pipelineGitlab->url; - $list->account = $pipelineGitlab->account; - $list->password = $pipelineGitlab->password; - $list->token = $pipelineGitlab->token; - $list->private = $pipelineGitlab->private; - $list->createdBy = $pipelineGitlab->createdBy; - $list->createdDate = $pipelineGitlab->createdDate; - $list->editedBy = $pipelineGitlab->editedBy; - $list->editedDate = $pipelineGitlab->editedDate; - $list->deleted = $pipelineGitlab->deleted; - $list->is_admin = $token->is_admin; - - $lists[] = $list; - } - - return $lists; + return $gitlabList; } /** diff --git a/module/gitlab/view/browse.html.php b/module/gitlab/view/browse.html.php index 3ddbdcdf5a..c4a5663170 100644 --- a/module/gitlab/view/browse.html.php +++ b/module/gitlab/view/browse.html.php @@ -46,9 +46,10 @@ url;?> createLink('gitlab', 'delete', "gitlabID=$id"), '', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn'"); + $disabled = !empty($gitlab->isAdminToken) ? '' : 'disabled'; + common::printLink('gitlab', 'edit', "gitlabID=$id", " ", '',"title={$lang->gitlab->edit} class='btn btn-primary {$disabled}'"); + common::printLink('gitlab', 'bindUser', "id=$id", " ", '', "title={$lang->gitlab->bindUser} class='btn btn-primary {$disabled}'"); + if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'delete', "gitlabID=$id"), '', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn {$disabled}'"); ?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index ebabdcb63d..bb693f5039 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -63,6 +63,7 @@ $lang->moduleOrder[205] = 'cron'; $lang->moduleOrder[210] = 'dev'; $lang->moduleOrder[215] = 'message'; $lang->moduleOrder[220] = 'gitlab'; +$lang->moduleOrder[225] = 'mr'; $lang->resource = new stdclass(); @@ -1132,13 +1133,13 @@ $lang->svn->methodOrder[15] = 'apiSync'; /* GitLab. */ $lang->resource->gitlab = new stdclass(); -$lang->resource->gitlab->browse = 'browse'; $lang->resource->gitlab->create = 'create'; $lang->resource->gitlab->edit = 'edit'; $lang->resource->gitlab->importIssue = 'importIssue'; $lang->resource->gitlab->delete = 'delete'; $lang->resource->gitlab->bindUser = 'bindUser'; $lang->resource->gitlab->bindProduct = 'bindProduct'; + //$lang->resource->gitlab->webhook = 'webhook'; $lang->gitlab->methodOrder[5] = 'browse'; @@ -1147,9 +1148,14 @@ $lang->gitlab->methodOrder[15] = 'edit'; $lang->gitlab->methodOrder[20] = 'importIssue'; $lang->gitlab->methodOrder[30] = 'delete'; $lang->gitlab->methodOrder[35] = 'bindUser'; -$lang->gitlab->methodOrder[40] = 'bindProduct'; //$lang->gitlab->methodOrder[45] = 'webhook'; +/* merge request. */ +$lang->resource->mr = new stdclass(); +$lang->resource->mr->common = "common"; + +$lang->mr->methodOrder[5] = 'common'; + /* Git. */ $lang->resource->git = new stdclass(); $lang->resource->git->diff = 'diff';