Skip to content

Commit

Permalink
feat: remove order and islegacy flag (#704)
Browse files Browse the repository at this point in the history
Co-authored-by: Jossilainen <[email protected]>
  • Loading branch information
Jossilainen and Jossilainen authored Aug 19, 2024
1 parent 823013b commit 7c120c7
Show file tree
Hide file tree
Showing 24 changed files with 417 additions and 114 deletions.
9 changes: 9 additions & 0 deletions .changeset/pr-704-2022804484.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

---
"fusion-project-portal": patch
---
Order and IsLegacy is removed from Onboarded apps. Order is removed from Portal.


> [!IMPORTANT]
> This change requires database migration.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ namespace Equinor.ProjectExecutionPortal.Application.Commands.OnboardedApps.Onbo

public class OnboardAppCommand : IRequest<Guid>
{
public OnboardAppCommand(string appKey, bool isLegacy, IList<string>? contextTypes)
public OnboardAppCommand(string appKey, IList<string>? contextTypes)
{
AppKey = appKey;
IsLegacy = isLegacy;
ContextTypes = contextTypes;
}

public string AppKey { get; }
public bool IsLegacy { get; }
public IList<string>? ContextTypes { get; set; }

public class Handler : IRequestHandler<OnboardAppCommand, Guid>
Expand Down Expand Up @@ -50,7 +48,7 @@ public async Task<Guid> Handle(OnboardAppCommand command, CancellationToken canc
throw new InvalidActionException($"Onboarded app: {command.AppKey} is already onboarded");
}

var onboardedApp = new OnboardedApp(command.AppKey, 0, command.IsLegacy);
var onboardedApp = new OnboardedApp(command.AppKey);

try
{
Expand All @@ -61,7 +59,6 @@ public async Task<Guid> Handle(OnboardAppCommand command, CancellationToken canc
throw new InvalidOperationException(ex.Message);
}


_readWriteContext.Set<OnboardedApp>().Add(onboardedApp);

await _readWriteContext.SaveChangesAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ namespace Equinor.ProjectExecutionPortal.Application.Commands.OnboardedApps.Upda

public class UpdateOnboardedAppCommand : IRequest<Guid>
{
public UpdateOnboardedAppCommand(string appKey, bool isLegacy, IList<string>? contextTypes)
public UpdateOnboardedAppCommand(string appKey, IList<string>? contextTypes)
{
AppKey = appKey;
IsLegacy = isLegacy;
ContextTypes = contextTypes;
}

public string AppKey { get; }
public bool IsLegacy { get; }
public IList<string>? ContextTypes { get; set; }

public class Handler : IRequestHandler<UpdateOnboardedAppCommand, Guid>
Expand All @@ -42,8 +40,6 @@ public async Task<Guid> Handle(UpdateOnboardedAppCommand command, CancellationTo
throw new NotFoundException("App is not onboarded", command.AppKey);
}

entity.Update(command.IsLegacy);

try
{
entity.AddContextTypes(await _contextTypeService.GetContextTypesByContextTypeKey(command.ContextTypes, cancellationToken));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Equinor.ProjectExecutionPortal.Application.Helpers;
using Equinor.ProjectExecutionPortal.Application.Services.ContextTypeService;
using Equinor.ProjectExecutionPortal.Domain.Common.Exceptions;
using Equinor.ProjectExecutionPortal.Domain.Entities;
using Equinor.ProjectExecutionPortal.Infrastructure;
using MediatR;
Expand All @@ -9,13 +8,12 @@ namespace Equinor.ProjectExecutionPortal.Application.Commands.Portals.CreatePort

public class CreatePortalCommand : IRequest<Guid>
{
public CreatePortalCommand(string name, string shortName, string subText, string? description, int order, string icon, IList<string> contextTypes)
public CreatePortalCommand(string name, string shortName, string subText, string? description, string icon, IList<string> contextTypes)
{
Name = name;
ShortName = shortName;
SubText = subText;
Description = description;
Order = order;
Icon = icon;
ContextTypes = contextTypes;
}
Expand All @@ -24,7 +22,6 @@ public CreatePortalCommand(string name, string shortName, string subText, string
public string ShortName { get; set; }
public string SubText { get; set; }
public string? Description { get; set; }
public int Order { get; set; }
public string Icon { get; set; }
public IList<string> ContextTypes { get; set; }

Expand All @@ -43,7 +40,7 @@ public async Task<Guid> Handle(CreatePortalCommand command, CancellationToken ca
{
var slug = SlugHelper.Sluggify(command.Name);

var portal = new Portal(slug, command.Name, command.ShortName, command.SubText, command.Description, command.Order, command.Icon);
var portal = new Portal(slug, command.Name, command.ShortName, command.SubText, command.Description, command.Icon);

portal.AddContextTypes(await _contextTypeService.GetContextTypesByContextTypeKey(command.ContextTypes, cancellationToken));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ namespace Equinor.ProjectExecutionPortal.Application.Commands.Portals.UpdatePort

public class UpdatePortalCommand : IRequest<Guid>
{
public UpdatePortalCommand(Guid id, string name, string shortName, string subText, string? description, int order, string icon, IList<string>? contextTypes)
public UpdatePortalCommand(Guid id, string name, string shortName, string subText, string? description, string icon, IList<string>? contextTypes)
{
Id = id;
Name = name;
ShortName = shortName;
SubText = subText;
Description = description;
Order = order;
Icon = icon;
ContextTypes = contextTypes;
}
Expand All @@ -27,7 +26,6 @@ public UpdatePortalCommand(Guid id, string name, string shortName, string subTex
public string ShortName { get; }
public string SubText { get; }
public string? Description { get; set; }
public int Order { get; }
public string Icon { get; }
public IList<string>? ContextTypes { get; set; }

Expand Down Expand Up @@ -55,7 +53,7 @@ public async Task<Guid> Handle(UpdatePortalCommand command, CancellationToken ca

var slug = SlugHelper.Sluggify(command.Name);

entity.Update(slug, command.Name, command.ShortName, command.SubText, command.Description, command.Order, command.Icon);
entity.Update(slug, command.Name, command.ShortName, command.SubText, command.Description, command.Icon);

entity.AddContextTypes(await _contextTypeService.GetContextTypesByContextTypeKey(command.ContextTypes, cancellationToken));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class OnboardedAppDto : IMapFrom<Domain.Entities.OnboardedApp>
{
public Guid Id { get; set; }
public string AppKey { get; set; }
public int Order { get; set; }
public bool IsLegacy { get; set; }
public FusionPortalAppInformation? AppInformation { get; set; }
public IList<ContextTypeDto> ContextTypes { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public Handler(IReadWriteContext context, IMapper mapper)
public async Task<IList<PortalDto>> Handle(GetPortalsQuery request, CancellationToken cancellationToken)
{
var entities = await _context.Set<Domain.Entities.Portal>()
.OrderBy(x => x.Order)
.AsNoTracking()
.Include(x => x.ContextTypes)
.ToListAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ public class PortalDto : IMapFrom<Domain.Entities.Portal>
public string ShortName { get; set; }
public string SubText { get; set; }
public string? Description { get; set; }
public int Order { get; set; }
public string Icon { get; set; }
public IList<ContextTypeDto> ContextTypes { get; set; }
public IList<ContextTypeDto> ContextTypes { get; set; }
public List<PortalAppDto> Apps { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,24 @@ namespace Equinor.ProjectExecutionPortal.Domain.Entities;

/// <summary>
/// An onboarded app is an app that is ready for use for the project portal.
/// These apps can then be added to Work Surfaces
/// </summary>
public class OnboardedApp : AuditableEntityBase, ICreationAuditable, IModificationAuditable
{
public const int AppKeyLengthMax = 200;
private readonly List<ContextType> _contextTypes = new();

public OnboardedApp(string appKey, int order, bool isLegacy)
public OnboardedApp(string appKey)
{
AppKey = appKey;
Order = order;
IsLegacy = isLegacy;
}

/// <summary>
/// AppKey referes to the app's unique ID in the Fusion Portal
/// AppKey refers to the app's unique ID in the Fusion Portal
/// </summary>
public string AppKey { get; set; }

/// <summary>
/// For ordering apps, not used per now
/// </summary>
public int Order { get; set; }

/// <summary>
/// This flag is used for conditional rendering of legacy apps on the client application
/// </summary>
public bool IsLegacy { get; set; }


public IReadOnlyCollection<ContextType> ContextTypes => _contextTypes.AsReadOnly();

public void Update(bool isLegacy)
{
IsLegacy = isLegacy;
}

public void AddContextTypes(IList<ContextType> contextTypes)
{
_contextTypes.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public class Portal : AuditableEntityBase, ICreationAuditable, IModificationAudi
private readonly List<PortalApp> _apps = new();
private readonly List<ContextType> _contextTypes = new();

public Portal(string key, string name, string shortName, string subText, string? description, int order, string icon)
public Portal(string key, string name, string shortName, string subText, string? description, string icon)
{
Key = key;
Name = name;
ShortName = shortName;
SubText = subText;
Description = description;
Order = order;
Icon = icon;
}

Expand All @@ -33,20 +32,18 @@ public Portal(string key, string name, string shortName, string subText, string?
public string ShortName { get; set; }
public string SubText { get; set; }
public string? Description { get; set; }
public int Order { get; set; }
public string Icon { get; set; }

public IReadOnlyCollection<PortalApp> Apps => _apps.AsReadOnly();
public IReadOnlyCollection<ContextType> ContextTypes => _contextTypes.AsReadOnly();

public void Update(string key, string name, string shortName, string subText, string? description, int order, string icon)
public void Update(string key, string name, string shortName, string subText, string? description, string icon)
{
Key = key;
Name = name;
ShortName = shortName;
SubText = subText;
Description = description;
Order = order;
Icon = icon;
}

Expand Down
Loading

0 comments on commit 7c120c7

Please sign in to comment.