Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add popup with choice of Accept or Won't Fix #5046

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

ugras-ergun-sonarsource
Copy link
Contributor

Fixes #5032

@ugras-ergun-sonarsource ugras-ergun-sonarsource marked this pull request as ready for review November 24, 2023 09:54
@ugras-ergun-sonarsource
Copy link
Contributor Author

Functional logic will be added in another ticket.

@georgii-borovinskikh-sonarsource georgii-borovinskikh-sonarsource changed the base branch from master to feature/mute-server-issues November 24, 2023 09:58
@@ -59,11 +59,13 @@
<None Remove="Connection\UI\OrganizationSelectionWindow.xaml" />
<None Remove="Notifications\NotificationIndicator.xaml" />
<None Remove="Progress\ProgressControl.xaml" />
<None Remove="Muting\MuteWindowDialog.xaml" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use the term Muting. Transition/Change status should be more appropriate

@@ -0,0 +1,60 @@
<vsui:DialogWindow x:Class="SonarLint.VisualStudio.Integration.Muting.MuteWindowDialog"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A screenshot would be nice to attach


<Border BorderBrush="Black" Name="BorderAccept" BorderThickness="1" HorizontalAlignment="Left" Height="75" Margin="25,25,0,0" VerticalAlignment="Top" Width="450" Visibility="{Binding AcceptVisibility}">
<Grid>
<RadioButton Name="rbAccept" GroupName="Transitions" Content="Accept" VerticalAlignment="Top" Margin="10,16,-10,0" FontWeight="Bold" Grid.ColumnSpan="2" Checked="RadioButton_Checked"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the text of the button, instead of creating hidden buttons is less confusing and more maintainable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, I believe this way it's more obvious what's happening. We create a logical separation of different transitions. Using the same control for two different conditions would be more confusing IMHO.

<Border BorderBrush="Black" Name="BorderAccept" BorderThickness="1" HorizontalAlignment="Left" Height="75" Margin="25,25,0,0" VerticalAlignment="Top" Width="450" Visibility="{Binding AcceptVisibility}">
<Grid>
<RadioButton Name="rbAccept" GroupName="Transitions" Content="Accept" VerticalAlignment="Top" Margin="10,16,-10,0" FontWeight="Bold" Grid.ColumnSpan="2" Checked="RadioButton_Checked"/>
<Label Content="The issue is valid but does not need fixing. It represents accepted technical debt." HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content should be in the resource file, IMO

<Label Content="The issue is raised unxpectedly on code that should not trigger an issue." HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
</Grid>
</Border>
<Label Content="Add a comment (optional):" HorizontalAlignment="Left" Margin="25,200,0,0" VerticalAlignment="Top"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SLI window had some formatting info in below the text box. We should at least add a ticket for that feature.


private void NewMethod(bool showAccept)
{
BorderWontFix.Visibility = showAccept ? Visibility.Hidden : Visibility.Visible;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my point about hidden buttons above

NewMethod(showAccept);
}

private void NewMethod(bool showAccept)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewMethod

/// Interaction logic for UserControl1.xaml
/// </summary>
[ContentProperty(nameof(MuteWindowDialog))]
[ExcludeFromCodeCoverage]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI Code not testable

@ugras-ergun-sonarsource
Copy link
Contributor Author

image

<value>Mark Issue as Resolved on SonarQube</value>
</data>
<data name="MuteWindow_WontFixContent" xml:space="preserve">
<value>The issue is valid but does not need fixing. It represents accepted technical debt.</value>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same content as Accept 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'll talk about it with Marco during the meet


<Border BorderBrush="Black" Name="BorderAccept" BorderThickness="1" HorizontalAlignment="Left" Height="75" Margin="25,25,0,0" VerticalAlignment="Top" Width="450" Visibility="{Binding AcceptVisibility}">
<Grid>
<RadioButton Name="rbAccept" GroupName="Transitions" Content="{x:Static resx:Strings.MuteWindow_AcceptTitle}" VerticalAlignment="Top" Margin="10,16,-10,0" FontWeight="Bold" Grid.ColumnSpan="2" Checked="RadioButton_Checked"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Radio button stye (and possibly others) is duplicated.

,115,0,0" VerticalAlignment="Top" Width="450">
<Grid>
<RadioButton x:Name="rbFalsePositive" GroupName="Transitions" Content="{x:Static resx:Strings.MuteWindow_FalsePositiveTitle}" VerticalAlignment="Top" Margin="10,16,-10,0" FontWeight="Bold" Grid.ColumnSpan="2" Checked="RadioButton_Checked"/>
<Label Content="{x:Static resx:Strings.MuteWindow_FalsePositiveContent}" HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style duplication

{
switch (sender)
{
case var value when value == rbWontFix:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocker: Could be replaced with a dictionary that would look nicer

<Label Content="{x:Static resx:Strings.MuteWindow_CommentLabel}" HorizontalAlignment="Left" Margin="25,200,0,0" VerticalAlignment="Top"/>
<TextBox Name="txtComment" HorizontalAlignment="Center" Height="60" Margin="0,225,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="450"/>
<Button Name="Cancel" Content="{x:Static resx:Strings.MuteWindow_CancelButton}" Padding="5,1" HorizontalAlignment="Left" Margin="300,300,0,0" VerticalAlignment="Top" Click="Cancel_Click"/>
<Button Name="Submit" Content="{x:Static resx:Strings.MuteWindow_SubmitButton}" Padding="5,1" HorizontalAlignment="Left" Margin="360,300,0,0" VerticalAlignment="Top" Click="Submit_Click">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style is not duplicated, however, it's hard to read

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually it is duplicated from the Cancel button

<TextBox Name="txtComment" HorizontalAlignment="Center" Height="60" Margin="0,225,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="450"/>
<Button Name="Cancel" Content="{x:Static resx:Strings.MuteWindow_CancelButton}" Padding="5,1" HorizontalAlignment="Left" Margin="300,300,0,0" VerticalAlignment="Top" Click="Cancel_Click"/>
<Button Name="Submit" Content="{x:Static resx:Strings.MuteWindow_SubmitButton}" Padding="5,1" HorizontalAlignment="Left" Margin="360,300,0,0" VerticalAlignment="Top" Click="Submit_Click">
<Button Name="Cancel" Content="{x:Static resx:Strings.MuteWindow_CancelButton}" Style="{StaticResource ButtonStyle}" Margin="300,300,0,0" Click="Cancel_Click"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these margins not part of the style definition? Btw you can also inherit styles and override certain properties in style definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

margins are different in each component

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define style as (I don't remember wpf syntax, so I will explain this with C# objects :-) )

style AcceptButton : GenericButton
{
override Margin Margin = "1, 2, 3, 4"
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting a property in a common place for only one component does not make sense.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. You separate styling from layout. Easier to read, easier to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a property and overriding it later create more noise IMO. Another solution would be creating a common style and child styles for each specific component based on the common one. Which would be an overkill in this situation just makes reading code harder.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but now you have styling split between the style resources and the layout elements, which is IMO more confusing and harder to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussing this takes more time than changing and I do not feel strongly about it so done.

<Label Content="{x:Static resx:Strings.MuteWindow_FalsePositiveContent}" Style="{StaticResource TransitionLabelStyle}" />
</Grid>
</Border>
<Label Content="{x:Static resx:Strings.MuteWindow_CommentLabel}" Style="{StaticResource LabelStyle}" Margin="25,200,0,0"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LabelStyle is only used once, margin can be moved there

</Grid>
</Border>
<Label Content="{x:Static resx:Strings.MuteWindow_CommentLabel}" Style="{StaticResource LabelStyle}" Margin="25,200,0,0"/>
<TextBox Name="txtComment" HorizontalAlignment="Center" Height="60" Margin="0,225,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="450"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Styles in the layout

</Grid>
</Border>

<Border Name="BorderAccept" Style="{StaticResource BorderStyle}" Margin="25,25,0,0" Visibility="{Binding AcceptVisibility}">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This margin value is used twice. There's only one BorderStyle instance with a different Mragin value. You can set this one as the default, and override it once at line 75

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ugras-ergun-sonarsource ugras-ergun-sonarsource merged commit 45a093a into feature/mute-server-issues Nov 24, 2023
4 checks passed
@ugras-ergun-sonarsource ugras-ergun-sonarsource deleted the ue/add-window branch November 24, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add popup with choice of Accept or Won't Fix
2 participants