Skip to content

Commit 57a0314

Browse files
Merge branch 'RC' into Develop/Fixes/TD-6100-refactor-latest
2 parents f360366 + 747c451 commit 57a0314

File tree

11 files changed

+121
-44
lines changed

11 files changed

+121
-44
lines changed

.github/dependabot.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,45 @@
44
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
55

66
version: 2
7+
registries:
8+
learninghubfeed:
9+
type: nuget-feed
10+
url: https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json
11+
username: "kevin.whittaker"
12+
password: ${{ secrets.AZURE_DEVOPS_PAT }}
13+
nuget.org:
14+
type: nuget-feed
15+
url: "https://api.nuget.org/v3/index.json"
716
updates:
817
- package-ecosystem: "nuget"
918
directory: "/" # Location of package manifests
1019
schedule:
1120
interval: "daily"
12-
open-pull-requests-limit: 10
21+
open-pull-requests-limit: 5
22+
registries:
23+
- learninghubfeed
24+
- nuget.org
1325
target-branch: "Automatic_version_update_dependabot"
1426
ignore:
1527
# Ignore updates to packages that start with 'Wildcards'
1628
- dependency-name: "Microsoft.FeatureManagement.AspNetCore*"
1729
- dependency-name: "LearningHub.Nhs.Models*"
1830
- dependency-name: "LearningHub.Nhs.Caching*"
19-
- dependency-name: "elfhHub.Nhs.Models*"
20-
- dependency-name: "linqtotwitter*"
21-
# Ignore some updates to the package
22-
- dependency-name: "Microsoft.VisualStudio.Web.CodeGeneration.Design"
23-
versions: [">7.0.0"]
24-
- dependency-name: "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
25-
versions: [">7.0.0"]
26-
- dependency-name: "Microsoft.AspNetCore.Mvc.Testing"
27-
versions: [">7.0.0"]
31+
- dependency-name: "elfhHub.Nhs.Models*"
32+
- dependency-name: "UK.NHS.CookieBanner"
33+
- dependency-name: "GDS.MultiPageFormData"
34+
- dependency-name: "linqtotwitter*"
35+
# Ignore some updates to the package
36+
- dependency-name: "Azure.Storage.Files.Shares"
37+
versions: [">12.11.0"]
38+
- dependency-name: "FluentAssertions"
39+
versions: [">6.12.0"]
40+
- dependency-name: "HtmlSanitizer"
41+
versions: [">6.0.453"]
42+
- dependency-name: "xunit"
43+
versions: [">2.4.1"]
44+
- dependency-name: "xunit.runner.visualstudio"
45+
versions: [">2.4.3"]
2846
- dependency-name: "Selenium.WebDriver.ChromeDriver"
2947
versions: ">=113.0.5672.1278" # Recommended version
3048
# For all packages, ignore all patch updates

