mirror of https://github.com/hashicorp/consul
ui: Remove Settings Ember Route (#12488)
parent
55851c784f
commit
ec536340df
|
@ -1,9 +1,32 @@
|
|||
import Route from 'consul-ui/routing/route';
|
||||
import { action } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
||||
|
||||
export default class ApplicationRoute extends Route.extend(WithBlockingActions) {
|
||||
@service('client/http') client;
|
||||
|
||||
data;
|
||||
|
||||
@action
|
||||
onClientChanged(e) {
|
||||
let data = e.data;
|
||||
if(data === '') {
|
||||
data = { blocking: true };
|
||||
}
|
||||
// this.data is always undefined first time round and its the 'first read'
|
||||
// of the value so we don't need to abort anything
|
||||
if(typeof this.data === 'undefined') {
|
||||
this.data = Object.assign({}, data);
|
||||
return;
|
||||
}
|
||||
if(this.data.blocking === true && data.blocking === false) {
|
||||
this.client.abort();
|
||||
}
|
||||
this.data = Object.assign({}, data);
|
||||
}
|
||||
|
||||
@action
|
||||
error(e, transition) {
|
||||
// TODO: Normalize all this better
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import Route from 'consul-ui/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class SettingsRoute extends Route {
|
||||
@service('client/http') client;
|
||||
@service('settings') repo;
|
||||
|
||||
@action
|
||||
change(slug, item) {
|
||||
switch (slug) {
|
||||
case 'client':
|
||||
item.blocking = !item.blocking;
|
||||
if (!item.blocking) {
|
||||
this.client.abort();
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.repo.persist({
|
||||
[slug]: item,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -17,6 +17,12 @@ as |route|>
|
|||
{{document-attrs class="has-partitions"}}
|
||||
{{/if}}
|
||||
|
||||
{{! Listen out for blocking query/client setting changes }}
|
||||
<DataSource
|
||||
@src={{uri 'settings://consul:client'}}
|
||||
@onchange={{route-action "onClientChanged"}}
|
||||
/>
|
||||
|
||||
{{! Tell CSS about our theme }}
|
||||
<DataSource
|
||||
@src={{uri 'settings://consul:theme'}}
|
||||
|
@ -36,6 +42,7 @@ as |source|>
|
|||
/>
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{#if (not-eq route.currentName 'oauth-provider-debug')}}
|
||||
|
||||
{{! redirect if we aren't on a URL with dc information }}
|
||||
|
|
|
@ -40,21 +40,33 @@ as |item|}}
|
|||
</Notice>
|
||||
<form>
|
||||
{{#if (not (env 'CONSUL_UI_DISABLE_REALTIME'))}}
|
||||
<Disclosure as |disclosure|>
|
||||
<disclosure.Details>
|
||||
<DataSink
|
||||
@data={{item}}
|
||||
@sink='settings://consul:client'
|
||||
@onchange={{action (fn disclosure.close)}}
|
||||
/>
|
||||
</disclosure.Details>
|
||||
<fieldset data-test-blocking-queries>
|
||||
<h2>Blocking Queries</h2>
|
||||
<p>Keep catalog info up-to-date without refreshing the page. Any changes made to services, nodes and intentions would be reflected in real time.</p>
|
||||
<div class="type-toggle">
|
||||
<label>
|
||||
<input
|
||||
{{on 'change' (queue
|
||||
(set item 'blocking' (not item.blocking))
|
||||
(fn disclosure.open)
|
||||
)}}
|
||||
type="checkbox"
|
||||
name="client[blocking]"
|
||||
checked={{if item.blocking 'checked'}}
|
||||
onchange={{route-action 'change' 'client' item}}
|
||||
/>
|
||||
<span>{{if item.blocking 'On' 'Off'}}</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</Disclosure>
|
||||
{{/if}}
|
||||
</form>
|
||||
</BlockSlot>
|
||||
|
|
|
@ -5,7 +5,7 @@ Feature: settings / show: Show Settings Page
|
|||
Scenario: I see the Blocking queries
|
||||
Given 1 datacenter model with the value "dc1"
|
||||
When I visit the settings page
|
||||
Then the url should be /setting
|
||||
Then the url should be /settings
|
||||
# FIXME
|
||||
# And the title should be "Settings - Consul"
|
||||
And I see blockingQueries
|
||||
|
@ -20,7 +20,7 @@ Feature: settings / show: Show Settings Page
|
|||
CONSUL_UI_DISABLE_REALTIME: "1"
|
||||
---
|
||||
When I visit the settings page
|
||||
Then the url should be /setting
|
||||
Then the url should be /settings
|
||||
# FIXME
|
||||
# And the title should be "Settings - Consul"
|
||||
And I don't see blockingQueries
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Route | settings', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:settings');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
|
@ -397,7 +397,17 @@
|
|||
_options: { path: '/' },
|
||||
},
|
||||
settings: {
|
||||
_options: { path: '/setting' },
|
||||
_options: {
|
||||
path: '/settings',
|
||||
},
|
||||
},
|
||||
/* This was introduced in 1.12. By the time we get to 1.15 */
|
||||
/* I'd say we are safe to remove, feel free to delete for 1.15 */
|
||||
setting: {
|
||||
_options: {
|
||||
path: '/setting',
|
||||
redirect: '../settings',
|
||||
},
|
||||
},
|
||||
notfound: {
|
||||
_options: { path: '/*notfound' },
|
||||
|
|
Loading…
Reference in New Issue