-
Notifications
You must be signed in to change notification settings - Fork 73
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
base: main
Are you sure you want to change the base?
Changes from all commits
f3c047d
c1e2922
dd249f7
ab6681a
1920a7b
8cbebb7
7f950cb
4279b30
f058f90
4e204a4
bda8b14
c85740d
160d666
dcaeb94
53663af
1739b58
f837897
55c8500
6f54dd2
c5a6487
73e2f93
fd717a6
3d2a84f
f91bdbd
8ba38b1
1dc9ccd
6244138
2457156
b15a35d
7bea3bd
55806b2
d360473
9c6dbb9
7ca7686
1cfca57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -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; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -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 GitHub Actions / Run dotnet build and test (ubuntu-latest)
Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Run dotnet build and test (ubuntu-latest)
Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Run integration tests against actual gitea and db
Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Run dotnet build and test (macos-latest)
Check failure on line 25 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Analyze
|
||||||||||||||||||||||||||
Comment on lines
21
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix constructor parameter and initialization. The constructor is missing the 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
Suggested change
🧰 Tools🪛 GitHub Check: Run dotnet build and test (macos-latest)[failure] 25-25: 🪛 GitHub Check: Analyze[failure] 25-25: [failure] 25-25: 🪛 GitHub Check: Run integration tests against actual gitea and db[failure] 25-25: 🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)[failure] 25-25: [failure] 25-25: 🪛 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) | ||||||||||||||||||||||||||
|
@@ -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 GitHub Actions / Run dotnet build and test (ubuntu-latest)
Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Run integration tests against actual gitea and db
Check failure on line 53 in backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs GitHub Actions / Run dotnet build and test (macos-latest)
|
||||||||||||||||||||||||||
hasChanges |= await _appDevelopmentService.UpdateLayoutReferences(notification.EditingContext, referencesToUpdate, cancellationToken); | ||||||||||||||||||||||||||
Comment on lines
+53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix Reference constructor argument type. The first argument to the 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
Suggested change
🧰 Tools🪛 GitHub Check: Run dotnet build and test (macos-latest)[failure] 53-53: 🪛 GitHub Check: Analyze[failure] 53-53: 🪛 GitHub Check: Run integration tests against actual gitea and db[failure] 53-53: 🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)[failure] 53-53: 🪛 GitHub Actions: Playwright tests on pr[error] 53-53: Argument 1: cannot convert from 'string' to 'Altinn.Studio.Designer.Enums.ReferenceType' |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return hasChanges; | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
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; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix namespace to match file location. The namespace -namespace Altinn.Studio.Designer.EventHandlers.LayoutPageDeleted;
+namespace Altinn.Studio.Designer.EventHandlers.LayoutPageIdChanged; 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
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 GitHub Actions / Run dotnet build and test (ubuntu-latest)
Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs GitHub Actions / Run integration tests against actual gitea and db
Check failure on line 22 in backend/src/Designer/EventHandlers/LayoutPageIdChanged/LayoutPageIdChangedLayoutsHandler.cs GitHub Actions / Run dotnet build and test (macos-latest)
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix type conversion error causing build failures. The first argument "page" cannot be converted to - 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
Suggested change
🧰 Tools🪛 GitHub Check: Run dotnet build and test (macos-latest)[failure] 22-22: 🪛 GitHub Check: Analyze[failure] 22-22: 🪛 GitHub Check: Run integration tests against actual gitea and db[failure] 22-22: 🪛 GitHub Check: Run dotnet build and test (ubuntu-latest)[failure] 22-22: 🪛 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); | ||||||
}); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing enum members
Task
andPage
toReferenceType
To resolve the compilation errors and properly handle all reference types, add
Task
andPage
to theReferenceType
enum.Apply this diff to update the enum:
📝 Committable suggestion