Skip to content

Commit

Permalink
Merge branch 'main' into 15-01-add-model-metadata-to-namesync-file-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
JamalAlabdullah authored Jan 22, 2025
2 parents 6b5b606 + f9ab025 commit e5c0bd8
Show file tree
Hide file tree
Showing 406 changed files with 5,526 additions and 2,754 deletions.
3 changes: 3 additions & 0 deletions backend/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
<Company>Altinn</Company>
<Product>Altinn Studio</Product>
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>

2 changes: 1 addition & 1 deletion backend/Migrations.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV OidcLoginSettings__ClientSecret=dummyRequired

RUN dotnet ef migrations script --project src/Designer/Designer.csproj --idempotent -o /app/migrations.sql

FROM alpine:3.21.0 AS final
FROM alpine:3.21.2 AS final
COPY --from=build /app/migrations.sql migrations.sql
RUN apk --no-cache add postgresql-client

Expand Down
37 changes: 18 additions & 19 deletions backend/packagegroups/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<ItemGroup Label="Altinn specific packages">
<PackageReference Update="Altinn.App.Core" Version="8.0.0-rc1" />
<PackageReference Update="Altinn.Common.AccessToken" Version="4.5.4" />
<PackageReference Update="Altinn.Common.AccessTokenClient" Version="3.0.10" />
<PackageReference Update="Altinn.Common.AccessToken" Version="4.5.5" />
<PackageReference Update="Altinn.Common.AccessTokenClient" Version="3.0.11" />
<PackageReference Update="Altinn.Platform.Storage.Interface" Version="3.34.0" />
</ItemGroup>

Expand All @@ -18,58 +18,57 @@
<PackageReference Update="Microsoft.ApplicationInsights.Kubernetes" Version="7.0.1" />
<PackageReference Update="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Update="Microsoft.AspNetCore.DataProtection.AzureKeyVault" Version="3.1.24" />
<PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.1" />
<PackageReference Update="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Update="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Update="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.24" />
<PackageReference Update="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="9.0.0" />
<PackageReference Update="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.1" />
<PackageReference Update="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.1" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="9.0.1" />
<PackageReference Update="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Update="Microsoft.DiaSymReader.Native" Version="1.7.0" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1" />
<PackageReference Update="Microsoft.FeatureManagement.AspNetCore" Version="4.0.0" />
<PackageReference Update="Scrutor" Version="5.1.1" />
<PackageReference Update="Polly" Version="8.5.0" />
<PackageReference Update="Polly" Version="8.5.1" />
<PackageReference Update="Altinn.Authorization.ABAC" Version="0.0.8" />
<PackageReference Update="Altinn.ApiClients.Maskinporten" Version="9.2.0" />
<PackageReference Update="MediatR" Version="12.4.1" />
<PackageReference Update="DotNetEnv" Version="3.1.1" />
<PackageReference Update="NuGet.Versioning" Version="6.12.1" />
<PackageReference Update="DistributedLock.Postgres" Version="1.2.1" />
<PackageReference Include="System.Text.Json" Version="[9.0.0]" />
<PackageReference Include="System.Text.Json" Version="[9.0.1]" />
<PackageReference Update="Microsoft.CodeAnalysis.Common" Version="[4.8.0, 4.12.0)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="[4.12.0]" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="[4.12.0]" />
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="[4.7.0]" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.1" />
<PackageReference Include="System.Net.Http" Version="[4.3.4]" />
<PackageReference Include="System.Text.RegularExpressions" Version="[4.3.1]" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
</ItemGroup>

