33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2025-01-03 07:12:36 +00:00

Added method for reverting applied patches, added methods to reduce duplicate code and edited build.sh

This commit is contained in:
datsepp 2019-09-10 13:53:40 +02:00
parent 82befbe554
commit aaeccd3402
10 changed files with 213 additions and 511 deletions

View File

@ -79,9 +79,10 @@ abstract class Helper
// Set name of the zip archive
$options->set('zip.name', 'build.zip');
$options->set('zip.deleted_log', 'deleted_files.log');
// Set temp archive for extracting and downloading files
$options->set('folder.temp', JPATH_COMPONENT . '/temp');
$options->set('folder.temp', Factory::getConfig()->get('tmp_path'));
$options->set('folder.backups', JPATH_COMPONENT . '/backups');
// Set full url for addressing the file

View File

@ -8,12 +8,14 @@
namespace PatchTester\Model;
use Joomla\Archive\Zip;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Version;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use PatchTester\GitHub\Exception\UnexpectedResponse;
use PatchTester\Helper;
@ -182,11 +184,12 @@ class PullModel extends AbstractModel
// Create tmp folder if it does not exist
if (!file_exists($ciSettings->get('folder.temp')))
{
mkdir($ciSettings->get('folder.temp'));
Folder::create($ciSettings->get('folder.temp'));
}
$tempPath = $ciSettings->get('folder.temp') . "/$id";
$backupsPath = $ciSettings->get('folder.backups') . "/$id";
$deletedFilesPath = $tempPath . '/' . $ciSettings->get('zip.deleted_log');
$zipPath = $tempPath . '/' . $ciSettings->get('zip.name');
$serverPath = sprintf($ciSettings->get('zip.url'), $id);
@ -201,69 +204,68 @@ class PullModel extends AbstractModel
if (!$serverHeaders || $serverHeaders[0] != 'HTTP/1.1 200 OK')
{
throw new \RuntimeException(Text::_('File does not exist on Server'));
throw new \RuntimeException(Text::_('COM_PATCHTESTER_SERVER_RESPONDED_NOT_200'));
}
mkdir($tempPath);
Folder::create($tempPath);
file_put_contents($zipPath, fopen($serverPath, "r"));
// Check if zip folder could have been downloaded
if (!file_exists($zipPath))
{
$this->rmDir($tempPath);
throw new \RuntimeException(Text::_('Zip has not been created'));
Folder::delete($tempPath);
throw new \RuntimeException(Text::_('COM_PATCHTESTER_ZIP_DOES_NOT_EXIST'));
}
$zip = new \ZipArchive;
$zip->open($zipPath);
$zip = new Zip;
// Check if zip contains files
if ($zip->numFiles === 0)
if (!$zip->extract($zipPath, $tempPath))
{
$zip->close();
$this->rmDir($tempPath);
throw new \RuntimeException(Text::_('Zip is empty'));
Folder::delete($tempPath);
throw new \RuntimeException(Text::_('COM_PATCHTESTER_ZIP_EXTRACT_FAILED'));
}
$zip->extractTo($tempPath);
$zip->close();
unlink($zipPath);
// Get a list of files from folder and deleted.log
$files = $this->getListOfFiles($tempPath);
File::delete($zipPath);
$files = Folder::files($tempPath, null, true, true);
$files = str_replace(Path::clean("$tempPath\\"), '', $files);
// ToDo add deleted files loop
$deletedFiles = file($deletedFilesPath);
mkdir($backupsPath);
Folder::create($backupsPath);
// Moves existent files to backup and replace them or creates new one if they don't exist
foreach ($files as $file)
{
$filePath = explode("/", $file);
$filePath = explode("\\", $file);
array_pop($filePath);
$filePath = implode("/", $filePath);
$filePath = implode("\\", $filePath);
if (file_exists(JPATH_ROOT . "/$file"))
{
// Create directories if they don't exist until file
if (!file_exists("$backupsPath/$filePath"))
{
mkdir("$backupsPath/$filePath",null, true);
Folder::create("$backupsPath/$filePath");
}
rename(JPATH_ROOT . "/$file", "$backupsPath/$file");
File::move(JPATH_ROOT . "/$file", "$backupsPath/$file");
}
// Create directories if they don't exist until file
if (!file_exists(JPATH_ROOT . "/$filePath"))
{
mkdir(JPATH_ROOT . "/$filePath",null, true);
Folder::create(JPATH_ROOT . "/$filePath");
}
copy("$tempPath/$file", JPATH_ROOT . "/$file");
if (file_exists("$tempPath/$file"))
{
File::copy("$tempPath/$file", JPATH_ROOT . "/$file");
}
}
// Clear temp folder and store applied patch in database
$this->rmDir($tempPath);
Folder::delete($tempPath);
$this->saveAppliedPatch($id, $files);
@ -274,83 +276,6 @@ class PullModel extends AbstractModel
return true;
}
/**
* Returns an array containing fileNames as string for a given $dir
*
* @param string $dir directory to scan
* @param array $files array with fileNames
* @param string $parent parent directory
*
* @return array fileNames
*
* @since 3.0
*/
private function getListOfFiles($dir, $files = [], $parent = null)
{
if (is_dir($dir))
{
// Remove dot files/folders
$temp = preg_grep("/^([^.])/", scandir($dir));
foreach ($temp as $key => $file)
{
if (is_dir($dir . '/' . $file))
{
unset($temp[$key]);
$files = $this->getListOfFiles($dir . '/' . $file, $files,
(is_null($parent) ? $file : $parent . '/' . $file));
}
if (!is_null($parent) && !is_dir($dir . '/' . $file))
{
$temp[$key] = $parent . '/' . $file;
}
}
$files = array_merge($files, $temp);
return $files;
}
else
{
return [];
}
}
/**
* Removes directory and its content recursively
*
* @param string $dir directory to delete
*
* @return void
*
* @since 3.0
*/
private function rmDir($dir)
{
if (is_dir($dir))
{
$files = scandir($dir);
foreach ($files as $file)
{
if ($file != "." && $file != "..")
{
if (is_dir($dir . "/" . $file))
{
$this->rmDir($dir . "/" . $file);
}
else
{
unlink($dir . "/" . $file);
}
}
}
rmdir($dir);
}
}
/**
* Patches the code with the supplied pull request
*
@ -636,32 +561,32 @@ class PullModel extends AbstractModel
// Delete file from root of it exists
if (file_Exists(JPATH_ROOT . "/$file"))
{
$filePath = explode("/", $file);
$filePath = explode("\\", $file);
array_pop($filePath);
$filePath = implode("/", $filePath);
$filePath = implode("\\", $filePath);
unlink(JPATH_ROOT . "/$file");
File::delete(JPATH_ROOT . "/$file");
// If folder is empty, remove it as well
if (count(glob(JPATH_ROOT . "/$filePath/*")) === 0)
{
rmdir(JPATH_ROOT . "/$filePath");
Folder::delete(JPATH_ROOT . "/$filePath");
}
// Move from backup, if it exists there
if (file_exists("$backupsPath/$file"))
{
rename("$backupsPath/$file", JPATH_ROOT . "/$file");
File::move("$backupsPath/$file", JPATH_ROOT . "/$file");
}
}
// Move from backup, if file exists there - got deleted by patch
elseif (file_exists("$backupsPath/$file"))
{
rename("$backupsPath/$file", JPATH_ROOT . "/$file");
File::move("$backupsPath/$file", JPATH_ROOT . "/$file");
}
}
$this->rmDir($backupsPath);
Folder::delete($backupsPath);
// Change the media version
$version = new Version;

View File

@ -21,8 +21,8 @@ HTMLHelper::_('script', 'com_patchtester/fetcher.js', array('version' => 'auto',
<div id="patchtester-container">
<h1 id="patchtester-progress-header"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
<p id="patchtester-progress-message"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
<div id="progress" class="progress progress-striped active">
<div id="progress-bar" class="bar bar-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<div id="progress" class="progress">
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated bg-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" role="progressbar"></div>
</div>
<input id="patchtester-token" type="hidden" name="<?php echo Factory::getSession()->getFormToken(); ?>" value="1" />
</div>

View File

@ -6,102 +6,140 @@
* @license GNU General Public License version 2 or later
*/
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */
$searchToolsOptions = array(
'filtersHidden' => true,
'filterButton' => true,
'defaultLimit' => Factory::getApplication()->get('list_limit', 20),
'searchFieldSelector' => '#filter_search',
'selectorFieldName' => 'client_id',
'showSelector' => false,
'orderFieldSelector' => '#list_fullordering',
'showNoResults' => false,
'noResultsText' => '',
'formSelector' => '#adminForm',
);
HTMLHelper::_('behavior.core');
HTMLHelper::_('bootstrap.tooltip');
HTMLHelper::_('formbehavior.chosen', 'select');
HTMLHelper::_('searchtools.form', '#adminForm', $searchToolsOptions);
HTMLHelper::_('stylesheet', 'com_patchtester/octicons.css', array('version' => '3.5.0', 'relative' => true));
HTMLHelper::_('script', 'com_patchtester/patchtester.js', array('version' => 'auto', 'relative' => true));
$listOrder = $this->escape($this->state->get('list.fullordering', 'a.pull_id DESC'));
$listLimit = (int) ($this->state->get('list.limit'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$filterBranch = $this->escape($this->state->get('filter.branch'));
$filterRtc = $this->escape($this->state->get('filter.rtc'));
?>
<form action="<?php echo Route::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
<div id="j-main-container">
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?></label>
<input type="text" name="filter_search" placeholder="<?php echo Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>" />
<form action="<?php echo Route::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<div class="js-stools" role="search">
<div class="js-stools-container-bar">
<div class="btn-toolbar">
<div class="btn-group mr-2">
<div class="input-group">
<label for="filter_search" class="sr-only">
<?php echo Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>
</label>
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="form-control" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>">
<div role="tooltip" id="filter_search-desc">
<?php echo $this->escape(Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION')); ?>
</div>
<div class="btn-group pull-left hidden-phone">
<button class="btn tip hasTooltip" type="submit" title="<?php echo Text::_('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button class="btn tip hasTooltip" type="button" onclick="document.getElementById('filter_search').value='';this.form.submit();" title="<?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?>"><i class="icon-remove"></i></button>
<span class="input-group-append">
<button type="submit" class="btn btn-primary" aria-label="<?php echo Text::_('JSEARCH_FILTER_SUBMIT'); ?>">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
</span>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo Text::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right">
<label for="list_fullordering" class="element-invisible"><?php echo Text::_('JGLOBAL_SORT_BY'); ?></label>
<select name="list_fullordering" id="list_fullordering" class="input-medium" onchange="this.form.submit();">
<div class="btn-group">
<button type="button" class="btn btn-primary hasTooltip js-stools-btn-filter">
<?php echo Text::_('JFILTER_OPTIONS'); ?>
<span class="fa fa-angle-down" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-primary js-stools-btn-clear mr-2">
<?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?>
</button>
</div>
<div class="ordering-select">
<div class="js-stools-field-list">
<select name="list_fullordering" id="list_fullordering" class="custom-select" onchange="this.form.submit()">
<option value=""><?php echo Text::_('JGLOBAL_SORT_BY'); ?></option>
<?php echo HTMLHelper::_('select.options', $this->getSortFields(), 'value', 'text', $listOrder); ?>
</select>
</div>
<div class="btn-group pull-right">
<label for="filter_applied" class="element-invisible"><?php echo Text::_('JSEARCH_TOOLS_DESC'); ?></label>
<select name="filter_applied" class="input-medium" onchange="this.form.submit();">
<div class="js-stools-field-list">
<span class="sr-only">
<label id="list_limit-lbl" for="list_limit">Select number of items per page.</label>
</span>
<select name="list_limit" id="list_limit" class="custom-select" onchange="this.form.submit()">
<?php echo HTMLHelper::_('select.options', $this->getLimitOptions(), 'value', 'text', $listLimit); ?>
</select>
</div>
</div>
</div>
</div>
<!-- Filters div -->
<div class="js-stools-container-filters clearfix">
<div class="js-stools-field-filter">
<select name="filter_applied" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></option>
<option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></option>
<option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="filter_rtc" class="element-invisible"><?php echo Text::_('JSEARCH_TOOLS_DESC'); ?></label>
<select name="filter_rtc" class="input-medium" onchange="this.form.submit();">
<div class="js-stools-field-filter">
<select name="filter_rtc" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option>
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_RTC'); ?></option>
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="filter_branch" class="element-invisible"><?php echo Text::_('JSEARCH_TOOLS_DESC'); ?></label>
<select name="filter_branch" class="input-medium" onchange="this.form.submit();">
<div class="js-stools-field-filter">
<select name="filter_branch" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
<?php echo HTMLHelper::_('select.options', $this->branches, 'text', 'text', $filterBranch, false); ?>
</select>
</div>
</div>
</div>
<div id="j-main-container" class="j-main-container">
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<div class="alert alert-info">
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped">
<table class="table">
<caption id="captionTable" class="sr-only">
<?php echo Text::_('COM_PATCHTESTER_PULLS_TABLE_CAPTION'); ?>, <?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
</caption>
<thead>
<tr>
<th width="5%" class="nowrap center">
<th scope="col" style="width:5%" class="text-center">
<?php echo Text::_('COM_PATCHTESTER_PULL_ID'); ?>
</th>
<th class="nowrap">
<th scope="col" style="min-width:100px">
<?php echo Text::_('JGLOBAL_TITLE'); ?>
</th>
<th width="8%" class="nowrap center hidden-phone">
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
<?php echo Text::_('COM_PATCHTESTER_BRANCH'); ?>
</th>
<th width="8%" class="nowrap center hidden-phone">
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
<?php echo Text::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
</th>
<th width="8%" class="nowrap center">
<?php echo Text::_('COM_PATCHTESTER_GITHUB'); ?>
</th>
<?php if ($this->trackerAlias !== false) : ?>
<th width="8%" class="nowrap center">
<?php echo Text::_('COM_PATCHTESTER_JISSUES'); ?>
</th>
<?php endif; ?>
<th width="10%" class="nowrap center">
<th scope="col" style="width:10%" class="text-center">
<?php echo Text::_('JSTATUS'); ?>
</th>
<th width="15%" class="nowrap center">
<th scope="col" style="width:15%" class="text-center">
<?php echo Text::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
</th>
</tr>
@ -119,4 +157,7 @@ $filterRtc = $this->escape($this->state->get('filter.rtc'));
<input type="hidden" name="pull_id" id="pull_id" value="" />
<?php echo HTMLHelper::_('form.token'); ?>
</div>
</div>
</div>
</div>
</form>

View File

@ -14,59 +14,58 @@ foreach ($this->items as $i => $item) :
$status = '';
if ($item->applied) :
$status = ' class="success"';
$status = ' class="table-active"';
endif;
?>
<tr<?php echo $status; ?>>
<td class="center">
<th scope="row" class="text-center">
<?php echo $item->pull_id; ?>
</td>
</th>
<td>
<span class="hasTooltip" title="<strong>Info</strong><br/><?php echo $this->escape($item->description); ?>"><?php echo $this->escape($item->title); ?></span>
<span><?php echo $this->escape($item->title); ?></span>
<div role="tooltip" id="tip<?php echo $i; ?>">
<?php echo $this->escape($item->description); ?>
</div>
<div class="row">
<div class="col-md-auto">
<a class="badge badge-info" href="<?php echo $item->pull_url; ?>" target="_blank">
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_GITHUB'); ?>
</a>
</div>
<div class="col-md-auto">
<a class="badge badge-info" href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>" target="_blank">
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_JOOMLA_ISSUE_TRACKER'); ?>
</a>
</div>
<?php if ($item->applied) : ?>
<div class="small">
<span class="label label-info"><?php echo Text::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
<div class="col-md-auto">
<span class="badge badge-info"><?php echo Text::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
</div>
<?php endif; ?>
</div>
</td>
<td class="center hidden-phone">
<td class="d-none d-md-table-cell text-center">
<?php echo $this->escape($item->branch); ?>
</td>
<td class="center hidden-phone">
<td class="d-none d-md-table-cell text-center">
<?php if ($item->is_rtc) : ?>
<span class="label label-success"><?php echo Text::_('JYES'); ?></span>
<span class="badge badge-success"><?php echo Text::_('JYES'); ?></span>
<?php else : ?>
<span class="label label-primary"><?php echo Text::_('JNO'); ?></span>
<span class="badge badge-secondary"><?php echo Text::_('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 Text::_('COM_PATCHTESTER_GITHUB'); ?>
</a>
</td>
<?php if ($this->trackerAlias !== false) : ?>
<td class="center">
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>" target="_blank">
<i class="icon-joomla"></i> <?php echo Text::_('COM_PATCHTESTER_JISSUE'); ?>
</a>
</td>
<?php endif; ?>
<td class="center">
<td class="text-center">
<?php if ($item->applied) : ?>
<div>
<span class="label label-success"><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></span>
</div>
<span class="badge badge-success"><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></span>
<?php else : ?>
<span class="label">
<?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?>
</span>
<span class="badge badge-secondary"><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></span>
<?php endif; ?>
</td>
<td class="center">
<td class="text-center">
<?php if ($item->applied) : ?>
<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch('revert', '<?php echo (int) $item->applied; ?>');"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></a><br />
<button class="btn btn-sm btn-success" onclick="event.stopPropagation(); PatchTester.submitpatch('revert', '<?php echo (int) $item->applied; ?>');"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
<?php else : ?>
<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch('apply', '<?php echo (int) $item->pull_id; ?>');"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></a>
<button class="btn btn-sm btn-primary" onclick="event.stopPropagation(); PatchTester.submitpatch('apply', '<?php echo (int) $item->pull_id; ?>');"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
<?php endif; ?>
</td>
</tr>

View File

@ -1,28 +0,0 @@
<?php
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
/** @var \PatchTester\View\DefaultHtmlView $this */
HTMLHelper::_('jquery.framework');
HTMLHelper::_('behavior.core');
HTMLHelper::_('script', 'com_patchtester/fetcher.js', array('version' => 'auto', 'relative' => true));
?>
<div id="patchtester-container">
<h1 id="patchtester-progress-header"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
<p id="patchtester-progress-message"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
<div id="progress" class="progress">
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated bg-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" role="progressbar"></div>
</div>
<input id="patchtester-token" type="hidden" name="<?php echo Factory::getSession()->getFormToken(); ?>" value="1" />
</div>

View File

@ -1,163 +0,0 @@
<?php
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */
$searchToolsOptions = array(
'filtersHidden' => true,
'filterButton' => true,
'defaultLimit' => Factory::getApplication()->get('list_limit', 20),
'searchFieldSelector' => '#filter_search',
'selectorFieldName' => 'client_id',
'showSelector' => false,
'orderFieldSelector' => '#list_fullordering',
'showNoResults' => false,
'noResultsText' => '',
'formSelector' => '#adminForm',
);
HTMLHelper::_('behavior.core');
HTMLHelper::_('searchtools.form', '#adminForm', $searchToolsOptions);
HTMLHelper::_('stylesheet', 'com_patchtester/octicons.css', array('version' => '3.5.0', 'relative' => true));
HTMLHelper::_('script', 'com_patchtester/patchtester.js', array('version' => 'auto', 'relative' => true));
$listOrder = $this->escape($this->state->get('list.fullordering', 'a.pull_id DESC'));
$listLimit = (int) ($this->state->get('list.limit'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$filterBranch = $this->escape($this->state->get('filter.branch'));
$filterRtc = $this->escape($this->state->get('filter.rtc'));
?>
<form action="<?php echo Route::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<div class="js-stools" role="search">
<div class="js-stools-container-bar">
<div class="btn-toolbar">
<div class="btn-group mr-2">
<div class="input-group">
<label for="filter_search" class="sr-only">
<?php echo Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>
</label>
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="form-control" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>">
<div role="tooltip" id="filter_search-desc">
<?php echo $this->escape(Text::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION')); ?>
</div>
<span class="input-group-append">
<button type="submit" class="btn btn-primary" aria-label="<?php echo Text::_('JSEARCH_FILTER_SUBMIT'); ?>">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
</span>
</div>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary hasTooltip js-stools-btn-filter">
<?php echo Text::_('JFILTER_OPTIONS'); ?>
<span class="fa fa-angle-down" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-primary js-stools-btn-clear mr-2">
<?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?>
</button>
</div>
<div class="ordering-select">
<div class="js-stools-field-list">
<select name="list_fullordering" id="list_fullordering" class="custom-select" onchange="this.form.submit()">
<option value=""><?php echo Text::_('JGLOBAL_SORT_BY'); ?></option>
<?php echo HTMLHelper::_('select.options', $this->getSortFields(), 'value', 'text', $listOrder); ?>
</select>
</div>
<div class="js-stools-field-list">
<span class="sr-only">
<label id="list_limit-lbl" for="list_limit">Select number of items per page.</label>
</span>
<select name="list_limit" id="list_limit" class="custom-select" onchange="this.form.submit()">
<?php echo HTMLHelper::_('select.options', $this->getLimitOptions(), 'value', 'text', $listLimit); ?>
</select>
</div>
</div>
</div>
</div>
<!-- Filters div -->
<div class="js-stools-container-filters clearfix">
<div class="js-stools-field-filter">
<select name="filter_applied" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></option>
<option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></option>
<option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option>
</select>
</div>
<div class="js-stools-field-filter">
<select name="filter_rtc" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option>
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_RTC'); ?></option>
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo Text::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
</select>
</div>
<div class="js-stools-field-filter">
<select name="filter_branch" class="custom-select" onchange="this.form.submit();">
<option value=""><?php echo Text::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
<?php echo HTMLHelper::_('select.options', $this->branches, 'text', 'text', $filterBranch, false); ?>
</select>
</div>
</div>
</div>
<div id="j-main-container" class="j-main-container">
<?php if (empty($this->items)) : ?>
<div class="alert alert-info">
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table">
<caption id="captionTable" class="sr-only">
<?php echo Text::_('COM_PATCHTESTER_PULLS_TABLE_CAPTION'); ?>, <?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
</caption>
<thead>
<tr>
<th scope="col" style="width:5%" class="text-center">
<?php echo Text::_('COM_PATCHTESTER_PULL_ID'); ?>
</th>
<th scope="col" style="min-width:100px">
<?php echo Text::_('JGLOBAL_TITLE'); ?>
</th>
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
<?php echo Text::_('COM_PATCHTESTER_BRANCH'); ?>
</th>
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
<?php echo Text::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
</th>
<th scope="col" style="width:10%" class="text-center">
<?php echo Text::_('JSTATUS'); ?>
</th>
<th scope="col" style="width:15%" class="text-center">
<?php echo Text::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
</th>
</tr>
</thead>
<tbody>
<?php echo $this->loadTemplate('items'); ?>
</tbody>
</table>
<?php endif; ?>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="pull_id" id="pull_id" value="" />
<?php echo HTMLHelper::_('form.token'); ?>
</div>
</div>
</div>
</div>
</form>

View File

@ -1,72 +0,0 @@
<?php
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
use Joomla\CMS\Language\Text;
/** @var \PatchTester\View\DefaultHtmlView $this */
foreach ($this->items as $i => $item) :
$status = '';
if ($item->applied) :
$status = ' class="table-active"';
endif;
?>
<tr<?php echo $status; ?>>
<th scope="row" class="text-center">
<?php echo $item->pull_id; ?>
</th>
<td>
<span><?php echo $this->escape($item->title); ?></span>
<div role="tooltip" id="tip<?php echo $i; ?>">
<?php echo $this->escape($item->description); ?>
</div>
<div class="row">
<div class="col-md-auto">
<a class="badge badge-info" href="<?php echo $item->pull_url; ?>" target="_blank">
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_GITHUB'); ?>
</a>
</div>
<div class="col-md-auto">
<a class="badge badge-info" href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>" target="_blank">
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_JOOMLA_ISSUE_TRACKER'); ?>
</a>
</div>
<?php if ($item->applied) : ?>
<div class="col-md-auto">
<span class="badge badge-info"><?php echo Text::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
</div>
<?php endif; ?>
</div>
</td>
<td class="d-none d-md-table-cell text-center">
<?php echo $this->escape($item->branch); ?>
</td>
<td class="d-none d-md-table-cell text-center">
<?php if ($item->is_rtc) : ?>
<span class="badge badge-success"><?php echo Text::_('JYES'); ?></span>
<?php else : ?>
<span class="badge badge-secondary"><?php echo Text::_('JNO'); ?></span>
<?php endif; ?>
</td>
<td class="text-center">
<?php if ($item->applied) : ?>
<span class="badge badge-success"><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></span>
<?php else : ?>
<span class="badge badge-secondary"><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></span>
<?php endif; ?>
</td>
<td class="text-center">
<?php if ($item->applied) : ?>
<button class="btn btn-sm btn-success" onclick="PatchTester.submitpatch('revert', '<?php echo (int) $item->applied; ?>');"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
<?php else : ?>
<button class="btn btn-sm btn-primary" onclick="PatchTester.submitpatch('apply', '<?php echo (int) $item->pull_id; ?>');"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
<?php endif; ?>
</td>
</tr>
<?php endforeach;

View File

@ -4,7 +4,6 @@ rm -rf build/packaging && mkdir build/packaging
rm -rf build/packages && mkdir build/packages
composer install --no-dev -o
cp -r administrator/components/com_patchtester build/packaging/admin
cp -r administrator/templates/atum/html/com_patchtester build/packaging/atum
cp -r media/com_patchtester build/packaging/media
rm -rf build/packaging/admin/backups/*.txt
mv build/packaging/admin/patchtester.xml build/packaging/patchtester.xml

View File

@ -112,7 +112,7 @@ if (typeof Joomla === 'undefined') {
jQuery('#progress').remove();
}
});
}
};
initialize();
};