Skip to content

Commit

Permalink
fix: refactor Net new issues
Browse files Browse the repository at this point in the history
  • Loading branch information
acke committed Sep 3, 2024
1 parent 5075e67 commit 0b97f76
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import io.snyk.plugin.ui.SnykSettingsDialog
import snyk.common.lsp.LanguageServerWrapper
import javax.swing.JComponent

class SnykProjectSettingsConfigurable(
open class SnykProjectSettingsConfigurable(
val project: Project,
) : SearchableConfigurable {
private val settingsStateService
Expand Down Expand Up @@ -118,7 +118,7 @@ class SnykProjectSettingsConfigurable(
}

if (snykSettingsDialog.isNetNewIssuesSelected() != pluginSettings().netNewIssues) {
handleNetNewIssuesChanged()
settingsStateService.netNewIssues = snykSettingsDialog.isNetNewIssuesSelected()
}

LanguageServerWrapper.getInstance().updateConfiguration()
Expand Down Expand Up @@ -162,10 +162,6 @@ class SnykProjectSettingsConfigurable(
)
}

private fun handleNetNewIssuesChanged() {
settingsStateService.netNewIssues = snykSettingsDialog.isNetNewIssuesSelected()
}

private fun isTokenModified(): Boolean = snykSettingsDialog.getToken() != settingsStateService.token

private fun isCustomEndpointModified(): Boolean =
Expand Down
12 changes: 8 additions & 4 deletions src/main/kotlin/io/snyk/plugin/ui/SnykSettingsDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class SnykSettingsDialog(
}

private fun initializeUiComponents() {
rootPanel.layout = UIGridLayoutManager(11, 1, JBUI.emptyInsets(), -1, -1)
rootPanel.layout = UIGridLayoutManager(10, 1, JBUI.emptyInsets(), -1, -1)

/** General settings ------------------ */

Expand Down Expand Up @@ -574,9 +574,13 @@ class SnykSettingsDialog(
newNewIssuesLabel.labelFor = netNewIssuesDropDown
projectSettingsPanel.add(
newNewIssuesLabel,
baseGridConstraintsAnchorWest(
baseGridConstraints(
row = 5,
column = 0,
anchor = UIGridConstraints.ANCHOR_WEST,
hSizePolicy = UIGridConstraints.SIZEPOLICY_CAN_SHRINK,
colSpan = 1,
indent = 0,
),
)

Expand All @@ -603,7 +607,7 @@ class SnykSettingsDialog(
rootPanel.add(
userExperiencePanel,
baseGridConstraints(
row = 7,
row = 6,
anchor = UIGridConstraints.ANCHOR_NORTHWEST,
fill = UIGridConstraints.FILL_HORIZONTAL,
hSizePolicy = UIGridConstraints.SIZEPOLICY_CAN_SHRINK or UIGridConstraints.SIZEPOLICY_CAN_GROW,
Expand Down Expand Up @@ -647,7 +651,7 @@ class SnykSettingsDialog(
rootPanel.add(
generalSettingsSpacer,
panelGridConstraints(
row = 6,
row = 5,
),
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/snyk/common/lsp/LanguageServerSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ data class LanguageServerSettings(
@SerializedName("enableSnykOSSQuickFixCodeActions") val enableSnykOSSQuickFixCodeActions: String? = null,
@SerializedName("requiredProtocolVersion") val requiredProtocolVersion: String =
pluginSettings().requiredLsProtocolVersion.toString(),
@SerializedName("enableDeltaFindings") val enableDeltaFindings: String = (pluginSettings().netNewIssues == "Net new issues").toString()
@SerializedName("enableDeltaFindings") val enableDeltaFindings: String = isDeltaFindingsEnabled()
)

private fun isDeltaFindingsEnabled() = (pluginSettings().netNewIssues == "Net new issues").toString()

data class SeverityFilter(
@SerializedName("critical") val critical: Boolean?,
@SerializedName("high") val high: Boolean?,
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/snyk/common/lsp/LanguageServerWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.snyk.plugin.getSnykTaskQueueService
import io.snyk.plugin.getWaitForResultsTimeout
import io.snyk.plugin.isSnykIaCLSEnabled
import io.snyk.plugin.pluginSettings
import io.snyk.plugin.services.SnykApplicationSettingsStateService
import io.snyk.plugin.toLanguageServerURL
import io.snyk.plugin.ui.toolwindow.SnykPluginDisposable
import kotlinx.coroutines.DelicateCoroutinesApi
Expand Down Expand Up @@ -405,11 +406,13 @@ class LanguageServerWrapper(
integrationVersion = pluginInfo.integrationVersion,
authenticationMethod = authMethod,
enableSnykOSSQuickFixCodeActions = "true",
enableDeltaFindings = (ps.netNewIssues == "Net new issues").toString(),

enableDeltaFindings = isDeltaFindingsEnabled(ps),
)
}

private fun isDeltaFindingsEnabled(ps: SnykApplicationSettingsStateService) =
(ps.netNewIssues == "Net new issues").toString()

fun updateConfiguration() {
if (!ensureLanguageServerInitialized()) return
val params = DidChangeConfigurationParams(getSettings())
Expand Down

0 comments on commit 0b97f76

Please sign in to comment.