Skip to content

Commit

Permalink
Merge pull request #3759 from Ginger-Automation/BugFix/40328_Timeout_…
Browse files Browse the repository at this point in the history
…DefaultValue

Bug fix/40328 Timeout default value
  • Loading branch information
Maheshkale447 authored Jun 24, 2024
2 parents a1c1f87 + d6c01ad commit 99dc935
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Ginger/Ginger/Actions/ActionEditPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<Label Content="Wait:" Style="{StaticResource $LabelStyle}" />
<Actions:UCValueExpression x:Name="xWaitVeUC" ToolTip="Action will wait this seconds long before start to run" HorizontalAlignment="Stretch" Width="80" />
<Label Content="Timeout:" Style="{StaticResource $LabelStyle}" Margin="10,0,0,0"/>
<TextBox x:Name="xTimeoutTextBox" TextChanged="txtTimeout_TextChanged" ToolTip="Timeout field is in seconds. Default is 30 minutes (1800 seconds). Use 0 for no timeout, allowing actions to run indefinitely. If an action exceeds the specified timeout duration, it will be stopped and marked as failed." Style="{StaticResource @TextBoxStyle}" Width="50" TextAlignment="Center" HorizontalAlignment="Left" />
<TextBox x:Name="xTimeoutTextBox" TextChanged="txtTimeout_TextChanged" PreviewTextInput="xTimeoutTextBox_PreviewTextInput" ToolTip="Timeout field is in seconds. Default is 30 minutes (1800 seconds). Use 0 for no timeout, allowing actions to run indefinitely. If an action exceeds the specified timeout duration, it will be stopped and marked as failed." Style="{StaticResource @TextBoxStyle}" Width="50" TextAlignment="Center" HorizontalAlignment="Left" />
</StackPanel>

<Expander x:Name="xRetryExpander" DockPanel.Dock="Top" Margin="0,10,0,0" ExpandDirection="Down" IsExpanded="False" Style="{StaticResource $ExpanderStyle}">
Expand Down
31 changes: 30 additions & 1 deletion Ginger/Ginger/Actions/ActionEditPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ private void txtTimeout_TextChanged(object sender, TextChangedEventArgs e)
{
if (xTimeoutTextBox.Text == String.Empty || xTimeoutTextBox.Text == null)
{
xTimeoutTextBox.Text = "0";
xTimeoutTextBox.Text = null;
xTimeoutTextBox.CaretIndex = 1;
}
}
Expand Down Expand Up @@ -2242,5 +2242,34 @@ protected override void IsVisibleChangedHandler(object sender, DependencyPropert
base.IsVisibleChangedHandler(sender, e);
}
}

private void xTimeoutTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{

bool isEmptyString = string.IsNullOrEmpty(e.Text);
if (isEmptyString)
{
//allow
e.Handled = false;
return;
}

string currentText = xTimeoutTextBox.Text != null ? xTimeoutTextBox.Text : string.Empty;
bool isValidInteger = int.TryParse(currentText + e.Text, out _);
if (isValidInteger)
{
//allow
e.Handled = false;
return;
}
else
{
//don't allow
e.Handled = true;
}

}


}
}

0 comments on commit 99dc935

Please sign in to comment.