mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-11 01:32:05 +00:00
Correctly link to the issue tracker if able (Fix #130)
This commit is contained in:
parent
60b48e2236
commit
0fe1c63146
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2016 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
namespace PatchTester;
|
||||
|
||||
/**
|
||||
* Helper class for Joomla's issue tracker integrations
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
abstract class TrackerHelper
|
||||
{
|
||||
/**
|
||||
* Array containing the supported repositories integrated with the Joomla! Issue Tracker
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
private static $projects = array(
|
||||
'joomla-cms' => array(
|
||||
'githubUser' => 'joomla',
|
||||
'githubrepo' => 'joomla-cms',
|
||||
'projectAlias' => 'joomla-cms',
|
||||
),
|
||||
'patchtester' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'patchtester',
|
||||
'projectAlias' => 'patchtester',
|
||||
),
|
||||
'weblinks' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'weblinks',
|
||||
'projectAlias' => 'weblinks',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the issue tracker project alias for a GitHub repository
|
||||
*
|
||||
* @param string $githubUser The owner of the GitHub repository (user or organization)
|
||||
* @param string $githubRepo The GitHub repository name
|
||||
*
|
||||
* @return string|boolean The project alias if supported or boolean false
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static function getTrackerAlias($githubUser, $githubRepo)
|
||||
{
|
||||
// If the repo isn't even listed, no point in going further
|
||||
if (!array_key_exists($githubRepo, self::$projects))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now the GitHub user must match the project (we don't support forks, sorry!)
|
||||
if (self::$projects[$githubRepo]['githubUser'] !== $githubUser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// This project is supported
|
||||
return self::$projects[$githubRepo]['projectAlias'];
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace PatchTester\View\Pulls;
|
||||
|
||||
use PatchTester\TrackerHelper;
|
||||
use PatchTester\View\DefaultHtmlView;
|
||||
|
||||
/**
|
||||
@ -36,7 +37,15 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* State object
|
||||
* Pagination object
|
||||
*
|
||||
* @var \JPagination
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var \Joomla\Registry\Registry
|
||||
* @since 2.0
|
||||
@ -44,12 +53,12 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Pagination object
|
||||
* The issue tracker project alias
|
||||
*
|
||||
* @var \JPagination
|
||||
* @var string|boolean
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $pagination;
|
||||
protected $trackerAlias;
|
||||
|
||||
/**
|
||||
* Method to render the view.
|
||||
@ -73,9 +82,10 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
// Only process the data if there are no environment errors
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
$this->state = $this->model->getState();
|
||||
$this->items = $this->model->getItems();
|
||||
$this->pagination = $this->model->getPagination();
|
||||
$this->state = $this->model->getState();
|
||||
$this->items = $this->model->getItems();
|
||||
$this->pagination = $this->model->getPagination();
|
||||
$this->trackerAlias = TrackerHelper::getTrackerAlias($this->state->get('github_user'), $this->state->get('github_repo'));
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
@ -92,7 +102,7 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
\JToolBarHelper::title(\JText::_('COM_PATCHTESTER'), 'patchtester icon-apply');
|
||||
\JToolbarHelper::title(\JText::_('COM_PATCHTESTER'), 'patchtester icon-apply');
|
||||
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
@ -110,7 +120,7 @@ class PullsHtmlView extends DefaultHtmlView
|
||||
);
|
||||
}
|
||||
|
||||
\JToolBarHelper::preferences('com_patchtester');
|
||||
\JToolbarHelper::preferences('com_patchtester');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,9 +81,11 @@ $filterApplied = $this->escape($this->state->get('filter.applied'));
|
||||
<th width="8%" class="nowrap center">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
|
||||
</th>
|
||||
<?php if ($this->trackerAlias !== false) : ?>
|
||||
<th width="8%" class="nowrap center">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_JISSUES'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th width="10%" class="nowrap center">
|
||||
<?php echo \JText::_('JSTATUS'); ?>
|
||||
</th>
|
||||
|
@ -30,11 +30,13 @@ foreach ($this->items as $i => $item) :
|
||||
<span class="octicon octicon-mark-github"></span> <?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<?php if ($this->trackerAlias !== false) : ?>
|
||||
<td class="center">
|
||||
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
|
||||
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>" target="_blank">
|
||||
<i class="icon-joomla"></i> <?php echo \JText::_('COM_PATCHTESTER_JISSUE'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="label label-success">
|
||||
|
@ -70,9 +70,11 @@ echo \JHtml::_(
|
||||
<th width="8%" class="nowrap center">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
|
||||
</th>
|
||||
<?php if ($this->trackerAlias !== false) : ?>
|
||||
<th width="8%" class="nowrap center">
|
||||
<?php echo \JText::_('COM_PATCHTESTER_JISSUES'); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th width="10%" class="nowrap center">
|
||||
<?php echo \JHtml::_('grid.sort', 'JSTATUS', 'applied', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
|
@ -29,11 +29,13 @@ foreach ($this->items as $i => $item) :
|
||||
<span class="octicon octicon-mark-github"></span> <?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<?php if ($this->trackerAlias !== false) : ?>
|
||||
<td>
|
||||
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
|
||||
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>" target="_blank">
|
||||
<i class="icon-joomla"></i> <?php echo \JText::_('COM_PATCHTESTER_JISSUE'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="label label-success">
|
||||
|
Loading…
Reference in New Issue
Block a user