From dd64d45e368074210327abfa67e3ff4cca76f5f2 Mon Sep 17 00:00:00 2001 From: Anton Chizhov Date: Mon, 9 Sep 2019 17:56:36 +0300 Subject: [PATCH] Ver 1.4.7: Careful cleaning auth/model/glossary when provider changed --- ApiKeyState.cs | 2 ++ AuthState.cs | 13 +++++++++++++ GlossaryState.cs | 5 +++++ ModelState.cs | 6 ++++++ Properties/AssemblyInfo.cs | 4 ++-- ProviderState.cs | 7 +++++++ RevisionHistory.cs | 2 ++ SmartRoutingState.cs | 6 +++++- 8 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ApiKeyState.cs b/ApiKeyState.cs index 93f0209..f17c42d 100644 --- a/ApiKeyState.cs +++ b/ApiKeyState.cs @@ -14,6 +14,8 @@ namespace Intento.MT.Plugin.PropertiesForm public class ApiKeyState : BaseState { public string apiKey; + + // Controlled components public SmartRoutingState smartRoutingState; public enum EApiKeyStatus diff --git a/AuthState.cs b/AuthState.cs index d1f512a..2ec7ac9 100644 --- a/AuthState.cs +++ b/AuthState.cs @@ -12,7 +12,10 @@ namespace Intento.MT.Plugin.PropertiesForm { public class AuthState : BaseState { + // Parent component public ProviderState providerState; + + // Controlled components public ModelState modelState; public GlossaryState glossaryState; @@ -180,6 +183,8 @@ public string Draw() form.AuthCombo_ComboBox_BackColor = SystemColors.Window; form.AuthText_TextBox_Text = string.Join(", ", providerDataAuthDict.Select(i => string.Format("{0}:{1}", i.Key, i.Value))); } + if (!string.IsNullOrEmpty(error_message)) + return error_message; error_message = ModelState.Draw(form, modelState); string error_message2 = GlossaryState.Draw(form, glossaryState); @@ -320,5 +325,13 @@ public static void FillOptions(AuthState state, IntentoMTFormOptions options) GlossaryState.FillOptions(state.glossaryState, options); } } + + public static void ClearOptions(IntentoMTFormOptions options) + { + options.UseCustomAuth = false; + options.CustomAuth = null; + ModelState.ClearOptions(options); + GlossaryState.ClearOptions(options); + } } } diff --git a/GlossaryState.cs b/GlossaryState.cs index bfb4531..6da2de3 100644 --- a/GlossaryState.cs +++ b/GlossaryState.cs @@ -143,5 +143,10 @@ public static void FillOptions(GlossaryState state, IntentoMTFormOptions options } } + public static void ClearOptions(IntentoMTFormOptions options) + { + options.Glossary = null; + } + } } diff --git a/ModelState.cs b/ModelState.cs index d774af6..d3bc007 100644 --- a/ModelState.cs +++ b/ModelState.cs @@ -243,5 +243,11 @@ public static void FillOptions(ModelState state, IntentoMTFormOptions options) } } + public static void ClearOptions(IntentoMTFormOptions options) + { + options.UseCustomModel = false; + options.CustomModel = null; + } + } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 5ec66c2..06302de 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.3.0")] -[assembly: AssemblyFileVersion("1.4.3.0")] +[assembly: AssemblyVersion("1.4.7.0")] +[assembly: AssemblyFileVersion("1.4.7.0")] [assembly: IntentoSDK.AssemblyGitHash(Intento.MT.Plugin.PropertiesForm.GitHash.hash)] diff --git a/ProviderState.cs b/ProviderState.cs index 7072bed..df93496 100644 --- a/ProviderState.cs +++ b/ProviderState.cs @@ -16,6 +16,7 @@ public class ProviderState : BaseState { public SmartRoutingState smartRoutingState; + // Controlled components public AuthState authState; List providersRaw; @@ -168,6 +169,12 @@ public void SelectedIndexChanged() } else if (providersNames != null && currentProviderId != providersNames[form.Providers_ComboBox_Text]) { + if (!string.IsNullOrEmpty(currentProviderName)) + { // Prev provider was not empty - need to clear parameters + authState = null; + AuthState.ClearOptions(options); + } + // another provider choosed currentProviderId = providersNames[form.Providers_ComboBox_Text]; providerData = providersData[currentProviderId]; diff --git a/RevisionHistory.cs b/RevisionHistory.cs index c15e869..bc15ef1 100644 --- a/RevisionHistory.cs +++ b/RevisionHistory.cs @@ -41,6 +41,8 @@ class RevisionHistory // - Pre- and Post-processing moved to PluginHelper in Settings form because it is common for all plugins // 1.4.3: 2019-08-23 // - Internal refactoring: IntentoMT namespace changed to Intento.MT + // 1.4.7: 2019-09-09 + // - Careful cleaning auth/model/glossary when provider changed } } diff --git a/SmartRoutingState.cs b/SmartRoutingState.cs index 51082f2..6d62b83 100644 --- a/SmartRoutingState.cs +++ b/SmartRoutingState.cs @@ -9,8 +9,12 @@ namespace Intento.MT.Plugin.PropertiesForm { public class SmartRoutingState : BaseState { - bool smartRouting; + private bool smartRouting; + + // Parent state public ApiKeyState apiKeyState; + + // Controlled components public ProviderState providerState; public SmartRoutingState(ApiKeyState apiKeyState, IntentoMTFormOptions _options) : base(apiKeyState, _options)