<ItemGroup Label="Packages used for testing">
<PackageReference Update="FluentAssertions" Version="7.0.0" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<!-- Do not upgrade Moq version from 4.18.4 -->
<PackageReference Update="Moq" Version="4.18.4" />
<PackageReference Update="xunit" Version="2.9.2" />
<PackageReference Update="xunit" Version="2.9.3" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Update="coverlet.collector" Version="6.0.3" />
<PackageReference Update="Basic.Reference.Assemblies" Version="1.7.8" />
<PackageReference Update="Fare" Version="2.2.1" />
<PackageReference Update="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
<PackageReference Update="Testcontainers" Version="4.1.0" />
<PackageReference Update="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="9.0.1" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="9.0.1" />
<PackageReference Update="WireMock.Net" Version="1.6.11" />
<PackageReference Update="DistributedLock.FileSystem" Version="1.0.3" />
</ItemGroup>
Expand Down
53 changes: 27 additions & 26 deletions backend/src/Designer/Controllers/AppDevelopmentController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -9,7 +10,6 @@
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Filters;
using Altinn.Studio.Designer.Helpers;
using Altinn.Studio.Designer.Infrastructure.GitRepository;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Models.Dto;
using Altinn.Studio.Designer.Services.Interfaces;
Expand All @@ -32,7 +32,6 @@ public class AppDevelopmentController : Controller
private readonly IAppDevelopmentService _appDevelopmentService;
private readonly IRepository _repository;
private readonly ISourceControl _sourceControl;
private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory;
private readonly ApplicationInsightsSettings _applicationInsightsSettings;
private readonly IMediator _mediator;

