* Code for task #65980.
This commit is contained in:
+39
-5
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;}
|
||||
@@ -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%;}
|
||||
@@ -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;}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 = '创建代码库';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
?>
|
||||
<div id="codeContainer" style="height: 600px; padding 10px 0;"></div>
|
||||
<div id="monacoEditor">
|
||||
<div id="codeContainer"></div>
|
||||
<div id="log">
|
||||
<div class="tip"></div>
|
||||
<div class="history"></div>
|
||||
</div>
|
||||
<div id="related">
|
||||
<div class="main-col main">
|
||||
<div class="content panel">
|
||||
<div class='btn-toolbar'>
|
||||
<div class="btn btn-left pull-left"><i class="icon icon-chevron-left"></i></div>
|
||||
<?php if(common::hasPriv('repo', 'blame') or common::hasPriv('repo', 'download')):?>
|
||||
<div class="dropdown pull-right">
|
||||
<button class="btn" type="button" data-toggle="context-dropdown"><i class="icon icon-ellipsis-v icon-rotate-90"></i></button>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
if(common::hasPriv('repo', 'blame')) echo '<li>' . html::a($this->repo->createLink('blame', ""), '<i class="icon icon-change"></i> ' . $lang->repo->blame, '', "data-app='{$app->tab}'") . '</li>';
|
||||
if(common::hasPriv('repo', 'download')) echo '<li>' . html::a($this->repo->createLink('download', ""), '<i class="icon icon-download"></i> ' . $lang->repo->download, 'hiddenwin') . '</li>';
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<div class="btn btn-right pull-right"><i class="icon icon-chevron-right"></i></div>
|
||||
<div class='panel-title'>
|
||||
<div class="tabs w-10" id="relationTabs"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
var codeHeight = $(window).innerHeight() - $('#mainHeader').height() - $('#appsBar').height() - $('#fileTabs .tabs-navbar').height();
|
||||
$('#codeContainer').css('height', codeHeight);
|
||||
|
||||
/**
|
||||
* Get relation by commit.
|
||||
*
|
||||
* @param string $commit
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function getRelation(commit)
|
||||
{
|
||||
$('#codeContainer').css('height', codeHeight / 5 * 3);
|
||||
$tabs = $('#relationTabs').data('zui.tabs');
|
||||
if($tabs) $tabs.closeAll();
|
||||
|
||||
$.post(createLink('repo', 'ajaxGetCommitRelation', 'commit=' + commit), function(data)
|
||||
{
|
||||
var titleList = JSON.parse(data).titleList;
|
||||
var tabs = [];
|
||||
$.each(titleList, function(i, titleObj)
|
||||
{
|
||||
var tab = setTab(titleObj);
|
||||
if($tabs)
|
||||
{
|
||||
$tabs.open(tab);
|
||||
}
|
||||
else
|
||||
{
|
||||
tabs.push(tab);
|
||||
}
|
||||
});
|
||||
|
||||
if(titleList.length > 0)
|
||||
{
|
||||
if($tabs)
|
||||
{
|
||||
$tabs.open(setTab(titleList[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#relationTabs').tabs({tabs: tabs});
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#related').show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tab data.
|
||||
*
|
||||
* @param object $titleObj
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function setTab(titleObj)
|
||||
{
|
||||
return {
|
||||
id: titleObj.type + '-' + titleObj.id,
|
||||
title: ' ' + titleObj.title,
|
||||
icon: titleObj.type == 'story' ? 'icon-lightbulb' : (titleObj.type == 'task' ? 'icon-check-sign' : 'icon-bug'),
|
||||
type: 'iframe',
|
||||
url: createLink('repo', 'ajaxGetRelationInfo', 'objectID=' + titleObj.id + '&objectType=' + titleObj.type)
|
||||
};
|
||||
}
|
||||
|
||||
require.config({
|
||||
paths: {vs: jsRoot + 'monaco-editor/min/vs'},
|
||||
'vs/nls': {
|
||||
@@ -50,6 +149,29 @@ $(function()
|
||||
readOnly: true,
|
||||
automaticLayout: true
|
||||
});
|
||||
|
||||
editor.onMouseDown(function(obj)
|
||||
{
|
||||
var line = obj.target.position.lineNumber;
|
||||
|
||||
var blame = blames[line];
|
||||
var p_line = parseInt(line);
|
||||
while(!blame.revision)
|
||||
{
|
||||
p_line--;
|
||||
blame = blames[p_line];
|
||||
}
|
||||
if($('#log').data('line') == p_line) return;
|
||||
|
||||
var time = blame.time != 'unknown' ? blame.time : '';
|
||||
var user = blame.committer != 'unknown' ? blame.committer : '';
|
||||
var version = blame.revision.toString().substring(0, 10);
|
||||
var content = blameTmpl.replace('%time', time).replace('%name', user).replace('%version', version).replace('%comment', blame.message);
|
||||
$('.history').text(content);
|
||||
$('#log').data('line', p_line);
|
||||
$('#log').css('display', 'flex');
|
||||
getRelation(version);
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* The create view file of repo module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
|
||||
* @author Yanyi Cao
|
||||
* @package repo
|
||||
* @version $Id: ajaxgetcommitrelation.html.php $
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
include '../../common/view/header.lite.html.php';
|
||||
?>
|
||||
<div class="main-col repoCode main">
|
||||
<div class="content panel">
|
||||
<div class="fade main-row split-row in" id="mainRow">
|
||||
<div class="side-col left-content">
|
||||
<table class="menu-title">
|
||||
<?php if($objectType == 'story'):?>
|
||||
<tr><th class='text-right'><?php echo $lang->release->storyTitle;?>: </th><td class="text"><?php echo $object->title; ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->story->legendSpec;?>: </th><td class="text"><?php echo $object->spec; ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->story->verify;?>: </th><td class="text"><?php echo $object->verify; ?></td></tr>
|
||||
<?php elseif($objectType == 'task'):?>
|
||||
<tr><th class='text-right'><?php echo $lang->task->name;?>: </th><td class="text"><?php echo $object->name; ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->task->desc;?>: </th><td class="text"><?php echo $object->desc; ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->task->story;?>: </th><td class="text"><?php echo $object->storyTitle; ?></td></tr>
|
||||
<?php elseif($objectType == 'bug'):?>
|
||||
<tr><th class='text-right'><?php echo $lang->bug->title;?>: </th><td class="text"><?php echo $object->title; ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->bug->type;?>: </th><td class="text"><?php echo zget($lang->bug->typeList, $object->type); ?></td></tr>
|
||||
<tr><th class='text-right'><?php echo $lang->bug->steps;?>: </th><td class="text"><?php echo $object->steps; ?></td></tr>
|
||||
<?php endif;?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="main-col">
|
||||
<?php include '../../common/view/action.html.php';?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.lite.html.php';?>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
$('a').attr('href', 'javascript:;').removeClass('iframe').css('color', '#3c4353');
|
||||
$('blockquote a').empty();
|
||||
$('.left-content').css('width', $('.repoCode .content').width() / 5 * 3);
|
||||
});
|
||||
</script>
|
||||
@@ -23,7 +23,6 @@ $encodePath = $this->repo->encodePath($entry);
|
||||
?>
|
||||
<?php if(!isonlybody()):?>
|
||||
<div id="mainContent" class="main-row fade">
|
||||
<?php endif;?>
|
||||
<?php $sideWidth = common::checkNotCN() ? '270' : '240';?>
|
||||
<div class="side-col" style="width: <?php echo $sideWidth;?>px; padding-top: <?php echo isonlybody() ? 22 : 0;?>px;">
|
||||
<div class="side-col file-tree" style="width: <?php echo $sideWidth;?>px;" data-min-width="<?php echo $sideWidth;?>">
|
||||
@@ -50,9 +49,11 @@ $encodePath = $this->repo->encodePath($entry);
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<div class="main-col repoCode main">
|
||||
<div class="content panel">
|
||||
<div class='btn-toolbar'>
|
||||
<?php if(!isonlybody()):?>
|
||||
<div class="btn btn-left pull-left"><i class="icon icon-chevron-left"></i></div>
|
||||
<?php if(common::hasPriv('repo', 'blame') or common::hasPriv('repo', 'download')):?>
|
||||
<div class="dropdown pull-right">
|
||||
@@ -66,6 +67,7 @@ $encodePath = $this->repo->encodePath($entry);
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<div class="btn btn-right pull-right"><i class="icon icon-chevron-right"></i></div>
|
||||
<?php endif;?>
|
||||
<div class='panel-title'>
|
||||
<div class="tabs w-10" id="fileTabs"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user