diff --git a/module/repo/control.php b/module/repo/control.php index eabeba0aba..237319b39b 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -270,11 +270,12 @@ class repo extends control $info = $this->scm->info($entry, $revision); $path = $entry ? $info->path : ''; if($info->kind == 'dir') $this->locate($this->repo->createLink('browse', "repoID=$repoID&branchID=&objectID=$objectID&path=" . $this->repo->encodePath($path) . "&revision=$revision")); - $content = $this->scm->cat($entry, $revision); - $entry = urldecode($entry); - $pathInfo = pathinfo($entry); - $encoding = empty($encoding) ? $repo->encoding : $encoding; - $encoding = strtolower(str_replace('_', '-', $encoding)); + $content = $this->scm->cat($entry, $revision); + $entry = urldecode($entry); + $pathInfo = pathinfo($entry); + $encoding = empty($encoding) ? $repo->encoding : $encoding; + $encoding = strtolower(str_replace('_', '-', $encoding)); + $blames = $this->scm->blame($entry, $revision); $suffix = ''; if(isset($pathInfo["extension"])) $suffix = strtolower($pathInfo["extension"]); @@ -304,6 +305,7 @@ class repo extends control $this->view->suffix = $suffix; $this->view->content = $content; $this->view->pathInfo = $pathInfo; + $this->view->blames = $blames; $this->display(); } @@ -1532,4 +1534,36 @@ class repo extends control { $this->repo->insertDeleteRecord($repoID); } + + /** + * Get relation by commit. + * + * @access public + * @return object + */ + public function ajaxGetCommitRelation($commit) + { + $repoID = $this->repo->saveState(); + $titleList = $this->repo->getRelationByCommit($repoID, $commit); + return $this->send(array('titleList' => $titleList)); + } + + /** + * Get relation story, task, bug info. + * + * @param int $objectID + * @param string $objectType + * @access public + * @return void + */ + public function ajaxGetRelationInfo($objectID, $objectType = 'story') + { + $this->app->loadLang('release'); + $this->view->object = $this->loadModel($objectType)->getById($objectID); + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->actions = $this->loadModel('action')->getList($objectType, $objectID); + $this->view->objectID = $objectID; + $this->view->objectType = $objectType; + $this->display(); + } } diff --git a/module/repo/css/ajaxgeteditorcontent.css b/module/repo/css/ajaxgeteditorcontent.css new file mode 100644 index 0000000000..5f0fe98e8d --- /dev/null +++ b/module/repo/css/ajaxgeteditorcontent.css @@ -0,0 +1,13 @@ +.m-repo-ajaxgeteditorcontent {overflow: hidden;} +#monacoEditor .tip {width: 15px; height: 15px; background: #D9D9D9; border-radius: 10px;} +#log {background: #fff; margin-top: 2px; color: #707070; display: none; padding: 5px;} +#log .history {margin-left: 5px;} +#related {display: none; margin-top: 2px;} +#relationTabs .tab-pane {display: none;} +#relationTabs .tabs-navbar {background: #F4F5F7;} +#relationTabs .tab-pane.active {display: block;} +#relationTabs .tab-nav-item {max-width: none !important;} +#relationTabs > .tabs-navbar {overflow: hidden; padding-bottom: 10px; position: relative; height: 35px;} +#relationTabs > .tabs-navbar > .nav-tabs {position: absolute; display: flex;} +#related .content, #related .btn {background-color: #F4F5F7; border: none;} +#related .nav-tabs > li.active > a:before {background: none; height: 0;} diff --git a/module/repo/css/ajaxgetrelationinfo.css b/module/repo/css/ajaxgetrelationinfo.css new file mode 100644 index 0000000000..2233e7d117 --- /dev/null +++ b/module/repo/css/ajaxgetrelationinfo.css @@ -0,0 +1,5 @@ +.repoCode .panel {margin-bottom: 0;} +.left-content {border-right: 1px solid #EDEEF2; padding-top: 15px;} +.text {width: 85%; white-space: normal; word-wrap: break-word; word-break: break-all; font-weight: normal; padding-left: 10px;} +.cell {min-height: 300px;} +.menu-title {width: 100%;} diff --git a/module/repo/css/monaco.css b/module/repo/css/monaco.css index 9d5e91bed0..890c02969f 100644 --- a/module/repo/css/monaco.css +++ b/module/repo/css/monaco.css @@ -1,7 +1,6 @@ .repoCode .nav > li > a {padding: 8px 10px;} .repoCode .nav-tabs > li > a > span {margin-right: 5px;} -#fileTabs .tab-pane {height: 600px;} #fileTabs .tab-pane {display: none;} #fileTabs .tab-pane.active {display: block;} #fileTabs .tab-nav-item {max-width: none !important;} @@ -16,5 +15,6 @@ #sourceSwapper .tree li > a {max-width: 100%;} .version-name {max-width: 90%} #filesTree #modules {margin-top: 5px;} +#filesTree {overflow-y: auto;} .repoCode .content, .repoCode .btn {background-color: #F4F5F7; border: none;} .repoCode .nav-tabs > li.active > a:before {background: none; height: 0;} diff --git a/module/repo/js/monaco.js b/module/repo/js/monaco.js index 50fa69315e..3c7263f365 100644 --- a/module/repo/js/monaco.js +++ b/module/repo/js/monaco.js @@ -1,6 +1,6 @@ $(function() { - var distance = 0; + var distance = 0; /** * Arrow tab line. @@ -44,6 +44,10 @@ $(function() } $('#fileTabs').tabs({tabs: [createTab(file['basename'], entry)]}); + var paneWidth = $(window).height() - 120; + $('#fileTabs .tab-pane').css('height', paneWidth + 'px') + $('#filesTree').css('height', paneWidth + 45) + $(document).on('click', '.repoFileName', function() { var path = $(this).data('path'); @@ -102,7 +106,7 @@ $(function() $(document).on('click', '.branch-or-tag', function() { var branchOrTag = $(this).text(); - if(branchOrTag != branchID) + if(branchOrTag != $.cookie('repoBranch')) { $('#filesTree').addClass('loading'); $.cookie('repoBranch', branchOrTag); diff --git a/module/repo/lang/de.php b/module/repo/lang/de.php index eef3df7db5..7630e4dcd4 100644 --- a/module/repo/lang/de.php +++ b/module/repo/lang/de.php @@ -26,6 +26,7 @@ $lang->repo->branch = 'Branch'; $lang->repo->tag = 'Tag'; $lang->repo->addWebHook = 'Add Webhook'; $lang->repo->apiGetRepoByUrl = 'API: Get repo by URL'; +$lang->repo->blamTmpl = '%time %name commited %version %comment'; $lang->repo->browseAction = 'Browse Repo'; $lang->repo->createAction = 'Create Repo'; diff --git a/module/repo/lang/en.php b/module/repo/lang/en.php index 025d4901ab..7eea815f38 100644 --- a/module/repo/lang/en.php +++ b/module/repo/lang/en.php @@ -26,6 +26,7 @@ $lang->repo->branch = 'Branch'; $lang->repo->tag = 'Tag'; $lang->repo->addWebHook = 'Add Webhook'; $lang->repo->apiGetRepoByUrl = 'API: Get repo by URL'; +$lang->repo->blamTmpl = '%time %name commited %version %comment'; $lang->repo->browseAction = 'Browse Repo'; $lang->repo->createAction = 'Create Repo'; diff --git a/module/repo/lang/fr.php b/module/repo/lang/fr.php index 28e405a979..32f93f5a36 100644 --- a/module/repo/lang/fr.php +++ b/module/repo/lang/fr.php @@ -26,6 +26,7 @@ $lang->repo->branch = 'Branch'; $lang->repo->tag = 'Tag'; $lang->repo->addWebHook = 'Add Webhook'; $lang->repo->apiGetRepoByUrl = 'API: Get repo by URL'; +$lang->repo->blamTmpl = '%time %name commited %version %comment'; $lang->repo->browseAction = 'Browse Repo'; $lang->repo->createAction = 'Créer Ref'; diff --git a/module/repo/lang/vi.php b/module/repo/lang/vi.php index aa05c51e62..81861ae77e 100644 --- a/module/repo/lang/vi.php +++ b/module/repo/lang/vi.php @@ -26,6 +26,7 @@ $lang->repo->branch = 'Branch'; $lang->repo->tag = 'Tag'; $lang->repo->addWebHook = 'Add Webhook'; $lang->repo->apiGetRepoByUrl = 'API: Get repo by URL'; +$lang->repo->blamTmpl = '%time %name commited %version %comment'; $lang->repo->browseAction = 'Browse Repo'; $lang->repo->createAction = 'Create Repo'; diff --git a/module/repo/lang/zh-cn.php b/module/repo/lang/zh-cn.php index e791a70c1d..2ac898fbb9 100644 --- a/module/repo/lang/zh-cn.php +++ b/module/repo/lang/zh-cn.php @@ -26,6 +26,7 @@ $lang->repo->branch = '分支'; $lang->repo->tag = '标签'; $lang->repo->addWebHook = '添加Webhook'; $lang->repo->apiGetRepoByUrl = '接口:通过URL获取代码库'; +$lang->repo->blamTmpl = '%time 由%name提交%version %comment'; $lang->repo->browseAction = '浏览代码库'; $lang->repo->createAction = '创建代码库'; diff --git a/module/repo/model.php b/module/repo/model.php index 8d2812fcd1..bbdcb39719 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -2316,6 +2316,7 @@ class repoModel extends model ->leftJoin(TABLE_REPOHISTORY)->alias('t2')->on('t1.revision=t2.id') ->leftJoin(TABLE_REPOBRANCH)->alias('t3')->on('t2.id=t3.revision') ->where('t1.repo')->eq($repo->id) + ->andWhere('t1.type')->eq('file') ->andWhere('left(t2.comment, 12)')->ne('Merge branch') ->beginIF($repo->SCM != 'Subversion' and $branch)->andWhere('t3.branch')->eq($branch)->fi() ->orderBy('t2.`time` asc') @@ -2586,4 +2587,71 @@ class repoModel extends model $this->loadModel('setting')->setItem('system.repo.synced', $this->config->repo->synced . ',' . $repoID); } + + /** + * Get relation by commit. + * + * @param int $repoID + * @param string $commit + * @access public + * @return array + */ + public function getRelationByCommit($repoID, $commit) + { + $relationList = $this->dao->select('BID as id, BType as type')->from(TABLE_RELATION) + ->where('relation')->eq('repo') + ->andWhere('AType')->eq('codeCommited') + ->andWhere('AID')->eq($repoID) + ->andWhere('AVersion')->eq($commit) + ->fetchAll(); + + $storyIDs = array(); + $bugIDs = array(); + $taskIDs = array(); + foreach($relationList as $relation) + { + if($relation->type == 'story') + { + $storyIDs[] = $relation->id; + } + elseif($relation->type == 'bug') + { + $bugIDs[] = $relation->id; + } + elseif($relation->type == 'task') + { + $taskIDs[] = $relation->id; + } + } + $stories = empty($storyIDs) ? array() : $this->loadModel('story')->getByList($storyIDs); + $bugs = empty($bugIDs) ? array() : $this->loadModel('bug')->getByList($bugIDs); + $tasks = empty($taskIDs) ? array() : $this->loadModel('task')->getByList($taskIDs); + + $titleList = array(); + foreach($relationList as $key => $relation) + { + $titleList[$key] = array( + 'id' => $relation->id, + 'type' => $relation->type, + 'title' => "#$relation->id " + ); + if($relation->type == 'story') + { + $story = zget($stories, $relation->id, array()); + $titleList[$key]['title'] .= zget($story, 'title', ''); + } + elseif($relation->type == 'bug') + { + $bug = zget($bugs, $relation->id, array()); + $titleList[$key]['title'] .= zget($bug, 'title', ''); + } + elseif($relation->type == 'task') + { + $task = zget($tasks, $relation->id, array()); + $titleList[$key]['title'] .= zget($task, 'name', ''); + } + } + + return $titleList; + } } diff --git a/module/repo/view/ajaxgeteditorcontent.html.php b/module/repo/view/ajaxgeteditorcontent.html.php index 3d1f5c3249..c228d10079 100644 --- a/module/repo/view/ajaxgeteditorcontent.html.php +++ b/module/repo/view/ajaxgeteditorcontent.html.php @@ -15,12 +15,111 @@ js::set('clientLang', $app->clientLang); js::set('fileExt', $this->config->repo->fileExt); js::set('codeContent', trim($content)); js::set('file', $pathInfo); +js::set('blames', $blames); +js::set('blameTmpl', $lang->repo->blamTmpl); +js::import($jsRoot . '/zui/tabs/tabs.min.js'); js::import($jsRoot . 'monaco-editor/min/vs/loader.js'); ?> -
+
+
+
+
+
+
+ +
diff --git a/module/repo/view/ajaxgetrelationinfo.html.php b/module/repo/view/ajaxgetrelationinfo.html.php new file mode 100644 index 0000000000..2f8f814f63 --- /dev/null +++ b/module/repo/view/ajaxgetrelationinfo.html.php @@ -0,0 +1,48 @@ + + +
+
+
+
+ + + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + diff --git a/module/repo/view/monaco.html.php b/module/repo/view/monaco.html.php index e02657c614..17e9b0f583 100644 --- a/module/repo/view/monaco.html.php +++ b/module/repo/view/monaco.html.php @@ -23,7 +23,6 @@ $encodePath = $this->repo->encodePath($entry); ?>
-
@@ -50,9 +49,11 @@ $encodePath = $this->repo->encodePath($entry);
+
+
+