Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
using Ginger.ValidationRules;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace Ginger.Configurations
{
Expand Down Expand Up @@ -62,6 +63,20 @@ private void SetControls()
GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xActivityTagsCheckBox, CheckBox.IsCheckedProperty, _VRTConfiguration, nameof(VRTConfiguration.ActivityTags));

ApplyValidationRules();

if (!string.IsNullOrEmpty(_VRTConfiguration.ApiKey))
{
xAPIKeyTextBox.ValueTextBox.AddValidationRule(new ValidateEmptyValue("API Key cannot be empty"));

// Now that validation is attached, remove the binding so the real key won't show
BindingOperations.ClearBinding(xAPIKeyTextBox.ValueTextBox, TextBox.TextProperty);

// Show a generic mask; don't leak length
const string masked = "••••••••••••••••••••";
Comment thread
ravirk91 marked this conversation as resolved.
xAPIKeyTextBox.ValueTextBox.Text = masked;
xAPIKeyTextBox.ValueTextBox.Tag = masked; // remember the mask marker
Comment thread
ravirk91 marked this conversation as resolved.
}
Comment thread
tanushahande2003 marked this conversation as resolved.
Comment thread
ravirk91 marked this conversation as resolved.

}

private void ApplyValidationRules()
Expand All @@ -87,6 +102,23 @@ private void CallVRTConfigPropertyChange()

private void xSaveButton_Click(object sender, RoutedEventArgs e)
{
// Preserve existing key unless user edited the field
var apiKeyBox = xAPIKeyTextBox.ValueTextBox;
string masked = apiKeyBox.Tag as string;

if (!string.IsNullOrEmpty(masked) && !string.Equals(apiKeyBox.Text, masked))
{
if (string.IsNullOrWhiteSpace(apiKeyBox.Text))
{
Reporter.ToLog(eLogLevel.ERROR, "API Key cannot be empty");
apiKeyBox.Text = masked;
return;
}
_VRTConfiguration.ApiKey = apiKeyBox.Text; // assign new key
apiKeyBox.Text = masked; // re-mask after save
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
// else: field untouched or no mask in use -> keep existing _VRTConfiguration.ApiKey

WorkSpace.Instance.Solution.SolutionOperations.SaveSolution(true, SolutionGeneral.Solution.eSolutionItemToSave.LoggerConfiguration);
Comment thread
tanushahande2003 marked this conversation as resolved.
Comment thread
tanushahande2003 marked this conversation as resolved.
}

Expand Down
Loading