diff --git a/package-lock.json b/package-lock.json index 64a5ac9..5784050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "configcat-feature-flags", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "configcat-feature-flags", - "version": "2.0.2", + "version": "2.0.3", "license": "MIT", "dependencies": { "configcat-publicapi-node-client": "^2.0.1" diff --git a/package.json b/package.json index 5f222ba..03a815c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "configcat-feature-flags", "displayName": "ConfigCat Feature Flags", "description": "ConfigCat Visual Studio Code extension to manage feature flags from Visual Studio Code.", - "version": "2.0.2", + "version": "2.0.3", "publisher": "ConfigCat", "repository": "https://github.com/configcat/vscode-extension-configcat", "preview": false, diff --git a/src/configs/config-provider.ts b/src/configs/config-provider.ts index 8579fc0..823ac9b 100644 --- a/src/configs/config-provider.ts +++ b/src/configs/config-provider.ts @@ -62,16 +62,16 @@ export class ConfigProvider implements vscode.TreeDataProvider { const productsService = this.publicApiService.createProductsService(publicApiConfiguration, workspaceConfiguration.publicApiBaseUrl); return productsService.getProducts().then(products => { - const items = products.data.map((p, index) => new Resource(p.productId ?? '', '', p.name ?? '', ResourceType.product, index === 0 ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.Collapsed)); + const items = products.data.map((p, index) => new Resource(p.productId ?? '', '', p.name ?? '', ResourceType.product, index === 0 ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.Collapsed, p.description ?? '')); statusBar.hide(); if (!items.length) { - items.push(new Resource('-1', '', 'Could not find any Products.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None)); + items.push(new Resource('-1', '', 'Could not find any Products.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None, '')); } return items; }, error => { handleError('Could not load Products.', error); statusBar.hide(); - return [new Resource('-1', '', 'Could not load Products.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None)]; + return [new Resource('-1', '', 'Could not load Products.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None, '')]; }); }, () => { return []; @@ -97,16 +97,16 @@ export class ConfigProvider implements vscode.TreeDataProvider { const configsService = this.publicApiService.createConfigsService(publicApiConfiguration, workspaceConfiguration.publicApiBaseUrl); return configsService.getConfigs(productId).then(configs => { - const items = configs.data.map(c => new Resource(c.configId ?? '', productId, c.name ?? '', ResourceType.config, vscode.TreeItemCollapsibleState.None)); + const items = configs.data.map(c => new Resource(c.configId ?? '', productId, c.name ?? '', ResourceType.config, vscode.TreeItemCollapsibleState.None, c.description ?? '')); statusBar.hide(); if (!items.length) { - items.push(new Resource('-1', '', 'Could not find any Configs.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None)); + items.push(new Resource('-1', '', 'Could not find any Configs.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None, '')); } return items; }, error => { handleError('Could not load Configs.', error); statusBar.hide(); - return [new Resource('-1', '', 'Could not load Configs.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None)]; + return [new Resource('-1', '', 'Could not load Configs.', ResourceType.unknown, vscode.TreeItemCollapsibleState.None, '')]; }); }, () => { return []; @@ -198,21 +198,18 @@ export class ConfigProvider implements vscode.TreeDataProvider { return; } - let evaluationVersion: EvaluationVersion; + let configDescription: string; try { - evaluationVersion = await ConfigInput.configVersionInput(); + configDescription = await ConfigInput.configDescriptionInput(); } catch (error) { return; } - if (!evaluationVersion) { - return; - } const configsService = this.publicApiService.createConfigsService(authenticationConfiguration, workspaceConfiguration.publicApiBaseUrl); let config = null; try { - config = await configsService.createConfig(productId, { name: configName, evaluationVersion: evaluationVersion }); + config = await configsService.createConfig(productId, { name: configName, evaluationVersion: EvaluationVersion.V2, description: configDescription }); } catch (error) { handleError('Could not create Config.', error) } @@ -320,8 +317,10 @@ class Resource extends vscode.TreeItem { public readonly label: string, public resourceType: ResourceType, public readonly collapsibleState: vscode.TreeItemCollapsibleState, + public readonly tooltip: string, ) { super(label, collapsibleState); + super.tooltip = tooltip; super.contextValue = resourceType; } -} \ No newline at end of file +} diff --git a/src/inputs/config-input.ts b/src/inputs/config-input.ts index 698fac2..eb958f6 100644 --- a/src/inputs/config-input.ts +++ b/src/inputs/config-input.ts @@ -1,4 +1,4 @@ -import { ConfigModel, EvaluationVersion } from 'configcat-publicapi-node-client'; +import { ConfigModel } from 'configcat-publicapi-node-client'; import * as vscode from 'vscode'; export class ConfigInput { @@ -37,23 +37,20 @@ export class ConfigInput { return Promise.resolve(name); } - - static async configVersionInput(): Promise { - - const pick = await vscode.window.showQuickPick( - [{label: "V2"}, {label:"V1", description: "(Legacy)"} ], - { - canPickMany: false, - placeHolder: 'Select the config version' - }); - - if (!pick) { - return Promise.reject(); - } - - return Promise.resolve(EvaluationVersion[pick.label]); - } + static async configDescriptionInput(): Promise { + const description = await vscode.window.showInputBox({ + prompt: 'Please enter the description of the Config', + placeHolder: 'This config is responsible for...', + ignoreFocusOut: true, + value: '' + }); + if (description === undefined) { + return Promise.reject(); + } + + return Promise.resolve(description); + } static async askConnect(): Promise {