Skip to content

Commit b4df300

Browse files
author
Michael Babker
committed
Ability to filter on branches (Ref #191)
1 parent c2f233d commit b4df300

File tree

7 files changed

+68
-5
lines changed

7 files changed

+68
-5
lines changed

administrator/components/com_patchtester/PatchTester/Controller/DisplayController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ protected function initializeState(\JModel $model)
109109
// Load the filter state.
110110
$state->set('filter.search', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''));
111111
$state->set('filter.applied', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.applied', 'filter_applied', ''));
112+
$state->set('filter.branch', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', ''));
112113
$state->set('filter.rtc', $this->getApplication()->getUserStateFromRequest($this->context . '.filter.rtc', 'filter_rtc', ''));
113114

114115
// Pre-fill the limits.

administrator/components/com_patchtester/PatchTester/Model/PullsModel.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ public function __construct($context, Registry $state = null, \JDatabaseDriver $
5252
$this->context = $context;
5353
}
5454

55+
/**
56+
* Method to get an array of branches.
57+
*
58+
* @return array
59+
*
60+
* @since __DEPLOY_VERSION__
61+
*/
62+
public function getBranches()
63+
{
64+
// Create a new query object.
65+
$db = $this->getDb();
66+
$query = $db->getQuery(true);
67+
68+
// Select distinct branches excluding empty values
69+
$query->select('DISTINCT(branch) AS text')
70+
->from('#__patchtester_pulls')
71+
->where($db->quoteName('branch') . ' != ' . $db->quote(''))
72+
->order('branch ASC');
73+
74+
return $db->setQuery($query)->loadAssocList();
75+
}
76+
5577
/**
5678
* Method to get an array of data items.
5779
*
@@ -127,6 +149,14 @@ protected function getListQuery()
127149
$query->where($db->quoteName('applied') . $value);
128150
}
129151

152+
// Filter for branch
153+
$branch = $this->getState()->get('filter.branch');
154+
155+
if (!empty($branch))
156+
{
157+
$query->where($db->quoteName('branch') . ' = ' . $db->quote($branch));
158+
}
159+
130160
// Filter for RTC patches
131161
$applied = $this->getState()->get('filter.rtc');
132162

administrator/components/com_patchtester/PatchTester/View/Pulls/PullsHtmlView.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
*/
2121
class PullsHtmlView extends DefaultHtmlView
2222
{
23+
/**
24+
* Array containing the list of branches
25+
*
26+
* @var array
27+
* @since __DEPLOY_VERSION__
28+
*/
29+
protected $branches = array();
30+
2331
/**
2432
* Array containing environment errors
2533
*
@@ -86,6 +94,7 @@ public function render()
8694
$this->items = $this->model->getItems();
8795
$this->pagination = $this->model->getPagination();
8896
$this->trackerAlias = TrackerHelper::getTrackerAlias($this->state->get('github_user'), $this->state->get('github_repo'));
97+
$this->branches = $this->model->getBranches();
8998
}
9099

91100
// Change the layout if there are environment errors

administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
$listOrder = $this->escape($this->state->get('list.ordering'));
1818
$listDirn = $this->escape($this->state->get('list.direction'));
1919
$filterApplied = $this->escape($this->state->get('filter.applied'));
20+
$filterBranch = $this->escape($this->state->get('filter.branch'));
2021
$filterRtc = $this->escape($this->state->get('filter.rtc'));
21-
$colSpan = $this->trackerAlias !== false ? 7 : 6;
22+
$colSpan = $this->trackerAlias !== false ? 8 : 7;
2223
?>
2324
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
2425
<div id="j-main-container">
@@ -39,8 +40,8 @@
3940
<label for="directionTable" class="element-invisible"><?php echo \JText::_('JFIELD_ORDERING_DESC'); ?></label>
4041
<select name="directionTable" id="directionTable" class="input-medium" onchange="PatchTester.orderTable()">
4142
<option value=""><?php echo \JText::_('JFIELD_ORDERING_DESC');?></option>
42-
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
43-
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
43+
<option value="asc"<?php if ($listDirn == 'asc') echo ' selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
44+
<option value="desc"<?php if ($listDirn == 'desc') echo ' selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
4445
</select>
4546
</div>
4647
<div class="btn-group pull-right">
@@ -66,6 +67,13 @@
6667
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
6768
</select>
6869
</div>
70+
<div class="btn-group pull-right">
71+
<label for="filter_branch" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
72+
<select name="filter_branch" class="input-medium" onchange="this.form.submit();">
73+
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
74+
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
75+
</select>
76+
</div>
6977
</div>
7078

7179
<?php if (empty($this->items)) : ?>

administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
6464
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
6565
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
6666
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"
67+
COM_PATCHTESTER_FILTER_BRANCH="Filter Target Branch"
6768
COM_PATCHTESTER_FILTER_RTC_PATCHES="Filter RTC Patches"
6869
COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION="Search the list by title or prefix with 'id:' to search by Pull ID."
6970
COM_PATCHTESTER_GITHUB="GitHub"

administrator/templates/atum/html/com_patchtester/pulls/default.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
$listOrder = $this->escape($this->state->get('list.ordering'));
1717
$listDirn = $this->escape($this->state->get('list.direction', 'desc'));
1818
$filterApplied = $this->escape($this->state->get('filter.applied'));
19+
$filterBranch = $this->escape($this->state->get('filter.branch'));
1920
$filterRtc = $this->escape($this->state->get('filter.rtc'));
20-
$colSpan = $this->trackerAlias !== false ? 7 : 6;
21+
$colSpan = $this->trackerAlias !== false ? 8 : 7;
2122
?>
2223
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
2324
<div id="j-main-container" class="j-main-container">
@@ -84,6 +85,13 @@
8485
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
8586
</select>
8687
</div>
88+
<div class="js-stools-field-filter">
89+
<label for="filter_branch" class="element-invisible"><?php echo \JText::_('JSEARCH_TOOLS_DESC'); ?></label>
90+
<select name="filter_branch" class="custom-select" onchange="this.form.submit();">
91+
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
92+
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
93+
</select>
94+
</div>
8795
</div>
8896
</div>
8997

administrator/templates/hathor/html/com_patchtester/pulls/default.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
$listOrder = $this->escape($this->state->get('list.ordering'));
1717
$listDirn = $this->escape($this->state->get('list.direction'));
1818
$filterApplied = $this->escape($this->state->get('filter.applied'));
19+
$filterBranch = $this->escape($this->state->get('filter.branch'));
1920
$filterRtc = $this->escape($this->state->get('filter.rtc'));
20-
$colSpan = $this->trackerAlias !== false ? 7 : 6;
21+
$colSpan = $this->trackerAlias !== false ? 8 : 7;
2122

2223
\JFactory::getDocument()->addStyleDeclaration(
2324
'
@@ -58,6 +59,11 @@
5859
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option>
5960
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
6061
</select>
62+
<label class="selectlabel" for="filter_branch"><?php echo JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></label>
63+
<select name="filter_branch" id="filter_branch">
64+
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
65+
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>
66+
</select>
6167
<button type="submit" id="filter-go"><?php echo \JText::_('JSUBMIT'); ?></button>
6268
</div>
6369
</fieldset>

0 commit comments

Comments
 (0)