Skip to content

Commit e031145

Browse files
authored
Merge pull request #1524 from alphagov/add-edit-link-to-previews
Add link back to Admin for Draft and Live Previews
2 parents 5ffe256 + 90566ec commit e031145

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

app/components/form_header_component/view.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def call
2121
govuk_service_navigation(
2222
service_name: form_name,
2323
service_url: form_start_page_url,
24+
navigation_items: navigation_items,
2425
),
2526
], "\n")
2627
else
@@ -64,5 +65,20 @@ def form_name
6465
def form_start_page_url
6566
form_path(mode: @mode.to_s, form_id: @current_context.form.id, form_slug: @current_context.form.form_slug)
6667
end
68+
69+
def navigation_items
70+
[
71+
{
72+
text: I18n.t("preview_header.your_questions"),
73+
href: your_questions_url,
74+
},
75+
]
76+
end
77+
78+
def your_questions_url
79+
return "#{Settings.forms_admin.base_url}/forms/#{@current_context.form.id}/live/pages" if @mode.preview_live?
80+
81+
"#{Settings.forms_admin.base_url}/forms/#{@current_context.form.id}/pages/"
82+
end
6783
end
6884
end

config/locales/cy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ cy:
466466
preview_banner:
467467
heading: This is a preview of this form. Do not enter personal information.
468468
title: Important
469+
preview_header:
470+
your_questions: Your questions
469471
privacy:
470472
changes:
471473
heading: Newidiadau i’r hysbysiad hwn

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ en:
466466
preview_banner:
467467
heading: This is a preview of this form. Do not enter personal information.
468468
title: Important
469+
preview_header:
470+
your_questions: Your questions
469471
privacy:
470472
changes:
471473
heading: Changes to this notice

spec/components/form_header_component/view_spec.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
it "links to the form start page" do
2222
render_inline(described_class.new(current_context:, mode:))
2323

24-
expect(page).to have_link "test_form_name", href: "/form/1/test"
24+
expect(page).to have_link("test_form_name", href: "/form/1/test")
2525
end
2626

2727
context "when mode is preview_draft" do
@@ -35,6 +35,13 @@
3535
expect(page).to have_content("test_form_name")
3636
end
3737

38+
it "has a link to 'Add and edit your questions' in admin" do
39+
allow(Settings.forms_admin).to receive(:base_url).and_return("http://forms-admin")
40+
render_inline(described_class.new(current_context:, mode:))
41+
42+
expect(page).to have_link("Your questions", href: "#{Settings.forms_admin.base_url}/forms/1/pages/")
43+
end
44+
3845
it "links to the forms-admin homepage" do
3946
allow(Settings.forms_admin).to receive(:base_url).and_return("http://forms-admin/")
4047

@@ -74,6 +81,18 @@
7481
expect(page).to have_selector(".app-header--preview-live")
7582
expect(page).to have_content("test_form_name")
7683
end
84+
85+
it "has a link to 'Your Questions' in admin" do
86+
render_inline(described_class.new(current_context:, mode:))
87+
88+
expect(page).to have_link("Your questions")
89+
end
90+
91+
it "does not have a link to Edit your question" do
92+
render_inline(described_class.new(current_context:, mode:))
93+
94+
expect(page).to have_no_link("Edit your question")
95+
end
7796
end
7897

7998
context "when the environment is production" do

0 commit comments

Comments
 (0)