* Adjust bug and story view page branch btn display rule.
This commit is contained in:
@@ -1835,17 +1835,6 @@ class bugModel extends model
|
||||
/* 如果bug是激活状态,这个bug可以被转为需求。 */
|
||||
/* If the status is active, the bug can be toStory. */
|
||||
if($module == 'bug' && $action == 'tostory') return $object->status == 'active';
|
||||
/* 如果bug的产品有代码库,这个bug可以创建分支。 */
|
||||
/* If bug's product has repo, the bug can be create code branch. */
|
||||
if($module == 'bug' && $action == 'createbranch')
|
||||
{
|
||||
global $dao;
|
||||
return (bool)$dao->select('id')->from(TABLE_REPO)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere("FIND_IN_SET({$object->product}, `product`)")
|
||||
->andWhere('SCM')->in(array('Gitlab', 'Gitea', 'Gogs', 'GitFox'))
|
||||
->fetch('id');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,16 @@ if(!$bug->deleted)
|
||||
/* Construct common actions for bug. */
|
||||
$actions = $operateList['mainActions'];
|
||||
if(!empty($operateList['suffixActions'])) $actions = array_merge($actions, array(array('type' => 'divider')), $operateList['suffixActions']);
|
||||
|
||||
$hasRepo = $this->loadModel('repo')->getListByProduct($bug->product, 'Gitlab,Gitea,Gogs,GitFox', 1);
|
||||
foreach($actions as $key => $action)
|
||||
{
|
||||
if(!$hasRepo && isset($action['icon']) && $action['icon'] == 'treemap')
|
||||
{
|
||||
unset($actions[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 初始化主栏内容。Init sections in main column. */
|
||||
@@ -107,7 +117,7 @@ detail
|
||||
set::toolbar($toolbar),
|
||||
set::sections($sections),
|
||||
set::tabs($tabs),
|
||||
set::actions($actions)
|
||||
set::actions(array_values($actions))
|
||||
);
|
||||
|
||||
modal
|
||||
|
||||
@@ -3035,6 +3035,16 @@ class repoModel extends model
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过产品ID和代码库类型获取代码库列表。
|
||||
* Get repo list by product id.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $scm
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getListByProduct(int $productID, string $scm = '', int $limit = 0): array
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_REPO)
|
||||
|
||||
@@ -3213,15 +3213,6 @@ class storyModel extends model
|
||||
|
||||
if($action == 'change') return (($isSuperReviewer !== false || count($story->reviewer) == 0 || count($story->notReview) == 0) && $story->status == 'active');
|
||||
if($action == 'review') return (($isSuperReviewer !== false || in_array($app->user->account, $story->notReview)) && $story->status == 'reviewing');
|
||||
if($action == 'createbranch')
|
||||
{
|
||||
global $dao;
|
||||
return (bool)$dao->select('id')->from(TABLE_REPO)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere("FIND_IN_SET({$story->product}, `product`)")
|
||||
->andWhere('SCM')->in(array('Gitlab', 'Gitea', 'Gogs', 'GitFox'))
|
||||
->fetch('id');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -170,11 +170,24 @@ $versionBtn = count($versions) > 1 ? to::title(dropdown
|
||||
set::items($versions)
|
||||
)) : null;
|
||||
|
||||
$hasRepo = $this->loadModel('repo')->getListByProduct($story->product, 'Gitlab,Gitea,Gogs,GitFox', 1);
|
||||
$actions = $story->deleted || $isInModal ? array() : $this->loadModel('common')->buildOperateMenu($story);
|
||||
$hasDivider = !empty($actions['mainActions']) && !empty($actions['suffixActions']);
|
||||
if(!empty($actions)) $actions = array_merge($actions['mainActions'], array(array('type' => 'divider')), $actions['suffixActions']);
|
||||
foreach($actions as $key => $action)
|
||||
{
|
||||
if(!$hasDivider && isset($action['type']) && $action['type'] == 'divider')
|
||||
{
|
||||
unset($actions[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$hasRepo && isset($action['icon']) && $action['icon'] == 'treemap')
|
||||
{
|
||||
unset($actions[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($action['url'])) $actions[$key]['url'] = str_replace(array('{id}', '{type}', '{product}', '{branch}', '{module}'), array($story->id, $story->type, $story->product, $story->branch, $story->module), $action['url']);
|
||||
if(isset($action['items']))
|
||||
{
|
||||
@@ -184,14 +197,14 @@ foreach($actions as $key => $action)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$hasDivider) unset($actions['type']);
|
||||
|
||||
detail
|
||||
(
|
||||
set::objectType('story'),
|
||||
set::toolbar($toolbar),
|
||||
set::sections($sections),
|
||||
set::tabs($tabs),
|
||||
set::actions($actions),
|
||||
set::actions(array_values($actions)),
|
||||
$parentTitle,
|
||||
$parentUrl,
|
||||
$versionBtn,
|
||||
|
||||
Reference in New Issue
Block a user