Skip to content

Commit

Permalink
UI fixes (#1142)
Browse files Browse the repository at this point in the history
* Simplified editors.

* Primary ctor.

* Move inheritance to new line

* Formatting fixes.

* Fix registration.
  • Loading branch information
SebastianStehle authored Nov 19, 2024
1 parent a49ef9d commit 920371b
Show file tree
Hide file tree
Showing 586 changed files with 1,617 additions and 5,214 deletions.
3 changes: 0 additions & 3 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ dotnet_diagnostic.RECS0117.severity = none
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1649.severity = none

# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = none

# IDE0305: Simplify collection initialization
dotnet_diagnostic.IDE0305.severity = none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ namespace Squidex.Extensions.APM.ApplicationInsights;

public sealed class ApplicationInsightsPlugin : IPlugin
{
private sealed class Configurator : ITelemetryConfigurator
private sealed class Configurator(IConfiguration config) : ITelemetryConfigurator
{
private readonly IConfiguration config;

public Configurator(IConfiguration config)
{
this.config = config;
}

public void Configure(TracerProviderBuilder builder)
{
builder.AddAzureMonitorTraceExporter(options =>
Expand Down
9 changes: 1 addition & 8 deletions backend/extensions/Squidex.Extensions/APM/Otlp/OtlpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@ namespace Squidex.Extensions.APM.Otlp;

public sealed class OtlpPlugin : IPlugin
{
private sealed class Configurator : ITelemetryConfigurator
private sealed class Configurator(IConfiguration config) : ITelemetryConfigurator
{
private readonly IConfiguration config;

public Configurator(IConfiguration config)
{
this.config = config;
}

public void Configure(TracerProviderBuilder builder)
{
builder.AddOtlpExporter(options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

namespace Squidex.Extensions.APM.Stackdriver;

internal sealed class StackdriverExceptionHandler : ILogAppender
internal sealed class StackdriverExceptionHandler(IContextExceptionLogger logger, IHttpContextAccessor httpContextAccessor) : ILogAppender
{
private readonly IContextExceptionLogger logger;
private readonly HttpContextWrapper httpContextWrapper;
private readonly HttpContextWrapper httpContextWrapper = new HttpContextWrapper(httpContextAccessor);

public sealed class HttpContextWrapper : IContextWrapper
{
Expand All @@ -43,13 +42,6 @@ public string GetUserAgent()
}
}

public StackdriverExceptionHandler(IContextExceptionLogger logger, IHttpContextAccessor httpContextAccessor)
{
this.logger = logger;

httpContextWrapper = new HttpContextWrapper(httpContextAccessor);
}

public void Append(IObjectWriter writer, SemanticLogLevel logLevel, Exception? exception)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@ namespace Squidex.Extensions.APM.Stackdriver;

public sealed class StackdriverPlugin : IPlugin
{
private sealed class Configurator : ITelemetryConfigurator
private sealed class Configurator(string projectId) : ITelemetryConfigurator
{
private readonly string projectId;

public Configurator(string projectId)
{
this.projectId = projectId;
}

public void Configure(TracerProviderBuilder builder)
{
builder.UseStackdriverExporter(projectId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ namespace Squidex.Extensions.APM.Zipkin;

public sealed class ZipkinPlugin : IPlugin
{
private sealed class Configurator : ITelemetryConfigurator
private sealed class Configurator(IConfiguration config) : ITelemetryConfigurator
{
private readonly IConfiguration config;

public Configurator(IConfiguration config)
{
this.config = config;
}

public void Configure(TracerProviderBuilder builder)
{
builder.AddZipkinExporter(options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,15 @@

namespace Squidex.Extensions.Actions.Algolia;

public sealed class AlgoliaActionHandler : RuleActionHandler<AlgoliaAction, AlgoliaJob>
public sealed class AlgoliaActionHandler(RuleEventFormatter formatter, IScriptEngine scriptEngine, IJsonSerializer serializer) : RuleActionHandler<AlgoliaAction, AlgoliaJob>(formatter)
{
private readonly ClientPool<(string AppId, string ApiKey, string IndexName), ISearchIndex> clients;
private readonly IScriptEngine scriptEngine;
private readonly IJsonSerializer serializer;

public AlgoliaActionHandler(RuleEventFormatter formatter, IScriptEngine scriptEngine, IJsonSerializer serializer)
: base(formatter)
{
clients = new ClientPool<(string AppId, string ApiKey, string IndexName), ISearchIndex>(key =>
private readonly ClientPool<(string AppId, string ApiKey, string IndexName), ISearchIndex> clients = new ClientPool<(string AppId, string ApiKey, string IndexName), ISearchIndex>(key =>
{
var client = new SearchClient(key.AppId, key.ApiKey);

return client.InitIndex(key.IndexName);
});

this.scriptEngine = scriptEngine;
this.serializer = serializer;
}

protected override async Task<(string Description, AlgoliaJob Data)> CreateJobAsync(EnrichedEvent @event, AlgoliaAction action)
{
if (@event is not IEnrichedEntityEvent entityEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@

namespace Squidex.Extensions.Actions.AzureQueue;

public sealed class AzureQueueActionHandler : RuleActionHandler<AzureQueueAction, AzureQueueJob>
public sealed class AzureQueueActionHandler(RuleEventFormatter formatter) : RuleActionHandler<AzureQueueAction, AzureQueueJob>(formatter)
{
private readonly ClientPool<(string ConnectionString, string QueueName), CloudQueue> clients;

public AzureQueueActionHandler(RuleEventFormatter formatter)
: base(formatter)
{
clients = new ClientPool<(string ConnectionString, string QueueName), CloudQueue>(key =>
private readonly ClientPool<(string ConnectionString, string QueueName), CloudQueue> clients = new ClientPool<(string ConnectionString, string QueueName), CloudQueue>(key =>
{
var storageAccount = CloudStorageAccount.Parse(key.ConnectionString);

Expand All @@ -30,7 +25,6 @@ public AzureQueueActionHandler(RuleEventFormatter formatter)

return queueRef;
});
}

protected override async Task<(string Description, AzureQueueJob Data)> CreateJobAsync(EnrichedEvent @event, AzureQueueAction action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,9 @@

namespace Squidex.Extensions.Actions.Comment;

public sealed class CommentActionHandler : RuleActionHandler<CommentAction, CommentCreated>
public sealed class CommentActionHandler(RuleEventFormatter formatter, ICollaborationService collaboration) : RuleActionHandler<CommentAction, CommentCreated>(formatter)
{
private const string Description = "Send a Comment";
private readonly ICollaborationService collaboration;

public CommentActionHandler(RuleEventFormatter formatter, ICollaborationService collaboration)
: base(formatter)
{
this.collaboration = collaboration;
}

protected override async Task<(string Description, CommentCreated Data)> CreateJobAsync(EnrichedEvent @event, CommentAction action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,9 @@

namespace Squidex.Extensions.Actions.CreateContent;

public sealed class CreateContentActionHandler : RuleActionHandler<CreateContentAction, Command>
public sealed class CreateContentActionHandler(RuleEventFormatter formatter, IAppProvider appProvider, ICommandBus commandBus, IJsonSerializer jsonSerializer) : RuleActionHandler<CreateContentAction, Command>(formatter)
{
private const string Description = "Create a content";
private readonly ICommandBus commandBus;
private readonly IAppProvider appProvider;
private readonly IJsonSerializer jsonSerializer;

public CreateContentActionHandler(RuleEventFormatter formatter, IAppProvider appProvider, ICommandBus commandBus, IJsonSerializer jsonSerializer)
: base(formatter)
{
this.appProvider = appProvider;
this.commandBus = commandBus;
this.jsonSerializer = jsonSerializer;
}

protected override async Task<(string Description, Command Data)> CreateJobAsync(EnrichedEvent @event, CreateContentAction action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,17 @@ namespace Squidex.Extensions.Actions.DeepDetect;

#pragma warning disable MA0048 // File name must match type name

internal sealed partial class DeepDetectActionHandler : RuleActionHandler<DeepDetectAction, DeepDetectJob>
internal sealed partial class DeepDetectActionHandler(
RuleEventFormatter formatter,
IHttpClientFactory httpClientFactory,
IJsonSerializer jsonSerializer,
IAppProvider appProvider,
IAssetQueryService assetQuery,
ICommandBus commandBus,
IUrlGenerator urlGenerator)
: RuleActionHandler<DeepDetectAction, DeepDetectJob>(formatter)
{
private const string Description = "Analyze Image";
private readonly IHttpClientFactory httpClientFactory;
private readonly IJsonSerializer jsonSerializer;
private readonly IAppProvider appProvider;
private readonly IAssetQueryService assetQuery;
private readonly ICommandBus commandBus;
private readonly IUrlGenerator urlGenerator;

public DeepDetectActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory,
IJsonSerializer jsonSerializer,
IAppProvider appProvider,
IAssetQueryService assetQuery,
ICommandBus commandBus,
IUrlGenerator urlGenerator)
: base(formatter)
{
this.httpClientFactory = httpClientFactory;
this.jsonSerializer = jsonSerializer;
this.appProvider = appProvider;
this.assetQuery = assetQuery;
this.commandBus = commandBus;
this.urlGenerator = urlGenerator;
}

protected override Task<(string Description, DeepDetectJob Data)> CreateJobAsync(EnrichedEvent @event, DeepDetectAction action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,11 @@

namespace Squidex.Extensions.Actions.Discourse;

public sealed class DiscourseActionHandler : RuleActionHandler<DiscourseAction, DiscourseJob>
public sealed class DiscourseActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory) : RuleActionHandler<DiscourseAction, DiscourseJob>(formatter)
{
private const string DescriptionCreatePost = "Create discourse Post";
private const string DescriptionCreateTopic = "Create discourse Topic";

private readonly IHttpClientFactory httpClientFactory;

public DiscourseActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory)
: base(formatter)
{
this.httpClientFactory = httpClientFactory;
}

protected override async Task<(string Description, DiscourseJob Data)> CreateJobAsync(EnrichedEvent @event, DiscourseAction action)
{
var url = $"{action.Url.ToString().TrimEnd('/')}/posts.json?api_key={action.ApiKey}&api_username={action.ApiUsername}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@

namespace Squidex.Extensions.Actions.ElasticSearch;

public sealed class ElasticSearchActionHandler : RuleActionHandler<ElasticSearchAction, ElasticSearchJob>
public sealed class ElasticSearchActionHandler(RuleEventFormatter formatter, IScriptEngine scriptEngine, IJsonSerializer serializer) : RuleActionHandler<ElasticSearchAction, ElasticSearchJob>(formatter)
{
private readonly ClientPool<(Uri Host, string? Username, string? Password), ElasticLowLevelClient> clients;
private readonly IScriptEngine scriptEngine;
private readonly IJsonSerializer serializer;

public ElasticSearchActionHandler(RuleEventFormatter formatter, IScriptEngine scriptEngine, IJsonSerializer serializer)
: base(formatter)
{
clients = new ClientPool<(Uri Host, string? Username, string? Password), ElasticLowLevelClient>(key =>
private readonly ClientPool<(Uri Host, string? Username, string? Password), ElasticLowLevelClient> clients = new ClientPool<(Uri Host, string? Username, string? Password), ElasticLowLevelClient>(key =>
{
var config = new ConnectionConfiguration(key.Host);

Expand All @@ -39,10 +32,6 @@ public ElasticSearchActionHandler(RuleEventFormatter formatter, IScriptEngine sc
return new ElasticLowLevelClient(config);
});

this.scriptEngine = scriptEngine;
this.serializer = serializer;
}

protected override async Task<(string Description, ElasticSearchJob Data)> CreateJobAsync(EnrichedEvent @event, ElasticSearchAction action)
{
var delete = @event.ShouldDelete(scriptEngine, action.Delete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@

namespace Squidex.Extensions.Actions.Email;

public sealed class EmailActionHandler : RuleActionHandler<EmailAction, EmailJob>
public sealed class EmailActionHandler(RuleEventFormatter formatter) : RuleActionHandler<EmailAction, EmailJob>(formatter)
{
public EmailActionHandler(RuleEventFormatter formatter)
: base(formatter)
{
}

protected override async Task<(string Description, EmailJob Data)> CreateJobAsync(EnrichedEvent @event, EmailAction action)
{
var ruleJob = new EmailJob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,10 @@

namespace Squidex.Extensions.Actions.Fastly;

public sealed class FastlyActionHandler : RuleActionHandler<FastlyAction, FastlyJob>
public sealed class FastlyActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory) : RuleActionHandler<FastlyAction, FastlyJob>(formatter)
{
private const string Description = "Purge key in fastly";

private readonly IHttpClientFactory httpClientFactory;

public FastlyActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory)
: base(formatter)
{
this.httpClientFactory = httpClientFactory;
}

protected override (string Description, FastlyJob Data) CreateJob(EnrichedEvent @event, FastlyAction action)
{
var id = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@

namespace Squidex.Extensions.Actions.Kafka;

public sealed class KafkaActionHandler : RuleActionHandler<KafkaAction, KafkaJob>
public sealed class KafkaActionHandler(RuleEventFormatter formatter, KafkaProducer kafkaProducer) : RuleActionHandler<KafkaAction, KafkaJob>(formatter)
{
private const string Description = "Push to Kafka";
private readonly KafkaProducer kafkaProducer;

public KafkaActionHandler(RuleEventFormatter formatter, KafkaProducer kafkaProducer)
: base(formatter)
{
this.kafkaProducer = kafkaProducer;
}

protected override async Task<(string Description, KafkaJob Data)> CreateJobAsync(EnrichedEvent @event, KafkaAction action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@

namespace Squidex.Extensions.Actions.Medium;

public sealed class MediumActionHandler : RuleActionHandler<MediumAction, MediumJob>
public sealed class MediumActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory, IJsonSerializer serializer) : RuleActionHandler<MediumAction, MediumJob>(formatter)
{
private const string Description = "Post to medium";

private readonly IHttpClientFactory httpClientFactory;
private readonly IJsonSerializer serializer;

private sealed class UserResponse
{
public UserResponseData Data { get; set; }
Expand All @@ -32,14 +29,6 @@ private sealed class UserResponseData
public string Id { get; set; }
}

public MediumActionHandler(RuleEventFormatter formatter, IHttpClientFactory httpClientFactory, IJsonSerializer serializer)
: base(formatter)
{
this.httpClientFactory = httpClientFactory;

this.serializer = serializer;
}

protected override async Task<(string Description, MediumJob Data)> CreateJobAsync(EnrichedEvent @event, MediumAction action)
{
var ruleJob = new MediumJob { AccessToken = action.AccessToken, PublicationId = action.PublicationId };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@

namespace Squidex.Extensions.Actions.Notification;

public sealed class NotificationActionHandler : RuleActionHandler<NotificationAction, CommentCreated>
public sealed class NotificationActionHandler(RuleEventFormatter formatter, ICollaborationService collaboration, IUserResolver userResolver) : RuleActionHandler<NotificationAction, CommentCreated>(formatter)
{
private const string Description = "Send a Notification";
private readonly ICollaborationService collaboration;
private readonly IUserResolver userResolver;

public NotificationActionHandler(RuleEventFormatter formatter, ICollaborationService collaboration, IUserResolver userResolver)
: base(formatter)
{
this.collaboration = collaboration;
this.userResolver = userResolver;
}

protected override async Task<(string Description, CommentCreated Data)> CreateJobAsync(EnrichedEvent @event, NotificationAction action)
{
Expand Down
Loading

0 comments on commit 920371b

Please sign in to comment.