diff --git a/src/Altinn.App.Core/Models/ApplicationMetadata.cs b/src/Altinn.App.Core/Models/ApplicationMetadata.cs index a00b8a337..edb20e29c 100644 --- a/src/Altinn.App.Core/Models/ApplicationMetadata.cs +++ b/src/Altinn.App.Core/Models/ApplicationMetadata.cs @@ -54,9 +54,9 @@ public ApplicationMetadata(string id) public AppIdentifier AppIdentifier { get; private set; } /// - /// A flag to specify that the form should use a custom logo + /// Configure options for setting organisation logo /// - [JsonProperty(PropertyName = "useCustomLogo")] - public bool UseCustomLogo { get; set; } + [JsonProperty(PropertyName = "logo")] + public Logo? Logo { get; set; } } } diff --git a/src/Altinn.App.Core/Models/Logo.cs b/src/Altinn.App.Core/Models/Logo.cs new file mode 100644 index 000000000..f10846d53 --- /dev/null +++ b/src/Altinn.App.Core/Models/Logo.cs @@ -0,0 +1,25 @@ +using Altinn.Platform.Storage.Interface.Models; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Altinn.App.Core.Models +{ + /// + /// The Logo configuration + /// + public class Logo + { + /// + /// A flag to specify that the form should display appOwner in header + /// + [JsonProperty(PropertyName = "displayAppOwnerNameInHeader")] + public bool DisplayAppOwnerNameInHeader { get; set; } + + /// + /// Specifies from where the logo url should be fetched + /// + [JsonProperty(PropertyName = "source")] + public string? Source { get; set; } + + } +} diff --git a/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs b/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs index a69e0afa0..e9f9b191c 100644 --- a/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs +++ b/test/Altinn.App.Core.Tests/Internal/App/AppMedataTest.cs @@ -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(); + IFrontendFeatures frontendFeatures = new FrontendFeatures(featureManagerMock.Object); + Dictionary 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() + { + { "nb", "Bestillingseksempelapp" } + }, + DataTypes = new List() + { + new() + { + Id = "vedlegg", + AllowedContentTypes = new List() { "application/pdf", "image/png", "image/jpeg" }, + MinCount = 0, + TaskId = "Task_1" + }, + new() + { + Id = "ref-data-as-pdf", + AllowedContentTypes = new List() { "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() + { + 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() { diff --git a/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/logo-org-source.applicationmetadata.json b/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/logo-org-source.applicationmetadata.json new file mode 100644 index 000000000..8a6c34aff --- /dev/null +++ b/test/Altinn.App.Core.Tests/Internal/App/TestData/AppMetadata/logo-org-source.applicationmetadata.json @@ -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" + } +}