Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -557,7 +557,7 @@
</UniformGrid>

<UniformGrid Rows="1" Columns="1">
<TextBox Text="Comment (Optional)" Name="TriageComment" Margin="5,5,5,0" Height="50" TextWrapping="WrapWithOverflow" GotFocus="OnFocusComment" LostFocus="OnLostFocusComment"/>
<TextBox Text="Note (Optional or required based on tenant configuration)" Name="TriageComment" Margin="5,5,5,0" Height="50" TextWrapping="WrapWithOverflow" GotFocus="OnFocusComment" LostFocus="OnLostFocusComment"/>
</UniformGrid>

<!-- Description and Changes tabs -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class CxConstants
public static string TOOLBAR_LOADING_SCANS => "Loading scans...";

/************ TRIAGE ************/
public static string TRIAGE_COMMENT_PLACEHOLDER => "Comment (Optional)";
public static string TRIAGE_COMMENT_PLACEHOLDER => "Note (Optional or required based on tenant configuration)";
public static string TRIAGE_UPDATE_FAILED => "Triage Update failed. {0}";
public static string TRIAGE_SHOW_FAILED => "Triage Show failed. {0}";
public static string TRIAGE_LOADING_CHANGES => "Loading changes...";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public static List<TreeViewItem> FilterAndGroupResults(AsyncPackage package, Lis

var isDevOrTestSelected = stateManager.enabledCustemStates.Contains("SCA Dev & Test Dependencies");
enabledGroupBys.Insert(0, GroupBy.ENGINE);

// Dictionary to store group headers and counts
var groupNodeCounts = new Dictionary<TreeViewItem, int>();

foreach (TreeViewItem item in results)
{
var result = item.Tag as Result;
Expand Down Expand Up @@ -51,33 +55,43 @@ public static List<TreeViewItem> FilterAndGroupResults(AsyncPackage package, Lis
continue;
}

List<TreeViewItem> children = GetInsertLocation(enabledGroupBys, treeResults, result);
List<TreeViewItem> children = GetInsertLocation(enabledGroupBys, treeResults, result, groupNodeCounts);

children.Add(item);
}

// Update group headers with counts
foreach (var kvp in groupNodeCounts)
{
var headerBlock = kvp.Key.Header as TextBlock;
if (headerBlock != null)
{
string baseLabel = (headerBlock.Tag as string).Replace("_", " ");
string labelWithCount = $"{baseLabel} ({kvp.Value})";

// Replace the existing header with a new TextBlock
kvp.Key.Header = UIUtils.CreateTreeViewItemHeader(string.Empty, labelWithCount);
kvp.Key.ToolTip = $"{baseLabel}";
}
}


return treeResults;
}

private static List<TreeViewItem> GetInsertLocation(List<GroupBy> enabledGroupBys, List<TreeViewItem> treeResults, Result result)
private static List<TreeViewItem> GetInsertLocation(List<GroupBy> enabledGroupBys, List<TreeViewItem> treeResults, Result result, Dictionary<TreeViewItem, int> groupNodeCounts)
{
var children = treeResults;
foreach (GroupBy groupBy in enabledGroupBys)
{
var generator = GetGroupByTitleGenerator(groupBy);
if (generator == null)
{
continue;
}
if (generator == null) continue;

var childNodeName = GetGroupByTitleGenerator(groupBy).Invoke(result);
if (childNodeName == null)
{
continue;
}
if (childNodeName == null) continue;

// single underscore is used as mnemonic
childNodeName = childNodeName.Replace("_", "__");
childNodeName = childNodeName.Replace("_", " ");

TreeViewItem child = null;

Expand All @@ -93,6 +107,12 @@ private static List<TreeViewItem> GetInsertLocation(List<GroupBy> enabledGroupBy
child = UIUtils.CreateTreeViewItemWithItemsSource(childNodeName, new List<TreeViewItem> { new TreeViewItem() });
(child.ItemsSource as List<TreeViewItem>).Clear();
children.Add(child);
groupNodeCounts[child] = 0; // initialize count
}
// Increment count for this group node
if (groupNodeCounts.ContainsKey(child))
{
groupNodeCounts[child]++;
}
children = child.ItemsSource as List<TreeViewItem>;
}
Expand Down
4 changes: 2 additions & 2 deletions ast-visual-studio-extension/CxExtension/Utils/UIUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static TextBlock CreateTreeViewItemHeader(string severity, string display

Label resultDisplayName = new Label
{
Content = displayName
Content = displayName.Replace("_", " ")
};
stackPanel.Children.Add(resultDisplayName);

Expand All @@ -60,7 +60,7 @@ public static TextBlock CreateTreeViewItemHeader(string severity, string display
resultUIElement.Inlines.Add(uiContainer);
resultUIElement.Tag = displayName;
resultUIElement.TextWrapping = TextWrapping.WrapWithOverflow;

if (!string.IsNullOrEmpty(severity)) resultUIElement.ToolTip = displayName.Replace("_" ," ");
return resultUIElement;
}

Expand Down
Loading