-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial work for Downtime Index page transition to Design System #2027
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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,118 @@ | ||
require "integration_test_helper" | ||
|
||
class LegacyDowntimeIntegrationTest < JavascriptIntegrationTest | ||
setup do | ||
setup_users | ||
|
||
@edition = FactoryBot.create( | ||
:transaction_edition, | ||
:published, | ||
title: "Apply to become a driving instructor", | ||
slug: "apply-to-become-a-driving-instructor", | ||
) | ||
|
||
WebMock.reset! | ||
stub_any_publishing_api_put_content | ||
stub_any_publishing_api_publish | ||
end | ||
|
||
test "Scheduling new downtime" do | ||
DowntimeScheduler.stubs(:schedule_publish_and_expiry) | ||
|
||
visit root_path | ||
click_link "Downtime" | ||
click_link "Apply to become a driving instructor" | ||
|
||
enter_start_time first_of_july_next_year_at_midday_bst | ||
enter_end_time first_of_july_next_year_at_six_pm_bst | ||
|
||
assert_match("midday to 6pm on #{day} 1 July", page.find_field("Message").value) | ||
click_button "Schedule downtime message" | ||
|
||
assert page.has_content?("downtime message scheduled") | ||
assert page.has_content?("Scheduled downtime") | ||
assert page.has_content?("midday to 6pm on 1 July") | ||
end | ||
|
||
test "Rescheduling downtime" do | ||
DowntimeScheduler.stubs(:schedule_publish_and_expiry) | ||
create_downtime | ||
|
||
visit root_path | ||
click_link "Downtime" | ||
click_link "Edit downtime" | ||
enter_end_time first_of_july_next_year_at_nine_thirty_pm_bst | ||
|
||
assert_match("This service will be unavailable from midday to 9:30pm on #{day} 1 July.", page.find_field("Message").value) | ||
click_on "Re-schedule downtime message" | ||
|
||
assert page.has_content?("downtime message re-scheduled") | ||
assert page.has_content?("midday to 9:30pm on 1 July") | ||
end | ||
|
||
test "Cancelling downtime" do | ||
PublishingApiWorkflowBypassPublisher.stubs(:call) | ||
create_downtime | ||
|
||
visit root_path | ||
click_link "Downtime" | ||
click_link "Edit downtime" | ||
click_on "Cancel downtime" | ||
|
||
assert page.has_content?("downtime message cancelled") | ||
assert_no_downtime_scheduled | ||
end | ||
|
||
def enter_start_time(start_time) | ||
complete_date_inputs("downtime_start_time", start_time) | ||
end | ||
|
||
def enter_end_time(end_time) | ||
complete_date_inputs("downtime_end_time", end_time) | ||
end | ||
|
||
def complete_date_inputs(input_id, time) | ||
select time.year.to_s, from: "#{input_id}_1i" | ||
select time.strftime("%B"), from: "#{input_id}_2i" | ||
select time.day.to_s, from: "#{input_id}_3i" | ||
select time.hour.to_s, from: "#{input_id}_4i" | ||
select time.strftime("%M"), from: "#{input_id}_5i" | ||
end | ||
|
||
def next_year | ||
Time.zone.now.next_year.year | ||
end | ||
|
||
def date_in_the_past | ||
Time.zone.local(Time.zone.now.last_year.year, 1, 1, 12, 0) | ||
end | ||
|
||
def first_of_july_next_year_at_midday_bst | ||
Time.zone.local(next_year, 7, 1, 12, 0) | ||
end | ||
|
||
def first_of_july_next_year_at_six_pm_bst | ||
Time.zone.local(next_year, 7, 1, 18, 0) | ||
end | ||
|
||
def first_of_july_next_year_at_nine_thirty_pm_bst | ||
Time.zone.local(next_year, 7, 1, 21, 30) | ||
end | ||
|
||
def day | ||
first_of_july_next_year_at_six_pm_bst.strftime("%A") | ||
end | ||
|
||
def create_downtime | ||
Downtime.create!( | ||
artefact: @edition.artefact, | ||
start_time: first_of_july_next_year_at_midday_bst, | ||
end_time: first_of_july_next_year_at_six_pm_bst, | ||
message: "foo", | ||
) | ||
end | ||
|
||
def assert_no_downtime_scheduled | ||
assert_equal 0, Downtime.count | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using the design system components (Error Alert, Success Alert, Notice), rather than copying this pattern from the legacy layout template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that implementing the design system component would be a separate task in of itself. I think the flash message probably shouldn't have been removed initially or should have done part as part of the layout card, which is why I'm putting it back for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need a team discussion around this, as I would expect that without using the components from the design system, the look of the flash messages won't be acceptable for releasing these pages, in which case we need to get a story for doing that done ASAP.
I think we probably need a discussion around how we're going to release pages (i.e. turn the default state of the toggle to on) anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented the flash messages as part of the actual page content itself.