Skip to content

Commit

Permalink
feat(AppLogo): extend settings for appowner logo in applactionMetadata (
Browse files Browse the repository at this point in the history
#297)

* feat(AppLogo): extend settings for appowner logo in applactionMetadata

* rename ShowAppOwnerInHeader to DisplayAppOwnerNameInHeader

* Add test for logo config in application metadata
  • Loading branch information
mikaelrss authored Aug 29, 2023
1 parent 21a62c3 commit 8e355e3
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Altinn.App.Core/Models/ApplicationMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public ApplicationMetadata(string id)
public AppIdentifier AppIdentifier { get; private set; }

/// <summary>
/// A flag to specify that the form should use a custom logo
/// Configure options for setting organisation logo
/// </summary>
[JsonProperty(PropertyName = "useCustomLogo")]
public bool UseCustomLogo { get; set; }
[JsonProperty(PropertyName = "logo")]
public Logo? Logo { get; set; }
}
}
25 changes: 25 additions & 0 deletions src/Altinn.App.Core/Models/Logo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Altinn.Platform.Storage.Interface.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Altinn.App.Core.Models
{
/// <summary>
/// The Logo configuration
/// </summary>
public class Logo
{
/// <summary>
/// A flag to specify that the form should display appOwner in header
/// </summary>
[JsonProperty(PropertyName = "displayAppOwnerNameInHeader")]
public bool DisplayAppOwnerNameInHeader { get; set; }

/// <summary>
/// Specifies from where the logo url should be fetched
/// </summary>
[JsonProperty(PropertyName = "source")]
public string? Source { get; set; }

}
}
69 changes: 69 additions & 0 deletions test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,75 @@ public async Task GetApplicationMetadata_onEntry_prefer_new_option()
actual.OnEntry?.InstanceSelection?.DefaultSelectedOption.Should().Be(3);
}

[Fact]
public async Task GetApplicationMetadata_logo_can_intstantiate_with_source_and_DisplayAppOwnerNameInHeader()
{
var featureManagerMock = new Mock<IFeatureManager>();
IFrontendFeatures frontendFeatures = new FrontendFeatures(featureManagerMock.Object);
Dictionary<string, bool> enabledFrontendFeatures = await frontendFeatures.GetFrontendFeatures();

AppSettings appSettings = GetAppSettings("AppMetadata", "logo-org-source.applicationmetadata.json");
IAppMetadata appMetadata = SetupAppMedata(Microsoft.Extensions.Options.Options.Create(appSettings));
ApplicationMetadata expected = new ApplicationMetadata("tdd/bestilling")
{
Id = "tdd/bestilling",
Org = "tdd",
Created = DateTime.Parse("2019-09-16T22:22:22"),
CreatedBy = "username",
Title = new Dictionary<string, string>()
{
{ "nb", "Bestillingseksempelapp" }
},
DataTypes = new List<DataType>()
{
new()
{
Id = "vedlegg",
AllowedContentTypes = new List<string>() { "application/pdf", "image/png", "image/jpeg" },
MinCount = 0,
TaskId = "Task_1"
},
new()
{
Id = "ref-data-as-pdf",
AllowedContentTypes = new List<string>() { "application/pdf" },
MinCount = 1,
TaskId = "Task_1"
}
},
PartyTypesAllowed = new PartyTypesAllowed()
{
BankruptcyEstate = true,
Organisation = true,
Person = true,
SubUnit = true
},
OnEntry = new OnEntry()
{
Show = "select-instance",
InstanceSelection = new()
{
SortDirection = "desc",
RowsPerPageOptions = new List<int>()
{
5, 3, 10, 25, 50, 100
},
DefaultRowsPerPage = 1,
DefaultSelectedOption = 3
}
},
Logo = new Logo
{
Source = "org",
DisplayAppOwnerNameInHeader = true
},
Features = enabledFrontendFeatures
};
var actual = await appMetadata.GetApplicationMetadata();
actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(expected);
}

[Fact]
public async void GetApplicationMetadata_throws_ApplicationConfigException_if_file_not_found()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"id": "tdd/bestilling",
"org": "tdd",
"created": "2019-09-16T22:22:22",
"createdBy": "username",
"title": { "nb": "Bestillingseksempelapp" },
"dataTypes": [
{
"id": "vedlegg",
"allowedContentTypes": [ "application/pdf", "image/png", "image/jpeg" ],
"minCount": 0,
"taskId": "Task_1",
},
{
"id": "ref-data-as-pdf",
"allowedContentTypes": [ "application/pdf" ],
"minCount": 1,
"taskId": "Task_1",
}
],
"partyTypesAllowed": {
"bankruptcyEstate": true,
"organisation": true,
"person": true,
"subUnit": true
},
"onEntry": {
"show": "select-instance",
"instanceSelection": {
"sortDirection": "desc",
"rowsPerPageOptions": [5, 3, 10, 25, 50, 100],
"defaultRowsPerPage": 1,
"defaultSelectedOption": 3
}
},
"logo": {
"displayAppOwnerNameInHeader": true,
"source": "org"
}
}

0 comments on commit 8e355e3

Please sign in to comment.