Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: hide features view until OSS is fully integrated [ROAD-263] #40

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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