Skip to content

Commit

Permalink
Merge pull request #522 from DFE-Digital/mattb/SWCD-2554-agency-resou…
Browse files Browse the repository at this point in the history
…rces-navigation

fix: create agency resources as feature flag, page category, and navigation item
  • Loading branch information
nealhippo authored Oct 17, 2024
2 parents 42308a6 + fb918d1 commit 9372505
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public static class Features
public const string ResourcesAndLearning = "resources-learning";
public const string FeedbackControl = "feedback-control";
public const string EmployerStandards = "employer-standards";
public const string AgencyResources = "agency-resources";
}
11 changes: 11 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_ErrorLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@
</a>
</li>
}
@if (featuresConfig.IsEnabled(Features.AgencyResources))
{
<li class="dfe-header__navigation-item" id="mmi-agencyResources">
<a class="dfe-header__navigation-link" href="/agency-resources">
Agency Resources
<svg class="dfe-icon dfe-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
}
</ul>
</div>
</nav>
Expand Down
4 changes: 4 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_Header.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
{
RenderMenuItem("employerStandards", "Employer standards", "employer-standards", category == "Employer standards");
}
if (featuresConfig.IsEnabled(Features.AgencyResources))
{
RenderMenuItem("agencyResources", "Agency resources", "agency-resources", category == "Agency resources");
}
}
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = async function (migration, { makeRequest }) {

const contentTypeId = 'content',
categoryFieldId = 'category',
agencyResourcesString = 'Agency resources';

const response = await makeRequest({
method: 'GET',
url: `/content_types?sys.id[in]=${contentTypeId}`
});

var update = false;
const validations = response.items[0].fields
.filter(field => field.id == categoryFieldId)[0]
.validations.map(rule => {
if (rule.in && !rule.in.includes(agencyResourcesString)) {
rule.in.push(agencyResourcesString);
update = true;
}
return rule;
});

if (update) {
migration
.editContentType(contentTypeId)
.editField(categoryFieldId).validations(validations);
}
};
3 changes: 2 additions & 1 deletion Contentful-Schema/migrations/manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
0007-add-header-field-to-navigation-menu.cjs
0008-details-component.cjs
0009-asset-download-component.cjs
0010-breadcrumbs.cjs
0010-breadcrumbs.cjs
0011-create-agency-standards-page-category.cjs
Binary file modified Contentful-Schema/migrations/migrations.tar.gz
Binary file not shown.

0 comments on commit 9372505

Please sign in to comment.