31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-05-31 04:40:47 +00:00

Process labels during fetch and store RTC state if the label is assigned (Fix #88)

This commit is contained in:
Michael Babker 2016-03-27 14:39:34 -04:00
parent 4811968a5c
commit 5b3e5bcd96
10 changed files with 74 additions and 6 deletions

View File

@ -111,6 +111,7 @@ class DisplayController extends AbstractController
// Load the filter state.
$state->set('filter.search', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''));
$state->set('filter.applied', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.applied', 'filter_applied', ''));
$state->set('filter.rtc', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.rtc', 'filter_rtc', ''));
// Pre-fill the limits.
$limit = $this->getApplication()->getUserStateFromRequest('global.list.limit', 'limit', $this->getApplication()->get('list_limit', 20), 'uint');

View File

@ -126,6 +126,17 @@ class PullsModel extends \JModelDatabase
$query->where($db->quoteName('applied') . $value);
}
// Filter for RTC patches
$applied = $this->getState()->get('filter.rtc');
if (!empty($applied))
{
// Not applied patches have a NULL value, so build our value part of the query based on this
$value = $applied == 'no' ? '0' : '1';
$query->where($db->quoteName('is_rtc') . ' = ' . $value);
}
// Handle the list ordering.
$ordering = $this->getState()->get('list.ordering');
$direction = $this->getState()->get('list.direction');
@ -318,12 +329,26 @@ class PullsModel extends \JModelDatabase
{
if (isset($pull->pull_request))
{
// Check if this PR is RTC
$isRTC = false;
foreach ($pull->labels as $label)
{
if ($label->name === 'RTC')
{
$isRTC = true;
break;
}
}
// Build the data object to store in the database
$pullData = array(
(int) $pull->number,
$this->getDb()->quote(\JHtml::_('string.truncate', $pull->title, 150)),
$this->getDb()->quote(\JHtml::_('string.truncate', $pull->body, 100)),
$this->getDb()->quote($pull->pull_request->url),
(int) $isRTC,
);
$data[] = implode($pullData, ',');
@ -333,7 +358,7 @@ class PullsModel extends \JModelDatabase
$this->getDb()->setQuery(
$this->getDb()->getQuery(true)
->insert('#__patchtester_pulls')
->columns(array('pull_id', 'title', 'description', 'pull_url'))
->columns(array('pull_id', 'title', 'description', 'pull_url', 'is_rtc'))
->values($data)
);

View File

@ -20,6 +20,7 @@ else :
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$filterRtc = $this->escape($this->state->get('filter.rtc'));
?>
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
<div id="j-main-container">
@ -52,13 +53,21 @@ $filterApplied = $this->escape($this->state->get('filter.applied'));
</select>
</div>
<div class="btn-group pull-right">
<label for="filter_applied" class="element-invisible"><?php echo \JText::_('JGLOBAL_SORT_BY'); ?></label>
<label for="filter_applied" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
<select name="filter_applied" class="input-medium" onchange="this.form.submit();">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></option>
<option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></option>
<option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="filter_rtc" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
<select name="filter_rtc" class="input-medium" onchange="this.form.submit();">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option>
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option>
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
</select>
</div>
</div>
<?php if (empty($this->items)) : ?>
@ -75,6 +84,9 @@ $filterApplied = $this->escape($this->state->get('filter.applied'));
<th class="nowrap">
<?php echo \JText::_('JGLOBAL_TITLE'); ?>
</th>
<th width="8%" class="nowrap center">
<?php echo \JText::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
</th>
<th width="8%" class="nowrap center">
<?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
</th>

View File

@ -27,6 +27,13 @@ foreach ($this->items as $i => $item) :
</div>
<?php endif; ?>
</td>
<td class="center">
<?php if ($item->is_rtc) : ?>
<span class="label label-success"><?php echo \JText::_('JYES'); ?></span>
<?php else : ?>
<span class="label label-primary"><?php echo \JText::_('JNO'); ?></span>
<?php endif; ?>
</td>
<td class="center">
<a class="btn btn-small btn-info" href="<?php echo $item->pull_url; ?>" target="_blank">
<span class="octicon octicon-mark-github"></span> <?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>

View File

@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `#__patchtester_pulls` (
`description` varchar(150) NOT NULL DEFAULT '',
`pull_url` varchar(255) NOT NULL,
`sha` varchar(40) NOT NULL DEFAULT '',
`is_rtc` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

View File

@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS "#__patchtester_pulls" (
"description" character varying(150) DEFAULT '' NOT NULL,
"pull_url" character varying(255) NOT NULL,
"sha" character varying(40) DEFAULT '' NOT NULL,
"is_rtc" smallint DEFAULT 1 NOT NULL,
PRIMARY KEY ("id")
);

View File

@ -5,6 +5,7 @@ CREATE TABLE [#__patchtester_pulls] (
[description] [nvarchar](150) NOT NULL DEFAULT '',
[pull_url] [nvarchar](255) NOT NULL,
[sha] [nvarchar](40) NOT NULL DEFAULT '',
[is_rtc] [smallint] NOT NULL DEFAULT 1,,
CONSTRAINT [PK_#__patchtester_pulls] PRIMARY KEY CLUSTERED
(
[id] ASC

View File

@ -16,7 +16,6 @@ COM_PATCHTESTER_CONFIGURATION="Joomla! Patch Tester Settings"
COM_PATCHTESTER_CONFIRM_RESET="Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?"
COM_PATCHTESTER_CONFLICT_S="The patch could not be applied because it conflicts with a previously applied patch: %s"
COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB="Could not connect to GitHub: %s"
COM_PATCHTESTER_DIFFERENT_SHA="The patch you've applied is in a different state than when data was last pulled from GitHub. Commit %1$s was expected however commit %2$s was applied."
COM_PATCHTESTER_ERROR_APPLIED_PATCHES="Cannot fetch data from GitHub while there are applied patches. Please revert those patches before continuing."
COM_PATCHTESTER_ERROR_CANNOT_COPY_FILE="Cannot copy source file %1$s to destination %2$s"
COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE="Cannot delete file %s"
@ -46,16 +45,19 @@ COM_PATCHTESTER_FIELD_REPO_DESC="Name of a repository on GitHub of which to moni
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"
COM_PATCHTESTER_FILTER_RTC_PATCHES="Filter RTC Patches"
COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION="Search the list by title or prefix with \"id:\" to search by Pull ID."
COM_PATCHTESTER_GITHUB="GitHub"
COM_PATCHTESTER_HEADING_FETCH_DATA="Fetching GitHub Data"
COM_PATCHTESTER_JISSUE="J! Issue"
COM_PATCHTESTER_JISSUES="Issue Tracker"
COM_PATCHTESTER_PULL_ID="Pull ID"
COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your user credentials in the Options. This will limit you to only 60 requests to the GitHub API per hour. Adding your credentials will allow 5,000 requests per hour."
COM_PATCHTESTER_NO_FILES_TO_PATCH="There are no files to patch from this pull request. This may mean that the files in the pull request are not present in your installation."
COM_PATCHTESTER_NO_ITEMS="No data has been retrieved from GitHub, please click the 'Fetch Data' button in the toolbar to retrieve the open pull requests."
COM_PATCHTESTER_NOT_APPLIED="Not Applied"
COM_PATCHTESTER_GITHUB="GitHub"
COM_PATCHTESTER_JISSUE="J! Issue"
COM_PATCHTESTER_JISSUES="Issue Tracker"
COM_PATCHTESTER_NOT_RTC="Not RTC"
COM_PATCHTESTER_READY_TO_COMMIT="Ready to Commit"
COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing"
COM_PATCHTESTER_REQUIREMENT_HTTPS="HTTPS wrappers must be enabled"
COM_PATCHTESTER_REQUIREMENT_OPENSSL="The OpenSSL extension must be installed and enabled in your php.ini"
@ -65,6 +67,7 @@ COM_PATCHTESTER_RESET_HAS_ERRORS="The reset process has completed however it enc
COM_PATCHTESTER_RESET_OK="The reset process has completed successfully."
COM_PATCHTESTER_REVERT_OK="Patch successfully reverted"
COM_PATCHTESTER_REVERT_PATCH="Revert Patch"
COM_PATCHTESTER_RTC="RTC"
COM_PATCHTESTER_TEST_THIS_PATCH="Test This Patch"
COM_PATCHTESTER_TOOLBAR_FETCH_DATA="Fetch Data"
COM_PATCHTESTER_TOOLBAR_RESET="Reset"

View File

@ -19,6 +19,7 @@ else :
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$filterRtc = $this->escape($this->state->get('filter.rtc'));
\JFactory::getDocument()->addStyleDeclaration(
'
@ -53,6 +54,12 @@ echo \JHtml::_(
<option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></option>
<option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option>
</select>
<label class="selectlabel" for="filter_rtc"><?php echo JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></label>
<select name="filter_rtc" id="filter_rtc">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option>
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option>
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
</select>
<button type="submit" id="filter-go"><?php echo \JText::_('JSUBMIT'); ?></button>
</div>
</fieldset>
@ -67,6 +74,9 @@ echo \JHtml::_(
<th class="nowrap">
<?php echo \JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="8%" class="nowrap center">
<?php echo \JText::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
</th>
<th width="8%" class="nowrap center">
<?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>
</th>

View File

@ -29,6 +29,13 @@ foreach ($this->items as $i => $item) :
</p>
<?php endif; ?>
</td>
<td class="center">
<?php if ($item->is_rtc) : ?>
<span class="label label-success"><?php echo \JText::_('JYES'); ?></span>
<?php else : ?>
<span class="label label-primary"><?php echo \JText::_('JNO'); ?></span>
<?php endif; ?>
</td>
<td>
<a class="btn btn-small btn-info" href="<?php echo $item->pull_url; ?>" target="_blank">
<span class="octicon octicon-mark-github"></span> <?php echo \JText::_('COM_PATCHTESTER_GITHUB'); ?>