mirror of https://github.com/status-im/consul.git
NET-5398: V2 unavailable UI message (#20359)
* Update ui server to include V2 Catalog flag * Fix typo * Add route and redirects for the unavailable warning * Add qualtrics link * Remove unneccessary check and redirect
This commit is contained in:
parent
d350115e7f
commit
b9f3e5e247
|
@ -0,0 +1,3 @@
|
|||
```release-note:feature
|
||||
ui: Adds a redirect and warning message around unavailable UI with V2 enabled
|
||||
```
|
|
@ -13,13 +13,21 @@ export default class ApplicationRoute extends Route.extend(WithBlockingActions)
|
|||
@service('client/http') client;
|
||||
@service('env') env;
|
||||
@service() hcp;
|
||||
@service() router;
|
||||
|
||||
data;
|
||||
|
||||
beforeModel() {
|
||||
if (this.env.var('CONSUL_V2_CATALOG_ENABLED')) {
|
||||
this.router.replaceWith('unavailable');
|
||||
}
|
||||
}
|
||||
|
||||
async model() {
|
||||
if (this.env.var('CONSUL_ACLS_ENABLED')) {
|
||||
await this.hcp.updateTokenIfNecessary(this.env.var('CONSUL_HTTP_TOKEN'));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Route from 'consul-ui/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class UnavailableRoute extends Route {
|
||||
@service('env') env;
|
||||
@service() router;
|
||||
|
||||
beforeModel() {
|
||||
if (!this.env.var('CONSUL_V2_CATALOG_ENABLED')) {
|
||||
this.router.replaceWith('index');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,41 +7,46 @@
|
|||
|
||||
{{! Add the a11y route announcer }}
|
||||
<route.Announcer @title='Consul' />
|
||||
{{! Tell CSS what we have enabled }}
|
||||
{{#if (can 'use acls')}}
|
||||
{{document-attrs class="has-acls"}}
|
||||
{{/if}}
|
||||
{{#if (can 'use nspaces')}}
|
||||
{{document-attrs class="has-nspaces" }}
|
||||
{{/if}}
|
||||
{{#if (can 'use partitions')}}
|
||||
{{document-attrs class="has-partitions" }}
|
||||
{{/if}}
|
||||
|
||||
{{! Listen out for blocking query/client setting changes }}
|
||||
<DataSource
|
||||
@src={{uri 'settings://consul:client'}}
|
||||
@onchange={{route-action 'onClientChanged'}}
|
||||
/>
|
||||
{{#unless (env 'CONSUL_V2_CATALOG_ENABLED')}}
|
||||
{{! Tell CSS what we have enabled }}
|
||||
{{#if (can 'use acls')}}
|
||||
{{document-attrs class='has-acls'}}
|
||||
{{/if}}
|
||||
{{#if (can 'use nspaces')}}
|
||||
{{document-attrs class='has-nspaces'}}
|
||||
{{/if}}
|
||||
{{#if (can 'use partitions')}}
|
||||
{{document-attrs class='has-partitions'}}
|
||||
{{/if}}
|
||||
|
||||
{{! Tell CSS about our theme }}
|
||||
<DataSource @src={{uri 'settings://consul:theme'}} as |source|>
|
||||
{{#each-in source.data as |key value|}}
|
||||
{{#if (and value (includes key (array 'color-scheme' 'contrast')))}}
|
||||
{{document-attrs class=(concat "prefers-" key "-" value) }}
|
||||
{{/if}}
|
||||
{{/each-in}}
|
||||
</DataSource>
|
||||
|
||||
{{! If ACLs are enabled try get a token }}
|
||||
{{#if (can 'use acls')}}
|
||||
{{! Listen out for blocking query/client setting changes }}
|
||||
<DataSource
|
||||
@src={{uri 'settings://consul:token'}}
|
||||
@onchange={{action (mut token) value='data'}}
|
||||
@src={{uri 'settings://consul:client'}}
|
||||
@onchange={{route-action 'onClientChanged'}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if (not-eq route.currentName 'oauth-provider-debug')}}
|
||||
{{! Tell CSS about our theme }}
|
||||
<DataSource @src={{uri 'settings://consul:theme'}} as |source|>
|
||||
{{#each-in source.data as |key value|}}
|
||||
{{#if (and value (includes key (array 'color-scheme' 'contrast')))}}
|
||||
{{document-attrs class=(concat 'prefers-' key '-' value)}}
|
||||
{{/if}}
|
||||
{{/each-in}}
|
||||
</DataSource>
|
||||
|
||||
{{! If ACLs are enabled try get a token }}
|
||||
{{#if (can 'use acls')}}
|
||||
<DataSource
|
||||
@src={{uri 'settings://consul:token'}}
|
||||
@onchange={{action (mut token) value='data'}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if
|
||||
(and (not (env 'CONSUL_V2_CATALOG_ENABLED')) (not-eq route.currentName 'oauth-provider-debug'))
|
||||
}}
|
||||
|
||||
{{! redirect if we aren't on a URL with dc information }}
|
||||
{{#if (eq route.currentName 'index')}}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
<Route @name={{routeName}} as |route|>
|
||||
{{#if (env 'CONSUL_V2_CATALOG_ENABLED')}}
|
||||
<div class='h-screen w-full flex flex-col justify-center items-center'>
|
||||
<div>
|
||||
<svg
|
||||
width='149'
|
||||
height='39'
|
||||
viewBox='0 0 149 39'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
class='mb-8'
|
||||
>
|
||||
<g clip-path='url(#clip0_2336_115454)'>
|
||||
<path
|
||||
d='M54.6631 13.8631C54.6631 9.36592 57.3284 6.74561 63.5515 6.74561C65.8492 6.7447 68.1385 7.01683 70.3697 7.55608L69.8428 11.578C67.8266 11.2067 65.7822 11.0028 63.7313 10.9686C60.4647 10.9686 59.3924 12.0715 59.3924 14.6919V24.1128C59.3924 26.727 60.4399 27.8361 63.7313 27.8361C65.7822 27.8018 67.8266 27.598 69.8428 27.2267L70.3697 31.2486C68.1385 31.7878 65.8492 32.06 63.5515 32.059C57.3532 32.059 54.6631 29.4387 54.6631 24.9415V13.8631Z'
|
||||
fill='black'
|
||||
/>
|
||||
<path
|
||||
d='M80.4668 32.0408C74.2003 32.0408 72.5205 28.6405 72.5205 24.9843V20.4262C72.5205 16.7394 74.2065 13.3452 80.473 13.3452C86.7395 13.3452 88.4193 16.7394 88.4193 20.4262V24.9843C88.4131 28.6405 86.7271 32.0408 80.4668 32.0408ZM80.4668 17.1782C78.0246 17.1782 77.0887 18.2507 77.0887 20.2799V25.1061C77.0887 27.1354 78.0246 28.2018 80.4668 28.2018C82.9089 28.2018 83.8387 27.1354 83.8387 25.1061V20.2799C83.8387 18.2812 82.9027 17.1782 80.4668 17.1782Z'
|
||||
fill='black'
|
||||
/>
|
||||
<path
|
||||
d='M102.328 31.6877V19.1345C102.328 18.1778 101.913 17.6964 100.865 17.6964C99.8178 17.6964 97.7661 18.3606 96.0988 19.2077V31.6877H91.5244V13.7172H95.0141L95.4542 15.2345C97.7321 14.1126 100.223 13.4712 102.768 13.3516C105.805 13.3516 106.896 15.4539 106.896 18.6592V31.6877H102.328Z'
|
||||
fill='black'
|
||||
/>
|
||||
<path
|
||||
d='M116.312 32.0412C114.172 32.0062 112.05 31.657 110.015 31.0052L110.634 27.5805C112.403 28.0763 114.231 28.3366 116.07 28.3544C118.097 28.3544 118.395 27.9096 118.395 26.5263C118.395 25.4233 118.172 24.8688 115.209 24.168C110.746 23.1016 110.219 21.9926 110.219 18.5252C110.219 14.9116 111.831 13.3272 117.037 13.3272C118.88 13.3221 120.716 13.5265 122.511 13.9366L122.108 17.5502C120.448 17.2493 118.768 17.0762 117.081 17.0322C115.091 17.0322 114.756 17.4771 114.756 18.5801C114.756 20.0182 114.868 20.1279 117.347 20.7555C122.442 22.084 122.926 22.7482 122.926 26.4349C122.913 29.9022 121.829 32.0412 116.312 32.0412Z'
|
||||
fill='black'
|
||||
/>
|
||||
<path
|
||||
d='M130.487 13.7168V26.2516C130.487 27.2084 130.897 27.6898 131.95 27.6898C133.004 27.6898 135.049 27.0255 136.711 26.1785V13.7168H141.285V31.6873H137.802L137.349 30.176C135.071 31.2988 132.58 31.9402 130.035 32.059C126.998 32.059 125.913 29.9566 125.913 26.7452V13.7168H130.487Z'
|
||||
fill='black'
|
||||
/>
|
||||
<path d='M145.221 31.6877V6.38037L149.795 5.771V31.6877H145.221Z' fill='black' />
|
||||
<path
|
||||
d='M20.1451 38.75C16.9414 38.7517 13.7857 37.9848 10.9519 36.5157C8.1181 35.0466 5.69179 32.9197 3.88359 30.3197C2.0754 27.7198 0.939957 24.7252 0.575821 21.596C0.211686 18.4668 0.629862 15.2975 1.79405 12.3632C2.95824 9.42894 4.83326 6.81831 7.25637 4.75795C9.67949 2.69759 12.5775 1.24976 15.6988 0.540121C18.8201 -0.169518 22.0704 -0.119518 25.1675 0.685782C28.2647 1.49108 31.1152 3.02734 33.4716 5.16123L28.8166 9.9631C26.9587 8.31623 24.655 7.2343 22.1844 6.84834C19.7138 6.46239 17.1824 6.78896 14.8967 7.78851C12.6111 8.78806 10.6693 10.4177 9.30646 12.4801C7.94365 14.5424 7.21832 16.9491 7.21832 19.4084C7.21832 21.8678 7.94365 24.2744 9.30646 26.3367C10.6693 28.3991 12.6111 30.0288 14.8967 31.0283C17.1824 32.0279 19.7138 32.3544 22.1844 31.9685C24.655 31.5825 26.9587 30.5006 28.8166 28.8537L33.4716 33.6373C29.842 36.9293 25.0834 38.7549 20.1451 38.75Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M35.9875 29.0672C35.6688 29.0672 35.3572 28.9743 35.0922 28.8002C34.8272 28.6261 34.6206 28.3786 34.4987 28.0891C34.3767 27.7996 34.3448 27.4811 34.4069 27.1737C34.4691 26.8664 34.6226 26.5841 34.848 26.3625C35.0734 26.1409 35.3605 25.99 35.6731 25.9289C35.9858 25.8677 36.3098 25.8991 36.6043 26.019C36.8987 26.139 37.1504 26.342 37.3275 26.6026C37.5046 26.8631 37.5991 27.1695 37.5991 27.4828C37.5991 27.903 37.4293 28.306 37.1271 28.6031C36.8249 28.9003 36.415 29.0672 35.9875 29.0672Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M20.0203 23.5891C19.1769 23.5891 18.3524 23.3432 17.6511 22.8825C16.9498 22.4219 16.4032 21.7671 16.0805 21.001C15.7577 20.2349 15.6733 19.392 15.8378 18.5787C16.0023 17.7654 16.4085 17.0184 17.0049 16.4321C17.6013 15.8457 18.3611 15.4464 19.1884 15.2847C20.0156 15.1229 20.873 15.2059 21.6523 15.5232C22.4315 15.8406 23.0975 16.3779 23.5661 17.0674C24.0347 17.7568 24.2848 18.5674 24.2848 19.3966C24.2848 20.5085 23.8355 21.5749 23.0358 22.3611C22.236 23.1474 21.1513 23.5891 20.0203 23.5891Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M37.8411 23.6497C37.5223 23.6497 37.2107 23.5568 36.9457 23.3827C36.6807 23.2086 36.4741 22.9612 36.3522 22.6716C36.2302 22.3821 36.1983 22.0636 36.2605 21.7562C36.3226 21.4489 36.4761 21.1666 36.7015 20.945C36.9269 20.7234 37.214 20.5725 37.5267 20.5114C37.8393 20.4503 38.1633 20.4816 38.4578 20.6016C38.7523 20.7215 39.004 20.9246 39.181 21.1851C39.3581 21.4457 39.4526 21.752 39.4526 22.0653C39.451 22.485 39.2807 22.8871 38.9788 23.1839C38.6769 23.4807 38.268 23.6481 37.8411 23.6497Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M33.0432 23.4671C32.7245 23.4671 32.4129 23.3742 32.1479 23.2001C31.8828 23.026 31.6763 22.7785 31.5543 22.489C31.4323 22.1995 31.4004 21.881 31.4626 21.5736C31.5248 21.2663 31.6783 20.984 31.9037 20.7624C32.129 20.5408 32.4162 20.3899 32.7288 20.3288C33.0414 20.2677 33.3655 20.299 33.6599 20.4189C33.9544 20.5389 34.2061 20.7419 34.3832 21.0025C34.5603 21.263 34.6548 21.5694 34.6548 21.8827C34.6548 22.3029 34.485 22.7059 34.1828 23.003C33.8805 23.3002 33.4706 23.4671 33.0432 23.4671Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M37.8411 18.3177C37.5223 18.3177 37.2107 18.2248 36.9457 18.0507C36.6807 17.8766 36.4741 17.6291 36.3522 17.3396C36.2302 17.0501 36.1983 16.7315 36.2605 16.4242C36.3226 16.1169 36.4761 15.8346 36.7015 15.613C36.9269 15.3914 37.214 15.2405 37.5267 15.1794C37.8393 15.1182 38.1633 15.1496 38.4578 15.2695C38.7523 15.3894 39.004 15.5925 39.181 15.8531C39.3581 16.1136 39.4526 16.4199 39.4526 16.7333C39.451 17.153 39.2807 17.5551 38.9788 17.8518C38.6769 18.1486 38.268 18.3161 37.8411 18.3177Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M33.0432 18.5008C32.7245 18.5008 32.4129 18.4079 32.1479 18.2338C31.8828 18.0597 31.6763 17.8122 31.5543 17.5227C31.4323 17.2332 31.4004 16.9146 31.4626 16.6073C31.5248 16.3 31.6783 16.0177 31.9037 15.7961C32.129 15.5745 32.4162 15.4236 32.7288 15.3625C33.0414 15.3013 33.3655 15.3327 33.6599 15.4526C33.9544 15.5726 34.2061 15.7756 34.3832 16.0362C34.5603 16.2967 34.6548 16.603 34.6548 16.9164C34.6548 17.3366 34.485 17.7396 34.1828 18.0367C33.8805 18.3339 33.4706 18.5008 33.0432 18.5008Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
<path
|
||||
d='M36.0803 12.9856C35.7616 12.9856 35.45 12.8927 35.185 12.7186C34.92 12.5445 34.7134 12.2971 34.5914 12.0076C34.4694 11.7181 34.4375 11.3995 34.4997 11.0922C34.5619 10.7848 34.7154 10.5025 34.9408 10.2809C35.1662 10.0594 35.4533 9.90847 35.7659 9.84734C36.0785 9.7862 36.4026 9.81758 36.697 9.9375C36.9915 10.0574 37.2432 10.2605 37.4203 10.521C37.5974 10.7816 37.6919 11.0879 37.6919 11.4013C37.6919 11.8215 37.5221 12.2245 37.2199 12.5216C36.9176 12.8187 36.5077 12.9856 36.0803 12.9856Z'
|
||||
fill='#E03875'
|
||||
/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id='clip0_2336_115454'>
|
||||
<rect width='150' height='39' fill='white' />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<Hds::ApplicationState as |A|>
|
||||
<A.Header @title='User Interface Unavailable' data-test-unavailable-header />
|
||||
<A.Body
|
||||
@text='The Consul v2 catalog API (beta) is enabled, and is not yet compatible with the Consul UI.'
|
||||
data-test-unavailable-body
|
||||
/>
|
||||
<A.Footer @hasDivider={{true}} as |F|>
|
||||
<F.Link::Standalone
|
||||
@icon='docs-link'
|
||||
@iconPosition='trailing'
|
||||
@isHrefExternal={{true}}
|
||||
@text='Learn more'
|
||||
@href='https://developer.hashicorp.com/consul/docs/architecture/catalog/v2#constraints-and-limitations'
|
||||
/>
|
||||
<F.Link::Standalone
|
||||
@icon='external-link'
|
||||
@iconPosition='trailing'
|
||||
@isHrefExternal={{true}}
|
||||
@text='Provide feedback'
|
||||
@href='https://hashicorp.sjc1.qualtrics.com/jfe/form/SV_cHDaObigIBbQneC'
|
||||
/>
|
||||
</A.Footer>
|
||||
</Hds::ApplicationState>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</Route>
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { currentURL, visit } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupTestEnv } from 'consul-ui/services/env';
|
||||
|
||||
const unavailableHeaderSelector = '[data-test-unavailable-header]';
|
||||
const unavailableBodySelector = '[data-test-unavailable-body]';
|
||||
|
||||
module('Acceptance | unavailable page', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
|
||||
test('it redirects to the unavailable page when the v2 catalog is enabled', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
setupTestEnv(this.owner, {
|
||||
CONSUL_V2_CATALOG_ENABLED: true,
|
||||
});
|
||||
|
||||
await visit('/');
|
||||
assert.equal(currentURL(), '/unavailable', 'It should redirect to the unavailable page');
|
||||
|
||||
// Expect the warning message to be visible
|
||||
assert.dom(unavailableHeaderSelector).hasText('User Interface Unavailable');
|
||||
assert.dom(unavailableBodySelector).exists({ count: 1 });
|
||||
});
|
||||
|
||||
test('it does not redirect to the unavailable page', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
setupTestEnv(this.owner, {
|
||||
CONSUL_V2_CATALOG_ENABLED: false,
|
||||
});
|
||||
|
||||
await visit('/');
|
||||
assert.equal(
|
||||
currentURL(),
|
||||
'/dc1/services',
|
||||
'It should continue to the services page when v2 catalog is disabled'
|
||||
);
|
||||
|
||||
// Expect the warning message to be not be visible
|
||||
assert.dom(unavailableHeaderSelector).doesNotExist();
|
||||
assert.dom(unavailableBodySelector).doesNotExist();
|
||||
});
|
||||
|
||||
test('it redirects away from the unavailable page when v2 catalog is not enabled', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
setupTestEnv(this.owner, {
|
||||
CONSUL_V2_CATALOG_ENABLED: false,
|
||||
});
|
||||
|
||||
await visit('/unavailable');
|
||||
assert.equal(currentURL(), '/dc1/services', 'It should redirect to the services page');
|
||||
|
||||
// Expect the warning message to be not be visible
|
||||
assert.dom(unavailableHeaderSelector).doesNotExist();
|
||||
assert.dom(unavailableBodySelector).doesNotExist();
|
||||
});
|
||||
});
|
|
@ -439,6 +439,9 @@
|
|||
redirect: '../settings',
|
||||
},
|
||||
},
|
||||
unavailable: {
|
||||
_options: { path: '/unavailable' },
|
||||
},
|
||||
notfound: {
|
||||
_options: { path: '/*notfound' },
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue