Skip to content

Commit 635327e

Browse files
committed
Added draft status
Sort language strings Signed-off-by: Roland Dalmulder <[email protected]>
1 parent 98e48eb commit 635327e

File tree

8 files changed

+93
-64
lines changed

8 files changed

+93
-64
lines changed

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

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function __construct($config = [])
5757
'applied',
5858
'rtc',
5959
'npm',
60+
'draft',
6061
'label',
6162
'branch',
6263
];
@@ -267,6 +268,16 @@ protected function getListQuery()
267268
$query->where($db->quoteName('pulls.is_npm') . ' = ' . $value);
268269
}
269270

271+
$draft = $this->getState()->get('filter.draft');
272+
273+
if (!empty($draft))
274+
{
275+
// Not applied patches have a NULL value, so build our value part of the query based on this
276+
$value = $draft === 'no' ? '0' : '1';
277+
278+
$query->where($db->quoteName('pulls.is_draft') . ' = ' . $value);
279+
}
280+
270281
$labels = $this->getState()->get('filter.label');
271282

272283
if (!empty($labels) && $labels[0] !== '')
@@ -351,7 +362,7 @@ public function requestFromGithub($page)
351362
// TODO - Option to configure the batch size
352363
$batchSize = 100;
353364

354-
$pullsResponse = Helper::initializeGithub()->getOpenIssues(
365+
$pullsResponse = Helper::initializeGithub()->getOpenPulls(
355366
$this->getState()->get('github_user'),
356367
$this->getState()->get('github_repo'),
357368
$page,
@@ -416,59 +427,54 @@ public function requestFromGithub($page)
416427

417428
foreach ($pulls as $pull)
418429
{
419-
if (isset($pull->pull_request))
420-
{
421-
// Check if this PR is RTC and has a `PR-` branch label
422-
$isRTC = false;
423-
$isNPM = false;
424-
$branch = '';
430+
// Check if this PR is RTC and has a `PR-` branch label
431+
$isRTC = false;
432+
$isNPM = false;
433+
$branch = $pull->base->ref;
425434

426-
foreach ($pull->labels as $label)
435+
foreach ($pull->labels as $label)
436+
{
437+
if (strtolower($label->name) === 'rtc')
427438
{
428-
if (strtolower($label->name) === 'rtc')
429-
{
430-
$isRTC = true;
431-
}
432-
elseif (strpos($label->name, 'PR-') === 0)
433-
{
434-
$branch = substr($label->name, 3);
435-
}
436-
elseif (in_array(
437-
strtolower($label->name),
438-
['npm resource changed', 'composer dependency changed'],
439-
true
440-
))
441-
{
442-
$isNPM = true;
443-
}
444-
445-
$labels[] = implode(
446-
',',
447-
[
448-
(int) $pull->number,
449-
$this->getDbo()->quote($label->name),
450-
$this->getDbo()->quote($label->color),
451-
]
452-
);
439+
$isRTC = true;
440+
}
441+
elseif (in_array(
442+
strtolower($label->name),
443+
['npm resource changed', 'composer dependency changed'],
444+
true
445+
))
446+
{
447+
$isNPM = true;
453448
}
454449

455-
// Build the data object to store in the database
456-
$pullData = [
457-
(int) $pull->number,
458-
$this->getDbo()->quote(
459-
HTMLHelper::_('string.truncate', $pull->title, 150)
460-
),
461-
$this->getDbo()->quote(
462-
HTMLHelper::_('string.truncate', $pull->body, 100)
463-
),
464-
$this->getDbo()->quote($pull->pull_request->html_url),
465-
(int) $isRTC,
466-
(int) $isNPM,
467-
$this->getDbo()->quote($branch),
468-
];
469-
470-
$data[] = implode(',', $pullData);
450+
$labels[] = implode(
451+
',',
452+
[
453+
(int) $pull->number,
454+
$this->getDbo()->quote($label->name),
455+
$this->getDbo()->quote($label->color),
456+
]
457+
);
471458
}
459+
460+
// Build the data object to store in the database
461+
$pullData = [
462+
(int) $pull->number,
463+
$this->getDbo()->quote(
464+
HTMLHelper::_('string.truncate', $pull->title, 150)
465+
),
466+
$this->getDbo()->quote(
467+
HTMLHelper::_('string.truncate', $pull->body, 100)
468+
),
469+
$this->getDbo()->quote($pull->html_url),
470+
(int) $isRTC,
471+
(int) $isNPM,
472+
$this->getDbo()->quote($branch),
473+
($pull->draft ? 1 : 0)
474+
];
475+
476+
$data[] = implode(',', $pullData);
477+
472478
}
473479

474480
// If there are no pulls to insert then bail, assume we're finished
@@ -484,7 +490,7 @@ public function requestFromGithub($page)
484490
->insert('#__patchtester_pulls')
485491
->columns(
486492
['pull_id', 'title', 'description', 'pull_url',
487-
'is_rtc', 'is_npm', 'branch']
493+
'is_rtc', 'is_npm', 'branch', 'is_draft']
488494
)
489495
->values($data)
490496
);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
<tr<?php echo $status; ?>>
2222
<th scope="row" class="text-center">
2323
<?php echo $item->pull_id; ?>
24+
<?php if ($item->is_draft) : ?>
25+
<span class="badge" style="color: #FFFFFF; background-color: #6e7681">
26+
<?php echo Text::_('COM_PATCHTESTER_IS_DRAFT'); ?>
27+
</span>
28+
<?php endif; ?>
2429
</th>
2530
<td>
2631
<span><?php echo $this->escape($item->title); ?></span>

administrator/components/com_patchtester/forms/filter_pulls.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@
4646
<option value="0">JNO</option>
4747
</field>
4848

49+
<field
50+
name="draft"
51+
type="list"
52+
default=""
53+
validate="options"
54+
onchange="this.form.submit();"
55+
>
56+
<option value="">COM_PATCHTESTER_FILTER_DRAFT_PATCHES</option>
57+
<option value="1">JYES</option>
58+
<option value="0">JNO</option>
59+
</field>
60+
4961
<field
5062
name="label"
5163
type="Label"

administrator/components/com_patchtester/install/sql/mysql/install.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `#__patchtester_pulls`
99
`is_rtc` tinyint(1) NOT NULL DEFAULT 0,
1010
`is_npm` tinyint(1) DEFAULT 0,
1111
`branch` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
12+
`is_draft` tinyint(1) unsigned DEFAULT 0 COMMENT 'If the pull request is a draft PR',
1213
PRIMARY KEY (`id`)
1314
) ENGINE = InnoDB
1415
DEFAULT CHARSET = utf8mb4

