Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into org-library-mvp
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/Designer/Controllers/PreviewController.cs
#	backend/src/Designer/Infrastructure/ServiceRegistration.cs
  • Loading branch information
TomasEng committed Mar 4, 2025
2 parents 0838f1c + b9e599d commit fe7ba74
Show file tree
Hide file tree
Showing 112 changed files with 1,746 additions and 364 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/deploy-gitea-runner-brg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Deploy Gitea Runner for brg organization
on:
push:
branches: [ main ]
paths:
- '.github/workflows/deploy-gitea-runner-brg.yaml'
- '.github/workflows/template-docker-push.yaml'
- '.github/workflows/template-flux-config-push.yaml'
- '.github/workflows/template-helm-push.yaml'
- '.github/workflows/template-short-sha.yaml'
- 'charts/gitea-runner-brg/**'
- 'charts/gitea-runner-brg-config/**'

workflow_dispatch:
inputs:
environments:
description: 'Environments to deploy to. Multiple environments can be specified by separating them with a comma.'
required: false
default: 'dev'

permissions:
id-token: write
contents: read

jobs:
get-short-sha:
uses: ./.github/workflows/template-short-sha.yaml

construct-environments-array:
uses: ./.github/workflows/template-construct-environments.yaml
with:
environments: ${{ github.event.inputs.environments || 'dev,staging,prod' }}

determine-tag:
needs: get-short-sha
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.determine-tag.outputs.tag }}
steps:
- name: Determine tag
id: determine-tag
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "tag=${{ needs.get-short-sha.outputs.short-sha }}" >> $GITHUB_OUTPUT
else
sanitized_branch_name=$(echo "${{ github.ref_name }}" | tr -d '()' | tr '/' '-')
echo "tag=${sanitized_branch_name}-${{ needs.get-short-sha.outputs.short-sha }}" >> $GITHUB_OUTPUT
fi
helm-push:
needs: [get-short-sha, determine-tag]
uses: ./.github/workflows/template-helm-push.yaml
with:
tag: 0.1.0+${{ needs.determine-tag.outputs.tag }} # Helm version needs to be valid sematic version
chart-name: gitea-runner-brg
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: dev # dev environment has push access and doesn't require review
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}

flux-config-push:
needs: [get-short-sha, helm-push, determine-tag, construct-environments-array]
strategy:
matrix:
environment: ${{ fromJSON(needs.construct-environments-array.outputs.environmentsjson) }}
uses: ./.github/workflows/template-flux-config-push.yaml
with:
tag: ${{ needs.determine-tag.outputs.tag }}
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: ${{ matrix.environment }}
config-chart-name: gitea-runner-brg-config
artifact-name: gitea-runner-brg
helm-set-arguments: chartVersion=0.1.0+${{ needs.determine-tag.outputs.tag }}
trace-workflow: true
trace-team-name: 'team-studio'
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
trace-connection-string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
trace-repo-token: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/template-flux-config-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
--password-stdin
- name: Setup Flux CLI
uses: fluxcd/flux2/action@v2.4.0
uses: fluxcd/flux2/action@v2.5.0

- name: Generate cofiguration file
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-helm-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
subscription-id: ${{ secrets.subscription-id }}

- name: 'Install helm'
uses: azure/setup-helm@v4.2.0
uses: azure/setup-helm@v4.3.0
with:
version: '3.15.3'
id: install
Expand Down
22 changes: 11 additions & 11 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.5" />
<PackageReference Update="Altinn.Common.AccessTokenClient" Version="3.0.12" />
<PackageReference Update="Altinn.Common.AccessToken" Version="5.0.2" />
<PackageReference Update="Altinn.Common.AccessTokenClient" Version="3.0.13" />
<PackageReference Update="Altinn.Platform.Storage.Interface" Version="3.34.0" />
</ItemGroup>

