diff --git a/domain/ide/workspace/ui/diagnostics_overview.go b/domain/ide/workspace/ui/diagnostics_overview.go index 46dab8a46..2ef115b28 100644 --- a/domain/ide/workspace/ui/diagnostics_overview.go +++ b/domain/ide/workspace/ui/diagnostics_overview.go @@ -129,7 +129,7 @@ func getFileNodes(issuesByFile snyk.IssuesByFile) map[Node][]Node { issueNodes := []Node{} for _, issue := range issues { issueNodes = append(issueNodes, Node{ - Icon: html.GetSeverityIconSvg(issue), + Icon: html.SeverityIcon(issue), Text: template.HTML(issue.AdditionalData.GetTitle()), }) } diff --git a/infrastructure/code/code_html.go b/infrastructure/code/code_html.go index f4a997045..d30eaa2be 100644 --- a/infrastructure/code/code_html.go +++ b/infrastructure/code/code_html.go @@ -91,7 +91,7 @@ func getCodeDetailsHtml(issue snyk.Issue) string { "IssueTitle": additionalData.Title, "IssueMessage": additionalData.Message, "IssueType": getIssueType(additionalData), - "SeverityIcon": html.GetSeverityIconSvg(issue), + "SeverityIcon": html.SeverityIcon(issue), "CWEs": issue.CWEs, "IssueOverview": html.MarkdownToHTML(additionalData.Text), "IsIgnored": issue.IsIgnored, @@ -104,17 +104,17 @@ func getCodeDetailsHtml(issue snyk.Issue) string { "PriorityScore": additionalData.PriorityScore, "SnykWebUrl": config.CurrentConfig().SnykUi(), "LessonUrl": issue.LessonUrl, - "LessonIcon": html.GetLessonIconSvg(), + "LessonIcon": html.LessonIcon(), "IgnoreLineAction": getLineToIgnoreAction(issue), "HasAIFix": additionalData.HasAIFix, - "ExternalIcon": getExternalIconSvg(), - "ScanAnimation": getScanAnimationSvg(), - "GitHubIcon": getGitHubIconSvg(), - "ArrowLeftDark": getArrowLeftDarkSvg(), - "ArrowLeftLight": getArrowLeftLightSvg(), - "ArrowRightDark": getArrowRightDarkSvg(), - "ArrowRightLight": getArrowRightLightSvg(), - "FileIcon": getFileIconSvg(), + "ExternalIcon": html.ExternalIcon(), + "ScanAnimation": html.ScanAnimation(), + "GitHubIcon": html.GitHubIcon(), + "ArrowLeftDark": html.ArrowLeftDark(), + "ArrowLeftLight": html.ArrowLeftLight(), + "ArrowRightDark": html.ArrowRightDark(), + "ArrowRightLight": html.ArrowRightLight(), + "FileIcon": html.FileIcon(), } if issue.IsIgnored { @@ -270,114 +270,3 @@ func formatDate(date time.Time) string { month := date.Format("January") return fmt.Sprintf("%s %d, %d", month, date.Day(), date.Year()) } - -func getFileIconSvg() template.HTML { - return template.HTML(` - `) -} - -func getExternalIconSvg() template.HTML { - return template.HTML(` - - - `) -} - -func getGitHubIconSvg() template.HTML { - return template.HTML(` - - `) -} - -func getScanAnimationSvg() template.HTML { - return template.HTML(` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - `) -} - -func getArrowLeftDarkSvg() template.HTML { - return template.HTML(` - - `) -} - -func getArrowLeftLightSvg() template.HTML { - return template.HTML(` - - `) -} - -func getArrowRightDarkSvg() template.HTML { - return template.HTML(` - - - `) -} - -func getArrowRightLightSvg() template.HTML { - return template.HTML(` - - `) -} diff --git a/infrastructure/oss/issue_html.go b/infrastructure/oss/issue_html.go index 0de912cc1..a04f67eaa 100644 --- a/infrastructure/oss/issue_html.go +++ b/infrastructure/oss/issue_html.go @@ -71,7 +71,7 @@ func getDetailsHtml(issue snyk.Issue) string { "IssueTitle": additionalData.Title, "IssueType": getIssueType(additionalData), "SeverityText": issue.Severity.String(), - "SeverityIcon": html.GetSeverityIconSvg(issue), + "SeverityIcon": html.SeverityIcon(issue), "VulnerableModule": additionalData.Name, "IssueOverview": html.MarkdownToHTML(string(overview)), "CVEs": additionalData.Identifiers.CVE, @@ -81,7 +81,7 @@ func getDetailsHtml(issue snyk.Issue) string { "ExploitMaturity": getExploitMaturity(additionalData), "IntroducedThroughs": getIntroducedThroughs(additionalData), "LessonUrl": additionalData.Lesson, - "LessonIcon": html.GetLessonIconSvg(), + "LessonIcon": html.LessonIcon(), "FixedIn": additionalData.FixedIn, "DetailedPaths": detailedPaths, "MoreDetailedPaths": len(detailedPaths) - 3, diff --git a/internal/html/arrow_icons.go b/internal/html/arrow_icons.go new file mode 100644 index 000000000..627069d02 --- /dev/null +++ b/internal/html/arrow_icons.go @@ -0,0 +1,52 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func ArrowLeftDark() template.HTML { + return template.HTML(` + + `) +} + +func ArrowLeftLight() template.HTML { + return template.HTML(` + + `) +} + +func ArrowRightDark() template.HTML { + return template.HTML(` + + + `) +} + +func ArrowRightLight() template.HTML { + return template.HTML(` + + `) +} diff --git a/internal/html/external_icon.go b/internal/html/external_icon.go new file mode 100644 index 000000000..3f69e2b99 --- /dev/null +++ b/internal/html/external_icon.go @@ -0,0 +1,26 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func ExternalIcon() template.HTML { + return template.HTML(` + + + `) +} diff --git a/internal/html/file_icon.go b/internal/html/file_icon.go new file mode 100644 index 000000000..8a6c6e0c0 --- /dev/null +++ b/internal/html/file_icon.go @@ -0,0 +1,23 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func FileIcon() template.HTML { + return template.HTML(``) +} diff --git a/internal/html/github_icon.go b/internal/html/github_icon.go new file mode 100644 index 000000000..f3bb462b7 --- /dev/null +++ b/internal/html/github_icon.go @@ -0,0 +1,29 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func GitHubIcon() template.HTML { + return template.HTML(` + + `) +} diff --git a/internal/html/html.go b/internal/html/html.go index c5cb70293..71539b08b 100644 --- a/internal/html/html.go +++ b/internal/html/html.go @@ -21,8 +21,6 @@ import ( "strings" "github.com/gomarkdown/markdown" - - "github.com/snyk/snyk-ls/domain/snyk" ) func MarkdownToHTML(md string) template.HTML { @@ -37,37 +35,3 @@ func IdxMinusOne(n int) int { func TrimCWEPrefix(cwe string) string { return strings.TrimPrefix(cwe, "CWE-") } - -func GetLessonIconSvg() template.HTML { - return template.HTML(` - - - `) -} - -func GetSeverityIconSvg(issue snyk.Issue) template.HTML { - switch issue.Severity { - case snyk.Critical: - return template.HTML(` - - - `) - case snyk.High: - return template.HTML(` - - - `) - case snyk.Medium: - return template.HTML(` - - - `) - case snyk.Low: - return template.HTML(` - - - `) - default: - return `` - } -} diff --git a/internal/html/lesson_icon.go b/internal/html/lesson_icon.go new file mode 100644 index 000000000..042319ac6 --- /dev/null +++ b/internal/html/lesson_icon.go @@ -0,0 +1,26 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func LessonIcon() template.HTML { + return template.HTML(` + + + `) +} diff --git a/internal/html/scan_animmation_icon.go b/internal/html/scan_animmation_icon.go new file mode 100644 index 000000000..0023c5e61 --- /dev/null +++ b/internal/html/scan_animmation_icon.go @@ -0,0 +1,73 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import "html/template" + +func ScanAnimation() template.HTML { + return template.HTML(` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `) +} diff --git a/internal/html/severity_icons.go b/internal/html/severity_icons.go new file mode 100644 index 000000000..56f142261 --- /dev/null +++ b/internal/html/severity_icons.go @@ -0,0 +1,50 @@ +/* + * © 2024 Snyk Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package html + +import ( + "html/template" + + "github.com/snyk/snyk-ls/domain/snyk" +) + +func SeverityIcon(issue snyk.Issue) template.HTML { + switch issue.Severity { + case snyk.Critical: + return template.HTML(` + + + `) + case snyk.High: + return template.HTML(` + + + `) + case snyk.Medium: + return template.HTML(` + + + `) + case snyk.Low: + return template.HTML(` + + + `) + default: + return `` + } +}