Skip to content

Commit 9929793

Browse files
authored
Merge pull request #3333 from TechnologyEnhancedLearning/Develop/Features/TD-5859-URLFlagOverride
TD-5859 url parameter flag override for tableau dashboard feature flag
2 parents 6e73fc2 + 50702e9 commit 9929793

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/SelfAssessmentReports/SelfAssessmentReportsController.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
namespace DigitalLearningSolutions.Web.Controllers.TrackingSystem.Centre.SelfAssessmentReports
22
{
3+
using DigitalLearningSolutions.Data.Enums;
4+
using DigitalLearningSolutions.Data.Extensions;
35
using DigitalLearningSolutions.Data.Services;
4-
using DigitalLearningSolutions.Web.Helpers;
5-
using Microsoft.AspNetCore.Authorization;
6-
using Microsoft.AspNetCore.Mvc;
7-
using Microsoft.FeatureManagement.Mvc;
6+
using DigitalLearningSolutions.Data.Utilities;
87
using DigitalLearningSolutions.Web.Attributes;
8+
using DigitalLearningSolutions.Web.Helpers;
9+
using DigitalLearningSolutions.Web.Helpers.ExternalApis;
910
using DigitalLearningSolutions.Web.Models.Enums;
10-
using DigitalLearningSolutions.Data.Enums;
11-
using DigitalLearningSolutions.Data.Utilities;
11+
using DigitalLearningSolutions.Web.Services;
1212
using DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Centre.Reports;
13-
using DigitalLearningSolutions.Web.Helpers.ExternalApis;
13+
using Microsoft.AspNetCore.Authorization;
14+
using Microsoft.AspNetCore.Mvc;
1415
using Microsoft.Extensions.Configuration;
15-
using DigitalLearningSolutions.Data.Extensions;
16-
using DigitalLearningSolutions.Web.Services;
16+
using Microsoft.FeatureManagement;
17+
using Microsoft.FeatureManagement.Mvc;
18+
using System;
19+
using System.Threading.Tasks;
1720

1821
[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
1922
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
@@ -30,12 +33,14 @@ public class SelfAssessmentReportsController : Controller
3033
private readonly string workbookName;
3134
private readonly string viewName;
3235
private readonly ISelfAssessmentService selfAssessmentService;
36+
private readonly IFeatureManager featureManager;
3337
public SelfAssessmentReportsController(
3438
ISelfAssessmentReportService selfAssessmentReportService,
3539
ITableauConnectionHelperService tableauConnectionHelper,
3640
IClockUtility clockUtility,
3741
IConfiguration config,
38-
ISelfAssessmentService selfAssessmentService
42+
ISelfAssessmentService selfAssessmentService,
43+
IFeatureManager featureManager
3944
)
4045
{
4146
this.selfAssessmentReportService = selfAssessmentReportService;
@@ -46,13 +51,17 @@ ISelfAssessmentService selfAssessmentService
4651
workbookName = config.GetTableauWorkbookName();
4752
viewName = config.GetTableauViewName();
4853
this.selfAssessmentService = selfAssessmentService;
54+
this.featureManager = featureManager;
4955
}
50-
public IActionResult Index()
56+
public async Task<IActionResult> IndexAsync()
5157
{
5258
var centreId = User.GetCentreId();
5359
var adminCategoryId = User.GetAdminCategoryId();
5460
var categoryId = this.selfAssessmentService.GetSelfAssessmentCategoryId(1);
55-
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId);
61+
var tableauFlag = await featureManager.IsEnabledAsync(FeatureFlags.TableauSelfAssessmentDashboards);
62+
var tableauQueryOverride = string.Equals(Request.Query["tableaulink"], "true", StringComparison.OrdinalIgnoreCase);
63+
var showTableauLink = tableauFlag || tableauQueryOverride;
64+
var model = new SelfAssessmentReportsViewModel(selfAssessmentReportService.GetSelfAssessmentsForReportList((int)centreId, adminCategoryId), adminCategoryId, categoryId, showTableauLink);
5665
return View(model);
5766
}
5867
[HttpGet]

DigitalLearningSolutions.Web/ViewModels/TrackingSystem/Centre/Reports/SelfAssessmentReportsViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
public class SelfAssessmentReportsViewModel
77
{
88
public SelfAssessmentReportsViewModel(
9-
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId
9+
IEnumerable<SelfAssessmentSelect> selfAssessmentSelects, int? adminCategoryId, int categoryId, bool showTableauLink
1010
)
1111
{
1212
SelfAssessmentSelects = selfAssessmentSelects;
1313
AdminCategoryId = adminCategoryId;
1414
CategoryId = categoryId;
15+
ShowTableauLink = showTableauLink;
1516
}
1617
public IEnumerable<SelfAssessmentSelect> SelfAssessmentSelects { get; set; }
1718
public int? AdminCategoryId { get; set; }
1819
public int CategoryId { get; set; }
20+
public bool ShowTableauLink { get; set; } = false;
1921
}
2022
}

DigitalLearningSolutions.Web/Views/TrackingSystem/Centre/SelfAssessmentReports/Index.cshtml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,20 @@
1919
<span class="nhsuk-u-visually-hidden"> - </span>
2020
</span>@ViewData["Title"]
2121
</h1>
22-
<feature name="@(FeatureFlags.TableauSelfAssessmentDashboards)">
23-
@if (Model.SelfAssessmentSelects.Any())
24-
{
25-
<vc:action-link asp-controller="SelfAssessmentReports" asp-action="TableauCompetencyDashboard" asp-all-route-data="@new Dictionary<string, string>();" link-text="View Tableau supervised self assessments dashboard" />
26-
}
27-
</feature>
22+
@if (Model.ShowTableauLink && Model.SelfAssessmentSelects.Any())
23+
{
24+
<vc:action-link asp-controller="SelfAssessmentReports" asp-action="TableauCompetencyDashboard" asp-all-route-data="@new Dictionary<string, string>();" link-text="View Tableau supervised self assessments dashboard" />
25+
}
2826
<h2>Excel learner activity reports</h2>
2927
<p class="nhsuk-lede-text">Download Excel competency self assessments activity reports for your centre.</p>
3028
<ul>
31-
@if((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId))
32-
{
33-
<li>
34-
<a asp-controller="SelfAssessmentReports" asp-action="DownloadDigitalCapabilityToExcel">Digital Skills Assessment Tool - Download report</a>
29+
@if ((Model.AdminCategoryId == null) || (Model.AdminCategoryId == Model.CategoryId))
30+
{
31+
<li>
32+
<a asp-controller="SelfAssessmentReports" asp-action="DownloadDigitalCapabilityToExcel">Digital Skills Assessment Tool - Download report</a>
3533

36-
</li>
37-
}
34+
</li>
35+
}
3836
@if (Model.SelfAssessmentSelects.Any())
3937
{
4038
@foreach (var report in Model.SelfAssessmentSelects)

DigitalLearningSolutions.Web/appSettings.UAT.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"UserFeedbackBar": true,
2323
"ExportQueryRowLimit": 250,
2424
"MaxBulkUploadRows": 200,
25-
"LoginWithLearningHub": true
25+
"LoginWithLearningHub": true,
26+
"TableauSelfAssessmentDashboards": false
2627
},
2728
"LearningHubOpenAPIBaseUrl": "https://uks-learninghubnhsuk-openapi-test.azurewebsites.net",
2829
"FreshdeskAPIConfig": {

DigitalLearningSolutions.Web/appsettings.Development.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"UserFeedbackBar": true,
2323
"ExportQueryRowLimit": 250,
2424
"MaxBulkUploadRows": 200,
25-
"LoginWithLearningHub": true
25+
"LoginWithLearningHub": true,
26+
"TableauSelfAssessmentDashboards": false
2627
},
2728
"LearningHubOpenAPIBaseUrl": "https://uks-learninghubnhsuk-openapi-test.azurewebsites.net",
2829
"LearningHubReportAPIConfig": {

0 commit comments

Comments
 (0)