-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
585 additions
and
280 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
Snyk.VisualStudio.Extension.2022/Settings/ISnykCliOptionsDialogPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Snyk.VisualStudio.Extension.Service; | ||
|
||
namespace Snyk.VisualStudio.Extension.Settings; | ||
|
||
public interface ISnykCliOptionsDialogPage | ||
{ | ||
void Initialize(ISnykServiceProvider provider); | ||
} |
72 changes: 72 additions & 0 deletions
72
Snyk.VisualStudio.Extension.2022/Settings/SnykCliOptionsDialogPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Windows.Forms; | ||
using Microsoft.VisualStudio.Shell; | ||
using Snyk.VisualStudio.Extension.Service; | ||
|
||
namespace Snyk.VisualStudio.Extension.Settings; | ||
|
||
[Guid("D1D89CEB-7691-4A67-8579-4C3DDE776982")] | ||
[ComVisible(true)] | ||
public class SnykCliOptionsDialogPage : DialogPage, ISnykCliOptionsDialogPage | ||
{ | ||
private SnykCliOptionsUserControl snykCliOptionsUserControl; | ||
private ISnykServiceProvider serviceProvider; | ||
|
||
public void Initialize(ISnykServiceProvider provider) | ||
{ | ||
this.serviceProvider = provider; | ||
this.SnykOptions = provider.Options; | ||
} | ||
|
||
public ISnykOptions SnykOptions { get; set; } | ||
|
||
protected override IWin32Window Window => SnykCliOptionsUserControl; | ||
public SnykCliOptionsUserControl SnykCliOptionsUserControl | ||
{ | ||
get | ||
{ | ||
if (snykCliOptionsUserControl == null) | ||
{ | ||
snykCliOptionsUserControl = new SnykCliOptionsUserControl(serviceProvider); | ||
} | ||
return snykCliOptionsUserControl; | ||
} | ||
} | ||
|
||
// This method is used when the user clicks "Ok" | ||
public override void SaveSettingsToStorage() | ||
{ | ||
HandleCliDownload(); | ||
this.SnykOptions.SaveSettings(); | ||
this.SnykOptions.InvokeSettingsChangedEvent(); | ||
} | ||
|
||
protected override void OnClosed(EventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private void HandleCliDownload() | ||
{ | ||
var releaseChannel = SnykCliOptionsUserControl.GetReleaseChannel().Trim(); | ||
var downloadUrl = SnykCliOptionsUserControl.GetCliDownloadUrl().Trim(); | ||
var manageBinariesAutomatically = SnykCliOptionsUserControl.GetManageBinariesAutomatically(); | ||
if (!manageBinariesAutomatically) | ||
{ | ||
this.SnykOptions.CurrentCliVersion = string.Empty; | ||
this.SnykOptions.BinariesAutoUpdate = false; | ||
serviceProvider.TasksService.CancelDownloadTask(); | ||
// Language Server restart will happen on DownloadCancelled Event. | ||
return; | ||
} | ||
if (this.SnykOptions.CliReleaseChannel != releaseChannel || this.SnykOptions.CliDownloadUrl != downloadUrl || this.SnykOptions.BinariesAutoUpdate != manageBinariesAutomatically) | ||
{ | ||
this.SnykOptions.CliDownloadUrl = downloadUrl; | ||
this.SnykOptions.CliReleaseChannel = releaseChannel; | ||
this.SnykOptions.BinariesAutoUpdate = manageBinariesAutomatically; | ||
serviceProvider.TasksService.CancelDownloadTask(); | ||
this.serviceProvider.TasksService.Download(); | ||
} | ||
} | ||
} |
238 changes: 238 additions & 0 deletions
238
Snyk.VisualStudio.Extension.2022/Settings/SnykCliOptionsUserControl.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.