Skip to content

Commit 9f8d9fd

Browse files
authored
CM-40765, CM-40767 - Add loading screen, rework sidebar, make views dynamic; add clear results action (#108)
1 parent 0ccff9b commit 9f8d9fd

37 files changed

+321
-339
lines changed

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## [Unreleased]
44

5-
## [v1.10.1]
5+
## [v1.11.0]
66

7-
- Code refactoring
7+
- Add extension loading screen
8+
- Add toolbar actions: Run All, Expand All, Collapse All, Clear Results
9+
- Rework extension sidebar. Now it vertically splits the screen and always shows the tree view on top
10+
- Rework sidebar views to be more dynamic with proper action states
11+
- Huge code refactoring
812

913
## [v1.10.0]
1014

@@ -99,7 +103,7 @@
99103

100104
The first stable release with the support of Secrets, SCA, TreeView, Violation Card, and more.
101105

102-
[v1.10.1]: https://github.com/cycodehq/vscode-extension/releases/tag/v1.10.1
106+
[v1.11.0]: https://github.com/cycodehq/vscode-extension/releases/tag/v1.11.0
103107

104108
[v1.10.0]: https://github.com/cycodehq/vscode-extension/releases/tag/v1.10.0
105109

@@ -137,4 +141,4 @@ The first stable release with the support of Secrets, SCA, TreeView, Violation C
137141

138142
[v1.0.0]: https://github.com/cycodehq/vscode-extension/releases/tag/v1.0.0
139143

140-
[Unreleased]: https://github.com/cycodehq/vscode-extension/compare/v1.10.1...HEAD
144+
[Unreleased]: https://github.com/cycodehq/vscode-extension/compare/v1.11.0...HEAD

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cycode",
33
"displayName": "Cycode",
4-
"version": "1.10.1",
4+
"version": "1.11.0",
55
"publisher": "cycode",
66
"description": "Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning.",
77
"repository": {
@@ -38,7 +38,7 @@
3838
"view/title": [
3939
{
4040
"command": "cycode.runAllScans",
41-
"when": "view =~ /^cycode./",
41+
"when": "view == cycode.view.tree",
4242
"group": "navigation@0"
4343
},
4444
{
@@ -52,14 +52,14 @@
5252
"group": "navigation@1"
5353
},
5454
{
55-
"command": "cycode.openMainMenu",
55+
"command": "cycode.clearAllScanResults",
5656
"when": "view == cycode.view.tree",
57-
"group": "navigation@1"
57+
"group": "navigation@2"
5858
},
5959
{
6060
"command": "cycode.openSettings",
61-
"when": "view =~ /^cycode./",
62-
"group": "navigation@2"
61+
"when": "view == cycode.view.tree",
62+
"group": "navigation@3"
6363
}
6464
],
6565
"view/item/context": [
@@ -172,10 +172,10 @@
172172
"icon": "$(gear)"
173173
},
174174
{
175-
"command": "cycode.openMainMenu",
175+
"command": "cycode.clearAllScanResults",
176176
"category": "Cycode",
177-
"title": "Return to Home Screen",
178-
"icon": "$(arrow-left)"
177+
"title": "Clear all scan results",
178+
"icon": "$(trash)"
179179
},
180180
{
181181
"command": "cycode.runAllScans",
@@ -219,28 +219,28 @@
219219
"views": {
220220
"cycode": [
221221
{
222-
"type": "webview",
223-
"id": "cycode.view.login",
224-
"name": "login",
225-
"when": "!cycode:auth.isAuthed && !cycode:auth.isAuthenticating"
222+
"type": "tree",
223+
"id": "cycode.view.tree",
224+
"name": "Scan Results",
225+
"when": "true"
226226
},
227227
{
228228
"type": "webview",
229-
"id": "cycode.view.authenticating",
230-
"name": "login",
231-
"when": "cycode:auth.isAuthenticating"
229+
"id": "cycode.view.loading",
230+
"name": "Loading",
231+
"when": "!cycode:cli.isInstalled"
232232
},
233233
{
234234
"type": "webview",
235-
"id": "cycode.view.main",
236-
"name": "scan",
237-
"when": "cycode:auth.isAuthed && (!cycode:scan.hasAnyDetections || !cycode:treeView.isShowed)"
235+
"id": "cycode.view.auth",
236+
"name": "Login",
237+
"when": "cycode:cli.isInstalled && !cycode:auth.isAuthed"
238238
},
239239
{
240-
"type": "tree",
241-
"id": "cycode.view.tree",
242-
"name": "Scan Results",
243-
"when": "cycode:scan.hasAnyDetections && cycode:treeView.isShowed"
240+
"type": "webview",
241+
"id": "cycode.view.scan",
242+
"name": "Scan",
243+
"when": "cycode:cli.isInstalled && cycode:auth.isAuthed"
244244
}
245245
]
246246
},

src/commands/auth-command.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { validateConfig } from '../utils/config';
21
import { container } from 'tsyringe';
32
import { CycodeService, ICycodeService } from '../services/cycode-service';
4-
export default () => {
5-
if (validateConfig()) {
6-
return;
7-
}
3+
import { getCommonCommand } from './common';
84

5+
export default getCommonCommand(async () => {
96
const cycodeService = container.resolve<ICycodeService>(CycodeService);
10-
void cycodeService.startAuth();
11-
};
7+
await cycodeService.startAuth();
8+
}, false);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { container } from 'tsyringe';
2+
import { ExtensionServiceSymbol, ScanResultsServiceSymbol } from '../symbols';
3+
import { IExtensionService } from '../services/extension-service';
4+
import { IScanResultsService } from '../services/scan-results-service';
5+
6+
export default async () => {
7+
const scanResultsService = container.resolve<IScanResultsService>(ScanResultsServiceSymbol);
8+
const extensionService = container.resolve<IExtensionService>(ExtensionServiceSymbol);
9+
10+
scanResultsService.dropAllScanResults();
11+
await extensionService.refreshProviders();
12+
};

src/commands/common.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as vscode from 'vscode';
2+
import { validateConfig } from '../utils/config';
3+
import { container } from 'tsyringe';
4+
import { IStateService } from '../services/state-service';
5+
import { StateServiceSymbol } from '../symbols';
6+
7+
export const getCommonCommand = (command: (...args: never[]) => void | Promise<void>, requiredAuth = true) => {
8+
return async (...args: never[]) => {
9+
if (validateConfig()) {
10+
return;
11+
}
12+
13+
const stateService = container.resolve<IStateService>(StateServiceSymbol);
14+
if (requiredAuth && !stateService.globalState.CliAuthed) {
15+
vscode.window.showErrorMessage('Please authenticate with Cycode first');
16+
return;
17+
}
18+
19+
await command(...args);
20+
};
21+
};

src/commands/iac-scan-command.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import * as vscode from 'vscode';
22
import { container } from 'tsyringe';
33
import TrayNotifications from '../utils/tray-notifications';
4-
import { validateConfig } from '../utils/config';
54
import { CycodeService, ICycodeService } from '../services/cycode-service';
65
import { CliScanType } from '../cli/models/cli-scan-type';
6+
import { getCommonCommand } from './common';
77

8-
export default () => {
8+
export default getCommonCommand(async () => {
99
// scan the current open document if opened
10-
11-
if (validateConfig()) {
12-
return;
13-
}
14-
1510
if (!vscode.window.activeTextEditor?.document || vscode.window.activeTextEditor.document.uri.scheme === 'output') {
1611
TrayNotifications.showMustBeFocusedOnFile();
1712
return;
1813
}
1914

2015
const cycodeService = container.resolve<ICycodeService>(CycodeService);
21-
void cycodeService.startScan(CliScanType.Iac, [vscode.window.activeTextEditor.document.fileName], true);
22-
};
16+
await cycodeService.startScan(CliScanType.Iac, [vscode.window.activeTextEditor.document.fileName], true);
17+
});
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { container } from 'tsyringe';
2-
import { validateConfig } from '../utils/config';
32
import { CycodeService, ICycodeService } from '../services/cycode-service';
43
import { CliScanType } from '../cli/models/cli-scan-type';
4+
import { getCommonCommand } from './common';
55

6-
export default () => {
7-
if (validateConfig()) {
8-
return;
9-
}
10-
6+
export default getCommonCommand(async () => {
117
const cycodeService = container.resolve<ICycodeService>(CycodeService);
12-
void cycodeService.startScanForCurrentProject(CliScanType.Iac);
13-
};
8+
await cycodeService.startScanForCurrentProject(CliScanType.Iac);
9+
});

src/commands/ignore-command.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import { validateConfig } from '../utils/config';
21
import { container } from 'tsyringe';
32
import { CycodeServiceSymbol } from '../symbols';
43
import { ICycodeService } from '../services/cycode-service';
54
import { CliIgnoreType } from '../cli/models/cli-ignore-type';
65
import { CliScanType } from '../cli/models/cli-scan-type';
6+
import { getCommonCommand } from './common';
77

8-
export default (scanType: CliScanType, ignoreType: CliIgnoreType, value: string) => {
9-
if (validateConfig()) {
10-
return;
11-
}
12-
8+
export default getCommonCommand(async (scanType: CliScanType, ignoreType: CliIgnoreType, value: string) => {
139
const cycodeService = container.resolve<ICycodeService>(CycodeServiceSymbol);
14-
void cycodeService.applyDetectionIgnore(scanType, ignoreType, value);
15-
};
10+
await cycodeService.applyDetectionIgnore(scanType, ignoreType, value);
11+
});

src/commands/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import sastScanForCurrentProjectCommand from './sast-scan-for-current-project-co
1111
import openViolationInFileCommand from './open-violation-in-file-command';
1212
import openViolationPanelCommand from './open-violation-panel-command';
1313
import openSettingsCommand from './open-settings-command';
14-
import openMainMenuCommand from './open-main-menu-command';
1514
import onTreeViewDetectionNodeClickCommand from './on-tree-view-detection-node-click-command';
1615
import treeViewExpandAllCommand from './tree-view-expand-all-command';
1716
import treeViewCollapseAllCommand from './tree-view-collapse-all-command';
1817
import runAllScansCommand from './run-all-scans-command';
18+
import clearAllScanResultsCommand from './clear-all-scan-results-command';
1919

2020
export enum VscodeCommands {
2121
SecretScanCommandId = 'cycode.secretScan',
@@ -31,7 +31,7 @@ export enum VscodeCommands {
3131
IgnoreCommandId = 'cycode.ignore',
3232

3333
OpenSettingsCommandId = 'cycode.openSettings',
34-
OpenMainMenuCommandId = 'cycode.openMainMenu',
34+
ClearAllScanResultsCommand = 'cycode.clearAllScanResults',
3535

3636
OpenViolationInFile = 'cycode.openViolationInFile',
3737
OpenViolationPanel = 'cycode.openViolationPanel',
@@ -60,7 +60,7 @@ const _VS_CODE_COMMANDS_ID_TO_CALLBACK: Record<string, (...args: never[]) => unk
6060
[VscodeCommands.OpenViolationInFile]: openViolationInFileCommand,
6161
[VscodeCommands.OpenViolationPanel]: openViolationPanelCommand,
6262
[VscodeCommands.OpenSettingsCommandId]: openSettingsCommand,
63-
[VscodeCommands.OpenMainMenuCommandId]: openMainMenuCommand,
63+
[VscodeCommands.ClearAllScanResultsCommand]: clearAllScanResultsCommand,
6464
[VscodeCommands.OnTreeViewDetectionNodeClickCommand]: onTreeViewDetectionNodeClickCommand,
6565
[VscodeCommands.TreeViewExpandAllCommand]: treeViewExpandAllCommand,
6666
[VscodeCommands.TreeViewCollapseAllCommand]: treeViewCollapseAllCommand,

src/commands/open-main-menu-command.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/commands/run-all-scans-command.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
import * as vscode from 'vscode';
21
import { container } from 'tsyringe';
3-
import { validateConfig } from '../utils/config';
42
import { CycodeService, ICycodeService } from '../services/cycode-service';
53
import { CliScanType } from '../cli/models/cli-scan-type';
6-
import { IStateService } from '../services/state-service';
7-
import { StateServiceSymbol } from '../symbols';
8-
9-
export default async () => {
10-
if (validateConfig()) {
11-
return;
12-
}
13-
14-
const stateService = container.resolve<IStateService>(StateServiceSymbol);
15-
if (!stateService.globalState.CliAuthed) {
16-
vscode.window.showErrorMessage('Please authenticate with Cycode first');
17-
return;
18-
}
4+
import { getCommonCommand } from './common';
195

6+
export default getCommonCommand(async () => {
207
const cycodeService = container.resolve<ICycodeService>(CycodeService);
218

229
const scanPromises = [];
@@ -25,4 +12,4 @@ export default async () => {
2512
scanPromises.push(cycodeService.startScanForCurrentProject(CliScanType.Iac));
2613
scanPromises.push(cycodeService.startScanForCurrentProject(CliScanType.Sast));
2714
await Promise.all(scanPromises);
28-
};
15+
});

src/commands/sast-scan-command.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
import * as vscode from 'vscode';
22
import { container } from 'tsyringe';
33
import TrayNotifications from '../utils/tray-notifications';
4-
import { validateConfig } from '../utils/config';
54
import { CycodeService, ICycodeService } from '../services/cycode-service';
65
import { CliScanType } from '../cli/models/cli-scan-type';
6+
import { getCommonCommand } from './common';
77

8-
export default () => {
9-
// scan the current open document if opened
10-
11-
if (validateConfig()) {
12-
return;
13-
}
14-
8+
export default getCommonCommand(async () => {
159
if (!vscode.window.activeTextEditor?.document || vscode.window.activeTextEditor.document.uri.scheme === 'output') {
1610
TrayNotifications.showMustBeFocusedOnFile();
1711
return;
1812
}
1913

2014
const cycodeService = container.resolve<ICycodeService>(CycodeService);
21-
void cycodeService.startScan(CliScanType.Sast, [vscode.window.activeTextEditor.document.fileName], true);
22-
};
15+
await cycodeService.startScan(CliScanType.Sast, [vscode.window.activeTextEditor.document.fileName], true);
16+
});
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { container } from 'tsyringe';
2-
import { validateConfig } from '../utils/config';
32
import { CycodeService, ICycodeService } from '../services/cycode-service';
43
import { CliScanType } from '../cli/models/cli-scan-type';
4+
import { getCommonCommand } from './common';
55

6-
export default () => {
7-
if (validateConfig()) {
8-
return;
9-
}
10-
6+
export default getCommonCommand(async () => {
117
const cycodeService = container.resolve<ICycodeService>(CycodeService);
12-
void cycodeService.startScanForCurrentProject(CliScanType.Sast);
13-
};
8+
await cycodeService.startScanForCurrentProject(CliScanType.Sast);
9+
});

src/commands/sca-scan-command.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { container } from 'tsyringe';
22
import { CycodeService, ICycodeService } from '../services/cycode-service';
3-
import { validateConfig } from '../utils/config';
43
import { CliScanType } from '../cli/models/cli-scan-type';
4+
import { getCommonCommand } from './common';
55

6-
export default () => {
7-
if (validateConfig()) {
8-
return;
9-
}
10-
6+
export default getCommonCommand(async () => {
117
const cycodeService = container.resolve<ICycodeService>(CycodeService);
12-
void cycodeService.startScanForCurrentProject(CliScanType.Sca);
13-
};
8+
await cycodeService.startScanForCurrentProject(CliScanType.Sca);
9+
});

0 commit comments

Comments
 (0)