diff --git a/module/bug/model.php b/module/bug/model.php index 65b95f0892..c8d6957204 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -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; } diff --git a/module/bug/ui/view.html.php b/module/bug/ui/view.html.php index 0a11663ac2..07a201413a 100644 --- a/module/bug/ui/view.html.php +++ b/module/bug/ui/view.html.php @@ -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 diff --git a/module/repo/model.php b/module/repo/model.php index 7f904fdc19..82bcc2630b 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -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) diff --git a/module/story/model.php b/module/story/model.php index aef8388055..7c5d4ad918 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -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; } diff --git a/module/story/ui/view.html.php b/module/story/ui/view.html.php index 7aaa1f62d4..e3b1a46959 100644 --- a/module/story/ui/view.html.php +++ b/module/story/ui/view.html.php @@ -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,