From c9f7ec29e114ea3098cdaf57f934aa4678dc0798 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Tue, 9 Jun 2020 11:13:34 +1200 Subject: [PATCH 01/10] NEW: Improved task runner UI. --- client/styles/task-runner.css | 51 ++++++++++++++++++++ src/Dev/TaskRunner.php | 61 ++++++++++++++++-------- templates/SilverStripe/Dev/TaskRunner.ss | 26 ++++++++++ 3 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 client/styles/task-runner.css create mode 100644 templates/SilverStripe/Dev/TaskRunner.ss diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css new file mode 100644 index 00000000000..973035f9527 --- /dev/null +++ b/client/styles/task-runner.css @@ -0,0 +1,51 @@ +/* This file is manually maintained, it is not generated from SCSS sources */ + +.task__panel { + margin: 15px; +} + +.task__list { + border-left: 1px solid #000000; + border-top: 1px solid #000000; + display: grid; + grid-template-columns: 1fr; + margin-top: 15px; +} + +@media (min-width:992px) { + .task__list { + grid-template-columns: 1fr 1fr; + } +} + +.task__item { + border-bottom: 1px solid #000000; + border-right: 1px solid #000000; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 15px; + transition: background-color 0.2s; +} + +.task__item:hover { + background-color: #ffffff; +} + +.task__item .description { + margin-bottom: 25px; +} + +.task__button { + border: 1px solid #000000; + border-radius: 5px; + background-color: #f6f7f8; + display: inline-block; + padding: 10px 15px; + text-decoration: none; + transition: background-color 0.2s; +} + +.task__button--warning:hover { + background-color: #ffebeb; +} diff --git a/src/Dev/TaskRunner.php b/src/Dev/TaskRunner.php index 094917c2f63..ccb4fc9ca72 100644 --- a/src/Dev/TaskRunner.php +++ b/src/Dev/TaskRunner.php @@ -2,15 +2,19 @@ namespace SilverStripe\Dev; +use ReflectionClass; use SilverStripe\Control\Controller; use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Core\Manifest\ModuleResourceLoader; +use SilverStripe\ORM\ArrayList; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; -use ReflectionClass; +use SilverStripe\View\ArrayData; +use SilverStripe\View\ViewableData; class TaskRunner extends Controller { @@ -44,33 +48,48 @@ protected function init() public function index() { + $baseUrl = Director::absoluteBaseURL(); $tasks = $this->getTasks(); - // Web mode - if (!Director::is_cli()) { - $renderer = new DebugView(); - echo $renderer->renderHeader(); - echo $renderer->renderInfo("SilverStripe Development Tools: Tasks", Director::absoluteBaseURL()); - $base = Director::absoluteBaseURL(); + if (Director::is_cli()) { + // CLI mode + $output = 'SILVERSTRIPE DEVELOPMENT TOOLS: Tasks' . PHP_EOL . '--------------------------' . PHP_EOL . PHP_EOL; - echo "
"; - echo "
"; - echo $renderer->renderFooter(); - // CLI mode - } else { - echo "SILVERSTRIPE DEVELOPMENT TOOLS: Tasks\n--------------------------\n\n"; - foreach ($tasks as $task) { - echo " * $task[title]: sake dev/tasks/" . $task['segment'] . "\n"; - } + return $output; } + + $list = ArrayList::create(); + + foreach ($tasks as $task) { + $list->push(ArrayData::create([ + 'TaskLink' => $baseUrl . 'dev/tasks/' . $task['segment'], + 'Title' => $task['title'], + 'Description' => $task['description'], + ])); + } + + $renderer = DebugView::create(); + $header = $renderer->renderHeader(); + $cssPath = ModuleResourceLoader::singleton()->resolveURL( + 'silverstripe/framework:client/styles/task-runner.css' + ); + + // inject task runner CSS into the heaader + $cssInclude = sprintf('', $cssPath); + $header = str_replace('', $cssInclude . '', $header); + + $data = [ + 'Tasks' => $list, + 'Header' => $header, + 'Footer' => $renderer->renderFooter(), + 'Info' => $renderer->renderInfo('SilverStripe Development Tools: Tasks', $baseUrl), + ]; + + return ViewableData::create()->renderWith(static::class, $data); } /** diff --git a/templates/SilverStripe/Dev/TaskRunner.ss b/templates/SilverStripe/Dev/TaskRunner.ss new file mode 100644 index 00000000000..188b879ba6e --- /dev/null +++ b/templates/SilverStripe/Dev/TaskRunner.ss @@ -0,0 +1,26 @@ +$Header.RAW +$Info.RAW + +
+
+

Tasks

+

These tasks can be run immediately.

+ <% if $Tasks.Count > 0 %> +
+ <% loop $Tasks %> +
+
+

$Title

+

$Description

+
+ +
+ <% end_loop %> +
+ <% end_if %> +
+
+ +$Footer.RAW From 339fe3936da727272539c421057ba9facd0299fd Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Mon, 22 Jun 2020 14:42:09 +1200 Subject: [PATCH 02/10] PR fixes --- client/styles/task-runner.css | 12 ++++++++---- templates/SilverStripe/Dev/TaskRunner.ss | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 973035f9527..404facc511b 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -1,7 +1,11 @@ /* This file is manually maintained, it is not generated from SCSS sources */ .task__panel { - margin: 15px; + margin-top: 10px; +} + +.task__intro { + margin: 0 15px; } .task__list { @@ -24,7 +28,7 @@ display: flex; flex-direction: column; justify-content: space-between; - padding: 15px; + padding: 8px; transition: background-color 0.2s; } @@ -33,7 +37,7 @@ } .task__item .description { - margin-bottom: 25px; + margin-bottom: 10px; } .task__button { @@ -41,7 +45,7 @@ border-radius: 5px; background-color: #f6f7f8; display: inline-block; - padding: 10px 15px; + padding: 5px 8px; text-decoration: none; transition: background-color 0.2s; } diff --git a/templates/SilverStripe/Dev/TaskRunner.ss b/templates/SilverStripe/Dev/TaskRunner.ss index 188b879ba6e..3a350854321 100644 --- a/templates/SilverStripe/Dev/TaskRunner.ss +++ b/templates/SilverStripe/Dev/TaskRunner.ss @@ -3,8 +3,10 @@ $Info.RAW
-

Tasks

-

These tasks can be run immediately.

+
+

Tasks

+

These tasks can be run immediately.

+
<% if $Tasks.Count > 0 %>
<% loop $Tasks %> From 156f9fb34dd8b412e1e2da1e119f71024dd9cc03 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 17 Jul 2020 11:42:00 +1200 Subject: [PATCH 03/10] PR fixes. --- client/styles/task-runner.css | 60 +++++++++++++----------- templates/SilverStripe/Dev/TaskRunner.ss | 10 ++-- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 404facc511b..520febcdda7 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -1,55 +1,61 @@ /* This file is manually maintained, it is not generated from SCSS sources */ -.task__panel { - margin-top: 10px; -} - -.task__intro { - margin: 0 15px; +.task { + padding-top: 20px; } -.task__list { - border-left: 1px solid #000000; - border-top: 1px solid #000000; - display: grid; - grid-template-columns: 1fr; - margin-top: 15px; +.task__panel { + padding: 0 15px 15px 15px; } @media (min-width:992px) { .task__list { + display: grid; grid-template-columns: 1fr 1fr; + column-gap: 100px; + row-gap: 30px; } } .task__item { - border-bottom: 1px solid #000000; - border-right: 1px solid #000000; - display: flex; - flex-direction: column; - justify-content: space-between; - padding: 8px; - transition: background-color 0.2s; + padding-bottom: 30px; } -.task__item:hover { - background-color: #ffffff; +@media (min-width:992px) { + .task__item { + padding-bottom: 0; + } } -.task__item .description { - margin-bottom: 10px; +.task__item:last-child { + padding-bottom: 0; +} + +.task__title { + color: #303b4d; +} + +.task__description { + color: #43536d; + margin-bottom: 20px; } .task__button { - border: 1px solid #000000; + border: 1px solid #ced5e1; border-radius: 5px; background-color: #f6f7f8; + color: #43536d; display: inline-block; - padding: 5px 8px; + margin-right: 10px; + padding: 6px 10px; text-decoration: none; transition: background-color 0.2s; } -.task__button--warning:hover { - background-color: #ffebeb; +.task__button:last-child { + margin-right: 0; +} + +.task__button:hover { + background-color: #ced5e1; } diff --git a/templates/SilverStripe/Dev/TaskRunner.ss b/templates/SilverStripe/Dev/TaskRunner.ss index 3a350854321..b8ca202eced 100644 --- a/templates/SilverStripe/Dev/TaskRunner.ss +++ b/templates/SilverStripe/Dev/TaskRunner.ss @@ -3,20 +3,16 @@ $Info.RAW
-
-

Tasks

-

These tasks can be run immediately.

-
<% if $Tasks.Count > 0 %>
<% loop $Tasks %>
-

$Title

-

$Description

+

$Title

+

$Description

<% end_loop %> From 78c0bcf4f1300ae7b827fce98c8450710b5dfd34 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 17 Jul 2020 13:50:34 +1200 Subject: [PATCH 04/10] PR fixes. --- client/styles/task-runner.css | 2 ++ templates/SilverStripe/Dev/TaskRunner.ss | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 520febcdda7..0459973e084 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -38,6 +38,7 @@ .task__description { color: #43536d; margin-bottom: 20px; + margin-top: 15px; } .task__button { @@ -56,6 +57,7 @@ margin-right: 0; } +.task__button:focus, .task__button:hover { background-color: #ced5e1; } diff --git a/templates/SilverStripe/Dev/TaskRunner.ss b/templates/SilverStripe/Dev/TaskRunner.ss index b8ca202eced..10020f74d2c 100644 --- a/templates/SilverStripe/Dev/TaskRunner.ss +++ b/templates/SilverStripe/Dev/TaskRunner.ss @@ -9,7 +9,7 @@ $Info.RAW

$Title

-

$Description

+
$Description
Run task From f5f002cbbd5baf86226db7760f822b6f171b6d4f Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 17 Jul 2020 14:47:26 +1200 Subject: [PATCH 05/10] PR fixes --- client/styles/task-runner.css | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 0459973e084..5f708e8d067 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -10,10 +10,8 @@ @media (min-width:992px) { .task__list { - display: grid; - grid-template-columns: 1fr 1fr; + columns: 2; column-gap: 100px; - row-gap: 30px; } } @@ -23,14 +21,11 @@ @media (min-width:992px) { .task__item { - padding-bottom: 0; + display: inline-block; + width: 100%; } } -.task__item:last-child { - padding-bottom: 0; -} - .task__title { color: #303b4d; } From 2438a3d87c7091f7f79683eb42676e3a108678e1 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Mon, 20 Jul 2020 10:38:51 +1200 Subject: [PATCH 06/10] Spacing corrections. --- client/styles/task-runner.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 5f708e8d067..33d1e0fa2c0 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -28,12 +28,12 @@ .task__title { color: #303b4d; + margin: 0 0 8px; } .task__description { color: #43536d; - margin-bottom: 20px; - margin-top: 15px; + margin-bottom: 12px; } .task__button { From 8585aea16041ca46b85d3a916afed9a424e653fa Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Mon, 20 Jul 2020 12:22:51 +1200 Subject: [PATCH 07/10] Unwanted line-breaks removed. --- src/Dev/TaskRunner.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Dev/TaskRunner.php b/src/Dev/TaskRunner.php index ccb4fc9ca72..d9de5fa1b2f 100644 --- a/src/Dev/TaskRunner.php +++ b/src/Dev/TaskRunner.php @@ -145,10 +145,12 @@ protected function getTasks() } $singleton = BuildTask::singleton($class); + $description = $singleton->getDescription(); + $description = trim($description); $desc = (Director::is_cli()) - ? Convert::html2raw($singleton->getDescription()) - : $singleton->getDescription(); + ? Convert::html2raw($description) + : $description; $availableTasks[] = [ 'class' => $class, From dfd007accaadbc4062f7d8e5c984a9336c2a41a1 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Tue, 21 Jul 2020 11:18:03 +1200 Subject: [PATCH 08/10] Update client/styles/task-runner.css Co-authored-by: Sacha Judd --- client/styles/task-runner.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 33d1e0fa2c0..33cf2a6ace5 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -53,6 +53,7 @@ } .task__button:focus, -.task__button:hover { +.task__button:hover, +.task__button:focus { background-color: #ced5e1; } From 8bd25e75e8901c0229eacde15d51d3d57ab13929 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Tue, 21 Jul 2020 11:20:42 +1200 Subject: [PATCH 09/10] Code cleanup. --- client/styles/task-runner.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/styles/task-runner.css b/client/styles/task-runner.css index 33cf2a6ace5..33d1e0fa2c0 100644 --- a/client/styles/task-runner.css +++ b/client/styles/task-runner.css @@ -53,7 +53,6 @@ } .task__button:focus, -.task__button:hover, -.task__button:focus { +.task__button:hover { background-color: #ced5e1; } From 471e1271e77a8ef529637a2ab44c7f8db3b3546f Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 31 Jul 2020 14:13:54 +1200 Subject: [PATCH 10/10] PR fixes --- src/Dev/TaskRunner.php | 43 +++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Dev/TaskRunner.php b/src/Dev/TaskRunner.php index d9de5fa1b2f..bb911d7126b 100644 --- a/src/Dev/TaskRunner.php +++ b/src/Dev/TaskRunner.php @@ -7,6 +7,7 @@ use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; +use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Manifest\ModuleResourceLoader; @@ -19,6 +20,8 @@ class TaskRunner extends Controller { + use Configurable; + private static $url_handlers = [ '' => 'index', '$TaskName' => 'runTask' @@ -29,6 +32,13 @@ class TaskRunner extends Controller 'runTask', ]; + /** + * @var array + */ + private static $css = [ + 'silverstripe/framework:client/styles/task-runner.css', + ]; + protected function init() { parent::init(); @@ -74,13 +84,7 @@ public function index() $renderer = DebugView::create(); $header = $renderer->renderHeader(); - $cssPath = ModuleResourceLoader::singleton()->resolveURL( - 'silverstripe/framework:client/styles/task-runner.css' - ); - - // inject task runner CSS into the heaader - $cssInclude = sprintf('', $cssPath); - $header = str_replace('', $cssInclude . '', $header); + $header = $this->addCssToHeader($header); $data = [ 'Tasks' => $list, @@ -178,4 +182,29 @@ protected function taskEnabled($class) return true; } + + /** + * Inject task runner CSS into the heaader + + * @param string $header + * @return string + */ + protected function addCssToHeader($header) + { + $css = (array) $this->config()->get('css'); + + if (!$css) { + return $header; + } + + foreach ($css as $include) { + $path = ModuleResourceLoader::singleton()->resolveURL($include); + + // inject CSS into the heaader + $element = sprintf('', $path); + $header = str_replace('', $element . '', $header); + } + + return $header; + } }