Skip to content

Commit

Permalink
Ver 1.4.7: Careful cleaning auth/model/glossary when provider changed
Browse files Browse the repository at this point in the history
  • Loading branch information
antonchi committed Sep 9, 2019
1 parent ccd0509 commit dd64d45
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ApiKeyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Intento.MT.Plugin.PropertiesForm
public class ApiKeyState : BaseState
{
public string apiKey;

// Controlled components
public SmartRoutingState smartRoutingState;

public enum EApiKeyStatus
Expand Down
13 changes: 13 additions & 0 deletions AuthState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
5 changes: 5 additions & 0 deletions GlossaryState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,10 @@ public static void FillOptions(GlossaryState state, IntentoMTFormOptions options
}
}

public static void ClearOptions(IntentoMTFormOptions options)
{
options.Glossary = null;
}

}
}
6 changes: 6 additions & 0 deletions ModelState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,11 @@ public static void FillOptions(ModelState state, IntentoMTFormOptions options)
}
}

public static void ClearOptions(IntentoMTFormOptions options)
{
options.UseCustomModel = false;
options.CustomModel = null;
}

}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
7 changes: 7 additions & 0 deletions ProviderState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ProviderState : BaseState
{
public SmartRoutingState smartRoutingState;

// Controlled components
public AuthState authState;

List<dynamic> providersRaw;
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions RevisionHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
}
6 changes: 5 additions & 1 deletion SmartRoutingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dd64d45

Please sign in to comment.