Skip to content

Commit

Permalink
release 2.2.3 (#35)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* update test

Co-authored-by: Dan O'Brien <[email protected]>
Co-authored-by: Arnold Trakhtenberg <[email protected]>

* fix test

* lint

* prepare 2.2.3

* cleanup

Co-authored-by: Dan O'Brien <[email protected]>
Co-authored-by: Dan O'Brien <[email protected]>
  • Loading branch information
3 people authored Mar 24, 2020
1 parent dcd0ea4 commit 676000f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 10 additions & 2 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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],
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions test/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
});

Expand Down

0 comments on commit 676000f

Please sign in to comment.