AdminUI/LearningHub.Nhs.AdminUI/Services/UserService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ public async Task<LearningHubValidationResult> ClearUserCachedPermissions(int us
338338
{
339339
await this.cacheService.RemoveAsync($"{userId}:AllRolesWithPermissions");
340340
await this.cacheService.RemoveAsync($"{userId}:DatabricksReporter");
341+
await this.cacheService.RemoveAsync($"{userId}:UserHasPublishedResources");
341342
return new LearningHubValidationResult(true);
342343
}
343344

AdminUI/LearningHub.Nhs.AdminUI/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"vue-carousel": "^0.18.0",
4444
"vue-clamp": "0.4.1",
4545
"vue-click-outside": "1.1.0",
46-
"vue-ctk-date-time-picker": "^2.5.0",
46+
"vue-ctk-date-time-picker": "2.5.0",
4747
"vue-router": "^3.6.5",
4848
"vue-simple-progress": "^1.1.1",
4949
"vue-typeahead": "^2.3.2",

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<None Remove="Enums\**" />
2929
<None Remove="wwwroot\lib\fontawesome-pro-5.9.0\**" />
3030
<TypeScriptCompile Remove="Enums\**" />
31-
<TypeScriptCompile Remove="node_modules\nhsuk-frontend\**" />
3231
<TypeScriptCompile Remove="wwwroot\lib\fontawesome-pro-5.9.0\**" />
3332
</ItemGroup>
3433
<ItemGroup>

LearningHub.Nhs.WebUI/Program.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
3636
builder.Host.UseNLog();
3737

38+
string corsMoodleUrl = builder.Configuration.GetValue<string>("MoodleAPIConfig:BaseUrl");
39+
40+
builder.Services.AddCors(options =>
41+
{
42+
options.AddPolicy("MoodleCORS", builder =>
43+
{
44+
builder.WithOrigins(corsMoodleUrl.TrimEnd('/'))
45+
.AllowAnyHeader()
46+
.AllowAnyMethod()
47+
.AllowCredentials();
48+
});
49+
});
50+
3851
builder.Services.AddHostedService<TimedHostedService>();
3952
builder.Services.ConfigureServices(builder.Configuration, builder.Environment);
4053

@@ -80,6 +93,8 @@
8093

8194
app.UseRouting();
8295

96+
app.UseCors("MoodleCORS");
97+
8398
app.UseAuthentication();
8499
app.UseAuthorization();
85100

LearningHub.Nhs.WebUI/Services/ResourceService.cs

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ namespace LearningHub.Nhs.WebUI.Services
66
using System.Net.Http;
77
using System.Text;
88
using System.Threading.Tasks;
9+
using LearningHub.Nhs.Caching;
910
using LearningHub.Nhs.Models.Common;
1011
using LearningHub.Nhs.Models.Entities.Activity;
1112
using LearningHub.Nhs.Models.Entities.Resource;
1213
using LearningHub.Nhs.Models.Enums;
14+
using LearningHub.Nhs.Models.Extensions;
1315
using LearningHub.Nhs.Models.Hierarchy;
1416
using LearningHub.Nhs.Models.Resource;
1517
using LearningHub.Nhs.Models.Resource.Contribute;
1618
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
1719
using LearningHub.Nhs.Models.Validation;
1820
using LearningHub.Nhs.WebUI.Interfaces;
1921
using LearningHub.Nhs.WebUI.Models;
22+
using Microsoft.AspNetCore.Http;
2023
using Microsoft.Extensions.Logging;
2124
using Microsoft.Extensions.Options;
2225
using Newtonsoft.Json;
@@ -29,20 +32,26 @@ public class ResourceService : BaseService<ResourceService>, IResourceService
2932
{
3033
private readonly Settings settings;
3134
private readonly IAzureMediaService azureMediaService;
35+
private readonly IHttpContextAccessor contextAccessor;
36+
private readonly ICacheService cacheService;
3237

3338
/// <summary>
3439
/// Initializes a new instance of the <see cref="ResourceService"/> class.
3540
/// </summary>
3641
/// <param name="learningHubHttpClient">Learning hub http client.</param>
3742
/// <param name="openApiHttpClient">The Open Api Http Client.</param>
3843
/// <param name="azureMediaService">Azure media services.</param>
44+
/// <param name="contextAccessor">The http context accessor.</param>
45+
/// <param name="cacheService">The cacheService.</param>
3946
/// <param name="logger">Logger.</param>
4047
/// <param name="settings">Settings.</param>
41-
public ResourceService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, IAzureMediaService azureMediaService, ILogger<ResourceService> logger, IOptions<Settings> settings)
48+
public ResourceService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, IAzureMediaService azureMediaService, IHttpContextAccessor contextAccessor, ICacheService cacheService, ILogger<ResourceService> logger, IOptions<Settings> settings)
4249
: base(learningHubHttpClient, openApiHttpClient, logger)
4350
{
4451
this.settings = settings.Value;
4552
this.azureMediaService = azureMediaService;
53+
this.contextAccessor = contextAccessor;
54+
this.cacheService = cacheService;
4655
}
4756

4857
/// <summary>
@@ -885,24 +894,8 @@ public async Task<LearningHubValidationResult> UnpublishResourceVersionAsync(int
885894
/// <returns>The <see cref="bool"/>.</returns>
886895
public async Task<bool> UserHasPublishedResourcesAsync()
887896
{
888-
var client = await this.OpenApiHttpClient.GetClientAsync();
889-
890-
var request = $"Resource/HasPublishedResources";
891-
var response = await client.GetAsync(request).ConfigureAwait(false);
892-
bool hasResources = false;
893-
if (response.IsSuccessStatusCode)
894-
{
895-
var result = response.Content.ReadAsStringAsync().Result;
896-
hasResources = bool.Parse(result);
897-
}
898-
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
899-
||
900-
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
901-
{
902-
throw new Exception("AccessDenied");
903-
}
904-
905-
return hasResources;
897+
var cacheKey = $"{this.contextAccessor.HttpContext.User.Identity.GetCurrentUserId()}:UserHasPublishedResources";
898+
return await this.cacheService.GetOrFetchAsync("UserHasPublishedResources", () => this.HasPublishedResources());
906899
}
907900

908901
/// <summary>
@@ -1340,5 +1333,32 @@ public async Task<List<string>> GetObsoleteResourceFile(int resourceVersionId, b
13401333

13411334
return filePaths;
13421335
}
1336+
1337+
/// <summary>
1338+
/// Check if the user has published resources.
1339+
/// </summary>
1340+
/// <returns>The bool.</returns>
1341+
/// <exception cref="Exception"></exception>
1342+
private async Task<bool> HasPublishedResources()
1343+
{
1344+
var client = await this.OpenApiHttpClient.GetClientAsync();
1345+
1346+
var request = $"Resource/HasPublishedResources";
1347+
var response = await client.GetAsync(request).ConfigureAwait(false);
1348+
bool hasResources = false;
1349+
if (response.IsSuccessStatusCode)
1350+
{
1351+
var result = response.Content.ReadAsStringAsync().Result;
1352+
hasResources = bool.Parse(result);
1353+
}
1354+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
1355+
||
1356+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
1357+
{
1358+
throw new Exception("AccessDenied");
1359+
}
1360+
1361+
return hasResources;
1362+
}
13431363
}
13441364
}

