mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-02-02 11:58:26 +00:00
Refactoring & Features
- Add support for an OAuth token - Join over the applied patches table on the list view - Data is all stored in database now versus fetching on each request
This commit is contained in:
parent
07b311e5c4
commit
1f432702bc
@ -20,6 +20,11 @@
|
||||
description="COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL"
|
||||
/>
|
||||
|
||||
<field name="gh_token" type="text"
|
||||
description="COM_PATCHTESTER_FIELD_GH_TOKEN_DESC"
|
||||
label="COM_PATCHTESTER_FIELD_GH_TOKEN_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC" label="JCONFIG_PERMISSIONS_LABEL">
|
||||
|
@ -19,6 +19,8 @@ COM_PATCHTESTER_ERROR_INSERT_DATABASE="Error inserting pull request data into th
|
||||
COM_PATCHTESTER_FETCH_SUCCESSFUL="Successfully retrieved pull requests."
|
||||
COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL="GitHub Account Password"
|
||||
COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC="Password for the account entered in the "_QQ_"GitHub Account"_QQ_" field. Note that accounts using Two Factor Authentication will not work with this component."
|
||||
COM_PATCHTESTER_FIELD_GH_TOKEN_DESC="Use this field to input a GitHub API Token in place of your username and password. Note that this is required if your account has Two Factor Authentication enabled."
|
||||
COM_PATCHTESTER_FIELD_GH_TOKEN_LABEL="GitHub Token"
|
||||
COM_PATCHTESTER_FIELD_GH_USER_LABEL="GitHub Account"
|
||||
COM_PATCHTESTER_FIELD_GH_USER_DESC="Name of account on GitHub of which to authenticate to the API with"
|
||||
COM_PATCHTESTER_FIELD_ORG_LABEL="GitHub Username"
|
||||
|
@ -78,8 +78,13 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
|
||||
$options = new JRegistry;
|
||||
|
||||
// If an API token is set in the params, use it for authentication
|
||||
if ($params->get('gh_token', ''))
|
||||
{
|
||||
$options->set('gh.token', $params->get('gh_token', ''));
|
||||
}
|
||||
// Set the username and password if set in the params
|
||||
if ($params->get('gh_user', '') && $params->get('gh_password'))
|
||||
elseif ($params->get('gh_user', '') && $params->get('gh_password'))
|
||||
{
|
||||
$options->set('api.username', $params->get('gh_user', ''));
|
||||
$options->set('api.password', $params->get('gh_password', ''));
|
||||
|
@ -56,8 +56,13 @@ class PatchtesterModelPulls extends JModelList
|
||||
|
||||
$options = new JRegistry;
|
||||
|
||||
// If an API token is set in the params, use it for authentication
|
||||
if ($params->get('gh_token', ''))
|
||||
{
|
||||
$options->set('gh.token', $params->get('gh_token', ''));
|
||||
}
|
||||
// Set the username and password if set in the params
|
||||
if ($params->get('gh_user', '') && $params->get('gh_password'))
|
||||
elseif ($params->get('gh_user', '') && $params->get('gh_password'))
|
||||
{
|
||||
$options->set('api.username', $params->get('gh_user', ''));
|
||||
$options->set('api.password', $params->get('gh_password', ''));
|
||||
@ -151,6 +156,10 @@ class PatchtesterModelPulls extends JModelList
|
||||
$query->select($this->getState('list.select', 'a.*'));
|
||||
$query->from($db->quoteName('#__patchtester_pulls', 'a'));
|
||||
|
||||
// Join the tests table to get applied patches
|
||||
$query->select($db->quoteName('t.id', 'applied'));
|
||||
$query->join('LEFT', $db->quoteName('#__patchtester_tests', 't') . ' ON t.pull_id = a.pull_id');
|
||||
|
||||
// Filter by search
|
||||
$search = $this->getState('filter.search');
|
||||
|
||||
@ -220,7 +229,6 @@ class PatchtesterModelPulls extends JModelList
|
||||
{
|
||||
$pulls = array_merge($pulls, $items);
|
||||
}
|
||||
|
||||
}
|
||||
while ($count);
|
||||
|
||||
|
@ -13,14 +13,11 @@ defined('_JEXEC') or die;
|
||||
foreach ($this->items as $i => $item) :
|
||||
$status = '';
|
||||
|
||||
if (isset($this->patches[$item->pull_id])) :
|
||||
$patch = $this->patches[$item->pull_id];
|
||||
$status = ($patch->applied) ? 'success' : '';
|
||||
else :
|
||||
$patch = false;
|
||||
if ($item->applied) :
|
||||
$status = ' class="success"';
|
||||
endif;
|
||||
?>
|
||||
<tr class="<?php echo $status ?>">
|
||||
<tr<?php echo $status; ?>>
|
||||
<td class="center">
|
||||
<?php echo $item->pull_id; ?>
|
||||
</td>
|
||||
@ -47,7 +44,7 @@ foreach ($this->items as $i => $item) :
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($patch && $patch->applied) : ?>
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="label label-success">
|
||||
<?php echo JText::_('COM_PATCHTESTER_APPLIED'); ?>
|
||||
</span>
|
||||
@ -58,8 +55,8 @@ foreach ($this->items as $i => $item) :
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($patch && $patch->applied) :
|
||||
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'pull.revert\', ' . (int) $patch->id . ');">' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||
<?php if ($item->applied) :
|
||||
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'pull.revert\', ' . (int) $item->applied . ');">' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||
else :
|
||||
echo '<a class="btn btn-small btn-primary" href="javascript:submitpatch(\'pull.apply\', ' . (int) $item->pull_id . ');">' . JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
||||
endif; ?>
|
||||
|
@ -32,14 +32,6 @@ class PatchtesterViewPulls extends JViewLegacy
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* Object containing data about applied patches
|
||||
*
|
||||
* @var object
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $patches;
|
||||
|
||||
/**
|
||||
* State object
|
||||
*
|
||||
@ -82,7 +74,6 @@ class PatchtesterViewPulls extends JViewLegacy
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->patches = $this->get('AppliedPatches');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
|
||||
// Check for errors.
|
||||
|
Loading…
x
Reference in New Issue
Block a user