From dc5d403c286621a5aaa3df99161dba9ec5d8b870 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 2 May 2019 14:35:42 +0100 Subject: [PATCH] ui: Adds {{Datacenter}} keyword for URL template interpolation (#5768) 1. Includes Datacenter variable for intperolation 2. Amends text on the Settings page to reflect new keyword 3. Adds further acceptance testing around the new dashboard buttons --- ui-v2/app/routes/dc/services/show.js | 4 +++- ui-v2/app/templates/dc/services/show.hbs | 2 +- ui-v2/app/templates/settings.hbs | 4 ++-- ui-v2/tests/acceptance/dc/services/show.feature | 13 +++++++++++++ ui-v2/tests/pages/dc/services/show.js | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ui-v2/app/routes/dc/services/show.js b/ui-v2/app/routes/dc/services/show.js index 361b0e15d..3b8083fbd 100644 --- a/ui-v2/app/routes/dc/services/show.js +++ b/ui-v2/app/routes/dc/services/show.js @@ -15,9 +15,11 @@ export default Route.extend({ model: function(params) { const repo = get(this, 'repo'); const settings = get(this, 'settings'); + const dc = this.modelFor('dc').dc.Name; return hash({ - item: repo.findBySlug(params.name, this.modelFor('dc').dc.Name), + item: repo.findBySlug(params.name, dc), urls: settings.findBySlug('urls'), + dc: dc, }); }, setupController: function(controller, model) { diff --git a/ui-v2/app/templates/dc/services/show.hbs b/ui-v2/app/templates/dc/services/show.hbs index 452017b2a..53860f601 100644 --- a/ui-v2/app/templates/dc/services/show.hbs +++ b/ui-v2/app/templates/dc/services/show.hbs @@ -34,7 +34,7 @@ {{/block-slot}} {{#block-slot 'actions'}} {{#if urls.service}} - {{#templated-anchor href=urls.service vars=(hash Service=(hash Name=item.Service.Service)) rel="external"}}Open Dashboard{{/templated-anchor}} + {{#templated-anchor data-test-dashboard-anchor href=urls.service vars=(hash Datacenter=dc Service=(hash Name=item.Service.Service)) rel="external"}}Open Dashboard{{/templated-anchor}} {{/if}} {{/block-slot}} {{#block-slot 'content'}} diff --git a/ui-v2/app/templates/settings.hbs b/ui-v2/app/templates/settings.hbs index 4a4874cc2..7215c9f96 100644 --- a/ui-v2/app/templates/settings.hbs +++ b/ui-v2/app/templates/settings.hbs @@ -16,12 +16,12 @@

Dashboard Links

- Add a link to the service detail page in the UI to get quick access to a service-wide metrics dashboard. Enter the dashboard URL into the field below. You can use the placeholder {{Service.Name}} which will be replaced with the name of the service currently being viewed. + Add a link to the service detail page in the UI to get quick access to a service-wide metrics dashboard. Enter the dashboard URL into the field below. You can use the placeholders {{'{{Datacenter}}'}} and {{'{{Service.Name}}'}} which will be replaced with the name of the datacenter/service currently being viewed.

diff --git a/ui-v2/tests/acceptance/dc/services/show.feature b/ui-v2/tests/acceptance/dc/services/show.feature index 0c707f31b..31ad75bc0 100644 --- a/ui-v2/tests/acceptance/dc/services/show.feature +++ b/ui-v2/tests/acceptance/dc/services/show.feature @@ -89,3 +89,16 @@ Feature: dc / services / show: Show Service - "2.2.2.2:8000" - "3.3.3.3:8888" --- + Scenario: Given a dashboard template has been set + Given 1 datacenter model with the value "dc1" + And settings from yaml + --- + consul:urls: + service: https://consul.io?service-name={{Service.Name}}&dc={{Datacenter}} + --- + When I visit the service page for yaml + --- + dc: dc1 + service: service-0 + --- + And I see href on the dashboardAnchor like "https://consul.io?service-name=service-0&dc=dc1" diff --git a/ui-v2/tests/pages/dc/services/show.js b/ui-v2/tests/pages/dc/services/show.js index 5b5fb2e38..fd9afa1e1 100644 --- a/ui-v2/tests/pages/dc/services/show.js +++ b/ui-v2/tests/pages/dc/services/show.js @@ -5,6 +5,9 @@ export default function(visitable, attribute, collection, text, filter) { instances: collection('#instances [data-test-tabular-row]', { address: text('[data-test-address]'), }), + dashboardAnchor: { + href: attribute('href', '[data-test-dashboard-anchor]'), + }, filter: filter, }; }