From 94792881dccd5b6be405d71cbb8ac981868fefc8 Mon Sep 17 00:00:00 2001 From: Stephen Ball Date: Tue, 5 May 2015 23:21:38 +0100 Subject: [PATCH 1/3] #18 Start on allowing deploying specific tags --- resources/assets/css/app.css | 4 +++ resources/assets/js/projects.js | 30 ++++++++++++++++++++- resources/lang/en/deployments.php | 5 ++++ resources/views/dialogs/reason.blade.php | 34 ++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/resources/assets/css/app.css b/resources/assets/css/app.css index 66bc07250..d2bd7bfd6 100644 --- a/resources/assets/css/app.css +++ b/resources/assets/css/app.css @@ -54,4 +54,8 @@ body.dragging * { /* Make sure there is always a space between the icon and the label as HTMLMin removes it */ span.label i.fa { margin-right: 2px; +} + +input[type=text].deployment-source { + display: none; } \ No newline at end of file diff --git a/resources/assets/js/projects.js b/resources/assets/js/projects.js index 99add346b..3a07177f2 100644 --- a/resources/assets/js/projects.js +++ b/resources/assets/js/projects.js @@ -1,11 +1,39 @@ var app = app || {}; (function ($) { + $('.deployment-source:radio').on('change', function (event) { + var target = $(event.currentTarget); + + $('input[type=text].deployment-source').hide(); + if (target.val() === 'branch') { + $('#deployment_branch').show(); + } else if (target.val() === 'tag') { + $('#deployment_tag').show(); + } + }); + + $('#reason').on('show.bs.modal', function (event) { + var modal = $(this); + $('.callout-danger', modal).hide(); + }); - $('#reason button').on('click', function (event) { + $('#reason button.btn-save').on('click', function (event) { var target = $(event.currentTarget); var icon = target.find('i'); var dialog = target.parents('.modal'); + var source = $('input[name=source]:checked').val(); + + $('.has-error', source).removeClass('has-error'); + + if (source === 'branch' || source === 'tag') { + if ($('#deployment_' + source).val() === '') { + $('#deployment_' + source).parentsUntil('div').addClass('has-error'); + + $('.callout-danger', dialog).show(); + event.stopPropagation(); + return; + } + } icon.addClass('fa-refresh fa-spin').removeClass('fa-save'); $('button.close', dialog).hide(); diff --git a/resources/lang/en/deployments.php b/resources/lang/en/deployments.php index 2b3851167..d757183d9 100644 --- a/resources/lang/en/deployments.php +++ b/resources/lang/en/deployments.php @@ -29,6 +29,11 @@ 'cancelled' => 'Cancelled', 'loading' => 'Loading', 'reason' => 'Reason for deployment', + 'source' => 'Source', + 'default' => 'Default branch (:branch)', + 'branch' => 'A different branch', + 'tag' => 'A tag', + 'warning' => 'The deployment could not be started, please make sure you have entered all required values.', 'describe_reason' => 'Please describe briefly the reason for this deployment', 'optional' => 'Select the optional deploy steps to run' diff --git a/resources/views/dialogs/reason.blade.php b/resources/views/dialogs/reason.blade.php index 044e72b2a..645ee0a1b 100644 --- a/resources/views/dialogs/reason.blade.php +++ b/resources/views/dialogs/reason.blade.php @@ -9,6 +9,40 @@