LearningHub.Nhs.WebUI/ViewComponents/NavigationItemsViewComponent.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,19 @@ public async Task<IViewComponentResult> InvokeAsync(string navView = "Default",
5757
var userId = this.User.Identity.GetCurrentUserId();
5858

5959
var (cacheExists, _) = await this.cacheService.TryGetAsync<string>($"{userId}:LoginWizard");
60-
6160
model = await this.permissionService.GetNavigationModelAsync(this.User, !cacheExists, controllerName);
6261

63-
model.NotificationCount = await this.notificationService.GetUserUnreadNotificationCountAsync(userId);
62+
// Check if NotificationCount is already stored for this request
63+
if (this.HttpContext.Items.TryGetValue("NotificationCount", out var cachedCount))
64+
{
65+
model.NotificationCount = (int)cachedCount;
66+
}
67+
else
68+
{
69+
var count = await this.notificationService.GetUserUnreadNotificationCountAsync(userId);
70+
this.HttpContext.Items["NotificationCount"] = count;
71+
model.NotificationCount = count;
72+
}
6473
}
6574

6675
return await Task.FromResult<IViewComponentResult>(this.View(navView, model));

LearningHub.Nhs.WebUI/Views/Policies/AcceptableUsePolicy.cshtml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.2 which requires a subscription or payment to gain access to such content;</p>
6969
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.3 in which the user has a commercial interest;</p>
7070
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.4 which promotes a business name and/or logo;</p>
71-
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.5 which contains a link to an app via iOS or Google Play; or</p>
71+
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.5 which contains a link to an app via iOS or Google Play or similar; or</p>
7272
<p class="nhsuk-u-padding-left-7 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.2.6 which has as its purpose or effect the collection and sharing of personal data;</p>
7373
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.3 be irrelevant to the purpose or aims of the Platform or while addressing relevant subject matter, contain an irrelevant, unsuitable or inappropriate slant (for example relating to potentially controversial opinions or beliefs of any kind intended to influence others);</p>
7474
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.4 be defamatory of any person;</p>
@@ -92,13 +92,12 @@
9292
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.22 contain harmful material;</p>
9393
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.23 give the impression that the Contribution emanates from us, if this is not the case; or</p>
9494
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.24 disclose any third party’s confidential information, identity, personally identifiable information or personal data (including data concerning health).</p>
95-
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.25 contain or request any material, the provision of which is not compliant <a href="https://www.england.nhs.uk/ig/ig-resources/">NHS England Information Governance guidance</a>[https://www.england.nhs.uk/ig/ig-resources/].</p>
95+
<p class="nhsuk-u-padding-left-4 nhsuk-u-padding-bottom-2 nhsuk-u-margin-0">4.5.25 contain or request any material, the provision of which is not compliant with <a href="https://www.england.nhs.uk/ig/ig-resources/">NHS England Information Governance guidance</a>[https://www.england.nhs.uk/ig/ig-resources/].</p>
9696
<p class="nhsuk-u-margin-bottom-2">4.6 Posts must be made with consideration of the NHS People Promise[https://www.england.nhs.uk/our-nhs-people/online-version/lfaop/our-nhs-people-promise/].</p>
9797
<p class="nhsuk-u-margin-bottom-2">4.7 You acknowledge and accept that, when using the Platform and accessing the Content, some Content that has been uploaded by third parties may be factually inaccurate, or the topics addressed by the Content may be offensive,indecent, or objectionable in nature. We are not responsible (legally or otherwise) for any claim you may have in relation to the Content.</p>
9898
<p class="nhsuk-u-margin-bottom-2">4.8 When producing Content to upload to the Platform, we encourage you to implement NICE guideline recommendations and ensure that sources of evidence are valid (for example, by peer review). </p>
9999
<h2 class="h2 nhsuk-heading-l">5 Metadata</h2>
100100
<p class="nhsuk-u-margin-bottom-2">When making any Contribution, you must where prompted include a sufficient description of the Content so that other users can understand the description, source, and age of the Content. For example, if Content has been quality assured, then the relevant information should be posted in the appropriate field. All metadata fields on the Platform must be completed appropriately before initiating upload. Including the correct information is important in order to help other users locate the Content (otherwise the Content may not appear in search results for others to select).</p>
101-
<p class="nhsuk-u-margin-bottom-2">When producing Content to upload to the Platform, we encourage you to implement NICE guideline recommendations and ensure that sources evidence are valid (for example, by peer review).</p>
102101
<h2 class="h2 nhsuk-heading-l">6 Updates</h2>
103102
<p class="nhsuk-u-margin-bottom-2">You must update each Contribution at least once every 3 (three) years, or update or remove it should it cease to be relevant or become outdated or revealed or generally perceived to be unsafe or otherwise unsuitable for inclusion on the Platform.</p>
104103
<h2 class="h2 nhsuk-heading-l">7 Accessibility</h2>
@@ -128,9 +127,9 @@
128127
<p class="nhsuk-u-margin-bottom-2">11.1 Course Manager means a person authorised by NHS England who is responsible for creating and managing courses and learning resources on the Learning Hub, including the moderation of learner's Contributions within social learning environments of an online course, such as discussion forums.</p>
129128
<p class="nhsuk-u-margin-bottom-2">11.2 Course Managers shall be responsible for monitoring local forum activity and ensuring compliance of all Contributions with the Learning Hub’s Acceptable Use Policy. Inappropriate Contributions shall be addressed promptly and escalated where necessary to the Learning Hub, who will review the user’s access to the Platform and the relevant forum. </p>
130129
<p class="nhsuk-u-margin-bottom-2">11.3 Course Managers shall also take responsibility for the following:</p>
131-
<p class="nhsuk-u-margin-bottom-2"> 11.3.1<strong>Clear Expectations:</strong>Set clear local forum rules within their course at the outset, compliantly with this Acceptable Use Policy, which includes expected behaviour, response times and moderation practices. </p>
130+
<p class="nhsuk-u-margin-bottom-2"> 11.3.1 <strong>Clear Expectations:</strong> Set clear local forum rules within their course at the outset, compliantly with this Acceptable Use Policy, which includes expected behaviour, response times and moderation practices. </p>
132131
<p class="nhsuk-u-margin-bottom-2">11.3.2 <strong>Inclusive Practice:</strong> Encourage participation from all learners/users and foster a respectful, inclusive environment that values diverse perspectives. This should involve reminding local forum users of the appropriate measures of this Acceptable Use Policy and potentially removing Contributions that infringe the rules of this Acceptable Use Policy including under paragraph 4.5 above.</p>
133-
<p class="nhsuk-u-margin-bottom-2">11.3.3<strong> Data Protection and Safety:</strong>Ensure that no sensitive or personal data is shared, requested or stored in local forums, including by promptly removing any inclusions or requests for such material and notifying NHS England promptly of any potential breaches by contacting NHS England’s Data Protection Officer team via england.dpo@nhs.net; and ensure that risks are actively managed and the local forums are maintained as a safe space for discussion.</p>
132+
<p class="nhsuk-u-margin-bottom-2">11.3.3 <strong>Data Protection and Safety:</strong> Ensure that no sensitive or personal data is shared, requested or stored in local forums, including by promptly removing any inclusions or requests for such material and notifying NHS England promptly of any potential breaches by contacting NHS England’s Data Protection Officer team via england.dpo@nhs.net; and ensure that risks are actively managed and the local forums are maintained as a safe space for discussion.</p>
134133
<p class="nhsuk-u-margin-bottom-2">11.4 All users must comply with this Acceptable Use Policy. Breaches may result in removal of Contributions and/or withdrawal or suspension of user access without notice. </p>
135134
</div>
136135
</section>

LearningHub.Nhs.WebUI/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LearningHub.Nhs.WebUI/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"vue-carousel-3d": "^1.0.1",
4848
"vue-clamp": "0.4.1",
4949
"vue-click-outside": "1.1.0",
50-
"vue-ctk-date-time-picker": "^2.5.0",
50+
"vue-ctk-date-time-picker": "2.5.0",
5151
"vue-router": "^3.6.5",
5252
"vue-simple-progress": "^1.1.1",
5353
"vue-typeahead": "^2.3.2",

0 commit comments

Comments
 (0)