Skip to content

Commit

Permalink
Added type input
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii-bezuhlyi committed Jun 18, 2024
1 parent 318f3d6 commit efcff37
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Apps.Crowdin/Actions/FileActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public async Task<FileEntity> AddFile(
DirectoryId = intDirectoryId,
Title = input.Title,
ExcludedTargetLanguages = input.ExcludedTargetLanguages?.ToList(),
AttachLabelIds = input.AttachLabelIds?.ToList()
AttachLabelIds = input.AttachLabelIds?.ToList(),
Type = input.Type == null
? ProjectFileType.Auto
: int.TryParse(input.Type, out var type)
? (ProjectFileType)type
: ProjectFileType.Auto
};

var file = await client.AddFileAsync(intProjectId!.Value, request);
Expand Down
77 changes: 77 additions & 0 deletions Apps.Crowdin/DataSourceHandlers/EnumHandlers/TypeDataSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Blackbird.Applications.Sdk.Common.Dictionaries;

namespace Apps.Crowdin.DataSourceHandlers.EnumHandlers;

public class TypeDataSource : IStaticDataSourceHandler
{
public Dictionary<string, string> GetData()
{
return new()
{
{ "0", "auto" },
{ "1", "android" },
{ "2", "macosx" },
{ "3", "resx" },
{ "4", "properties" },
{ "5", "gettext" },
{ "6", "yaml" },
{ "7", "php" },
{ "8", "json" },
{ "9", "fjs" },
{ "10", "xml" },
{ "11", "ini" },
{ "12", "rc" },
{ "13", "resw" },
{ "14", "resjson" },
{ "15", "qtts" },
{ "16", "joomla" },
{ "17", "chrome" },
{ "18", "react_intl" },
{ "19", "dtd" },
{ "20", "dklang" },
{ "21", "flex" },
{ "22", "nsh" },
{ "23", "wxl" },
{ "24", "xliff" },
{ "25", "xliff_two" },
{ "26", "html" },
{ "27", "haml" },
{ "28", "txt" },
{ "29", "csv" },
{ "30", "md" },
{ "31", "mdx_v1" },
{ "32", "mdx_v2" },
{ "33", "flsnp" },
{ "34", "fm_html" },
{ "35", "fm_md" },
{ "36", "mediawiki" },
{ "37", "docx" },
{ "38", "sbv" },
{ "39", "properties_play" },
{ "40", "properties_xml" },
{ "41", "maxthon" },
{ "42", "go_json" },
{ "43", "dita" },
{ "44", "mif" },
{ "45", "idml" },
{ "46", "stringsdict" },
{ "47", "plist" },
{ "48", "vtt" },
{ "49", "vdf" },
{ "50", "srt" },
{ "51", "stf" },
{ "52", "toml" },
{ "53", "contentful_rt" },
{ "54", "svg" },
{ "55", "js" },
{ "56", "coffee" },
{ "57", "ts" },
{ "58", "fbt" },
{ "59", "i18next_json" },
{ "60", "xaml" },
{ "61", "arb" },
{ "62", "adoc" },
{ "63", "webxml" }
};
}
}
7 changes: 6 additions & 1 deletion Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Blackbird.Applications.Sdk.Common;
using Apps.Crowdin.DataSourceHandlers.EnumHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Files;

namespace Apps.Crowdin.Models.Request.File;
Expand All @@ -20,4 +22,7 @@ public class AddNewFileRequest

[Display("Attach label IDs")]
public IEnumerable<int>? AttachLabelIds { get; set; }

[Display("Type", Description = "File type, by default: auto"), StaticDataSource(typeof(TypeDataSource))]
public string? Type { get; set; }
}

0 comments on commit efcff37

Please sign in to comment.