Expand All @@ -43,15 +42,13 @@ public class AppDevelopmentController : Controller
/// <param name="appDevelopmentService">The app development service</param>
/// <param name="repositoryService">The application repository service</param>
/// <param name="sourceControl">The source control service.</param>
/// <param name="altinnGitRepositoryFactory"></param>
/// <param name="applicationInsightsSettings">An <see cref="ApplicationInsightsSettings"/></param>
/// <param name="mediator"></param>
public AppDevelopmentController(IAppDevelopmentService appDevelopmentService, IRepository repositoryService, ISourceControl sourceControl, IAltinnGitRepositoryFactory altinnGitRepositoryFactory, ApplicationInsightsSettings applicationInsightsSettings, IMediator mediator)
public AppDevelopmentController(IAppDevelopmentService appDevelopmentService, IRepository repositoryService, ISourceControl sourceControl, ApplicationInsightsSettings applicationInsightsSettings, IMediator mediator)
{
_appDevelopmentService = appDevelopmentService;
_repository = repositoryService;
_sourceControl = sourceControl;
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
_applicationInsightsSettings = applicationInsightsSettings;
_mediator = mediator;
}
Expand Down Expand Up @@ -123,8 +120,17 @@ public async Task<ActionResult> SaveFormLayout(string org, string app, [FromQuer

if (formLayoutPayload.ComponentIdsChange is not null && !string.IsNullOrEmpty(layoutSetName))
{
foreach (var componentIdChange in formLayoutPayload.ComponentIdsChange)
foreach (var componentIdChange in formLayoutPayload.ComponentIdsChange.Where((componentIdChange) => componentIdChange.OldComponentId != componentIdChange.NewComponentId))
{
if (componentIdChange.NewComponentId == null)
{
await _mediator.Publish(new ComponentDeletedEvent
{
ComponentId = componentIdChange.OldComponentId,
LayoutSetName = layoutSetName,
EditingContext = editingContext
}, cancellationToken);
}
await _mediator.Publish(new ComponentIdChangedEvent
{
OldComponentId = componentIdChange.OldComponentId,
Expand Down Expand Up @@ -159,16 +165,26 @@ await _mediator.Publish(new LayoutPageAddedEvent
/// <param name="app">Application identifier which is unique within an organisation.</param>
/// <param name="layoutSetName">The name of the layout set the specific layout belongs to</param>
/// <param name="layoutName">The form layout to be deleted</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that observes if operation is cancelled.</param>
/// <returns>A success message if the save was successful</returns>
[HttpDelete]
[Route("form-layout/{layoutName}")]
public ActionResult DeleteFormLayout(string org, string app, [FromQuery] string layoutSetName, [FromRoute] string layoutName)
public async Task<ActionResult> DeleteFormLayout(string org, string app, [FromQuery] string layoutSetName, [FromRoute] string layoutName, CancellationToken cancellationToken)
{
try
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);

await _mediator.Publish(new LayoutPageDeletedEvent
{
EditingContext = editingContext,
LayoutSetName = layoutSetName,
LayoutName = layoutName,
}, cancellationToken);

_appDevelopmentService.DeleteFormLayout(editingContext, layoutSetName, layoutName);

return Ok();
}
catch (FileNotFoundException exception)
Expand Down Expand Up @@ -402,13 +418,15 @@ public async Task<ActionResult> DeleteLayoutSet(string org, string app, [FromRou
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
LayoutSets layoutSets = await _appDevelopmentService.DeleteLayoutSet(editingContext, layoutSetIdToUpdate, cancellationToken);

await _mediator.Publish(new LayoutSetDeletedEvent
{
EditingContext = editingContext,
LayoutSetId = layoutSetIdToUpdate
LayoutSetName = layoutSetIdToUpdate
}, cancellationToken);

LayoutSets layoutSets = await _appDevelopmentService.DeleteLayoutSet(editingContext, layoutSetIdToUpdate, cancellationToken);

return Ok(layoutSets);
}

Expand Down Expand Up @@ -543,23 +561,6 @@ public ActionResult GetWidgetSettings(string org, string app)
return Ok(widgetSettings);
}

[HttpGet]
[Route("option-list-ids")]
public ActionResult GetOptionListIds(string org, string app)
{
try
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, app, developer);
string[] optionListIds = altinnAppGitRepository.GetOptionsListIds();
return Ok(optionListIds);
}
catch (LibGit2Sharp.NotFoundException)
{
return NoContent();
}
}

[HttpGet("app-version")]
public VersionResponse GetAppVersion(string org, string app)
{
Expand Down
42 changes: 42 additions & 0 deletions backend/src/Designer/Controllers/ContactController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Helpers;
using Altinn.Studio.Designer.Services.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Altinn.Studio.Designer.Controllers
{
[Route("designer/api/[controller]")]
[ApiController]
public class ContactController : ControllerBase
{
private readonly IGitea _giteaService;

public ContactController(IGitea giteaService)
{
_giteaService = giteaService;
}

[AllowAnonymous]
[HttpGet("belongs-to-org")]
public async Task<IActionResult> BelongsToOrg()
{
bool isNotAuthenticated = !AuthenticationHelper.IsAuthenticated(HttpContext);
if (isNotAuthenticated)
{
return Ok(new BelongsToOrgDto { BelongsToOrg = false });
}

try
{
var organizations = await _giteaService.GetUserOrganizations();
return Ok(new BelongsToOrgDto { BelongsToOrg = organizations.Count > 0 });
}
catch (Exception)
{
return Ok(new BelongsToOrgDto { BelongsToOrg = false });
}
}
}
}
8 changes: 4 additions & 4 deletions backend/src/Designer/Controllers/ResourceAdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public async Task<ActionResult<List<AvailableService>>> GetAltinn2LinkServices(s
foreach (ServiceResource resource in allResources)
{
if (resource?.HasCompetentAuthority.Orgcode != null
&& resource.ResourceReferences != null && resource.ResourceReferences.Exists(r => r.ReferenceType != null && r.ReferenceType.Equals(ReferenceType.ServiceCode))
&& resource.ResourceReferences != null && resource.ResourceReferences.Exists(r => r.ReferenceType != null && r.ReferenceType.Equals(ResourceReferenceType.ServiceCode))
&& resource.ResourceType == ResourceType.Altinn2Service)
{
AvailableService service = new AvailableService();
Expand All @@ -496,8 +496,8 @@ public async Task<ActionResult<List<AvailableService>>> GetAltinn2LinkServices(s
service.ServiceName = resource.Title["nb"];
}

service.ExternalServiceCode = resource.ResourceReferences.First(r => r.ReferenceType.Equals(ReferenceType.ServiceCode)).Reference;
service.ExternalServiceEditionCode = Convert.ToInt32(resource.ResourceReferences.First(r => r.ReferenceType.Equals(ReferenceType.ServiceEditionCode)).Reference);
service.ExternalServiceCode = resource.ResourceReferences.First(r => r.ReferenceType.Equals(ResourceReferenceType.ServiceCode)).Reference;
service.ExternalServiceEditionCode = Convert.ToInt32(resource.ResourceReferences.First(r => r.ReferenceType.Equals(ResourceReferenceType.ServiceEditionCode)).Reference);
service.ServiceOwnerCode = resource.HasCompetentAuthority.Orgcode;
unfiltered.Add(service);
}
Expand Down Expand Up @@ -551,7 +551,7 @@ private ValidationProblemDetails ValidateResource(ServiceResource resource)

if (resource.ResourceType == ResourceType.MaskinportenSchema)
{
if (resource.ResourceReferences == null || !resource.ResourceReferences.Any((x) => x.ReferenceType == ReferenceType.MaskinportenScope))
if (resource.ResourceReferences == null || !resource.ResourceReferences.Any((x) => x.ReferenceType == ResourceReferenceType.MaskinportenScope))
{
ModelState.AddModelError($"{resource.Identifier}.resourceReferences", "resourceerror.missingmaskinportenscope");
}
Expand Down
1 change: 1 addition & 0 deletions backend/src/Designer/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class UserController : ControllerBase
/// </summary>
/// <param name="giteaWrapper">the gitea wrapper</param>
/// <param name="antiforgery">Access to the antiforgery system in .NET Core</param>
/// <param name="userService">User service</param>
public UserController(IGitea giteaWrapper, IAntiforgery antiforgery, IUserService userService)
{
_giteaApi = giteaWrapper;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Designer/Designer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<Watch Remove="Configuration\ResourceRegistryMaskinportenIntegrationSettings.cs" />
<Watch Remove="Controllers\PolicyController.cs" />
<Watch Remove="Configuration\MaskinportenClientSettings.cs" />
<Watch Remove="Controllers\CompetentAuthority.cs" />
<Watch Remove="Controllers\ResourceAdmController.cs" />
<Watch Remove="Controllers\ResourceAdminController.cs" />
<Watch Remove="Enums\ReferenceSource.cs" />
Expand All @@ -95,6 +94,7 @@
<Watch Remove="Models\AccessListMember.cs" />
<Watch Remove="Models\AvailableService.cs" />
<Watch Remove="Models\BrregPartyResultSet.cs" />
<Watch Remove="Models\CompetentAuthority.cs" />
<Watch Remove="Models\ConceptSchema.cs" />
<Watch Remove="Models\ContactPoint.cs" />
<Watch Remove="Models\CreateAccessListModel.cs" />
Expand Down
28 changes: 3 additions & 25 deletions backend/src/Designer/Enums/ReferenceType.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
using System.Runtime.Serialization;

namespace Altinn.Studio.Designer.Enums
{
/// <summary>
/// Enum for reference types of resources in the resource registry
/// </summary>
public enum ReferenceType
{
[EnumMember(Value = "Default")]
Default = 0,

[EnumMember(Value = "Uri")]
Uri = 1,

[EnumMember(Value = "DelegationSchemeId")]
DelegationSchemeId = 2,

[EnumMember(Value = "MaskinportenScope")]
MaskinportenScope = 3,

[EnumMember(Value = "ServiceCode")]
ServiceCode = 4,

[EnumMember(Value = "ServiceEditionCode")]
ServiceEditionCode = 5,

[EnumMember(Value = "ApplicationId")]
ApplicationId = 6,
LayoutSet,
Layout,
Component
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Altinn.Studio.Designer.Enums
/// <summary>
/// Enum for the different reference sources for resources in the resource registry
/// </summary>
public enum ReferenceSource
public enum ResourceReferenceSource
{
[EnumMember(Value = "Default")]
Default = 0,
Expand Down
Loading

0 comments on commit e5c0bd8

Please sign in to comment.