* Finish task #59441,59442,59443,59444,59445.

This commit is contained in:
caoyanyi
2022-07-04 14:53:16 +08:00
parent 01f6be9b57
commit 018ba38397
16 changed files with 372 additions and 71 deletions
+43 -1
View File
@@ -601,10 +601,11 @@ class gitlabModel extends model
* @param int $gitlabID
* @param string $orderBy
* @param string $minRole
* @param string $keyword
* @access public
* @return object
*/
public function apiGetGroups($gitlabID, $orderBy = 'id_desc', $minRole = '')
public function apiGetGroups($gitlabID, $orderBy = 'id_desc', $minRole = '', $keyword = '')
{
$apiRoot = $this->getApiRoot($gitlabID);
$url = sprintf($apiRoot, "/groups");
@@ -617,6 +618,8 @@ class gitlabModel extends model
$url .= '&min_access_level=' . $this->config->gitlab->accessLevel[$minRole];
}
if($keyword) $url .= '&search=' . urlencode($keyword);
$order = 'id';
$sort = 'desc';
if(strpos($orderBy, '_') !== false) list($order, $sort) = explode('_', $orderBy);
@@ -2854,4 +2857,43 @@ class gitlabModel extends model
$apiRoot .= '&sudo=' . $users[0]->id;
return $this->apiGet($apiRoot, '/user');
}
/**
* Get gitlab menu.
*
* @param int $gitlabID
* @param string $type
* @access public
* @return void
*/
public function getGitlabMenu($gitlabID = 0, $type = 'project')
{
$html = '<div class="btn-toolbar pull-left">';
/* Gitlab server list. */
$gitlabs = $this->getPairs();
$html .= "<div class='btn-group'>";
$tips = $gitlabID >0 ? zget($gitlabs, $gitlabID, $this->lang->gitlab->server) : $this->lang->gitlab->server;
$html .= html::a('javascript:;', $tips . " <span class='caret'></span>", '', "data-toggle='dropdown' class='btn btn-link'");
$html .= "<ul class='dropdown-menu'>";
foreach($gitlabs as $id => $gitlab)
{
$html .= '<li' . ($gitlabID == $id ? " class='active'" : '') . '>';
$html .= html::a(helper::createLink('gitlab', zget($this->config->gitlab->menus, $type, 'project'), "gitlabID=$id"), $gitlab);
}
$html .= '</ul></div>';
/* Other route. */
foreach($this->config->gitlab->menus as $key => $method)
{
$lang = 'browse' . ucwords($key);
$title = $this->lang->gitlab->$lang;
$label = "<span class='text'>$title</span>";
$active = $key == $type ? 'btn-active-text' : '';
$html .= html::a(inlink($method, "gitlabID=$gitlabID"), $label, '', "id='{$key}' class='btn btn-link $active' title='$title'");
}
$html .= '</div>';
return $html;
}
}