Skip to content

Commit 83a2c12

Browse files
authored
fix: keep auto-org enabled [IDE-1703] (#436)
fix: keep auto-org enabled Also update the HTML button styles.
1 parent 70a7a42 commit 83a2c12

3 files changed

Lines changed: 63 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### Changed
55
- Added support for improved Settings UI for simpler configuration of Snyk settings (experimental).
66
- Automatic organization configuration is now enabled by default.
7+
- Added support for risk score filtering (closed beta).
78
- Bump LS protocol version to 22.
89

910
## [2.6.0]

Snyk.VisualStudio.Extension.2022/Settings/SnykGeneralOptionsDialogPage.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@ private async Task HandleSolutionOptionsConfigurationAsync()
118118
// Implement logic for organization
119119
// Use UI state instead of reading from database to get current user intent
120120
var isAutoMode = control.IsAutoOrganizationChecked;
121-
var preferredOrganizationText = control.Organization;
121+
var organizationText = control.Organization;
122122

123123
await this.serviceProvider.SnykOptionsManager.SaveOrgSetByUserAsync(!isAutoMode);
124-
await this.serviceProvider.SnykOptionsManager.SavePreferredOrgAsync(preferredOrganizationText);
124+
if (!isAutoMode)
125+
await this.serviceProvider.SnykOptionsManager.SavePreferredOrgAsync(organizationText);
126+
else
127+
await this.serviceProvider.SnykOptionsManager.SaveAutoDeterminedOrgAsync(organizationText);
125128
await this.UpdateFolderConfigForCurrentSolutionAsync();
126129
}
127130

Snyk.VisualStudio.Extension.2022/UI/Html/BaseHtmlProvider.cs

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ public virtual string ReplaceCssVariables(string html)
6262
var editorBackground = backgroundColor;
6363
var editorForeground = textColor;
6464

65-
// Buttons - use command bar colors which are designed for interactive elements
65+
// Primary buttons - use hyperlink color for a prominent blue appearance
66+
var primaryButtonBackground = linkColor;
67+
var primaryButtonForeground = "#FFFFFF";
68+
var primaryButtonHoverBackground = AdjustBrightness(primaryButtonBackground, 1.15f);
69+
70+
// Secondary buttons - use input background for visible contrast with main background
71+
var secondaryButtonBackground = inputBackground;
72+
var secondaryButtonForeground = textColor;
73+
var secondaryButtonHoverBackground = AdjustBrightness(secondaryButtonBackground, 1.15f);
74+
75+
// Legacy vscode- prefixed button variables (kept for compatibility)
6676
var buttonBackground = VSColorTheme.GetThemedColor(EnvironmentColors.CommandBarMenuBackgroundGradientBeginColorKey).ToHex();
6777
var buttonText = textColor;
6878
var buttonHoverBackground = VSColorTheme.GetThemedColor(EnvironmentColors.CommandBarMouseOverBackgroundBeginColorKey).ToHex();
@@ -97,19 +107,27 @@ public virtual string ReplaceCssVariables(string html)
97107
{ "vscode-errorForeground", errorForeground },
98108
{ "vscode-input-background", inputBackground },
99109
{ "vscode-editor-inactiveSelectionBackground", inactiveSelectionBackground },
100-
{ "vscode-button-background", buttonBackground },
101-
{ "vscode-button-foreground", buttonText },
102-
{ "vscode-button-hoverBackground", buttonHoverBackground },
103-
{ "vscode-button-secondaryBackground", ColorToRgba(buttonBackground, 0.6) },
104-
{ "vscode-button-secondaryForeground", buttonText },
105-
{ "vscode-button-secondaryHoverBackground", ColorToRgba(buttonHoverBackground, 0.7) },
106110
{ "vscode-list-hoverBackground", listHoverBackground },
107111
{ "vscode-input-border", inputBorder },
108112
{ "vscode-panel-border", borderColor },
109113
{ "vscode-focusBorder", linkColor },
110114
{ "vscode-scrollbarSlider-background", scrollbarThumb },
111115
{ "vscode-scrollbarSlider-hoverBackground", scrollbarThumbHover },
112116
{ "vscode-scrollbarSlider-activeBackground", scrollbarThumbHover },
117+
// Button variables (vscode- prefix for legacy compatibility)
118+
{ "vscode-button-background", buttonBackground },
119+
{ "vscode-button-foreground", buttonText },
120+
{ "vscode-button-hoverBackground", buttonHoverBackground },
121+
{ "vscode-button-secondaryBackground", ColorToRgba(buttonBackground, 0.6) },
122+
{ "vscode-button-secondaryForeground", buttonText },
123+
{ "vscode-button-secondaryHoverBackground", ColorToRgba(buttonHoverBackground, 0.7) },
124+
// Button variables (LS HTML uses these without vscode- prefix)
125+
{ "button-background-color", primaryButtonBackground },
126+
{ "button-foreground", primaryButtonForeground },
127+
{ "button-hover-background", primaryButtonHoverBackground },
128+
{ "button-secondary-background", secondaryButtonBackground },
129+
{ "button-secondary-foreground", secondaryButtonForeground },
130+
{ "button-secondary-hover-background", secondaryButtonHoverBackground },
113131
// Legacy variables (for fallback HTML)
114132
{ "default-font", "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif" },
115133
{ "text-color", textColor },
@@ -165,5 +183,37 @@ private string ColorToRgba(string hexColor, double alpha)
165183
int b = Convert.ToInt32(hexColor.Substring(4, 2), 16);
166184
return $"rgba({r}, {g}, {b}, {alpha:F2})";
167185
}
186+
187+
/// <summary>
188+
/// Adjusts the brightness of a hex color by a given factor.
189+
/// </summary>
190+
/// <param name="hexColor">The hex color string (e.g., "#0e639c")</param>
191+
/// <param name="factor">Brightness multiplier (> 1.0 for lighter, < 1.0 for darker)</param>
192+
/// <returns>Adjusted hex color string</returns>
193+
private string AdjustBrightness(string hexColor, float factor)
194+
{
195+
if (string.IsNullOrEmpty(hexColor) || !hexColor.StartsWith("#"))
196+
{
197+
return hexColor;
198+
}
199+
200+
try
201+
{
202+
var hex = hexColor.Substring(1);
203+
int r = Convert.ToInt32(hex.Substring(0, 2), 16);
204+
int g = Convert.ToInt32(hex.Substring(2, 2), 16);
205+
int b = Convert.ToInt32(hex.Substring(4, 2), 16);
206+
207+
r = Math.Min(255, Math.Max(0, (int)(r * factor)));
208+
g = Math.Min(255, Math.Max(0, (int)(g * factor)));
209+
b = Math.Min(255, Math.Max(0, (int)(b * factor)));
210+
211+
return $"#{r:X2}{g:X2}{b:X2}";
212+
}
213+
catch
214+
{
215+
return hexColor;
216+
}
217+
}
168218
}
169219
}

0 commit comments

Comments
 (0)