Skip to content

Commit

Permalink
refactor: hide features view until OSS is fully integrated [ROAD-263] (
Browse files Browse the repository at this point in the history
…#40)

* refactor: hide features view until OSS is fully integrated

* fix: enabled both features by default
  • Loading branch information
michelkaporin authored Aug 17, 2021
1 parent 89e0039 commit afcb87c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@
"snyk.features.codeSecurity": {
"type": "boolean",
"title": "Snyk Code security issues",
"description": "Find and fix vulnerabilities in your application code in real time."
"description": "Find and fix vulnerabilities in your application code in real time.",
"default": true
},
"snyk.features.codeQuality": {
"type": "boolean",
"title": "Snyk Code quality issues",
"description": "Find and fix code quality issues in your application code in real time."
"description": "Find and fix code quality issues in your application code in real time.",
"default": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { configuration } from '../../../common/configuration/instance';
import { SNYK_CONTEXT } from '../../../common/constants/views';
import { IContextService } from '../../../common/services/contextService';

enum WelcomeViewEventMessageType {
enum FeaturesViewEventMessageType {
FeaturesSelected = 'featuresSelected',
}

type WelcomeViewEventMessage = {
type: WelcomeViewEventMessageType;
type FeaturesViewEventMessage = {
type: FeaturesViewEventMessageType;
value: unknown;
};

Expand All @@ -34,9 +34,9 @@ export class FeaturesViewProvider implements vscode.WebviewViewProvider {

webviewView.webview.html = this.getHtmlForWebview(webviewView.webview);

webviewView.webview.onDidReceiveMessage(async (data: WelcomeViewEventMessage) => {
webviewView.webview.onDidReceiveMessage(async (data: FeaturesViewEventMessage) => {
switch (data.type) {
case WelcomeViewEventMessageType.FeaturesSelected: {
case FeaturesViewEventMessageType.FeaturesSelected: {
await configuration.setFeaturesConfiguration(data.value as FeaturesConfiguration);
await this.contextService.setContext(SNYK_CONTEXT.FEATURES_SELECTED, true);
break;
Expand All @@ -50,9 +50,9 @@ export class FeaturesViewProvider implements vscode.WebviewViewProvider {
}

private getHtmlForWebview(webview: vscode.Webview) {
const scriptUri = this.getWebViewUri('out', 'snyk', 'base', 'views', 'welcome', 'welcomeViewScript.js');
const styleVSCodeUri = this.getWebViewUri('media', 'views', 'welcome', 'vscode.css');
const styleWelcomeUri = this.getWebViewUri('media', 'views', 'welcome', 'welcome.css');
const scriptUri = this.getWebViewUri('out', 'snyk', 'base', 'views', 'featureSelection', 'featuresViewScript.js');
const styleVSCodeUri = this.getWebViewUri('media', 'views', 'featureSelection', 'vscode.css');
const styleUri = this.getWebViewUri('media', 'views', 'featureSelection', 'featureSelection.css');
const avatarUri = this.getWebViewUri('images', 'avatar-transparent.svg');

// Use a nonce to only allow a specific script to be run.
Expand All @@ -72,7 +72,7 @@ export class FeaturesViewProvider implements vscode.WebviewViewProvider {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="${styleVSCodeUri}" rel="stylesheet">
<link href="${styleWelcomeUri}" rel="stylesheet">
<link href="${styleUri}" rel="stylesheet">
<title>Snyk</title>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/snyk/common/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export class Configuration implements IConfiguration {
);

if (!codeSecurityEnabled && !codeQualityEnabled) {
return undefined;
// TODO: return 'undefined' to render feature selection screen once OSS integration is available
return { codeSecurityEnabled: true, codeQualityEnabled: true };
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/common/services/viewManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import { EventEmitter, TreeView } from 'vscode';
import { FeaturesConfiguration } from '../configuration/configuration';
import { REFRESH_VIEW_DEBOUNCE_INTERVAL } from '../constants/general';
import { FeaturesViewProvider } from '../../base/views/welcome/welcomeViewProvider';
import { FeaturesViewProvider } from '../../base/views/featureSelection/featuresViewProvider';
import { TreeNode } from '../views/treeNode';
import { configuration } from '../configuration/instance';

Expand Down
2 changes: 1 addition & 1 deletion src/snyk/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { createDCIgnoreCommand, openSnykSettingsCommand } from './common/vscodeC
import { EmptyTreeDataProvider } from './base/views/emptyTreeDataProvider';
import { CodeQualityIssueProvider } from './snykCode/views/qualityIssueProvider';
import { SupportProvider } from './base/views/supportProvider';
import { FeaturesViewProvider } from './base/views/welcome/welcomeViewProvider';
import { FeaturesViewProvider } from './base/views/featureSelection/featuresViewProvider';
import { CodeSecurityIssueProvider } from './snykCode/views/securityIssueProvider';
import { analytics } from './common/analytics/analytics';
import { IExtension } from './base/modules/interfaces';
Expand Down
4 changes: 2 additions & 2 deletions src/test/integration/viewNavigation.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { strictEqual } from 'assert';
import { configuration } from '../../snyk/common/configuration/instance';
import { getExtension } from '../../extension';
import { SNYK_VIEW_FEATURES, SNYK_VIEW_WELCOME } from '../../snyk/common/constants/views';
import { TreeView } from 'vscode';
import { FeaturesViewProvider } from '../../snyk/base/views/welcome/welcomeViewProvider';
import { FeaturesViewProvider } from '../../snyk/base/views/featureSelection/featuresViewProvider';
import { TreeNode } from '../../snyk/common/views/treeNode';
import { configuration } from '../../snyk/common/configuration/instance';

suite('View Navigation', () => {
setup(async () => {
Expand Down

0 comments on commit afcb87c

Please sign in to comment.