Expand All @@ -16,7 +16,7 @@
<PackageReference Update="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Update="JWTCookieAuthentication" Version="4.0.4" />
<PackageReference Update="LibGit2Sharp" Version="0.31.0" />
<PackageReference Update="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Update="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
<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" />
Expand All @@ -30,7 +30,7 @@
<PackageReference Update="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="9.0.2" />
<PackageReference Update="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Update="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.74" />
<PackageReference Update="Microsoft.DiaSymReader.Native" Version="1.7.0" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2" />
Expand All @@ -44,9 +44,9 @@
<PackageReference Update="NuGet.Versioning" Version="6.13.1" />
<PackageReference Update="DistributedLock.Postgres" Version="1.3.0" />
<PackageReference Include="System.Text.Json" Version="[9.0.2]" />
<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="Microsoft.CodeAnalysis.Common" Version="[4.8.0, 4.13.0)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="[4.13.0]" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="[4.13.0]" />
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="[4.7.0]" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.2" />
<PackageReference Include="System.Net.Http" Version="[4.3.4]" />
Expand All @@ -69,14 +69,14 @@
<PackageReference Update="Basic.Reference.Assemblies" Version="1.7.8" />
<PackageReference Update="Fare" Version="2.2.1" />
<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="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Common" Version="4.13.0" />
<PackageReference Update="Microsoft.Extensions.TimeProvider.Testing" Version="9.2.0" />
<PackageReference Update="Testcontainers" Version="4.2.0" />
<PackageReference Update="Testcontainers" Version="4.3.0" />
<PackageReference Update="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageReference Update="Microsoft.AspNetCore.SignalR.Client" Version="9.0.2" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="9.0.2" />
<PackageReference Update="WireMock.Net" Version="1.7.2" />
<PackageReference Update="WireMock.Net" Version="1.7.4" />
<PackageReference Update="DistributedLock.FileSystem" Version="1.0.3" />
<PackageReference Update="System.Linq.Dynamic.Core" Version="1.6.0.2" />
</ItemGroup>
Expand Down
127 changes: 127 additions & 0 deletions backend/src/Designer/Controllers/LayoutController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System.Threading.Tasks;
using Altinn.Studio.Designer.Helpers;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Models.Dto;
using Altinn.Studio.Designer.Services.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;

namespace Altinn.Studio.Designer.Controllers
{
[ApiController]
[Authorize]
[AutoValidateAntiforgeryToken]
[Route("designer/api/{org}/{app}/layouts/layoutSet/{layoutSetId}/")]
public class LayoutController(ILayoutService layoutService) : Controller
{
[EndpointSummary("Retrieve pages")]
[ProducesResponseType<Pages>(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpGet("pages")]
public async Task<ActionResult<Pages>> GetPages(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Pages pages = await layoutService.GetPagesByLayoutSetId(editingContext, layoutSetId);
return Ok(pages);
}

[EndpointSummary("Create page")]
[ProducesResponseType<Pages>(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[HttpPost("pages")]
public async Task<ActionResult<Page>> CreatePage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromBody] Page page
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);

Page existingPage = await layoutService.GetPageById(editingContext, layoutSetId, page.id);
if (existingPage != null)
{
return Conflict();
}
await layoutService.CreatePage(editingContext, layoutSetId, page.id);
return Created();
}

[EndpointSummary("Retrieve page")]
[ProducesResponseType<Page>(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpGet("pages/{pageId}")]
[ProducesResponseType<Page>(StatusCodes.Status200OK)]
public async Task<ActionResult<Page>> GetPage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Page page = await layoutService.GetPageById(editingContext, layoutSetId, pageId);
if (page == null)
{
return NotFound();
}
return Ok(page);
}

[EndpointSummary("Modify page")]
[ProducesResponseType<Page>(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpPut("pages/{pageId}")]
public async Task<ActionResult<Page>> ModifyPage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId,
[FromBody] Page page
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Page existingPage = await layoutService.GetPageById(editingContext, layoutSetId, pageId);
if (existingPage == null)
{
return NotFound();
}

await layoutService.UpdatePage(editingContext, layoutSetId, pageId, page);
return Ok();
}

[EndpointSummary("Delete page")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpDelete("pages/{pageId}")]
public async Task<ActionResult> DeletePage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Page page = await layoutService.GetPageById(editingContext, layoutSetId, pageId);
if (page == null)
{
return NotFound();
}

await layoutService.DeletePage(editingContext, layoutSetId, pageId);
return Ok();
}
}
}
42 changes: 2 additions & 40 deletions backend/src/Designer/Controllers/PreviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Altinn.Platform.Storage.Interface.Models;
using Altinn.Studio.Designer.Filters;
using Altinn.Studio.Designer.Helpers;
using Altinn.Studio.Designer.Helpers.Preview;
using Altinn.Studio.Designer.Infrastructure.GitRepository;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Models.App;
Expand Down Expand Up @@ -61,8 +62,6 @@ public class PreviewController(IHttpContextAccessor httpContextAccessor,

// This value will be overridden to act as the task number for apps that use layout sets
private const int PartyId = 51001;
private const string MINIMUM_NUGET_VERSION = "8.0.0.0";
private const int MINIMUM_PREVIEW_NUGET_VERSION = 15;
private const string OptionsFolderPath = "App/options/";

/// <summary>
Expand Down Expand Up @@ -143,7 +142,7 @@ public async Task<ActionResult<ApplicationMetadata>> ApplicationMetadata(string
ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken);
string appNugetVersionString = _appDevelopmentService.GetAppLibVersion(AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer)).ToString();
// This property is populated at runtime by the apps, so we need to mock it here
applicationMetadata.AltinnNugetVersion = GetMockedAltinnNugetBuildFromVersion(appNugetVersionString);
applicationMetadata.AltinnNugetVersion = NugetVersionHelper.GetMockedAltinnNugetBuildFromVersion(appNugetVersionString);
applicationMetadata = SetMockedPartyTypesAllowedAsAllFalse(applicationMetadata);
return Ok(applicationMetadata);
}
Expand Down Expand Up @@ -696,29 +695,6 @@ private static string ReplaceIndexToFetchCorrectOrgAppInCshtml(string originalCo
return modifiedContent;
}

