Skip to content

Commit

Permalink
Merge pull request #231 from Checkmarx/bug/disableScanStartBtn
Browse files Browse the repository at this point in the history
Disable scan start button if not selected Project and Branch (AST-79348)
  • Loading branch information
sarahCx authored Dec 31, 2024
2 parents f577dab + 0f01b6f commit 2fead48
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public async Task LoadBranchesAsync(string projectId)
/// <param name="e"></param>
public void OnChangeBranch(object sender, SelectionChangedEventArgs e)
{
if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) return;
if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1)
{
cxToolbar.CheckScanButtonStateByCombos();
return;
}

ResetFilteringState(branchesCombo.SelectedItem as ComboBoxItem);

Expand All @@ -118,7 +122,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e)

_ = scansCombobox.LoadScansAsync(projectId, selectedBranch);

cxToolbar.ScanButtonByCombos();
cxToolbar.CheckScanButtonStateByCombos();
}
protected override void ResetOthersComboBoxesAndResults()
{
Expand Down
12 changes: 6 additions & 6 deletions ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void Init()
control.IsChecked = readOnlyStore.GetBoolean(SettingsUtils.groupByCollection, groupBy.ToString(), SettingsUtils.groupByDefaultValues[groupBy]);
}

ScanButtonByCombos();
CheckScanButtonStateByCombos();

_ = IdeScansEnabledAsync();

Expand Down Expand Up @@ -311,11 +311,11 @@ private static async Task<bool> ASTProjectMatchesWorkspaceProjectAsync(EnvDTE.DT
return false;
}

public void ScanButtonByCombos()
public void CheckScanButtonStateByCombos()
{
var projectId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.projectIdProperty);
var branch = SettingsUtils.GetToolbarValue(Package, SettingsUtils.branchProperty);
ScanStartButton.IsEnabled = !(string.IsNullOrEmpty(projectId) || string.IsNullOrEmpty(branch));
var isProject = ProjectsCombo?.SelectedItem != null && ProjectsCombo.SelectedIndex != -1;
var isBranch = BranchesCombo?.SelectedItem != null && BranchesCombo.SelectedIndex != -1;
ScanStartButton.IsEnabled = isProject && isBranch;
}

private async Task IdeScansEnabledAsync()
Expand Down Expand Up @@ -410,7 +410,7 @@ private async Task PollScanStartedAsync()
var scanId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.createdScanIdProperty);
if (string.IsNullOrWhiteSpace(scanId))
{
ScanStartButton.IsEnabled = true;
CheckScanButtonStateByCombos();
return;
};
var options = default(TaskHandlerOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ private async Task LoadProjectsComboboxAsync()
public void OnChangeProject(object sender, SelectionChangedEventArgs e)
{
ComboBox projectsCombo = cxToolbar.ProjectsCombo;
if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) return;
if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1)
{
cxToolbar.CheckScanButtonStateByCombos();
return;
}


ResetFilteringState(projectsCombo.SelectedItem as ComboBoxItem);
Expand All @@ -168,7 +172,7 @@ public void OnChangeProject(object sender, SelectionChangedEventArgs e)

_ = branchesCombobox.LoadBranchesAsync(selectedProject);

cxToolbar.ScanButtonByCombos();
cxToolbar.CheckScanButtonStateByCombos();
}

protected override void ResetOthersComboBoxesAndResults()
Expand Down

0 comments on commit 2fead48

Please sign in to comment.