Skip to content

Commit

Permalink
refactor(sln): rename client org/project, resolve warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
seangwright committed Aug 1, 2023
1 parent 25b5b39 commit 9c002d3
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 39 deletions.
4 changes: 1 addition & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
<CopyDocumentationFilesFromPackages>true</CopyDocumentationFilesFromPackages>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<NoWarn>$(NoWarn);1591</NoWarn>
<RootNamespace>Kentico.Xperience.Contacts.Importer</RootNamespace>

<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>

Expand All @@ -46,7 +44,7 @@
</PropertyGroup>

<ItemGroup Label="StaticCodeAnalysis">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.41.0.50478">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.6.0.74858">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

[assembly: UIPage(
parentType: typeof(ContactsImporterApplication),
name: "Importer",
slug: "import",
name: "Upload",
slug: "upload",
uiPageType: typeof(ImportTemplate),
icon: Icons.PersonalisationVariants,
templateName: ImportTemplate.TEMPLATE_NAME,
Expand All @@ -16,7 +16,7 @@ namespace Kentico.Xperience.Contacts.Importer.Admin
internal class ImportTemplate : Page<CustomLayoutProperties>
{
public const string IDENTIFIER = "Kentico.Xperience.Contacts.Import.Web.Admin.ImportTemplate";
public const string TEMPLATE_NAME = "@kentico-xperience-contacts-import/web-admin/ImportLayout";
public const string TEMPLATE_NAME = "@kentico/contacts-import-web-admin/ImportLayout";

private readonly IContactGroupInfoProvider contactGroupInfoProvider;

Expand All @@ -25,7 +25,7 @@ public ImportTemplate(IContactGroupInfoProvider contactGroupInfoProvider) =>

public override async Task<CustomLayoutProperties> ConfigureTemplateProperties(CustomLayoutProperties properties)
{
properties.Label = "Import Contacts";
properties.Label = "Upload Contacts";

var contactGroups = await contactGroupInfoProvider.Get()
.Columns(nameof(ContactGroupInfo.ContactGroupGUID), nameof(ContactGroupInfo.ContactGroupDisplayName))
Expand Down
18 changes: 9 additions & 9 deletions src/Kentico.Xperience.Contacts.Importer/Client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Kentico.Xperience.Contacts.Importer/Client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "kentico-xperience-contacts-import-web-admin",
"name": "kentico-contacts-import-web-admin",
"version": "1.0.0",
"description": "Kentico Xperience Contacts Import project.",
"private": true,
Expand All @@ -24,7 +24,7 @@
"@babel/preset-react": "7.22.5",
"@babel/preset-typescript": "7.22.5",
"@kentico/xperience-webpack-config": "26.3.1",
"@types/react": "18.2.15",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
"babel-loader": "9.1.3",
"webpack": "5.88.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = (opts, argv) => {
return baseWebpackConfig({
// Sets the organizationName and projectName
// The JS module is registered on the backend using these values
orgName: "kentico-xperience-contacts-import",
projectName: "web-admin",
orgName: "kentico",
projectName: "contacts-import-web-admin",
webpackConfigEnv,
argv,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override void OnInit()
{
base.OnInit();

RegisterClientModule("kentico-xperience-contacts-import", "web-admin");
RegisterClientModule("kentico", "contacts-import-web-admin");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<PackageId>Kentico.Xperience.Contacts.Import</PackageId>
<VersionSuffix Condition="$(Configuration) == 'Debug'">$([System.DateTime]::Now.ToString('yyMMddHHmm'))</VersionSuffix>
<PackageOutputDir Condition="$(Configuration) == 'Debug'">$(LOCAL_NUGET_REPO)\</PackageOutputDir>
<RootNamespace>Kentico.Xperience.Contacts.Importer</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,14 +16,14 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);S1075</NoWarn>
<AdminOrgName>kentico-xperience-contacts-import</AdminOrgName>
<AdminOrgName>kentico</AdminOrgName>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="CMS.AssemblyDiscoverableAttribute">
</AssemblyAttribute>
<AdminClientPath Include="Client\dist\**">
<ProjectName>web-admin</ProjectName>
<ProjectName>contacts-import-web-admin</ProjectName>
</AdminClientPath>
<Compile Remove="Client\node_modules\**" />
<EmbeddedResource Remove="Client\node_modules\**" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
[assembly: RegisterLocalizationResource(typeof(ContactsImporterResources), SystemContext.SYSTEM_CULTURE_NAME)]
namespace Kentico.Xperience.Contacts.Importer.Resources
{
internal class ContactsImporterResources
public class ContactsImporterResources
{
public ContactsImporterResources()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ImportService : IImportService
/// </summary>
public sealed class ContactInfoMap : ClassMap<ContactInfo>
{
/// <summary>
/// Defines import map for ContactInfo.TYPEINFO.ColumnNames
/// </summary>
public ContactInfoMap()
{
Map(m => m.ContactGUID);
Expand All @@ -33,7 +36,6 @@ public ContactInfoMap()
Map(m => m.ContactAddress1);
Map(m => m.ContactAge);
Map(m => m.ContactMiddleName);
// ContactInfo.TYPEINFO.ColumnNames
}
}

Expand All @@ -42,13 +44,15 @@ private sealed class ContactDeleteArgument
// Pragma disable reason: used implicitly
#pragma warning disable S3459
// ReSharper disable once InconsistentNaming // kentico naming convention
public Guid ContactGUID { get; set; }
public Guid ContactGUID { get; }
#pragma warning restore S3459
};

private sealed class SimplifiedMap : ClassMap<ContactDeleteArgument>
{
#pragma warning disable S1144
public SimplifiedMap() => Map(m => m.ContactGUID);
#pragma warning restore S1144
}

/// <exception cref="Exception">Thrown when contact group is missing</exception>
Expand Down Expand Up @@ -90,7 +94,7 @@ private async Task BulkDeleteContactFromCsvAsync(Stream csvStream, ImportContext
var records = csv.GetRecordsAsync<ContactDeleteArgument>();

int totalProcessed = 0;

async IAsyncEnumerable<List<Guid>> Pipe2TransformBatches(IAsyncEnumerable<ContactDeleteArgument> models)
{
var currentBatch = new List<Guid>(context.BatchSize);
Expand All @@ -115,7 +119,7 @@ async IAsyncEnumerable<List<Guid>> Pipe2TransformBatches(IAsyncEnumerable<Contac
// we are no concerned here that totalProcessed is captured from foreign closure
// we do not await this task, it doesn't concern import routine
#pragma warning disable CS4014
Task.Run(async () => { await onResultCallbackAsync.Invoke(new List<ImportResult>(), totalProcessed); });
Task.Run(async () => await onResultCallbackAsync.Invoke(new List<ImportResult>(), totalProcessed));
#pragma warning restore CS4014
}
}
Expand Down Expand Up @@ -196,7 +200,7 @@ private async Task InsertContactsFromCsvAsync(Stream csvStream, ImportContext co

if (totalProcessed % context.BatchSize == 0)
{
Task.Run(async () => { await onResultCallbackAsync.Invoke(new List<ImportResult>(), totalProcessed); });
Task.Run(async () => await onResultCallbackAsync.Invoke(new List<ImportResult>(), totalProcessed));
}
}

Expand All @@ -216,7 +220,7 @@ private async Task InsertContactsFromCsvAsync(Stream csvStream, ImportContext co
})
{
// we cannot use ContactInfoProvider.ProviderObject.BulkInsertInfos - insert is not immediate (all items stored in memory before insert) so direct piping is not possible

foreach (var contactBatch in Pipe2TransformBatches(records))
{
ContactInfoProvider.ProviderObject.BulkInsertInfos(contactBatch.Where(x => x.insert).Select(x => x.info), new BulkInsertSettings
Expand All @@ -234,7 +238,7 @@ private async Task InsertContactsFromCsvAsync(Stream csvStream, ImportContext co
}
}

private Task InsertGroupMembersAsync(IEnumerable<Guid> contactGuids, ContactGroupInfo group) =>
private static Task InsertGroupMembersAsync(IEnumerable<Guid> contactGuids, ContactGroupInfo group) =>
Task.Run(() =>
{
string query = @"
Expand Down Expand Up @@ -262,7 +266,7 @@ FROM [dbo].[OM_ContactGroupMember] [CGM]
}, QueryTypeEnum.SQLQuery);
});

private Task DeletedContactsAsync(List<Guid> contactGuids, int batchLimit)
private static Task DeletedContactsAsync(List<Guid> contactGuids, int batchLimit)
{
// for future implementation of bulk delete
#pragma warning disable S125
Expand Down
6 changes: 3 additions & 3 deletions src/Kentico.Xperience.Contacts.Importer/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[8.41.0.50478, )",
"resolved": "8.41.0.50478",
"contentHash": "kfh38H/+U96R4LmFQD/4agkvT258QkF5Sg7ApKo2DG0wMnUtji/H5aypGsKfX2cH8kw9lrLR/vdwmBiD9QFx1w=="
"requested": "[9.6.0.74858, )",
"resolved": "9.6.0.74858",
"contentHash": "tBwiOBYcoSyHVUejjz6iH3VOpSFx7gJSuQ3695BQaoqQBcqy0IeRsKAk5FAR4fbm3QLyEM9bimKk1l038TFN2w=="
},
"AngleSharp": {
"type": "Transitive",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public static IEnumerable<ContactInfo> Generate(int count)
var faker = new Bogus.Faker<ContactInfo>();

faker.RuleFor(c => c.ContactGUID, f => f.Random.Guid())
.RuleFor(c => c.ContactCreated, f => f.Date.Between(new DateTime(), new DateTime()))
.RuleFor(c => c.ContactCreated, f => f.Date.Between(
new DateTime(2023, 01, 01, 01, 01, 01, DateTimeKind.Utc), new DateTime(2023, 08, 01, 01, 01, 01, DateTimeKind.Utc)))
.RuleFor(c => c.ContactFirstName, f => f.Person.FirstName)
.RuleFor(c => c.ContactEmail, f => f.Internet.Email())
.RuleFor(c => c.ContactLastName, f => f.Person.LastName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
"requested": "[8.41.0.50478, )",
"resolved": "8.41.0.50478",
"contentHash": "kfh38H/+U96R4LmFQD/4agkvT258QkF5Sg7ApKo2DG0wMnUtji/H5aypGsKfX2cH8kw9lrLR/vdwmBiD9QFx1w=="
"requested": "[9.6.0.74858, )",
"resolved": "9.6.0.74858",
"contentHash": "tBwiOBYcoSyHVUejjz6iH3VOpSFx7gJSuQ3695BQaoqQBcqy0IeRsKAk5FAR4fbm3QLyEM9bimKk1l038TFN2w=="
},
"AngleSharp": {
"type": "Transitive",
Expand Down

0 comments on commit 9c002d3

Please sign in to comment.