Skip to content

Commit 06a6ecb

Browse files
authored
feat: ES-141 UI for modifying scanoss.json skip functionality (#98)
* feat: add skip settings ui feat: init tree service feat: create results tree component feat: style settings dialog, add skip settings component feat: get proper result workflow state when requesting by path feat: add scanning skip state to tree nodes feat: add skip state to tree nodes feat: add context menu for skipping patterns feat: improve scanoss settings pattern matching feat: toggle between included or excluded from scan settings, refetch tree after changes feat: update tests feat: pr comments feat: build tree concurrently feat: fix deadlock feat: ES-141 add shortcut for app settings feat: ES-141 add save button feat: ES-141 add legend for skip settings help feat: ES-141 use relative path for tree nodes feat: ES-141 handle some edge cases, use toggleskippattern instead of two separate methods feat: ES-141 fix tests feat: ES-141 remove unused methods feat: ES-141 new approach without save state on the client feat: ES-141 refetch ree on each node change * feat: fix tests * feat: ES-141 better handling of edge cases
1 parent e98cac3 commit 06a6ecb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3328
-267
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ go_lint_docker: ## Run docker instance of Go linting across the code base
4848

4949
run: cp_assets ## Runs the application in development mode
5050
$(eval APPARGS := $(ARGS))
51-
@wails dev -ldflags "-X github.com/scanoss/scanoss.cc/backend/entities.AppVersion=$(VERSION)" $(if $(strip $(APPARGS)),-appargs "$(APPARGS)")
51+
@wails dev -ldflags "-X github.com/scanoss/scanoss.cc/backend/entities.AppVersion=$(VERSION)" $(if $(strip $(APPARGS)),-appargs "--debug $(APPARGS)")
5252

5353
npm: ## Install NPM dependencies for the frontend
5454
@echo "Running npm install for frontend..."

app.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (a *App) initializeMenu() {
118118
groupedShortcuts := a.keyboardService.GetGroupedShortcuts()
119119
actionShortcuts := groupedShortcuts[entities.GroupActions]
120120
globalShortcuts := groupedShortcuts[entities.GroupGlobal]
121-
121+
viewShortcuts := groupedShortcuts[entities.GroupView]
122122
// Global edit menu
123123
EditMenu := AppMenu.AddSubmenu("Edit")
124124
for _, shortcut := range globalShortcuts {
@@ -133,9 +133,11 @@ func (a *App) initializeMenu() {
133133

134134
// View menu
135135
ViewMenu := AppMenu.AddSubmenu("View")
136-
ViewMenu.AddText("Sync Scroll Position", keys.Combo("e", keys.ShiftKey, keys.CmdOrCtrlKey), func(cd *menu.CallbackData) {
137-
runtime.EventsEmit(a.ctx, string(entities.ActionToggleSyncScrollPosition))
138-
})
136+
for _, shortcut := range viewShortcuts {
137+
ViewMenu.AddText(shortcut.Name, shortcut.Accelerator, func(cd *menu.CallbackData) {
138+
runtime.EventsEmit(a.ctx, string(shortcut.Action))
139+
})
140+
}
139141

140142
// Scan menu
141143
ScanMenu := AppMenu.AddSubmenu("Scan")

backend/entities/keyboard.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
// View
5656
ActionToggleSyncScrollPosition Action = "toggleSyncScrollPosition"
5757
ActionShowKeyboardShortcutsModal Action = "showKeyboardShortcutsModal"
58-
58+
ActionOpenSettings Action = "openSettings"
5959
// Scan
6060
ActionScanWithOptions Action = "scanWithOptions"
6161
)
@@ -108,6 +108,7 @@ var AllShortcutActions = []struct {
108108
{ActionToggleSyncScrollPosition, "ToggleSyncScrollPosition"},
109109
{ActionShowKeyboardShortcutsModal, "ShowKeyboardShortcutsModal"},
110110
{ActionScanWithOptions, "ScanWithOptions"},
111+
{ActionOpenSettings, "OpenSettings"},
111112
}
112113

113114
var DefaultShortcuts = []Shortcut{
@@ -291,6 +292,7 @@ var DefaultShortcuts = []Shortcut{
291292
Action: ActionReplaceComponentWithComments,
292293
},
293294

295+
// View
294296
{
295297
Name: "Sync Scroll Position",
296298
Description: "Sync the scroll position of the editors",
@@ -299,6 +301,14 @@ var DefaultShortcuts = []Shortcut{
299301
Group: GroupView,
300302
Action: ActionToggleSyncScrollPosition,
301303
},
304+
{
305+
Name: "Settings",
306+
Description: "Open the app settings",
307+
Accelerator: keys.CmdOrCtrl(","),
308+
Keys: "mod+,",
309+
Group: GroupView,
310+
Action: ActionOpenSettings,
311+
},
302312

303313
// Scan
304314
{

backend/entities/result.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ type WorkflowState string
108108
const (
109109
Pending WorkflowState = "pending"
110110
Completed WorkflowState = "completed"
111+
Mixed WorkflowState = "mixed"
111112
)
112113

113114
type FilterConfig struct {

backend/entities/scanoss_settings.go

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,212 @@ func (sf *SettingsFile) GetBomEntryFromResult(result Result) ComponentFilter {
184184

185185
return ComponentFilter{}
186186
}
187+
188+
var DefaultSkippedDirs = []string{
189+
"nbproject",
190+
"nbbuild",
191+
"nbdist",
192+
"__pycache__",
193+
"venv",
194+
"_yardoc",
195+
"eggs",
196+
"wheels",
197+
"htmlcov",
198+
"__pypackages__",
199+
"example",
200+
"examples",
201+
"docs",
202+
"tests",
203+
"doc",
204+
"test",
205+
}
206+
207+
var DefaultSkippedFiles = []string{
208+
"gradlew",
209+
"gradlew.bat",
210+
"mvnw",
211+
"mvnw.cmd",
212+
"gradle-wrapper.jar",
213+
"maven-wrapper.jar",
214+
"thumbs.db",
215+
"babel.config.js",
216+
"license.txt",
217+
"license.md",
218+
"copying.lib",
219+
"makefile",
220+
}
221+
222+
var DefaultSkippedDirExtensions = []string{".egg-info"}
223+
224+
var DefaultSkippedExtensions = []string{
225+
".1",
226+
".2",
227+
".3",
228+
".4",
229+
".5",
230+
".6",
231+
".7",
232+
".8",
233+
".9",
234+
".ac",
235+
".adoc",
236+
".am",
237+
".asciidoc",
238+
".bmp",
239+
".build",
240+
".cfg",
241+
".chm",
242+
".class",
243+
".cmake",
244+
".cnf",
245+
".conf",
246+
".config",
247+
".contributors",
248+
".copying",
249+
".crt",
250+
".csproj",
251+
".css",
252+
".csv",
253+
".dat",
254+
".data",
255+
".doc",
256+
".docx",
257+
".dtd",
258+
".dts",
259+
".iws",
260+
".c9",
261+
".c9revisions",
262+
".dtsi",
263+
".dump",
264+
".eot",
265+
".eps",
266+
".geojson",
267+
".gdoc",
268+
".gif",
269+
".glif",
270+
".gmo",
271+
".gradle",
272+
".guess",
273+
".hex",
274+
".htm",
275+
".html",
276+
".ico",
277+
".iml",
278+
".in",
279+
".inc",
280+
".info",
281+
".ini",
282+
".ipynb",
283+
".jpeg",
284+
".jpg",
285+
".json",
286+
".jsonld",
287+
".lock",
288+
".log",
289+
".m4",
290+
".map",
291+
".markdown",
292+
".md",
293+
".md5",
294+
".meta",
295+
".mk",
296+
".mxml",
297+
".o",
298+
".otf",
299+
".out",
300+
".pbtxt",
301+
".pdf",
302+
".pem",
303+
".phtml",
304+
".plist",
305+
".png",
306+
".po",
307+
".ppt",
308+
".prefs",
309+
".properties",
310+
".pyc",
311+
".qdoc",
312+
".result",
313+
".rgb",
314+
".rst",
315+
".scss",
316+
".sha",
317+
".sha1",
318+
".sha2",
319+
".sha256",
320+
".sln",
321+
".spec",
322+
".sql",
323+
".sub",
324+
".svg",
325+
".svn-base",
326+
".tab",
327+
".template",
328+
".test",
329+
".tex",
330+
".tiff",
331+
".toml",
332+
".ttf",
333+
".txt",
334+
".utf-8",
335+
".vim",
336+
".wav",
337+
".woff",
338+
".woff2",
339+
".xht",
340+
".xhtml",
341+
".xls",
342+
".xlsx",
343+
".xml",
344+
".xpm",
345+
".xsd",
346+
".xul",
347+
".yaml",
348+
".yml",
349+
".wfp",
350+
".editorconfig",
351+
".dotcover",
352+
".pid",
353+
".lcov",
354+
".egg",
355+
".manifest",
356+
".cache",
357+
".coverage",
358+
".cover",
359+
".gem",
360+
".lst",
361+
".pickle",
362+
".pdb",
363+
".gml",
364+
".pot",
365+
".plt",
366+
".whml",
367+
".pom",
368+
".smtml",
369+
".min.js",
370+
".mf",
371+
".base64",
372+
".s",
373+
".diff",
374+
".patch",
375+
".rules",
376+
// File endings
377+
"-doc",
378+
"changelog",
379+
"config",
380+
"copying",
381+
"license",
382+
"authors",
383+
"news",
384+
"licenses",
385+
"notice",
386+
"readme",
387+
"swiftdoc",
388+
"texidoc",
389+
"todo",
390+
"version",
391+
"ignore",
392+
"manifest",
393+
"sqlite",
394+
"sqlite3",
395+
}

backend/entities/tree.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package entities
2+
3+
import (
4+
"path/filepath"
5+
)
6+
7+
type TreeNode struct {
8+
ID string `json:"id"`
9+
Name string `json:"name"`
10+
Path string `json:"path"`
11+
IsFolder bool `json:"isFolder"`
12+
WorkflowState WorkflowState `json:"workflowState"`
13+
ScanningSkipState SkipState `json:"scanningSkipState"`
14+
Children []TreeNode `json:"children"`
15+
}
16+
17+
type SkipState string
18+
19+
const (
20+
SkipStateIncluded SkipState = "included"
21+
SkipStateExcluded SkipState = "excluded"
22+
SkipStateMixed SkipState = "mixed"
23+
)
24+
25+
func NewTreeNode(path string, result ResultDTO, isFolder bool) TreeNode {
26+
return TreeNode{
27+
ID: path,
28+
Name: filepath.Base(path),
29+
Path: path,
30+
IsFolder: isFolder,
31+
WorkflowState: result.WorkflowState,
32+
ScanningSkipState: SkipStateIncluded,
33+
Children: make([]TreeNode, 0),
34+
}
35+
}

backend/mappers/result_mapper_impl.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ func (m ResultMapperImpl) MapToResultDTO(result entities.Result) entities.Result
6969
return cached.(entities.ResultDTO)
7070
}
7171

72+
var detectedPurl string
73+
if result.Purl != nil && len(*result.Purl) > 0 {
74+
detectedPurl = (*result.Purl)[0]
75+
}
76+
7277
dto := entities.ResultDTO{
7378
MatchType: entities.MatchType(result.MatchType),
7479
Path: result.Path,
75-
DetectedPurl: (*result.Purl)[0],
80+
DetectedPurl: detectedPurl,
7681
DetectedPurlUrl: m.mapDetectedPurlUrl(result),
7782
ConcludedPurl: bomEntry.ReplaceWith,
7883
ConcludedPurlUrl: m.mapConcludedPurlUrl(result),
@@ -160,6 +165,10 @@ func (m ResultMapperImpl) getProjectURL(purl string, compute func() (string, err
160165
}
161166

162167
func (m ResultMapperImpl) mapDetectedPurlUrl(result entities.Result) string {
168+
if result.Purl == nil || len(*result.Purl) == 0 {
169+
return ""
170+
}
171+
163172
detectedPurl := (*result.Purl)[0]
164173

165174
purlObject, err := purlutils.PurlFromString(detectedPurl)

backend/repository/component_repository_json_impl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func NewJSONComponentRepository(fr utils.FileReader, resultsRepository ResultRep
5858
}
5959

6060
func (r *JSONComponentRepository) FindByFilePath(path string) (entities.Component, error) {
61-
result, err := r.resultsRepository.GetResultByPath(path)
62-
if err != nil {
63-
return entities.Component{}, err
61+
result := r.resultsRepository.GetResultByPath(path)
62+
if result == nil {
63+
return entities.Component{}, errors.New("no result found")
6464
}
6565

6666
components := result.Matches

0 commit comments

Comments
 (0)