Skip to content

Commit

Permalink
Storage - Fix new profile creation
Browse files Browse the repository at this point in the history
UI - Fix a crash when dragging and dropping in the sidebar
  • Loading branch information
RobertBeekman committed Mar 15, 2024
1 parent 18d7531 commit 7e981a6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 34 deletions.
4 changes: 1 addition & 3 deletions src/Artemis.Core/Models/Profile/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ internal override void Save()
FolderEntity.Name = Name;
FolderEntity.IsExpanded = IsExpanded;
FolderEntity.Suspended = Suspended;

FolderEntity.ProfileId = Profile.EntityId;


SaveRenderElement();
}

Expand Down
1 change: 0 additions & 1 deletion src/Artemis.Core/Models/Profile/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ internal override void Save()
LayerEntity.Order = Order;
LayerEntity.Suspended = Suspended;
LayerEntity.Name = Name;
LayerEntity.ProfileId = Profile.EntityId;

General.ApplyToEntity();
Transform.ApplyToEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ internal ProfileConfiguration(ProfileCategory category, string name, string icon
Icon = new ProfileConfigurationIcon(Entity);
Icon.SetIconByName(icon);
ActivationCondition = new NodeScript<bool>("Activate profile", "Whether or not the profile should be active", this);

Entity.Profile.Id = Guid.NewGuid();
Entity.ProfileConfiguration.ProfileId = Entity.Profile.Id;
}

internal ProfileConfiguration(ProfileCategory category, ProfileContainerEntity entity)
Expand Down Expand Up @@ -188,7 +191,7 @@ public Module? Module
/// alongside any activation requirements of the <see cref="Module" />, if set
/// </summary>
public NodeScript<bool> ActivationCondition { get; }

/// <summary>
/// Gets the entity used by this profile config
/// </summary>
Expand Down
9 changes: 0 additions & 9 deletions src/Artemis.Storage.Legacy/Migrations/IProfileMigration.cs

This file was deleted.

5 changes: 1 addition & 4 deletions src/Artemis.Storage/Entities/Profile/FolderEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Abstract;

namespace Artemis.Storage.Entities.Profile;

Expand All @@ -9,6 +8,4 @@ public class FolderEntity : RenderElementEntity
public string? Name { get; set; }
public bool IsExpanded { get; set; }
public bool Suspended { get; set; }

public Guid ProfileId { get; set; }
}
5 changes: 1 addition & 4 deletions src/Artemis.Storage/Entities/Profile/LayerEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.AdaptionHints;

Expand All @@ -23,6 +22,4 @@ public LayerEntity()
public PropertyGroupEntity? GeneralPropertyGroup { get; set; }
public PropertyGroupEntity? TransformPropertyGroup { get; set; }
public LayerBrushEntity? LayerBrush { get; set; }

public Guid ProfileId { get; set; }
}
24 changes: 12 additions & 12 deletions src/Artemis.Storage/Migrations/ArtemisDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Version")
.IsUnique();
b.ToTable("Releases");
b.ToTable("Releases", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginEntity", b =>
Expand All @@ -58,7 +58,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("PluginGuid")
.IsUnique();
b.ToTable("Plugins");
b.ToTable("Plugins", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
Expand All @@ -81,7 +81,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("PluginEntityId");
b.ToTable("PluginFeatures");
b.ToTable("PluginFeatures", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginSettingEntity", b =>
Expand Down Expand Up @@ -109,7 +109,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Name", "PluginGuid")
.IsUnique();
b.ToTable("PluginSettings");
b.ToTable("PluginSettings", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileCategoryEntity", b =>
Expand Down Expand Up @@ -137,7 +137,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Name")
.IsUnique();
b.ToTable("ProfileCategories");
b.ToTable("ProfileCategories", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileContainerEntity", b =>
Expand Down Expand Up @@ -165,7 +165,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("ProfileCategoryId");
b.ToTable("ProfileContainers");
b.ToTable("ProfileContainers", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b =>
Expand Down Expand Up @@ -227,7 +227,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("Id");
b.ToTable("Devices");
b.ToTable("Devices", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Workshop.EntryEntity", b =>
Expand Down Expand Up @@ -268,7 +268,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("EntryId")
.IsUnique();
b.ToTable("Entries");
b.ToTable("Entries", (string)null);
});

modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
Expand All @@ -291,7 +291,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b =>
{
b.OwnsOne("System.Collections.Generic.List<Artemis.Storage.Entities.Surface.DeviceInputIdentifierEntity>", "InputIdentifiers", b1 =>
b.OwnsOne("Artemis.Storage.Entities.Surface.DeviceEntity.InputIdentifiers#System.Collections.Generic.List<Artemis.Storage.Entities.Surface.DeviceInputIdentifierEntity>", "InputIdentifiers", b1 =>
{
b1.Property<string>("DeviceEntityId")
.HasColumnType("TEXT");
Expand All @@ -301,15 +301,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b1.HasKey("DeviceEntityId");
b1.ToTable("Devices");
b1.ToTable("Devices", (string)null);
b1.ToJson("InputIdentifiers");
b1.WithOwner()
.HasForeignKey("DeviceEntityId");
});
b.OwnsOne("System.Collections.Generic.List<Artemis.Storage.Entities.Surface.InputMappingEntity>", "InputMappings", b1 =>
b.OwnsOne("Artemis.Storage.Entities.Surface.DeviceEntity.InputMappings#System.Collections.Generic.List<Artemis.Storage.Entities.Surface.InputMappingEntity>", "InputMappings", b1 =>
{
b1.Property<string>("DeviceEntityId")
.HasColumnType("TEXT");
Expand All @@ -319,7 +319,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b1.HasKey("DeviceEntityId");
b1.ToTable("Devices");
b1.ToTable("Devices", (string)null);
b1.ToJson("InputMappings");
Expand Down
5 changes: 5 additions & 0 deletions src/Artemis.Storage/Repositories/ProfileRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ public void Remove(ProfileContainerEntity profileContainerEntity)

public void Save(ProfileContainerEntity profileContainerEntity)
{
profileContainerEntity.ProfileConfiguration.Version = profileMigrators.Max(m => m.Version);

using ArtemisDbContext dbContext = getContext();
dbContext.Update(profileContainerEntity);
dbContext.SaveChanges();
}

public void SaveRange(List<ProfileContainerEntity> profileContainerEntities)
{
foreach (ProfileContainerEntity profileContainerEntity in profileContainerEntities)
profileContainerEntity.ProfileConfiguration.Version = profileMigrators.Max(m => m.Version);

using ArtemisDbContext dbContext = getContext();
dbContext.UpdateRange(profileContainerEntities);
dbContext.SaveChanges();
Expand Down
3 changes: 3 additions & 0 deletions src/Artemis.UI/Screens/Sidebar/SidebarCategoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public SidebarCategoryViewModel(ProfileCategory profileCategory, IProfileService

public void AddProfileConfiguration(ProfileConfiguration profileConfiguration, ProfileConfiguration? target)
{
if (profileConfiguration == target)
return;

ProfileCategory oldCategory = profileConfiguration.Category;
ProfileCategory.AddProfileConfiguration(profileConfiguration, target);

Expand Down

0 comments on commit 7e981a6

Please sign in to comment.