Skip to content

Commit

Permalink
Update to use notification-banner layout in other places (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Mar 19, 2024
1 parent a988579 commit 6f93104
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 223 deletions.
6 changes: 4 additions & 2 deletions internal/templatefn/fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,16 @@ type notificationBannerData struct {
App page.AppData
Title string
Content template.HTML
Heading bool
Success bool
}

func notificationBanner(app page.AppData, title string, content template.HTML, success bool) notificationBannerData {
func notificationBanner(app page.AppData, title string, content template.HTML, options ...string) notificationBannerData {
return notificationBannerData{
App: app,
Title: title,
Content: content,
Success: success,
Heading: slices.Contains(options, "heading"),
Success: slices.Contains(options, "success"),
}
}
9 changes: 8 additions & 1 deletion internal/templatefn/fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,12 @@ func TestNotificationBanner(t *testing.T) {
Title: "title",
Content: "content",
Success: true,
}, notificationBanner(app, "title", "content", true))
Heading: true,
}, notificationBanner(app, "title", "content", "heading", "success"))

assert.Equal(t, notificationBannerData{
App: app,
Title: "title",
Content: "content",
}, notificationBanner(app, "title", "content"))
}
40 changes: 16 additions & 24 deletions web/template/attorney/code_of_conduct.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,23 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "success" }}
</h2>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading">
{{ if .App.IsReplacementAttorney }}
{{ if .App.IsTrustCorporation }}
{{ tr .App "weHaveIdentifiedTheTrustCorporationsReplacementAttorneyReferenceNumber" }}
{{ else }}
{{ tr .App "weHaveIdentifiedYourReplacementAttorneyReferenceNumber" }}
{{ end }}
{{ else }}
{{ if .App.IsTrustCorporation }}
{{ tr .App "weHaveIdentifiedTheTrustCorporationsAttorneyReferenceNumber" }}
{{ else }}
{{ tr .App "weHaveIdentifiedYourAttorneyReferenceNumber" }}
{{ end }}
{{ end }}
</p>
</div>
</div>
{{ $notificationContent := "" }}
{{ if .App.IsReplacementAttorney }}
{{ if .App.IsTrustCorporation }}
{{ $notificationContent = "weHaveIdentifiedTheTrustCorporationsReplacementAttorneyReferenceNumber" }}
{{ else }}
{{ $notificationContent = "weHaveIdentifiedYourReplacementAttorneyReferenceNumber" }}
{{ end }}
{{ else }}
{{ if .App.IsTrustCorporation }}
{{ $notificationContent = "weHaveIdentifiedTheTrustCorporationsAttorneyReferenceNumber" }}
{{ else }}
{{ $notificationContent = "weHaveIdentifiedYourAttorneyReferenceNumber" }}
{{ end }}
{{ end }}

{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App $notificationContent) "success" "heading") }}

<h1 class="govuk-heading-xl">{{ tr .App "actingAsAttorney" }}</h1>

{{ $content := "" }}
Expand Down
15 changes: 1 addition & 14 deletions web/template/certificateprovider/who_is_eligible.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "success" }}
</h2>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading">
{{ tr .App "weHaveIdentifiedYourCertificateProviderReferenceNumber" }}
</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "weHaveIdentifiedYourCertificateProviderReferenceNumber") "success" "heading") }}

<h1 class="govuk-heading-xl">
{{ tr .App "whoIsEligibleToBeCertificateProvider" }}
Expand Down
41 changes: 15 additions & 26 deletions web/template/donor/lpa_details_saved.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,22 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ $notificationContent := "" }}
{{ if .IsFirstCheck }}
{{ if .Donor.CertificateProvider.CarryOutBy.IsPaper }}
{{ $notificationContent = "lpaDetailsSavedContentOnFirstSubmissionCPCarryingOutRolePaper" }}
{{ else }}
{{ $notificationContent = "lpaDetailsSavedContentOnFirstSubmissionCPCarryingOutRoleOnline" }}
{{ end }}
{{ else }}
{{ if .Donor.CertificateProvider.CarryOutBy.IsPaper }}
{{ $notificationContent = "lpaDetailsSavedContentOnSubsequentSubmissionCPCarryingOutRolePaper" }}
{{ else }}
{{ $notificationContent = "lpaDetailsSavedContentOnSubsequentSubmissionCPCarryingOutRoleOnline" }}
{{ end }}
{{ end }}

