Skip to content

Commit

Permalink
Replace instances of hard coded strings with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
nwarms committed Jan 8, 2025
1 parent 457d16a commit d3221bf
Show file tree
Hide file tree
Showing 77 changed files with 537 additions and 281 deletions.
1 change: 1 addition & 0 deletions DfE.FindInformationAcademiesTrusts/Pages/Cookies.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page
@using DfE.FindInformationAcademiesTrusts.Configuration
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model CookiesModel

@{
Expand Down
1 change: 1 addition & 0 deletions DfE.FindInformationAcademiesTrusts/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page
@using DfE.FindInformationAcademiesTrusts.Configuration
@using Microsoft.FeatureManagement.Mvc.TagHelpers
@model ErrorModel

@{
Expand Down
1 change: 1 addition & 0 deletions DfE.FindInformationAcademiesTrusts/Pages/Search.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model SearchModel

@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using NetEscapades.AspNetCore.SecurityHeaders.TagHelpers
@{
var authenticatedUserId = User.Identity is not null && User.Identity.IsAuthenticated ? User.Identity.Name ?? "Unknown" : "Anonymous";
var authenticatedUserId = User.Identity is not null && User.Identity.IsAuthenticated ? User.Identity.Name ?? "Unknown" : "Anonymous";
}
<script type="text/javascript" integrity="sha384-g/ZkzetdQypWdY0NBZT5r2L3BR9/hURD8OBcd1rEaBpgX6QC7EaTL+o+mzWrBcXW" crossorigin="anonymous" src="https://js.monitor.azure.com/scripts/b/ext/ai.clck.2.8.18.min.js"></script>
<script type="text/javascript" asp-add-nonce>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model ContentPageModel

@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@if (CookiesHelper.ShowCookieBanner(Context, TempData))
{
<div class="govuk-cookie-banner " data-nosnippet role="region" aria-label="Cookies on Find information about academies and trusts">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using DfE.FindInformationAcademiesTrusts.Configuration
@using Microsoft.FeatureManagement.Mvc.TagHelpers
<footer class="govuk-footer">
<div class="govuk-width-container">
<div class="govuk-footer__navigation">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model BasePageModel
<header class="dfe-header">
<a href="#main-content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@model BasePageModel
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using NetEscapades.AspNetCore.SecurityHeaders.TagHelpers
@model BasePageModel
@{
var inputId = "header-search";
var placeholderText = "Search for a trust";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@using DfE.FindInformationAcademiesTrusts.Configuration
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Microsoft.FeatureManagement.Mvc.TagHelpers
@using NetEscapades.AspNetCore.SecurityHeaders.TagHelpers
<!DOCTYPE html>
<html lang="en" class="govuk-template ">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using NetEscapades.AspNetCore.SecurityHeaders.TagHelpers
@model IPageSearchFormModel
<div data-testid="app-search-form">
<h3 class="govuk-heading-m govuk-!-margin-bottom-3">
Enter a trust reference number or name
</h3>
<h3 class="govuk-heading-m govuk-!-margin-bottom-3">
Enter a trust reference number or name
</h3>
<div class="govuk-hint">
Include any punctuation in the name.
Include any punctuation in the name.
</div>

@* This is used by the no javascript users *@
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@model IPaginationModel
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model IPaginationModel

<nav class="govuk-pagination" aria-label="results">
@* Previous link *@
Expand Down Expand Up @@ -32,7 +33,7 @@
@if (Model.PageStatus.HasPreviousPage && Model.PageStatus.PageIndex - 1 != 1)
{
<li class="govuk-pagination__item">
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" aria-label="Page @(Model.PageStatus.PageIndex - 1)" data-testid="page-@(Model.PageStatus.PageIndex - 1)">
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" aria-label="Page @(Model.PageStatus.PageIndex - 1)" data-testid="page-@(Model.PageStatus.PageIndex - 1)">
@(Model.PageStatus.PageIndex - 1)
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public abstract class AcademiesPageModel(
IDateTimeProvider dateTimeProvider
) : TrustsAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Academies" };
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { PageName = ViewConstants.OverviewPageTitle };

protected IExportService ExportService { get; } = exportService;
public IDateTimeProvider DateTimeProvider { get; } = dateTimeProvider;

Expand All @@ -28,9 +30,11 @@ public override async Task<IActionResult> OnGetAsync()
var eesDataSource = await DataSourceService.GetAsync(Source.ExploreEducationStatistics);

DataSourcesPerPage.AddRange([
new DataSourcePageListEntry("Details", [new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry("Pupil numbers", [new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry("Free school meals", [
new DataSourcePageListEntry(ViewConstants.AcademiesDetailsPageTitle,
[new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry(ViewConstants.AcademiesPupilNumbersPageTitle,
[new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry(ViewConstants.AcademiesFreeSchoolMealsPageTitle, [
new DataSourceListEntry(giasDataSource, "Pupils eligible for free school meals"),
new DataSourceListEntry(eesDataSource, "Local authority average 2023/24"),
new DataSourceListEntry(eesDataSource, "National average 2023/24")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class AcademiesDetailsModel(
: AcademiesPageModel(dataSourceService, trustService, exportService, logger,
dateTimeProvider)
{
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { TabName = "Details" };
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { TabName = ViewConstants.AcademiesDetailsPageTitle };

public AcademyDetailsServiceModel[] Academies { get; set; } = default!;
public IOtherServicesLinkBuilder LinkBuilder { get; } = linkBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class FreeSchoolMealsModel(
: AcademiesPageModel(dataSourceService, trustService, exportService, logger, dateTimeProvider)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { TabName = "Free school meals" };
base.TrustPageMetadata with { TabName = ViewConstants.AcademiesFreeSchoolMealsPageTitle };

public AcademyFreeSchoolMealsServiceModel[] Academies { get; set; } = default!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public class PupilNumbersModel(
IDateTimeProvider dateTimeProvider)
: AcademiesPageModel(dataSourceService, trustService, exportService, logger, dateTimeProvider)
{
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { TabName = "Pupil numbers" };
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with
{
TabName = ViewConstants.AcademiesPupilNumbersPageTitle
};

public AcademyPupilNumbersServiceModel[] Academies { get; set; } = default!;

public override async Task<IActionResult> OnGetAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model AcademiesPageModel

@{
Expand All @@ -19,17 +20,17 @@
Contents
</h2>
<ul class="govuk-tabs__list">
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf("Details")">
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf(ViewConstants.AcademiesDetailsPageTitle)">
<a id="academies-details-link" class="govuk-tabs__tab" asp-page="./Details" asp-route-uid="@Model.TrustSummary.Uid">
<span class="govuk-visually-hidden">Academies </span>Details
</a>
</li>
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf("Pupil numbers")">
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf(ViewConstants.AcademiesPupilNumbersPageTitle)">
<a id="academies-pupil-numbers-link" class="govuk-tabs__tab" asp-page="./PupilNumbers" asp-route-uid="@Model.TrustSummary.Uid">
<span class="govuk-visually-hidden">Academies </span>Pupil numbers
</a>
</li>
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf("Free school meals")">
<li class="govuk-tabs__list-item @GetCurrentlySelectedClassIf(ViewConstants.AcademiesFreeSchoolMealsPageTitle)">
<a id="free-school-meals-link" class="govuk-tabs__tab" asp-page="./FreeSchoolMeals" asp-route-uid="@Model.TrustSummary.Uid">
<span class="govuk-visually-hidden">Academies </span>Free school meals
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ ILogger<ContactsAreaModel> logger
)
: TrustsAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with { PageName = "Contacts" };
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { PageName = ViewConstants.ContactsPageTitle };

public Person? ChairOfTrustees { get; set; }
public Person? AccountingOfficer { get; set; }
public Person? ChiefFinancialOfficer { get; set; }
Expand All @@ -29,7 +31,8 @@ public override async Task<IActionResult> OnGetAsync()

SubNavigationLinks =
[
new TrustSubNavigationLinkModel("In DfE", "./InDfE", Uid, TrustPageMetadata.PageName!, this is InDfeModel),
new TrustSubNavigationLinkModel(ViewConstants.ContactsInDfePageTitle, "./InDfE", Uid,
TrustPageMetadata.PageName!, this is InDfeModel),
new TrustSubNavigationLinkModel("In the trust", "./InTrust", Uid, TrustPageMetadata.PageName!,
this is InTrustModel)
];
Expand All @@ -42,7 +45,7 @@ public override async Task<IActionResult> OnGetAsync()
var mstrDataSource = await DataSourceService.GetAsync(Source.Mstr);

DataSourcesPerPage.AddRange([
new DataSourcePageListEntry("In DfE", [
new DataSourcePageListEntry(ViewConstants.ContactsInDfePageTitle, [
new DataSourceListEntry(new DataSourceServiceModel(Source.FiatDb,
TrustRelationshipManager?.LastModifiedAtTime, null,
TrustRelationshipManager?.LastModifiedByEmail),
Expand All @@ -59,7 +62,6 @@ public override async Task<IActionResult> OnGetAsync()
new DataSourceListEntry(mstrDataSource, "Accounting officer email"),
new DataSourceListEntry(mstrDataSource, "Chief financial officer email"),
new DataSourceListEntry(mstrDataSource, "Chair of trustees email")

]
)
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class EditContactModel(
public override TrustPageMetadata TrustPageMetadata => base.TrustPageMetadata with
{
SubPageName = $"Edit {role.MapRoleToViewString()} details",
PageName = "Contacts"
PageName = ViewConstants.ContactsPageTitle
};

public const string NameField = "Name";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model EditSfsoLeadModel

@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model EditTrustRelationshipManagerModel

@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@page "/trusts/contacts/in-dfe"
@using DfE.FindInformationAcademiesTrusts.Data.Enums
@using DfE.FindInformationAcademiesTrusts.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model InDfeModel

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class InDfeModel(
: ContactsAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "In DfE" };
base.TrustPageMetadata with { SubPageName = ViewConstants.ContactsInDfePageTitle };
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/trusts/contacts/in-the-trust"
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model InTrustModel

@{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@model EditContactModel
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model EditContactModel

<partial name="Trusts/_TrustBanner" model="@Model"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GovernanceAreaModel(
: TrustsAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { PageName = "Governance" };
base.TrustPageMetadata with { PageName = ViewConstants.GovernancePageTitle };

public TrustGovernanceServiceModel TrustGovernance { get; set; } = default!;

Expand All @@ -26,24 +26,34 @@ public override async Task<IActionResult> OnGetAsync()

SubNavigationLinks =
[
new TrustSubNavigationLinkModel($"Trust leadership ({TrustGovernance.CurrentTrustLeadership.Length})",
new TrustSubNavigationLinkModel(
$"T{ViewConstants.GovernanceTrustLeadershipPageTitle} ({TrustGovernance.CurrentTrustLeadership.Length})",
"./TrustLeadership", Uid, TrustPageMetadata.PageName!, this is TrustLeadershipModel),
new TrustSubNavigationLinkModel($"Trustees ({TrustGovernance.CurrentTrustees.Length})", "./Trustees", Uid,
new TrustSubNavigationLinkModel(
$"{ViewConstants.GovernanceTrusteesPageTitle} ({TrustGovernance.CurrentTrustees.Length})", "./Trustees",
Uid,
TrustPageMetadata.PageName!, this is TrusteesModel),
new TrustSubNavigationLinkModel($"Members ({TrustGovernance.CurrentMembers.Length})", "./Members", Uid,
new TrustSubNavigationLinkModel(
$"{ViewConstants.GovernanceMembersPageTitle} ({TrustGovernance.CurrentMembers.Length})", "./Members",
Uid,
TrustPageMetadata.PageName!, this is MembersModel),
new TrustSubNavigationLinkModel($"Historic members ({TrustGovernance.HistoricMembers.Length})",
new TrustSubNavigationLinkModel(
$"{ViewConstants.GovernanceHistoricMembersPageTitle} ({TrustGovernance.HistoricMembers.Length})",
"./HistoricMembers", Uid, TrustPageMetadata.PageName!, this is HistoricMembersModel)
];

// Add data sources
var giasDataSource = await DataSourceService.GetAsync(Source.Gias);

DataSourcesPerPage.AddRange([
new DataSourcePageListEntry("Trust leadership", [new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry("Trustees", [new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry("Members", [new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry("Historic members", [new DataSourceListEntry(giasDataSource)])
new DataSourcePageListEntry(ViewConstants.GovernanceTrustLeadershipPageTitle,
[new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry(ViewConstants.GovernanceTrusteesPageTitle,
[new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry(ViewConstants.GovernanceMembersPageTitle,
[new DataSourceListEntry(giasDataSource)]),
new DataSourcePageListEntry(ViewConstants.GovernanceHistoricMembersPageTitle,
[new DataSourceListEntry(giasDataSource)])
]);

return pageResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/trusts/governance/historic-members"
@using DfE.FindInformationAcademiesTrusts.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model HistoricMembersModel

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class HistoricMembersModel(
: GovernanceAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Historic members" };
base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceHistoricMembersPageTitle };
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page
@using DfE.FindInformationAcademiesTrusts.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model MembersModel

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class MembersModel(
: GovernanceAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Members" };
base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceMembersPageTitle };
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/trusts/governance/trust-leadership"
@using DfE.FindInformationAcademiesTrusts.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model TrustLeadershipModel

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class TrustLeadershipModel(
: GovernanceAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Trust leadership" };
base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceTrustLeadershipPageTitle };
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page
@using DfE.FindInformationAcademiesTrusts.Extensions
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model TrusteesModel

@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class TrusteesModel(
: GovernanceAreaModel(dataSourceService, trustService, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Trustees" };
base.TrustPageMetadata with { SubPageName = ViewConstants.GovernanceTrusteesPageTitle };
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public class CurrentRatingsModel(
academyService, exportService, dateTimeProvider, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Current ratings" };
base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedCurrentRatingsPageTitle };
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public class ImportantDatesModel(
academyService, exportService, dateTimeProvider, logger)
{
public override TrustPageMetadata TrustPageMetadata =>
base.TrustPageMetadata with { SubPageName = "Important dates" };
base.TrustPageMetadata with { SubPageName = ViewConstants.OfstedImportantDatesPageTitle };
}
Loading

0 comments on commit d3221bf

Please sign in to comment.