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

Ui/add changelog link #9216

Merged
merged 9 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 4 additions & 1 deletion ui/app/templates/vault.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
© {{date-format (now) "YYYY"}} HashiCorp
</span>
<span>
Vault {{activeCluster.leaderNode.version}}
<a href={{changelog-url-for activeCluster.leaderNode.version}}
class="link has-text-grey">
Vault {{activeCluster.leaderNode.version}}
</a>
</span>
{{#if (is-version "OSS")}}
<span>
Expand Down
33 changes: 33 additions & 0 deletions ui/lib/core/addon/helpers/changelog-url-for.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { helper } from '@ember/component/helper';

/*
This helper returns a url to the changelog for the specified version.
It assumes that Changelog headers for Vault versions >= 1.4.3 are structured as:

## v1.5.0
### Month, DD, YYYY

## v1.4.5
### Month, DD, YYY

etc.
*/

export function changelogUrlFor([version]) {
chelshaw marked this conversation as resolved.
Show resolved Hide resolved
let url = 'http://www.github.com/hashicorp/vault/blob/master/CHANGELOG.md#';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be https?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yes! nice catch.


// strip the '+prem' from enterprise versions and remove periods
let versionNumber = version
.split('+')[0]
.split('.')
.join('');

// only recent versions have a predictable url
if (versionNumber >= '143') {
return url.concat('v', versionNumber);
} else {
return url;
}
}

export default helper(changelogUrlFor);
1 change: 1 addition & 0 deletions ui/lib/core/app/helpers/changelog-url-for.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, changelogUrlFor } from 'core/helpers/changelog-url-for';
29 changes: 29 additions & 0 deletions ui/tests/integration/helpers/changelog-url-for-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { changelogUrlFor } from '../../../helpers/changelog-url-for';

const CHANGELOG_URL = 'http://www.github.com/hashicorp/vault/blob/master/CHANGELOG.md#';

module('Integration | Helper | changelog-url-for', function(hooks) {
setupRenderingTest(hooks);

test('it builds an enterprise URL', function(assert) {
const result = changelogUrlFor(['1.5.0+prem']);
assert.equal(result, CHANGELOG_URL.concat('v150'));
});

test('it builds an OSS URL', function(assert) {
const result = changelogUrlFor(['1.4.3']);
assert.equal(result, CHANGELOG_URL.concat('v143'));
});

test('it returns the base changelog URL if the version is less than 1.4.3', function(assert) {
const result = changelogUrlFor(['1.4.0']);
assert.equal(result, CHANGELOG_URL);
});

test('it returns the base changelog URL if version cannot be found', function(assert) {
const result = changelogUrlFor(['']);
assert.equal(result, CHANGELOG_URL);
});
});