From 676000f78a6823e5f3814d577c220b5a327c729b Mon Sep 17 00:00:00 2001 From: Arnold Trakhtenberg Date: Tue, 24 Mar 2020 11:42:53 -0700 Subject: [PATCH] release 2.2.3 (#35) * add Open in Browser to hover card (#34) * add Open in Browser to hover card * refactor implementation, tests work * remove unneeded includes * Update src/providers.ts Co-Authored-By: Arnold Trakhtenberg * update test Co-authored-by: Dan O'Brien Co-authored-by: Arnold Trakhtenberg * fix test * lint * prepare 2.2.3 * cleanup Co-authored-by: Dan O'Brien Co-authored-by: Dan O'Brien --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/providers.ts | 12 ++++++++++-- test/providers.test.ts | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1e67dcf..dab9282b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to the "launchdarkly" extension will be documented in this file. +## [2.2.3] - 2020-03-24 + +### Added + +- Added "Open in browser" link to hover display + ## [2.2.2] - 2020-02-24 ### Changed diff --git a/package.json b/package.json index 3ea1ea4b..3a3da71e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "launchdarkly", "displayName": "LaunchDarkly", "description": "View LaunchDarkly feature flags in your editor.", - "version": "2.2.2", + "version": "2.2.3", "publisher": "launchdarkly", "engines": { "vscode": "^1.34.0" diff --git a/src/providers.ts b/src/providers.ts index 8c9ddd0d..ff5fc8c5 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -120,7 +120,10 @@ class LaunchDarklyHoverProvider implements HoverProvider { (await this.flagStore.getFeatureFlag(candidate)) || (await this.flagStore.getFeatureFlag(kebabCase(candidate))); if (data) { - const hover = generateHoverString(data.flag, data.config); + const env = data.flag.environments[this.config.env]; + const sitePath = env._site.href; + const browserUrl = url.resolve(this.config.baseUri, sitePath); + const hover = generateHoverString(data.flag, data.config, browserUrl); resolve(new Hover(hover)); return; } @@ -180,7 +183,7 @@ const openFlagInBrowser = async (config: Configuration, flagKey: string, flagSto opn(url.resolve(config.baseUri, sitePath)); }; -export function generateHoverString(flag: Flag, c: FlagConfiguration) { +export function generateHoverString(flag: Flag, c: FlagConfiguration, url?: string) { const fields = [ ['Name', flag.name], ['Key', c.key], @@ -205,6 +208,11 @@ export function generateHoverString(flag: Flag, c: FlagConfiguration) { hoverString = hoverString.appendCodeblock(`${field[1]}`); } }); + if (url) { + hoverString.appendText('\n'); + hoverString = hoverString.appendMarkdown(`[Open in browser](${url})`); + hoverString.isTrusted = true; + } return hoverString; } diff --git a/test/providers.test.ts b/test/providers.test.ts index 26a61885..4a851325 100644 --- a/test/providers.test.ts +++ b/test/providers.test.ts @@ -32,8 +32,8 @@ let testPath = path.join(__dirname, '..', '..', 'test'); suite('provider utils tests', () => { test('generateHoverString', () => { assert.equal( - "**LaunchDarkly feature flag**\n\nName: \n```\nTest\n```\n\n\nKey: \n```\ntest\n```\n\n\nEnabled: \n```\ntrue\n```\n\n\nDefault variation: \n```\n\"SomeVariation\"\n```\n\n\nOff variation: \n```\n{\n \"thisIsJson\": \"AnotherVariation\"\n}\n```\n\n\n1 prerequisite\n\n3 user targets\n\n0 rules", - providers.generateHoverString(flag, flagConfig).value, + "**LaunchDarkly feature flag**\n\nName: \n```\nTest\n```\n\n\nKey: \n```\ntest\n```\n\n\nEnabled: \n```\ntrue\n```\n\n\nDefault variation: \n```\n\"SomeVariation\"\n```\n\n\nOff variation: \n```\n{\n \"thisIsJson\": \"AnotherVariation\"\n}\n```\n\n\n1 prerequisite\n\n3 user targets\n\n0 rules\n\n[Open in browser](http://app.launchdarkly.com/example)", + providers.generateHoverString(flag, flagConfig, "http://app.launchdarkly.com/example").value, ); });