Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 11809-fix-size-for-…
Browse files Browse the repository at this point in the history
…text-and-icon-in-binding-datamodell
  • Loading branch information
JamalAlabdullah committed Dec 8, 2023
2 parents c3dde45 + 646a5bc commit 4bc2812
Show file tree
Hide file tree
Showing 75 changed files with 215 additions and 1,108 deletions.
5 changes: 3 additions & 2 deletions backend/src/Designer/Controllers/ProcessModelingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Controllers
{
Expand Down Expand Up @@ -56,14 +57,14 @@ public async Task<IActionResult> SaveProcessDefinition(string org, string repo,
}

[HttpGet("templates/{appVersion}")]
public IEnumerable<string> GetTemplates(string org, string repo, Version appVersion)
public IEnumerable<string> GetTemplates(string org, string repo, SemanticVersion appVersion)
{
Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
return _processModelingService.GetProcessDefinitionTemplates(appVersion);
}

[HttpPut("templates/{appVersion}/{templateName}")]
public async Task<FileStreamResult> SaveProcessDefinitionFromTemplate(string org, string repo, Version appVersion, string templateName, CancellationToken cancellationToken)
public async Task<FileStreamResult> SaveProcessDefinitionFromTemplate(string org, string repo, SemanticVersion appVersion, string templateName, CancellationToken cancellationToken)
{
Guard.AssertArgumentNotNull(appVersion, nameof(appVersion));
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
Expand Down
6 changes: 3 additions & 3 deletions backend/src/Designer/Helpers/PackageVersionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Helpers
{
public static class PackageVersionHelper
{
public static bool TryGetPackageVersionFromCsprojFile(string csprojFilePath, string packageName, out System.Version version)
public static bool TryGetPackageVersionFromCsprojFile(string csprojFilePath, string packageName, out SemanticVersion version)
{
version = null;
var doc = XDocument.Load(csprojFilePath);
Expand All @@ -26,8 +27,7 @@ public static bool TryGetPackageVersionFromCsprojFile(string csprojFilePath, str
return false;
}

version = System.Version.Parse(versionString);
return true;
return SemanticVersion.TryParse(versionString, out version);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using Microsoft.AspNetCore.Http;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Services.Implementation
{
Expand Down Expand Up @@ -218,15 +219,15 @@ public async Task SaveRuleConfig(AltinnRepoEditingContext altinnRepoEditingConte
}

/// <inheritdoc />
public Version GetAppLibVersion(AltinnRepoEditingContext altinnRepoEditingContext)
public SemanticVersion GetAppLibVersion(AltinnRepoEditingContext altinnRepoEditingContext)
{
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer);

var csprojFiles = altinnAppGitRepository.FindFiles(new[] { "*.csproj" });

foreach (string csprojFile in csprojFiles)
{
if (PackageVersionHelper.TryGetPackageVersionFromCsprojFile(csprojFile, "Altinn.App.Api", out Version version))
if (PackageVersionHelper.TryGetPackageVersionFromCsprojFile(csprojFile, "Altinn.App.Api", out SemanticVersion version))
{
return version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -10,6 +10,7 @@
using Altinn.Studio.Designer.Infrastructure.GitRepository;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Services.Implementation.ProcessModeling
{
Expand All @@ -21,18 +22,18 @@ public ProcessModelingService(IAltinnGitRepositoryFactory altinnGitRepositoryFac
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
}

private string TemplatesFolderIdentifier(Version version) => string.Join(".", nameof(Services), nameof(Implementation), nameof(ProcessModeling), "Templates", $"v{version.Major}");
private string TemplatesFolderIdentifier(SemanticVersion version) => string.Join(".", nameof(Services), nameof(Implementation), nameof(ProcessModeling), "Templates", $"v{version.Major}");

/// <inheritdoc/>
public IEnumerable<string> GetProcessDefinitionTemplates(Version version)
public IEnumerable<string> GetProcessDefinitionTemplates(SemanticVersion version)
{
return EnumerateTemplateResources(version)
.Select(
templateName => templateName.Split(TemplatesFolderIdentifier(version)).Last().TrimStart('.'))!;
}

/// <inheritdoc/>
public async Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, Version version, CancellationToken cancellationToken = default)
public async Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, SemanticVersion version, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer);
Expand Down Expand Up @@ -86,13 +87,13 @@ public async Task<Stream> UpdateProcessTaskNameAsync(AltinnRepoEditingContext al
return processStream;
}

private IEnumerable<string> EnumerateTemplateResources(Version version)
private IEnumerable<string> EnumerateTemplateResources(SemanticVersion version)
{
return typeof(ProcessModelingService).Assembly.GetManifestResourceNames()
.Where(resourceName => resourceName.Contains(TemplatesFolderIdentifier(version)));
}

private Stream GetTemplateStream(Version version, string templateName)
private Stream GetTemplateStream(SemanticVersion version, string templateName)
{
var templates = EnumerateTemplateResources(version).ToList();
if (!templates.Exists(template => template.EndsWith(templateName)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public interface IAppDevelopmentService
/// </summary>
/// <param name="altinnRepoEditingContext">An <see cref="AltinnRepoEditingContext"/>.</param>
/// <returns>A <see cref="System.Version"/> holding the version of the app-lib used in app.</returns>
public System.Version GetAppLibVersion(AltinnRepoEditingContext altinnRepoEditingContext);
public NuGet.Versioning.SemanticVersion GetAppLibVersion(AltinnRepoEditingContext altinnRepoEditingContext);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Models;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.Services.Interfaces
{
Expand All @@ -14,7 +14,7 @@ public interface IProcessModelingService
/// </summary>
/// <param name="version">Version of the app-lib</param>
/// <returns>An IEnumerable containing supported templates for given version.</returns>
IEnumerable<string> GetProcessDefinitionTemplates(Version version);
IEnumerable<string> GetProcessDefinitionTemplates(SemanticVersion version);

/// <summary>
/// Saves the process definition file for a given app from a template.
Expand All @@ -23,7 +23,7 @@ public interface IProcessModelingService
/// <param name="templateName">Name of the template.</param>
/// <param name="version">Version of the app-lib.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that observes if operation is cancelled.</param>
Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, Version version, CancellationToken cancellationToken = default);
Task SaveProcessDefinitionFromTemplateAsync(AltinnRepoEditingContext altinnRepoEditingContext, string templateName, SemanticVersion version, CancellationToken cancellationToken = default);

/// <summary>
/// Saves the process definition file for a given app.
Expand Down
3 changes: 2 additions & 1 deletion backend/src/Designer/ViewModels/Response/VersionResponse.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using NuGet.Versioning;

namespace Altinn.Studio.Designer.ViewModels.Response
{
public class VersionResponse
{
public Version Version { get; set; }
public SemanticVersion Version { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public GetVersionOfTheAppLibTests(WebApplicationFactory<Program> factory) : base

[Theory]
[InlineData("ttd", "empty-app", "testUser", "7.4.0", "Templates/AppCsprojTemplate.txt")]
[InlineData("ttd", "empty-app", "testUser", "8.0.0-preview.11", "Templates/AppCsprojTemplate.txt")]
public async Task GetAppLibVersion_GivenCsProjFile_ShouldReturnOK(string org, string app, string developer, string version, string csprojTemplate)
{
string targetRepository = TestDataHelper.GenerateTestRepoName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public GetTemplatesTests(WebApplicationFactory<Program> factory) : base(factory)

[Theory]
[InlineData("ttd", "empty-app", "8.0.0", "start-data-confirmation-end.bpmn", "start-data-confirmation-feedback-end.bpmn", "start-data-end.bpmn", "start-data-signing-end.bpmn")]
[InlineData("ttd", "empty-app", "8.0.0-preview.11", "start-data-confirmation-end.bpmn", "start-data-confirmation-feedback-end.bpmn", "start-data-end.bpmn", "start-data-signing-end.bpmn")]
[InlineData("ttd", "empty-app", "7.4.0", "start-data-confirmation-end.bpmn", "start-data-data-data-end.bpmn", "start-data-end.bpmn")]
[InlineData("ttd", "empty-app", "6.1.0")]
public async Task GetTemplates_ShouldReturnOK(string org, string app, string version, params string[] expectedTemplates)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public async Task SaveProcessDefinitionFromTemplate_WrongTemplate_ShouldReturn40

[Theory]
[InlineData("ttd", "empty-app", "testUser", "8.0.0", "start-data-confirmation-end.bpmn")]
[InlineData("ttd", "empty-app", "testUser", "8.0.0-preview.11", "start-data-confirmation-end.bpmn")]
public async Task SaveProcessDefinitionFromTemplate_ShouldReturnOk_AndSaveTemplate(string org, string app, string developer, string version, string templateName)
{
string targetRepository = TestDataHelper.GenerateTestRepoName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void TryGetPackageVersionFromCsprojFile_GivenValidCsprojFile_ReturnsTrue(
{
string testTemplateCsProjPath = Path.Combine(CommonDirectoryPath.GetSolutionDirectory().DirectoryPath, "..", "testdata", "AppTemplates", "AspNet", "App", "App.csproj");

bool result = PackageVersionHelper.TryGetPackageVersionFromCsprojFile(testTemplateCsProjPath, packageName, out Version version);
bool result = PackageVersionHelper.TryGetPackageVersionFromCsprojFile(testTemplateCsProjPath, packageName, out var version);

result.Should().Be(expectedResult);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Designer.Tests.Utils;
using FluentAssertions;
using Moq;
using NuGet.Versioning;
using SharedResources.Tests;
using Xunit;

Expand All @@ -22,7 +23,7 @@ public class ProcessModelingServiceTests : FluentTestsBase<ProcessModelingServic
[MemberData(nameof(TemplatesTestData))]
public void GetProcessDefinitionTemplates_GivenVersion_ReturnsListOfTemplates(string versionString, params string[] expectedTemplates)
{
Version version = Version.Parse(versionString);
SemanticVersion version = SemanticVersion.Parse(versionString);

IProcessModelingService processModelingService = new ProcessModelingService(new Mock<IAltinnGitRepositoryFactory>().Object);

Expand Down
2 changes: 1 addition & 1 deletion frontend/app-development/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useRef } from 'react';
import postMessages from 'app-shared/utils/postMessages';
import { AltinnPopoverSimple } from 'app-shared/components/molecules/AltinnPopoverSimple';
import { HandleServiceInformationActions } from './features/administration/handleServiceInformationSlice';
import { HandleServiceInformationActions } from './features/overview/handleServiceInformationSlice';
import {
fetchRemainingSession,
keepAliveSession,
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4bc2812

Please sign in to comment.