Skip to content

Commit

Permalink
feat: add settings, changed mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev committed Apr 17, 2024
1 parent 0b51111 commit 241d4ba
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
42 changes: 42 additions & 0 deletions src/VirtoCommerce.WhiteLabeling.Core/ModuleConstants.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System.Collections.Generic;
using VirtoCommerce.Platform.Core.Settings;

namespace VirtoCommerce.WhiteLabeling.Core;

public static class ModuleConstants
Expand All @@ -20,4 +23,43 @@ public static class Permissions
};
}
}

public static class Settings
{
public static class General
{
public static SettingDescriptor WhiteLabelingEnabled { get; } = new()
{
Name = "WhiteLabeling.WhiteLabelingEnabled",
GroupName = "WhiteLabeling|General",
ValueType = SettingValueType.Boolean,
IsPublic = true,
DefaultValue = true,
};

public static IEnumerable<SettingDescriptor> AllGeneralSettings
{
get
{
yield return WhiteLabelingEnabled;
}
}
}

public static IEnumerable<SettingDescriptor> AllSettings
{
get
{
return General.AllGeneralSettings;
}
}

public static IEnumerable<SettingDescriptor> StoreLevelSettings
{
get
{
yield return General.WhiteLabelingEnabled;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.818.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public Task<WhiteLabelingSettings> Handle(GetWhiteLabelingSettingsQuery request,
{
UserId = "cfcec63a-faa5-4511-9aef-ee7672af6710",
OrganizationId = "f081c52234754c9c8229aa42d6a19220",
LogoUrl = "/static/images/common/logo-1.svg",
SecondaryLogoUrl = "/static/images/common/logo-white-1.svg",
LogoUrl = "https://vcst-dev.govirto.com/cms-content/assets/b2b-store-assets/logo-white-labeling-test.svg",
SecondaryLogoUrl = "https://vcst-dev.govirto.com/cms-content/assets/b2b-store-assets/logo-inverted-white-labeling-test.svg",
FaviconUrl = "/static/icons/favicon-1.svg",
FooterLinks = new List<FooterLink>()
{
Expand Down Expand Up @@ -63,14 +63,6 @@ public Task<WhiteLabelingSettings> Handle(GetWhiteLabelingSettingsQuery request,
}
}
}
},
new WhiteLabelingSettings()
{
UserId = "07e6a601-b90e-4dbd-a7d0-0f1f89db4f2e",
OrganizationId = "",
LogoUrl = "/static/images/common/logo.svg",
SecondaryLogoUrl = "/static/images/common/logo-white.svg",
FaviconUrl = "/static/icons/favicon.svg",
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.ExperienceApiModule.Core" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.800.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.818.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.WhiteLabeling.Core\VirtoCommerce.WhiteLabeling.Core.csproj" />
Expand Down
14 changes: 7 additions & 7 deletions src/VirtoCommerce.WhiteLabeling.Web/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using VirtoCommerce.ExperienceApiModule.Core.Infrastructure;
using VirtoCommerce.Platform.Core.Modularity;
using VirtoCommerce.Platform.Core.Security;
using VirtoCommerce.Platform.Core.Settings;
using VirtoCommerce.StoreModule.Core.Model;
using VirtoCommerce.WhiteLabeling.Core;
using VirtoCommerce.WhiteLabeling.Data;

Expand All @@ -25,13 +27,6 @@ public void Initialize(IServiceCollection serviceCollection)
serviceCollection.AddMediatR(assemblyMarker);
serviceCollection.AddAutoMapper(assemblyMarker);
serviceCollection.AddSchemaBuilders(assemblyMarker);

// Override models
//AbstractTypeFactory<OriginalModel>.OverrideType<OriginalModel, ExtendedModel>().MapToType<ExtendedEntity>();
//AbstractTypeFactory<OriginalEntity>.OverrideType<OriginalEntity, ExtendedEntity>();

// Register services
//serviceCollection.AddTransient<IMyService, MyService>();
}

public void PostInitialize(IApplicationBuilder appBuilder)
Expand All @@ -41,6 +36,11 @@ public void PostInitialize(IApplicationBuilder appBuilder)
// Register permissions
var permissionsRegistrar = serviceProvider.GetRequiredService<IPermissionsRegistrar>();
permissionsRegistrar.RegisterPermissions(ModuleInfo.Id, "WhiteLabeling", ModuleConstants.Security.Permissions.AllPermissions);

// Register settings
var settingsRegistrar = serviceProvider.GetRequiredService<ISettingsRegistrar>();
settingsRegistrar.RegisterSettings(ModuleConstants.Settings.AllSettings, ModuleInfo.Id);
settingsRegistrar.RegisterSettingsForType(ModuleConstants.Settings.StoreLevelSettings, nameof(Store));
}

public void Uninstall()
Expand Down

0 comments on commit 241d4ba

Please sign in to comment.