-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #874 from SkillsFundingAgency/CON-1513-update-to-u…
…se-global-header Con 1513 update to use global header
- Loading branch information
Showing
4 changed files
with
71 additions
and
113 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
65 changes: 65 additions & 0 deletions
65
src/Employer/Employer.Web/Extensions/HtmlHelperExtensions.cs
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,65 @@ | ||
using System; | ||
using Esfa.Recruit.Employer.Web.Configuration; | ||
using Esfa.Recruit.Employer.Web.Configuration.Routing; | ||
using Esfa.Recruit.Shared.Web.Extensions; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using Microsoft.Extensions.Options; | ||
using SFA.DAS.MA.Shared.UI.Configuration; | ||
using SFA.DAS.MA.Shared.UI.Models; | ||
|
||
namespace Esfa.Recruit.Employer.Web.Extensions | ||
{ | ||
public static class HtmlHelperExtensions | ||
{ | ||
public static IHeaderViewModel GetHeaderViewModel(this IHtmlHelper html, bool hideMenu = false) | ||
{ | ||
var externalLinks = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions<ExternalLinksConfiguration>)) as IOptions<ExternalLinksConfiguration>).Value; | ||
var authConfig = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions<AuthenticationConfiguration>)) as IOptions<AuthenticationConfiguration>).Value; | ||
var requestRoot = html.ViewContext.HttpContext.Request.GetRequestUrlRoot(); | ||
var requestPath = html.ViewContext.HttpContext.Request.Path; | ||
var commitmentsSiteUrl = new Uri(externalLinks.CommitmentsSiteUrl); | ||
|
||
var headerModel = new HeaderViewModel(new HeaderConfiguration | ||
{ | ||
EmployerCommitmentsBaseUrl = $"{commitmentsSiteUrl.Scheme}://{commitmentsSiteUrl.Host}/commitments", | ||
EmployerFinanceBaseUrl = externalLinks.ManageApprenticeshipSiteUrl, | ||
ManageApprenticeshipsBaseUrl = externalLinks.ManageApprenticeshipSiteUrl, | ||
AuthenticationAuthorityUrl = authConfig.Authority, | ||
ClientId = authConfig.ClientId, | ||
EmployerRecruitBaseUrl = requestRoot, | ||
SignOutUrl = new Uri($"{requestRoot}/services/logout/"), | ||
ChangeEmailReturnUrl = new Uri($"{requestRoot}{requestPath}"), | ||
ChangePasswordReturnUrl = new Uri($"{requestRoot}{requestPath}") | ||
}, | ||
new UserContext | ||
{ | ||
User = html.ViewContext.HttpContext.User, | ||
HashedAccountId = html.ViewContext.RouteData.Values["employerAccountId"]?.ToString() | ||
}); | ||
|
||
headerModel.SelectMenu("recruitment"); | ||
|
||
if ((html.ViewBag.IsErrorPage is bool && html.ViewBag.IsErrorPage) || (html.ViewBag.ShowNav is bool && !html.ViewBag.ShowNav)) | ||
{ | ||
headerModel.HideMenu(); | ||
} | ||
|
||
return headerModel; | ||
} | ||
|
||
public static IFooterViewModel GetFooterViewModel(this IHtmlHelper html) | ||
{ | ||
var externalLinks = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions<ExternalLinksConfiguration>)) as IOptions<ExternalLinksConfiguration>).Value; | ||
|
||
return new FooterViewModel(new FooterConfiguration | ||
{ | ||
ManageApprenticeshipsBaseUrl = externalLinks.ManageApprenticeshipSiteUrl | ||
}, | ||
new UserContext | ||
{ | ||
User = html.ViewContext.HttpContext.User, | ||
HashedAccountId = html.ViewContext.RouteData.Values["employerAccountId"]?.ToString() | ||
}); | ||
} | ||
} | ||
} |
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