<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "lpaDetailsSaved" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ if .IsFirstCheck }}
{{ if .Donor.CertificateProvider.CarryOutBy.IsPaper }}
{{ trFormat .App "lpaDetailsSavedContentOnFirstSubmissionCPCarryingOutRolePaper" "CertificateProviderFullName" .Donor.CertificateProvider.FullName }}
{{ else }}
{{ trFormat .App "lpaDetailsSavedContentOnFirstSubmissionCPCarryingOutRoleOnline" "CertificateProviderFullName" .Donor.CertificateProvider.FullName }}
{{ end }}
{{ else }}
{{ if .Donor.CertificateProvider.CarryOutBy.IsPaper }}
{{ trFormat .App "lpaDetailsSavedContentOnSubsequentSubmissionCPCarryingOutRolePaper" "CertificateProviderFullName" .Donor.CertificateProvider.FullName }}
{{ else }}
{{ trFormat .App "lpaDetailsSavedContentOnSubsequentSubmissionCPCarryingOutRoleOnline" "CertificateProviderFullName" .Donor.CertificateProvider.FullName }}
{{ end }}
{{ end }}
</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "lpaDetailsSaved" (trFormatHtml .App $notificationContent "CertificateProviderFullName" .Donor.CertificateProvider.FullName) "success") }}

{{ if .Donor.Tasks.PayForLpa.IsCompleted }}
<div class="govuk-button-group">
Expand Down
11 changes: 1 addition & 10 deletions web/template/donor/need_help_signing_confirmation.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<p class="govuk-notification-banner__title">{{ tr .App "informationSaved" }}</p>
</div>
<div class="govuk-notification-banner__content">
<h1 class="govuk-body">
{{ tr .App "weKnowYouWillNeedHelpSigning" }}
</h1>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "informationSaved" (trHtml .App "weKnowYouWillNeedHelpSigning") "success") }}

{{ trHtml .App "weKnowYouWillNeedHelpSigningContent" }}

Expand Down
11 changes: 1 addition & 10 deletions web/template/donor/we_have_updated_your_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ trFormat .App "detailUpdated" "Detail" (tr .App (.App.Query.Get "detail")) }}
</h1>
</div>
<div class="govuk-notification-banner__content">
{{ trFormat .App "weHaveUpdatedYourDetail" "Detail" $detail }}
</div>
</div>
{{ template "notification-banner" (notificationBanner .App (trFormat .App "detailUpdated" "Detail" (tr .App (.App.Query.Get "detail"))) (trFormatHtml .App "weHaveUpdatedYourDetail" "Detail" $detail) "success") }}

<p class="govuk-body">{{ trFormat .App "yourDetailHasBeenUpdated" "Detail" $detail }}</p>

Expand Down
2 changes: 1 addition & 1 deletion web/template/layout/notification-banner.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body app-full-width">
<p class="{{ if .Heading }}govuk-notification-banner__heading{{ else }}govuk-body app-full-width{{ end }}">
{{ .Content }}
</p>
</div>
Expand Down
9 changes: 1 addition & 8 deletions web/template/lpa_deleted.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title">{{ tr .App "lpaDeleted" }}</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">{{ trFormatHtml .App "lpaNumberHasBeenDeleted" "UID" (.App.Query.Get "uid") }}</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "lpaDeleted" (trFormatHtml .App "lpaNumberHasBeenDeleted" "UID" (.App.Query.Get "uid")) "success") }}

<a href="{{ link .App global.Paths.Dashboard.Format }}" class="govuk-button">{{ tr .App "returnToDashboard" }}</a>
</div>
Expand Down
9 changes: 1 addition & 8 deletions web/template/lpa_withdrawn.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title">{{ tr .App "lpaWithdrawn" }}</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">{{ trFormatHtml .App "youHaveWithdrawnLpaNumber" "UID" (.App.Query.Get "uid") }}</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "lpaWithdrawn" (trFormatHtml .App "youHaveWithdrawnLpaNumber" "UID" (.App.Query.Get "uid")) "success") }}

<p class="govuk-body">{{ tr .App "opgWillNowContactAnyoneWhoHasAlreadyBeenContacted" }}</p>

Expand Down
17 changes: 2 additions & 15 deletions web/template/supporter/dashboard.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{{ if .App.Query.Has "nameUpdated" }}
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "nameUpdated" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ trFormatHtml .App "yourNameHasBeenUpdatedToNewName" "NewName" (.App.Query.Get "nameUpdated") }}
</p>
</div>
</div>
{{ end}}
{{ template "notification-banner" (notificationBanner .App "nameUpdated" (trFormatHtml .App "yourNameHasBeenUpdatedToNewName" "NewName" (.App.Query.Get "nameUpdated")) "success") }}
{{ end }}

