Fixed issue 210, sub-tabs links not follows the active branche in Source view.

This commit is contained in:
Loic d'Anterroches 2009-05-26 21:47:54 +02:00
parent 88ce10b8e6
commit bc434504b1
4 changed files with 15 additions and 20 deletions

View File

@ -126,14 +126,10 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
*/ */
function callbackCommit($m) function callbackCommit($m)
{ {
try { $co = $this->scm->getCommit($m[0]);
if ('commit' != $this->scm->testHash($m[0])) { if (!$co) {
return $m[0]; // not a commit. return $m[0]; // not a commit.
} }
} catch (IDF_Scm_Exception $e) {
return $m[0]; // commit not found.
}
$co = $this->scm->getCommit($m[0]);
return '<a href="' return '<a href="'
.Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', array($this->project->shortname, $co->commit)) .Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', array($this->project->shortname, $co->commit))
.'">'.$m[0].'</a>'; .'">'.$m[0].'</a>';
@ -141,18 +137,14 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
function callbackSource($m) function callbackSource($m)
{ {
$branches = $this->scm->getBranches(); if (!$this->scm->isAvailable()) return $m[0];
if (count($branches) == 0) return $m[0];
$file = $m[2]; $file = $m[2];
if ('commit' != $this->scm->testHash($branches[0], $file)) { $request_file_info = $this->scm->getPathInfo($file);
return $m[0];
}
$request_file_info = $this->scm->getFileInfo($file, $branches[0]);
if (!$request_file_info) { if (!$request_file_info) {
return $m[0]; return $m[0];
} }
if ($request_file_info->type != 'tree') { if ($request_file_info->type != 'tree') {
return $m[1].'<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::tree', array($this->project->shortname, $branches[0], $file)).'">'.$m[2].'</a>'; return $m[1].'<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::tree', array($this->project->shortname, $this->scm->getMainBranch(), $file)).'">'.$m[2].'</a>';
} }
return $m[0]; return $m[0];
} }

View File

@ -88,6 +88,7 @@ class IDF_Views_Source
} }
$rchanges = new Pluf_Template_ContextVars($rchanges); $rchanges = new Pluf_Template_ContextVars($rchanges);
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');
$in_branches = $scm->inBranches($commit, '');
return Pluf_Shortcuts_RenderToResponse('idf/source/changelog.html', return Pluf_Shortcuts_RenderToResponse('idf/source/changelog.html',
array( array(
'page_title' => $title, 'page_title' => $title,
@ -95,6 +96,7 @@ class IDF_Views_Source
'changes' => $rchanges, 'changes' => $rchanges,
'commit' => $commit, 'commit' => $commit,
'branches' => $branches, 'branches' => $branches,
'tree_in' => $in_branches,
'scm' => $scmConf, 'scm' => $scmConf,
), ),
$request); $request);
@ -128,7 +130,6 @@ class IDF_Views_Source
$res = new Pluf_Template_ContextVars($scm->getTree($commit)); $res = new Pluf_Template_ContextVars($scm->getTree($commit));
$cache->set($key, $res); $cache->set($key, $res);
} }
//$tree_in = in_array($commit, $branches);
$scmConf = $request->conf->getVal('scm', 'git'); $scmConf = $request->conf->getVal('scm', 'git');
$props = $scm->getProperties($commit); $props = $scm->getProperties($commit);
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/tree.html', return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/tree.html',

View File

@ -1,9 +1,10 @@
{extends "idf/base.html"} {extends "idf/base.html"}
{block tabsource} class="active"{/block} {block tabsource} class="active"{/block}
{block subtabs} {block subtabs}
{if array_key_exists($commit, $branches)}{assign $currentCommit = $commit}{else}{assign $currentCommit = $project.getScmRoot()}{/if}
<div id="sub-tabs"> <div id="sub-tabs">
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $project.getScmRoot())}">{trans 'Source Tree'}</a> | <a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $currentCommit)}">{trans 'Source Tree'}</a> |
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, $project.getScmRoot())}">{trans 'Change Log'}</a> <a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, $currentCommit)}">{trans 'Change Log'}</a>
{if $inCommit}| {trans 'Commit'}{/if} | {if $inCommit}| {trans 'Commit'}{/if} |
<a {if $inHelp}class="active" {/if}href="{url 'IDF_Views_Source::help', array($project.shortname)}">{trans 'How To Get The Code'}</a> <a {if $inHelp}class="active" {/if}href="{url 'IDF_Views_Source::help', array($project.shortname)}">{trans 'How To Get The Code'}</a>
</div> </div>

View File

@ -27,12 +27,13 @@
</tbody> </tbody>
</table> </table>
{/block} {/block}
{block context} {block context}
{if $scm != 'svn'} {if $scm != 'svn'}
<p><strong>{trans 'Branches:'}</strong><br /> <p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch} {foreach $branches as $branch => $path}
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $branch)} {aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br /> <span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach} {/foreach}
</p> </p>
{else} {else}