administrator/components/com_patchtester/install/sql/postgresql/install.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS "#__patchtester_pulls"
99
"is_rtc" smallint DEFAULT 1 NOT NULL,
1010
"is_npm" smallint DEFAULT 1 NOT NULL,
1111
"branch" character varying(255) DEFAULT '' NOT NULL,
12+
"is_draft" smallint DEFAULT 0 NOT NULL,
1213
PRIMARY KEY ("id")
1314
);
1415

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE #__patchtester_pulls ADD is_draft TINYINT(1) UNSIGNED DEFAULT 0 NULL COMMENT 'If the pull request is a draft PR';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "#__patchtester_pulls" ADD COLUMN "is_draft" smallint DEFAULT 0 NOT NULL;

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ COM_PATCHTESTER_FETCH_PAGE_NUMBER="Processing page %s of GitHub data"
3737
COM_PATCHTESTER_FETCH_PAGE_NUMBER_OF_TOTAL="Processing page %1$s of %2$s pages of GitHub data"
3838
COM_PATCHTESTER_FETCH_PROCESSING="Processing data from GitHub"
3939
COM_PATCHTESTER_FETCH_SUCCESSFUL="Successfully retrieved pull requests"
40+
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC="Configuration Values for GitHub Authentication"
41+
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
42+
COM_PATCHTESTER_FIELDSET_CI_SETTINGS="CI Server Settings"
43+
COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC="Configuration Values for CI Server Patching"
44+
COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC="Configuration Values for GitHub Repository"
45+
COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL="GitHub Repository"
4046
COM_PATCHTESTER_FIELD_CI_SERVER_NAME="CI Server Address"
4147
COM_PATCHTESTER_FIELD_CI_SERVER_NAME_DESC="Server address for compiled patches."
4248
COM_PATCHTESTER_FIELD_CI_SERVER_SWITCH="Switch CI Integration"
@@ -50,51 +56,47 @@ COM_PATCHTESTER_FIELD_GH_TOKEN_DESC="Use this field to input a GitHub API Token
5056
COM_PATCHTESTER_FIELD_GH_TOKEN_LABEL="GitHub Token"
5157
COM_PATCHTESTER_FIELD_ORG_DESC="A username or organisation on GitHub to monitor pull requests for."
5258
COM_PATCHTESTER_FIELD_ORG_LABEL="Custom Project Owner"
53-
COM_PATCHTESTER_FIELD_REPO_DESC="Name of a repository on GitHub to monitor pull requests for."
54-
COM_PATCHTESTER_FIELD_REPO_LABEL="Custom Project Repository"
5559
COM_PATCHTESTER_FIELD_REPOSITORY_CUSTOM="Custom"
5660
COM_PATCHTESTER_FIELD_REPOSITORY_DESC="Available Joomla! repositories. Select to autopopulate the organisation and repository fields values."
5761
COM_PATCHTESTER_FIELD_REPOSITORY_LABEL="GitHub Repository"
5862
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_INSTALL_FROM_WEB="Joomla! Install From Web Plugin"
5963
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_JOOMLA_CMS="Joomla! CMS"
6064
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_PATCHTESTER="Joomla! Patch Tester Component"
6165
COM_PATCHTESTER_FIELD_REPOSITORY_OPTION_WEBLINKS="Joomla! Weblinks Package"
62-
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_DESC="Configuration Values for GitHub Authentication"
63-
COM_PATCHTESTER_FIELDSET_AUTHENTICATION_LABEL="GitHub Authentication"
64-
COM_PATCHTESTER_FIELDSET_CI_SETTINGS="CI Server Settings"
65-
COM_PATCHTESTER_FIELDSET_CI_SETTINGS_DESC="Configuration Values for CI Server Patching"
66-
COM_PATCHTESTER_FIELDSET_REPOSITORIES_DESC="Configuration Values for GitHub Repository"
67-
COM_PATCHTESTER_FIELDSET_REPOSITORIES_LABEL="GitHub Repository"
66+
COM_PATCHTESTER_FIELD_REPO_DESC="Name of a repository on GitHub to monitor pull requests for."
67+
COM_PATCHTESTER_FIELD_REPO_LABEL="Custom Project Repository"
6868
COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s"
6969
COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s"
7070
COM_PATCHTESTER_FILTER_APPLIED_PATCHES="Filter Applied Patches"
7171
COM_PATCHTESTER_FILTER_BRANCH="Filter Target Branch"
72+
COM_PATCHTESTER_FILTER_DRAFT_PATCHES="Filter Draft Patches"
7273
COM_PATCHTESTER_FILTER_LABEL="Filter Label"
7374
COM_PATCHTESTER_FILTER_NPM_PATCHES="Filter NPM Patches"
7475
COM_PATCHTESTER_FILTER_RTC_PATCHES="Filter RTC Patches"
7576
COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION="Search the list by title or prefix with 'id:' to search by Pull ID."
7677
COM_PATCHTESTER_GITHUB="GitHub"
7778
COM_PATCHTESTER_HEADING_FETCH_DATA="Fetching GitHub Data"
79+
COM_PATCHTESTER_IS_DRAFT="Draft"
7880
COM_PATCHTESTER_JISSUE="J! Issue"
7981
COM_PATCHTESTER_JISSUES="Issue Tracker"
80-
COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your GitHub API token in the Options. This will limit you to only 60 requests to the GitHub API per hour. Configuring authentication via an API token will allow 5,000 requests per hour."
81-
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."
82-
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."
8382
COM_PATCHTESTER_NOT_APPLIED="Not Applied"
8483
COM_PATCHTESTER_NOT_NPM="Not NPM"
8584
COM_PATCHTESTER_NOT_RTC="Not RTC"
85+
COM_PATCHTESTER_NO_CREDENTIALS="You have not entered your GitHub API token in the Options. This will limit you to only 60 requests to the GitHub API per hour. Configuring authentication via an API token will allow 5,000 requests per hour."
86+
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."
87+
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."
8688
COM_PATCHTESTER_NPM="NPM"
8789
COM_PATCHTESTER_PATCH_BREAKS_SITE="The patch could not be applied because it would break the site. Check the pull request to see if it is up-to-date."
90+
COM_PATCHTESTER_PULLS_TABLE_CAPTION="Table of Pull Requests"
8891
COM_PATCHTESTER_PULL_ID="Pull ID"
8992
COM_PATCHTESTER_PULL_ID_ASC="Pull ID ascending"
9093
COM_PATCHTESTER_PULL_ID_DESC="Pull ID descending"
91-
COM_PATCHTESTER_PULLS_TABLE_CAPTION="Table of Pull Requests"
9294
COM_PATCHTESTER_READY_TO_COMMIT="Ready to Commit"
9395
COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing"
94-
COM_PATCHTESTER_REQUIREMENT_HTTPS="HTTPS wrappers must be enabled"
95-
COM_PATCHTESTER_REQUIREMENT_OPENSSL="The OpenSSL extension must be installed and enabled in your php.ini"
9696
COM_PATCHTESTER_REQUIREMENTS_HEADING="Requirements Not Met"
9797
COM_PATCHTESTER_REQUIREMENTS_NOT_MET="Your system does not meet the requirements to run the Patch Tester component:"
98+
COM_PATCHTESTER_REQUIREMENT_HTTPS="HTTPS wrappers must be enabled"
99+
COM_PATCHTESTER_REQUIREMENT_OPENSSL="The OpenSSL extension must be installed and enabled in your php.ini"
98100
COM_PATCHTESTER_RESET_HAS_ERRORS="The reset process has completed however it encountered errors. Please remove any .txt files in the '%1$s' directory and truncate the '%2$s' database table."
99101
COM_PATCHTESTER_RESET_OK="The reset process has completed successfully."
100102
COM_PATCHTESTER_REVERT_OK="Patch successfully reverted"

0 commit comments

Comments
 (0)