<h1 class="govuk-heading-xl">{{ template "pageTitle" . }}</h1>

Expand Down
69 changes: 15 additions & 54 deletions web/template/supporter/manage_team_members.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,27 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{{ if .App.Query.Has "inviteSent" }}
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "invitationSent" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ trFormatHtml .App "weHaveSentInvite" "Email" (.App.Query.Get "inviteSent") }}
</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "invitationSent" (trFormatHtml .App "weHaveSentInvite" "Email" (.App.Query.Get "inviteSent")) "success") }}
{{ end}}

{{ if .App.Query.Has "nameUpdated" }}
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "nameUpdated" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ if .App.Query.Has "selfUpdated" }}
{{ trFormatHtml .App "yourNameHasBeenUpdatedToNewName" "NewName" (.App.Query.Get "nameUpdated") }}
{{ else }}
{{ trFormatHtml .App "teamMembersNameUpdatedToNewName" "NewName" (.App.Query.Get "nameUpdated") }}
{{ end }}
</p>
</div>
</div>
{{ $nameUpdatedContent := "teamMembersNameUpdatedToNewName" }}
{{ if .App.Query.Has "selfUpdated" }}
{{ $nameUpdatedContent = "yourNameHasBeenUpdatedToNewName" }}
{{ end }}

{{ template "notification-banner" (notificationBanner .App "nameUpdated" (trFormatHtml .App $nameUpdatedContent "NewName" (.App.Query.Get "nameUpdated")) "success") }}
{{ end}}

{{ if and (.App.Query.Has "statusUpdated") (.App.Query.Has "statusEmail") }}
<div class="govuk-notification-banner" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ if eq (.App.Query.Get "statusUpdated") "suspended" }}
{{ tr .App "teamMemberSuspended" }}
{{ else }}
{{ tr .App "accessUpdated" }}
{{ end }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ if eq (.App.Query.Get "statusUpdated") "suspended" }}
{{ trFormatHtml .App "emailHasBeenSuspended" "Email" (.App.Query.Get "statusEmail") }}
{{ else }}
{{ trFormatHtml .App "emailCanNowAccessOrganisation" "Email" (.App.Query.Get "statusEmail") }}
{{ end }}
</p>
</div>
</div>
{{ $statusUpdatedTitle := "accessUpdated" }}
{{ $statusUpdatedContent := "emailCanNowAccessOrganisation" }}
{{ if eq (.App.Query.Get "statusUpdated") "suspended" }}
{{ $statusUpdatedTitle = "teamMemberSuspended" }}
{{ $statusUpdatedContent = "emailHasBeenSuspended" }}
{{ end }}

{{ template "notification-banner" (notificationBanner .App $statusUpdatedTitle (trFormatHtml .App $statusUpdatedContent "Email" (.App.Query.Get "statusEmail"))) }}
{{ end}}

<h1 class="govuk-heading-xl">{{ tr .App "manageOrganisation" }}</h1>
Expand Down
15 changes: 1 addition & 14 deletions web/template/supporter/organisation_created.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "organisationCreated" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">
{{ trFormatHtml .App "yourOrganisationHasBeenCreated" "Name" .Organisation.Name }}
</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "organisationCreated" (trFormatHtml .App "yourOrganisationHasBeenCreated" "Name" .Organisation.Name) "success") }}

{{ trHtml .App "organisationCreatedContent" }}

Expand Down
13 changes: 1 addition & 12 deletions web/template/supporter/organisation_deleted.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="govuk-notification-banner" role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "organisationDeleted" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
{{ trFormatHtml .App "theOrganisationHasBeenDeleted" "OrganisationName" (.App.Query.Get "organisationName") }}
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "organisationDeleted" (trFormatHtml .App "theOrganisationHasBeenDeleted" "OrganisationName" (.App.Query.Get "organisationName"))) }}
</div>
</div>
{{ end }}
11 changes: 1 addition & 10 deletions web/template/supporter/organisation_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{{ if eq (.App.Query.Get "updated") "name" }}
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
{{ tr .App "organisationNameSaved" }}
</h1>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-body">{{ tr .App "yourOrganisationNameHasBeenSaved" }}</p>
</div>
</div>
{{ template "notification-banner" (notificationBanner .App "organisationNameSaved" (trHtml .App "yourOrganisationNameHasBeenSaved") "success") }}
{{ end }}

<h1 class="govuk-heading-xl">{{ tr .App "manageOrganisation" }}</h1>
Expand Down
Loading

0 comments on commit 6f93104

Please sign in to comment.