From efcff37cc63846892dd7a4ba4498fb7f48d9d5dc Mon Sep 17 00:00:00 2001 From: vitalii-bezuhlyi Date: Tue, 18 Jun 2024 13:15:19 +0300 Subject: [PATCH] Added type input --- Apps.Crowdin/Actions/FileActions.cs | 7 +- .../EnumHandlers/TypeDataSource.cs | 77 +++++++++++++++++++ .../Models/Request/File/AddNewFileRequest.cs | 7 +- 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 Apps.Crowdin/DataSourceHandlers/EnumHandlers/TypeDataSource.cs diff --git a/Apps.Crowdin/Actions/FileActions.cs b/Apps.Crowdin/Actions/FileActions.cs index 48759a1..8fd0a77 100644 --- a/Apps.Crowdin/Actions/FileActions.cs +++ b/Apps.Crowdin/Actions/FileActions.cs @@ -85,7 +85,12 @@ public async Task 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); diff --git a/Apps.Crowdin/DataSourceHandlers/EnumHandlers/TypeDataSource.cs b/Apps.Crowdin/DataSourceHandlers/EnumHandlers/TypeDataSource.cs new file mode 100644 index 0000000..6972677 --- /dev/null +++ b/Apps.Crowdin/DataSourceHandlers/EnumHandlers/TypeDataSource.cs @@ -0,0 +1,77 @@ +using Blackbird.Applications.Sdk.Common.Dictionaries; + +namespace Apps.Crowdin.DataSourceHandlers.EnumHandlers; + +public class TypeDataSource : IStaticDataSourceHandler +{ + public Dictionary 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" } + }; + } +} \ No newline at end of file diff --git a/Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs b/Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs index 1eb37f8..9581785 100644 --- a/Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs +++ b/Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs @@ -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; @@ -20,4 +22,7 @@ public class AddNewFileRequest [Display("Attach label IDs")] public IEnumerable? AttachLabelIds { get; set; } + + [Display("Type", Description = "File type, by default: auto"), StaticDataSource(typeof(TypeDataSource))] + public string? Type { get; set; } } \ No newline at end of file