diff --git a/administrator/components/com_patchtester/config.xml b/administrator/components/com_patchtester/config.xml index cbcc676..17b20fc 100644 --- a/administrator/components/com_patchtester/config.xml +++ b/administrator/components/com_patchtester/config.xml @@ -20,6 +20,11 @@ description="COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC" label="COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL" /> + +
diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index a2b4a87..1693596 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -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" diff --git a/administrator/components/com_patchtester/models/pull.php b/administrator/components/com_patchtester/models/pull.php index 86a6106..ae0adcc 100644 --- a/administrator/components/com_patchtester/models/pull.php +++ b/administrator/components/com_patchtester/models/pull.php @@ -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', '')); diff --git a/administrator/components/com_patchtester/models/pulls.php b/administrator/components/com_patchtester/models/pulls.php index f522bd2..41a212b 100644 --- a/administrator/components/com_patchtester/models/pulls.php +++ b/administrator/components/com_patchtester/models/pulls.php @@ -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); diff --git a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php index 9cd58fc..cced92b 100644 --- a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php @@ -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; ?> - +> pull_id; ?> @@ -47,7 +44,7 @@ foreach ($this->items as $i => $item) : endif; ?> - applied) : ?> + applied) : ?> @@ -58,8 +55,8 @@ foreach ($this->items as $i => $item) : - applied) : - echo '' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . ''; + applied) : + echo '' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . ''; else : echo '' . JText::_('COM_PATCHTESTER_APPLY_PATCH') . ''; endif; ?> diff --git a/administrator/components/com_patchtester/views/pulls/view.html.php b/administrator/components/com_patchtester/views/pulls/view.html.php index 6bd1a91..e1ed4e6 100644 --- a/administrator/components/com_patchtester/views/pulls/view.html.php +++ b/administrator/components/com_patchtester/views/pulls/view.html.php @@ -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.