Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update all Summary 2.0 components that has a reference to an updated component id #14372

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f3c047d
Delete all Summary 2.0 components that has a reference to deleted com…
mlqn Nov 21, 2024
c1e2922
dotnet format
mlqn Nov 27, 2024
dd249f7
Fix SaveFormLayout
mlqn Nov 27, 2024
ab6681a
Merge remote-tracking branch 'origin/main' into 13525-automatically-d…
mlqn Nov 28, 2024
1920a7b
Add backend tests
mlqn Nov 29, 2024
8cbebb7
Cleanup
mlqn Nov 29, 2024
7f950cb
Refactoring
mlqn Dec 4, 2024
4279b30
Cleanup
mlqn Dec 5, 2024
f058f90
Fix tests
mlqn Dec 6, 2024
4e204a4
Fix tests
mlqn Dec 6, 2024
bda8b14
Fix SaveFormLayout
mlqn Dec 6, 2024
c85740d
Cleanup overrides
mlqn Dec 15, 2024
160d666
Merge remote-tracking branch 'origin/main' into 13525-automatically-d…
mlqn Dec 16, 2024
dcaeb94
Recursive deletion
mlqn Dec 16, 2024
53663af
Fix warnings
mlqn Dec 18, 2024
1739b58
Clean up code
mlqn Dec 19, 2024
f837897
Update Summary2 and Subform when updating component id
mlqn Dec 20, 2024
55c8500
Cleanup code
mlqn Jan 6, 2025
6f54dd2
Merge remote-tracking branch 'origin/main' into 13525-automatically-d…
mlqn Jan 6, 2025
c5a6487
Fix code
mlqn Jan 6, 2025
73e2f93
Cleanup
mlqn Jan 6, 2025
fd717a6
Add tests
mlqn Jan 7, 2025
3d2a84f
Cleanup
mlqn Jan 7, 2025
f91bdbd
Remove update changes
mlqn Jan 7, 2025
8ba38b1
Revert "Remove update changes"
mlqn Jan 7, 2025
1dc9ccd
Fix revert
mlqn Jan 7, 2025
6244138
Add frontend warnings
mlqn Jan 7, 2025
2457156
Merge remote-tracking branch 'origin/13525-automatically-delete-all-s…
mlqn Jan 7, 2025
b15a35d
Fix error
mlqn Jan 7, 2025
7bea3bd
Fixes after CR
mlqn Jan 16, 2025
55806b2
Merge branch 'main' into 13525-automatically-delete-all-summary-20-co…
mlqn Jan 16, 2025
d360473
Merge branch 'main' into 13525-automatically-delete-all-summary-20-co…
mlqn Jan 16, 2025
9c6dbb9
Fix name conflicts
mlqn Jan 16, 2025
7ca7686
Fix coderabbit warnings
mlqn Jan 16, 2025
1cfca57
Merge remote-tracking branch 'origin/13525-automatically-delete-all-s…
mlqn Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 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 Down Expand Up @@ -123,8 +124,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 +169,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 All @@ -185,16 +205,24 @@ public ActionResult DeleteFormLayout(string org, string app, [FromQuery] string
/// <param name="app">Application identifier which is unique within an organisation.</param>
/// <param name="layoutSetName">Name of the layout set the specific layout belongs to</param>
/// <param name="layoutName">The current name of the form layout</param>
/// <param name="cancellationToken">An <see cref="CancellationToken"/> that observes if operation is cancelled.</param>
/// <returns>A success message if the save was successful</returns>
[HttpPost]
[Route("form-layout-name/{layoutName}")]
public ActionResult UpdateFormLayoutName(string org, string app, [FromQuery] string layoutSetName, [FromRoute] string layoutName, [FromBody] string newName)
public async Task<ActionResult> UpdateFormLayoutName(string org, string app, [FromQuery] string layoutSetName, [FromRoute] string layoutName, [FromBody] string newName, CancellationToken cancellationToken)
{
try
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
_appDevelopmentService.UpdateFormLayoutName(editingContext, layoutSetName, layoutName, newName);
await _mediator.Publish(new LayoutPageIdChangedEvent
{
EditingContext = editingContext,
LayoutSetName = layoutSetName,
LayoutName = layoutName,
NewLayoutName = newName,
}, cancellationToken);
return Ok();
}
catch (FileNotFoundException exception)
Expand Down Expand Up @@ -385,6 +413,12 @@ public async Task<ActionResult> UpdateLayoutSetName(string org, string app, [Fro
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
LayoutSets layoutSets = await _appDevelopmentService.UpdateLayoutSetName(editingContext, layoutSetIdToUpdate, newLayoutSetName, cancellationToken);
await _mediator.Publish(new LayoutSetIdChangedEvent
{
EditingContext = editingContext,
LayoutSetName = layoutSetIdToUpdate,
NewLayoutSetName = newLayoutSetName,
}, cancellationToken);
return Ok(layoutSets);
}

Expand All @@ -402,13 +436,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
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
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
}
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing enum members Task and Page to ReferenceType

To resolve the compilation errors and properly handle all reference types, add Task and Page to the ReferenceType enum.

Apply this diff to update the enum:

 public enum ReferenceType
 {
     LayoutSet,
     Layout,
     Component,
+    Task,
+    Page
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LayoutSet,
Layout,
Component
LayoutSet,
Layout,
Component,
Task,
Page

}
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
31 changes: 31 additions & 0 deletions backend/src/Designer/Enums/ResourceReferenceType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Runtime.Serialization;

namespace Altinn.Studio.Designer.Enums
{
/// <summary>
/// Enum for reference types of resources in the resource registry
/// </summary>
public enum ResourceReferenceType
{
[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,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using MediatR;

namespace Altinn.Studio.Designer.EventHandlers.ComponentDeleted;

public class ComponentDeletedLayoutsHandler(IFileSyncHandlerExecutor fileSyncHandlerExecutor, IAppDevelopmentService appDevelopmentService) : INotificationHandler<ComponentDeletedEvent>
{
public async Task Handle(ComponentDeletedEvent notification, CancellationToken cancellationToken)
{
await fileSyncHandlerExecutor.ExecuteWithExceptionHandlingAndConditionalNotification(
notification.EditingContext,
SyncErrorCodes.ComponentDeletedLayoutsSyncError,
"layouts",
async () =>
{
List<Reference> referencesToDelete = [new Reference(ReferenceType.Component, notification.LayoutSetName, notification.ComponentId)];
return await appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToDelete, cancellationToken);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using MediatR;

Expand All @@ -13,12 +15,14 @@
{
private readonly IAltinnGitRepositoryFactory _altinnGitRepositoryFactory;
private readonly IFileSyncHandlerExecutor _fileSyncHandlerExecutor;
private readonly IAppDevelopmentService _appDevelopmentService;

public ComponentIdChangedLayoutsHandler(IAltinnGitRepositoryFactory altinnGitRepositoryFactory,
IFileSyncHandlerExecutor fileSyncHandlerExecutor)
{
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
_fileSyncHandlerExecutor = fileSyncHandlerExecutor;
_appDevelopmentService = appDevelopmentService;

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

The name 'appDevelopmentService' does not exist in the current context

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

The name 'appDevelopmentService' does not exist in the current context

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run integration tests against actual gitea and db

The name 'appDevelopmentService' does not exist in the current context

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (macos-latest)

The name 'appDevelopmentService' does not exist in the current context

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze

The name 'appDevelopmentService' does not exist in the current context

Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze

The name 'appDevelopmentService' does not exist in the current context
Comment on lines 21 to +25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix constructor parameter and initialization.

The constructor is missing the appDevelopmentService parameter, which is required to initialize the private field.

Apply this diff to fix the constructor:

 public ComponentIdChangedLayoutsHandler(IAltinnGitRepositoryFactory altinnGitRepositoryFactory,
-    IFileSyncHandlerExecutor fileSyncHandlerExecutor)
+    IFileSyncHandlerExecutor fileSyncHandlerExecutor,
+    IAppDevelopmentService appDevelopmentService)
 {
     _altinnGitRepositoryFactory = altinnGitRepositoryFactory;
     _fileSyncHandlerExecutor = fileSyncHandlerExecutor;
-    _appDevelopmentService = appDevelopmentService;
+    _appDevelopmentService = appDevelopmentService ?? throw new ArgumentNullException(nameof(appDevelopmentService));
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
IFileSyncHandlerExecutor fileSyncHandlerExecutor)
{
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
_fileSyncHandlerExecutor = fileSyncHandlerExecutor;
_appDevelopmentService = appDevelopmentService;
public ComponentIdChangedLayoutsHandler(IAltinnGitRepositoryFactory altinnGitRepositoryFactory,
IFileSyncHandlerExecutor fileSyncHandlerExecutor,
IAppDevelopmentService appDevelopmentService)
{
_altinnGitRepositoryFactory = altinnGitRepositoryFactory;
_fileSyncHandlerExecutor = fileSyncHandlerExecutor;
_appDevelopmentService = appDevelopmentService ?? throw new ArgumentNullException(nameof(appDevelopmentService));
🧰 Tools
🪛 GitHub Check: Run dotnet build and test (macos-latest)

[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Check: Analyze

[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context


[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Check: Run integration tests against actual gitea and db

[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)

[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context


[failure] 25-25:
The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Actions: CodeQL

[error] 25-25: The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Actions: Playwright tests on pr

[error] 25-25: The name 'appDevelopmentService' does not exist in the current context

🪛 GitHub Actions: Build and Test on windows, linux and macos

[error] 25-25: The name 'appDevelopmentService' does not exist in the current context

}

public async Task Handle(ComponentIdChangedEvent notification, CancellationToken cancellationToken)
Expand All @@ -45,6 +49,10 @@
hasChanges = true;
}
}

List<Reference> referencesToUpdate = [new Reference("component", notification.LayoutSetName, notification.OldComponentId, notification.NewComponentId)];

Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run integration tests against actual gitea and db

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (macos-latest)

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'
hasChanges |= await _appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToUpdate, cancellationToken);
Comment on lines +53 to +54
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix Reference constructor argument type.

The first argument to the Reference constructor should be of type ReferenceType enum instead of a string literal.

Apply this diff to fix the argument type:

-List<Reference> referencesToUpdate = [new Reference("component", notification.LayoutSetName, notification.OldComponentId, notification.NewComponentId)];
+List<Reference> referencesToUpdate = [new Reference(ReferenceType.Component, notification.LayoutSetName, notification.OldComponentId, notification.NewComponentId)];

Make sure to add the following import:

+using Altinn.Studio.Designer.Enums;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
List<Reference> referencesToUpdate = [new Reference("component", notification.LayoutSetName, notification.OldComponentId, notification.NewComponentId)];
hasChanges |= await _appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToUpdate, cancellationToken);
using Altinn.Studio.Designer.Enums;
List<Reference> referencesToUpdate = [new Reference(ReferenceType.Component, notification.LayoutSetName, notification.OldComponentId, notification.NewComponentId)];
hasChanges |= await _appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToUpdate, cancellationToken);
🧰 Tools
🪛 GitHub Check: Run dotnet build and test (macos-latest)

[failure] 53-53:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Analyze

[failure] 53-53:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Run integration tests against actual gitea and db

[failure] 53-53:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)

[failure] 53-53:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Actions: Playwright tests on pr

[error] 53-53: Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'


return hasChanges;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Enums;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using MediatR;

namespace Altinn.Studio.Designer.EventHandlers.LayoutPageDeleted;

public class LayoutPageDeletedLayoutsHandler(IFileSyncHandlerExecutor fileSyncHandlerExecutor, IAppDevelopmentService appDevelopmentService) : INotificationHandler<LayoutPageDeletedEvent>
{
public async Task Handle(LayoutPageDeletedEvent notification, CancellationToken cancellationToken)
{
await fileSyncHandlerExecutor.ExecuteWithExceptionHandlingAndConditionalNotification(
notification.EditingContext,
SyncErrorCodes.LayoutPageDeletedLayoutsSyncError,
"layouts",
async () =>
{
List<Reference> referencesToDelete = [new Reference(ReferenceType.Layout, notification.LayoutSetName, notification.LayoutName)];
return await appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToDelete, cancellationToken);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Events;
using Altinn.Studio.Designer.Hubs.SyncHub;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using MediatR;

namespace Altinn.Studio.Designer.EventHandlers.LayoutPageDeleted;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix namespace to match file location.

The namespace LayoutPageDeleted doesn't match the file location LayoutPageIdChanged.

-namespace Altinn.Studio.Designer.EventHandlers.LayoutPageDeleted;
+namespace Altinn.Studio.Designer.EventHandlers.LayoutPageIdChanged;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
namespace Altinn.Studio.Designer.EventHandlers.LayoutPageDeleted;
namespace Altinn.Studio.Designer.EventHandlers.LayoutPageIdChanged;


public class LayoutPageIdChangedLayoutsHandler(IFileSyncHandlerExecutor fileSyncHandlerExecutor, IAppDevelopmentService appDevelopmentService) : INotificationHandler<LayoutPageIdChangedEvent>
{
public async Task Handle(LayoutPageIdChangedEvent notification, CancellationToken cancellationToken)
{
await fileSyncHandlerExecutor.ExecuteWithExceptionHandlingAndConditionalNotification(
notification.EditingContext,
SyncErrorCodes.LayoutPageIdChangedLayoutsSyncError,
"layouts",
async () =>
{
List<Reference> referencesToUpdate = [new Reference("page", notification.LayoutSetName, notification.LayoutName, notification.NewLayoutName)];

Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (ubuntu-latest)

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run integration tests against actual gitea and db

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Run dotnet build and test (macos-latest)

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs

View workflow job for this annotation

GitHub Actions / Analyze

Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix type conversion error causing build failures.

The first argument "page" cannot be converted to ReferenceType enum. This is causing build failures across multiple environments.

-                List<Reference> referencesToUpdate = [new Reference("page", notification.LayoutSetName, notification.LayoutName, notification.NewLayoutName)];
+                List<Reference> referencesToUpdate = [new Reference(ReferenceType.Page, notification.LayoutSetName, notification.LayoutName, notification.NewLayoutName)];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
List<Reference> referencesToUpdate = [new Reference("page", notification.LayoutSetName, notification.LayoutName, notification.NewLayoutName)];
List<Reference> referencesToUpdate = [new Reference(ReferenceType.Page, notification.LayoutSetName, notification.LayoutName, notification.NewLayoutName)];
🧰 Tools
🪛 GitHub Check: Run dotnet build and test (macos-latest)

[failure] 22-22:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Analyze

[failure] 22-22:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Run integration tests against actual gitea and db

[failure] 22-22:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)

[failure] 22-22:
Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

🪛 GitHub Actions: Playwright tests on pr

[error] 22-22: Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType'

return await appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToUpdate, cancellationToken);
});
}
}
Loading
Loading