/// <summary>
/// Method to get the mocked altinn nuget build from the version
/// We are returnning the minimum BUILD version of the nuget package that is required for app frontend to work
/// from v4 and above.
/// </summary>
/// <param name="version">The version of the nuget package</param>
/// <returns>The minimum build version of the nuget package</returns>
private string GetMockedAltinnNugetBuildFromVersion(string version)
{

string[] versionParts = version.Split('.');
if (!IsValidSemVerVersion(versionParts))
{
return string.Empty;
}

if (IsPreviewVersion(versionParts) && GetPreviewVersion(versionParts) < MINIMUM_PREVIEW_NUGET_VERSION)
{
return string.Empty;
}

return MINIMUM_NUGET_VERSION;
}

/// <summary>
/// Method to override the partyTypesAllowed in app metadata to bypass the check in app-frontend for a valid party during instantiation.
Expand All @@ -734,19 +710,5 @@ private static ApplicationMetadata SetMockedPartyTypesAllowedAsAllFalse(Applicat
return applicationMetadata;
}

private bool IsValidSemVerVersion(string[] versionParts)
{
return versionParts.Length >= 3 && Convert.ToInt32(versionParts[0]) >= 8;
}

private bool IsPreviewVersion(string[] versionParts)
{
return versionParts[2].Contains("-preview") && versionParts.Length == 4;
}

private int GetPreviewVersion(string[] versionParts)
{
return Convert.ToInt32(versionParts[3]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ await _fileSyncHandlerExecutor.ExecuteWithExceptionHandlingAndConditionalNotific
{
bool hasChanges = false;
string[] layoutNames = repository.GetLayoutNames(notification.LayoutSetName);
foreach (var layoutName in layoutNames)
foreach (var layoutFileName in layoutNames)
{

string layoutName = layoutFileName.Replace(".json", "");
var layout = await repository.GetLayout(notification.LayoutSetName, layoutName, cancellationToken);
if (TryChangeComponentId(layout, notification.OldComponentId, notification.NewComponentId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ await _fileSyncHandlerExecutor.ExecuteWithExceptionHandlingAndConditionalNotific
TextResource jsonTexts = await repository.GetTextV1("nb");
int initialCount = jsonTexts.Resources.Count;
AddTextResourceIfNotExists(jsonTexts.Resources, "next", "Neste");
AddTextResourceIfNotExists(jsonTexts.Resources, "back", "Tilbake");
AddTextResourceIfNotExists(jsonTexts.Resources, "back", "Forrige");

if (jsonTexts.Resources.Count != initialCount)
{
Expand Down
Loading

0 comments on commit fe7ba74

Please sign in to comment.