Skip to content

Commit

Permalink
Updated status enums
Browse files Browse the repository at this point in the history
  • Loading branch information
mathijs-bb committed Dec 5, 2024
1 parent 31a7bfa commit af8d64e
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 76 deletions.
8 changes: 4 additions & 4 deletions Apps.Lionbridge/Actions/JobActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public async Task<JobDto> UpdateJob([ActionParameter] GetJobRequest jobRequest,
job = await Client.ExecuteWithErrorHandling<JobDto>(apiRequest);
}

if (request.JobCompletionStatus != null)
{
job = await UpdateJobCompletionStatus(jobRequest.JobId, request.JobCompletionStatus, job);
}
//if (request.JobCompletionStatus != null)
//{
// job = await UpdateJobCompletionStatus(jobRequest.JobId, request.JobCompletionStatus, job);
//}

return job ?? await GetJob(jobRequest);
}
Expand Down
11 changes: 5 additions & 6 deletions Apps.Lionbridge/Apps.Lionbridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
<Nullable>enable</Nullable>
<Product>Lionbridge</Product>
<Description>Lionbridge is the translation and localization expert. Advanced automation tools are indispensable to simplify your content journey and effectively reach your customers faster and more cost-efficiently than ever before</Description>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<AssemblyName>Apps.Lionbridge</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blackbird.Applications.Sdk.Common" Version="2.6.0"/>
<PackageReference Include="Blackbird.Applications.Sdk.Utils" Version="1.0.25"/>
<PackageReference Include="Blackbird.Applications.Sdk.Common" Version="2.11.0" />
<PackageReference Include="Blackbird.Applications.Sdk.Utils" Version="1.0.25" />
<PackageReference Include="MimeTypes" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="RestSharp" Version="110.2.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="image\icon.png" CopyToOutputDirectory="Always"/>
<EmbeddedResource Include="image\icon.png" CopyToOutputDirectory="Always" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions Apps.Lionbridge/Connections/ConnectionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class ConnectionDefinition : IConnectionDefinition
{
Name = "Lionbridge connection",
AuthenticationType = ConnectionAuthenticationType.Undefined,
ConnectionUsage = ConnectionUsage.Actions,
ConnectionProperties = new List<ConnectionProperty>
{
new(CredNames.ClientId) { DisplayName = "Client ID" },
Expand All @@ -24,6 +23,6 @@ public class ConnectionDefinition : IConnectionDefinition
public IEnumerable<AuthenticationCredentialsProvider> CreateAuthorizationCredentialsProviders(
Dictionary<string, string> values)
=> values.Select(x =>
new AuthenticationCredentialsProvider(AuthenticationCredentialsRequestLocation.None, x.Key, x.Value))
new AuthenticationCredentialsProvider(x.Key, x.Value))
.ToList();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Utils.Sdk.DataSourceHandlers;

namespace Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;

public class JobStatusDataHandler : IStaticDataSourceItemHandler
{

public IEnumerable<DataSourceItem> GetData()
{
return new List<DataSourceItem>()
{
new("CREATED", "Created" ),
new("SENDING", "Sending" ),
new("SENT_TO_PROVIDER", "Sent to provider" ),
new("IN_TRANSLATION", "In translation" ),
new("CANCELLED", "Cancelled" ),
new("COMPLETED", "Complete"),
};
}
}
13 changes: 0 additions & 13 deletions Apps.Lionbridge/DataSourceHandlers/EnumDataHandlers/JobStatuses.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Utils.Sdk.DataSourceHandlers;

namespace Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;

public class RequestStatusDataHandler : IStaticDataSourceItemHandler
{

public IEnumerable<DataSourceItem> GetData()
{
return new List<DataSourceItem>()
{
new("CREATED", "Created" ),
new("SENDING", "Sending" ),
new("SENT_TO_PROVIDER", "Sent to provider" ),
new("IN_TRANSLATION", "In translation" ),
new("REVIEW_TRANSLATION", "Ready for review" ),
new("TRANSLATION_REJECTED", "Translation rejected" ),
new("TRANSLATION_APPROVED", "Translation approved"),
new("CANCELLED", "Cancelled"),
};
}
}

This file was deleted.

6 changes: 3 additions & 3 deletions Apps.Lionbridge/DataSourceHandlers/JobDataSourceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Apps.Lionbridge.DataSourceHandlers;

public class JobDataSourceHandler(InvocationContext invocationContext)
: LionbridgeInvocable(invocationContext), IAsyncDataSourceHandler
: LionbridgeInvocable(invocationContext), IAsyncDataSourceItemHandler
{
public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
public async Task<IEnumerable<DataSourceItem>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
var endpoint = ApiEndpoints.Jobs;
Expand All @@ -19,6 +19,6 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
return response.Embedded.Jobs.Where(job =>
context.SearchString == null ||
job.JobName.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
.ToDictionary(job => job.JobId, job => job.JobName);
.Select(job => new DataSourceItem(job.JobId, job.JobName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Apps.Lionbridge.DataSourceHandlers;

public class ProviderDataSourceHandler(InvocationContext invocationContext)
: LionbridgeInvocable(invocationContext), IAsyncDataSourceHandler
: LionbridgeInvocable(invocationContext), IAsyncDataSourceItemHandler
{
public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
public async Task<IEnumerable<DataSourceItem>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
var endpoint = "/providers?includeDeletedOnes=false";
Expand All @@ -29,6 +29,6 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
endpoint = $"/providers?includeDeletedOnes=false&next={nextToken}";
} while (nextToken != null);

return providers.ToDictionary(provider => provider.ProviderId, provider => provider.ProviderName);
return providers.Select(provider => new DataSourceItem(provider.ProviderId, provider.ProviderName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Apps.Lionbridge.DataSourceHandlers;

public class RequestDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceHandler
public class RequestDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceItemHandler
{
private readonly string? _jobId;

Expand All @@ -20,7 +20,7 @@ public RequestDataSourceHandler(InvocationContext invocationContext, [ActionPara
_jobId = request.JobId;
}

public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
public async Task<IEnumerable<DataSourceItem>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(_jobId))
Expand All @@ -35,7 +35,7 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
return response.Embedded.Requests.Where(job =>
context.SearchString == null ||
job.RequestName.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
.ToDictionary(job => job.RequestId, BuildReadableName);
.Select(job => new DataSourceItem(job.RequestId, BuildReadableName(job)));
}

private string BuildReadableName(RequestDto requestDto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Apps.Lionbridge.DataSourceHandlers;

public class SupportAssetDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceHandler
public class SupportAssetDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceItemHandler
{
private readonly string _jobId;

Expand All @@ -17,7 +17,7 @@ public SupportAssetDataSourceHandler(InvocationContext invocationContext, [Actio
_jobId = request.LionBridgeJobId;
}

public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
public async Task<IEnumerable<DataSourceItem>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
if(string.IsNullOrEmpty(_jobId))
Expand All @@ -33,6 +33,6 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
return response.Embedded.SupportAssets.Where(job =>
context.SearchString == null ||
job.Filename.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
.ToDictionary(job => job.SupportAssetId, job => job.Filename);
.Select(job => new DataSourceItem(job.SupportAssetId, job.Filename));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Apps.Lionbridge.DataSourceHandlers;

public class TranslationMemoryDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceHandler
public class TranslationMemoryDataSourceHandler : LionbridgeInvocable, IAsyncDataSourceItemHandler
{
private readonly string _jobId;

Expand All @@ -18,7 +18,7 @@ public TranslationMemoryDataSourceHandler(InvocationContext invocationContext,
_jobId = request.LionBridgeJobId;
}

public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
public async Task<IEnumerable<DataSourceItem>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
if(string.IsNullOrEmpty(_jobId))
Expand All @@ -34,6 +34,6 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
return response.Embedded.tmupdates.Where(job =>
context.SearchString == null ||
job.FileName.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
.ToDictionary(job => job.TmupdateId, job => job.FileName);
.Select(job => new DataSourceItem(job.TmupdateId, job.FileName));
}
}
6 changes: 0 additions & 6 deletions Apps.Lionbridge/LionbridgeApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ public IEnumerable<ApplicationCategory> Categories
get => [ApplicationCategory.LspPortal];
set { }
}

public string Name
{
get => "Lionbridge";
set { }
}

public T GetInstance<T>() => throw new NotImplementedException();
}
5 changes: 3 additions & 2 deletions Apps.Lionbridge/Models/Requests/Job/UpdateJobRequest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Apps.Lionbridge.DataSourceHandlers;
using Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;

namespace Apps.Lionbridge.Models.Requests.Job;
Expand Down Expand Up @@ -43,6 +44,6 @@ public class UpdateJobRequest
"in the 'Label keys' input parameter.")]
public IEnumerable<string>? LabelValues { get; set; }

[Display("Job status"), DataSource(typeof(JobCompletionStatuses))]
public string? JobCompletionStatus { get; set; }
//[Display("Job status"), StaticDataSource(typeof(JobStatusDataHandler))]
//public string? JobCompletionStatus { get; set; }
}
3 changes: 2 additions & 1 deletion Apps.Lionbridge/Webhooks/Inputs/GetRequestsInput.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Apps.Lionbridge.DataSourceHandlers;
using Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;

namespace Apps.Lionbridge.Webhooks.Inputs;
Expand All @@ -13,6 +14,6 @@ public class GetRequestsInput
[Display("Request IDs"), DataSource(typeof(RequestDataSourceHandler))]
public IEnumerable<string>? RequestIds { get; set; }

[Display("Status codes"), DataSource(typeof(RequestStatuses))]
[Display("Status codes"), StaticDataSource(typeof(RequestStatusDataHandler))]
public IEnumerable<string>? StatusCodes { get; set; }
}
3 changes: 2 additions & 1 deletion Apps.Lionbridge/Webhooks/Inputs/JobStatusUpdatedInput.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Apps.Lionbridge.DataSourceHandlers;
using Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;

namespace Apps.Lionbridge.Webhooks.Inputs;

public class JobStatusUpdatedInput
{
[Display("Status codes"), DataSource(typeof(JobStatuses))]
[Display("Status codes"), StaticDataSource(typeof(JobStatusDataHandler))]
public IEnumerable<string>? StatusCodes { get; set; }

[Display("Job ID"), DataSource(typeof(JobDataSourceHandler))]
Expand Down
3 changes: 2 additions & 1 deletion Apps.Lionbridge/Webhooks/Inputs/RequestStatusUpdatedInput.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Apps.Lionbridge.DataSourceHandlers.EnumDataHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;

namespace Apps.Lionbridge.Webhooks.Inputs;

public class RequestStatusUpdatedInput
{
[Display("Status codes"), DataSource(typeof(RequestStatuses))]
[Display("Status codes"), StaticDataSource(typeof(RequestStatusDataHandler))]
public IEnumerable<string>? StatusCodes { get; set; }
}

0 comments on commit af8d64e

Please sign in to comment.