-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init work to transition Downtimes to Design System
- Add new feature `design_system_downtime_index_page` to the FlipFlop config. - Update the routes with new constraint. - Duplicate the controllers, views and test of Downtimes and append the `legacy_` prefix to them. - Add new test in the routes integration test for the new feature. - Make the new Downtimes index page use the Design System layout.
- Loading branch information
1 parent
931b5b9
commit c8767e8
Showing
13 changed files
with
494 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,7 @@ | ||
class DowntimesController < ApplicationController | ||
before_action :require_govuk_editor | ||
before_action :load_edition, except: [:index] | ||
before_action :process_params, only: %i[create update] | ||
|
||
def index | ||
@transactions = TransactionEdition.published.order_by(%i[title asc]) | ||
end | ||
|
||
def new | ||
@downtime = Downtime.new(artefact: @edition.artefact) | ||
end | ||
|
||
def create | ||
@downtime = Downtime.new(downtime_params) | ||
if @downtime.save | ||
DowntimeScheduler.schedule_publish_and_expiry(@downtime) | ||
flash[:success] = "#{edition_link} downtime message scheduled (from #{view_context.downtime_datetime(@downtime)})".html_safe | ||
redirect_to downtimes_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
@downtime = Downtime.for(@edition.artefact) | ||
end | ||
|
||
def update | ||
@downtime = Downtime.for(@edition.artefact) | ||
|
||
if params["commit"] == "Cancel downtime" | ||
DowntimeRemover.destroy_immediately(@downtime) | ||
flash[:success] = "#{edition_link} downtime message cancelled".html_safe | ||
redirect_to downtimes_path | ||
elsif @downtime.update(downtime_params) | ||
DowntimeScheduler.schedule_publish_and_expiry(@downtime) | ||
flash[:success] = "#{edition_link} downtime message re-scheduled (from #{view_context.downtime_datetime(@downtime)})".html_safe | ||
redirect_to downtimes_path | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def downtime_params | ||
params[:downtime].permit([ | ||
"artefact_id", | ||
"message", | ||
"end_time(1i)", | ||
"end_time(2i)", | ||
"end_time(3i)", | ||
"end_time(4i)", | ||
"end_time(5i)", | ||
"start_time(1i)", | ||
"start_time(2i)", | ||
"start_time(3i)", | ||
"start_time(4i)", | ||
"start_time(5i)", | ||
]) | ||
end | ||
|
||
def load_edition | ||
@edition = Edition.find(params[:edition_id]) | ||
end | ||
|
||
def process_params | ||
squash_multiparameter_datetime_attributes(downtime_params, %w[start_time end_time]) | ||
end | ||
|
||
def edition_link | ||
view_context.link_to(@edition.title, edit_edition_downtime_path(@edition), class: "link-inherit bold") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class LegacyDowntimesController < ApplicationController | ||
before_action :require_govuk_editor | ||
before_action :load_edition, except: [:index] | ||
before_action :process_params, only: %i[create update] | ||
|
||
def index | ||
@transactions = TransactionEdition.published.order_by(%i[title asc]) | ||
end | ||
|
||
def new | ||
@downtime = Downtime.new(artefact: @edition.artefact) | ||
end | ||
|
||
def create | ||
@downtime = Downtime.new(downtime_params) | ||
if @downtime.save | ||
DowntimeScheduler.schedule_publish_and_expiry(@downtime) | ||
flash[:success] = "#{edition_link} downtime message scheduled (from #{view_context.downtime_datetime(@downtime)})".html_safe | ||
redirect_to downtimes_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
@downtime = Downtime.for(@edition.artefact) | ||
end | ||
|
||
def update | ||
@downtime = Downtime.for(@edition.artefact) | ||
|
||
if params["commit"] == "Cancel downtime" | ||
DowntimeRemover.destroy_immediately(@downtime) | ||
flash[:success] = "#{edition_link} downtime message cancelled".html_safe | ||
redirect_to downtimes_path | ||
elsif @downtime.update(downtime_params) | ||
DowntimeScheduler.schedule_publish_and_expiry(@downtime) | ||
flash[:success] = "#{edition_link} downtime message re-scheduled (from #{view_context.downtime_datetime(@downtime)})".html_safe | ||
redirect_to downtimes_path | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def downtime_params | ||
params[:downtime].permit([ | ||
"artefact_id", | ||
"message", | ||
"end_time(1i)", | ||
"end_time(2i)", | ||
"end_time(3i)", | ||
"end_time(4i)", | ||
"end_time(5i)", | ||
"start_time(1i)", | ||
"start_time(2i)", | ||
"start_time(3i)", | ||
"start_time(4i)", | ||
"start_time(5i)", | ||
]) | ||
end | ||
|
||
def load_edition | ||
@edition = Edition.find(params[:edition_id]) | ||
end | ||
|
||
def process_params | ||
squash_multiparameter_datetime_attributes(downtime_params, %w[start_time end_time]) | ||
end | ||
|
||
def edition_link | ||
view_context.link_to(@edition.title, edit_edition_downtime_path(@edition), class: "link-inherit bold") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<%= f.hidden_field :artefact_id %> | ||
|
||
<%= render :partial => 'shared/error_summary', locals: { object: @downtime} %> | ||
|
||
<div class="downtime-dates"> | ||
<div class="form-group"> | ||
<p>This service will be unavailable from</p> | ||
</div> | ||
|
||
<div class="row js-start-time"> | ||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Hour", for: "downtime_start_time_4i" %> | ||
<%= select_hour @downtime.start_time&.hour || 1.hour.from_now.beginning_of_hour, { field_name: "start_time(4i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Minute", for: "downtime_start_time_5i" %> | ||
<%= select_minute @downtime.start_time&.minute, { field_name: "start_time(5i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<p class="joining-on">on</p> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Day", for: "downtime_start_time_3i" %> | ||
<%= select_day @downtime.start_time&.day || Date.tomorrow.day, { field_name: "start_time(3i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Month", for: "downtime_start_time_2i" %> | ||
<%= select_month@downtime.start_time&.month || Date.tomorrow.month, { field_name: "start_time(2i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Year", for: "downtime_start_time_1i" %> | ||
<%= select_year @downtime.start_time&.year || Date.tomorrow.year, { field_name: "start_time(1i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<p>to</p> | ||
</div> | ||
|
||
<div class="row js-stop-time"> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :end_time, "Hour", for: "downtime_end_time_4i" %> | ||
<%= select_hour @downtime.end_time&.hour || 1.hour.from_now.beginning_of_hour, { field_name: "end_time(4i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :end_time, "Minute", for: "downtime_end_time_5i" %> | ||
<%= select_minute @downtime.end_time&.minute, { field_name: "end_time(5i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<p class="joining-on">on</p> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :start_time, "Day", for: "downtime_end_time_3i" %> | ||
<%= select_day @downtime.end_time&.day || Date.tomorrow.day, { field_name: "end_time(3i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :end_time, "Month", for: "downtime_end_time_2i" %> | ||
<%= select_month @downtime.end_time&.month || Date.tomorrow.month, { field_name: "end_time(2i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
|
||
<div class="form-group date col-sm-1"> | ||
<%= f.label :end_time, "Year", for: "downtime_end_time_1i" %> | ||
<%= select_year @downtime.end_time&.year || Date.tomorrow.year, { field_name: "end_time(1i)", prefix: "downtime" }, { class: "form-control date" } %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<hr> | ||
|
||
<%= form_group(f, :message) do %> | ||
<%= f.text_area :message, class: 'form-control input-md-6 js-downtime-message', rows: 5 %> | ||
<% end %> | ||
|
||
<p class="add-bottom-margin help-note"> | ||
<span class="glyphicon glyphicon-exclamation-sign"></span> | ||
<span class="js-schedule-message">Messages appear on the start page one day before the downtime is due.</span> | ||
</p> | ||
|
||
<hr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<% content_for :page_title, 'Re-schedule downtime message' %> | ||
|
||
<ul class="breadcrumb"> | ||
<li class="crumb"><%= link_to 'Downtime', downtimes_path %></li> | ||
<li class="active"><%= @downtime.artefact.name %></li> | ||
</ul> | ||
|
||
<div class="page-title"> | ||
<h1> | ||
<span class="small"><%= @downtime.artefact.name %></span> | ||
Re-schedule downtime message | ||
</h1> | ||
</div> | ||
|
||
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module': 'downtime-message' } do |f| %> | ||
<%= render 'form', f: f %> | ||
<%= f.submit 'Re-schedule downtime message', class: 'js-submit btn btn-success' %> | ||
<%= f.submit 'Cancel downtime', class: 'add-left-margin btn btn-danger' %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<% content_for :page_title, 'Downtime messages' %> | ||
|
||
<div class="page-title"> | ||
<h1>Downtime messages</h1> | ||
<p class="lead">Show a message on a published transaction start page for a specific time.</p> | ||
</div> | ||
|
||
<table class="table table-bordered table-striped" data-module="filterable-table"> | ||
<caption class="h2 remove-top-margin"> | ||
<h2 class="remove-top-margin remove-bottom-margin">Services</h2> | ||
</caption> | ||
<thead> | ||
<tr class="table-header"> | ||
<th>Service start page</th> | ||
<th>Service status</th> | ||
<th>Action</th> | ||
</tr> | ||
<tr class="if-no-js-hide table-header-secondary"> | ||
<td colspan="3"> | ||
<form> | ||
<label class="remove-bottom-margin" for="table-filter">Filter services</label> | ||
<p class="help-inline">For example ‘driving’ or ‘scheduled downtime’</p> | ||
<input id="table-filter" type="text" class="form-control normal js-filter-table-input"> | ||
</form> | ||
</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @transactions.each do |transaction| %> | ||
<tr> | ||
<td> | ||
<h3 class="publication-table-title"> | ||
<%= link_to transaction.title, Downtime.for(transaction.artefact).present? ? | ||
edit_edition_downtime_path(transaction) : | ||
new_edition_downtime_path(transaction) %> | ||
</h3> | ||
<%= link_to "/#{transaction.slug}", "#{Plek.website_root}/#{transaction.slug}", class: 'link-muted' %> | ||
</td> | ||
<% if downtime = Downtime.for(transaction.artefact) %> | ||
<td> | ||
Scheduled downtime<br /> | ||
<span class="text-muted"><%= downtime_datetime(downtime) %></span> | ||
</td> | ||
<td> | ||
<%= link_to 'Edit downtime', edit_edition_downtime_path(transaction), class: 'btn btn-info' %> | ||
</td> | ||
<% else %> | ||
<td>Live</td> | ||
<td> | ||
<%= link_to 'Add downtime', new_edition_downtime_path(transaction), class: 'btn btn-default' %> | ||
</td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% content_for :page_title, 'Schedule downtime' %> | ||
|
||
<ul class="breadcrumb"> | ||
<li class="crumb"><%= link_to 'Downtime', downtimes_path %></li> | ||
<li class="active"><%= @downtime.artefact.name %></li> | ||
</ul> | ||
|
||
<div class="page-title"> | ||
<h1> | ||
<span class="small"><%= @downtime.artefact.name %></span> | ||
Schedule a downtime message | ||
</h1> | ||
</div> | ||
|
||
<%= form_for @downtime, url: edition_downtime_path(@edition), html: { class: 'form well remove-top-margin', 'data-module' => 'downtime-message' } do |f| %> | ||
<%= render 'form', f: f %> | ||
<%= f.submit 'Schedule downtime message', class: 'js-submit btn btn-success' %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.