ui: Remove Settings Ember Route (#12488)

pull/12543/head
John Cowen 2022-03-09 08:29:27 +00:00 committed by GitHub
parent 55851c784f
commit ec536340df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 38 deletions

View File

@ -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

View File

@ -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,
});
}
}

View File

@ -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 }}

View File

@ -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>

View File

@ -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

View File

@ -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);
});
});

View File

@ -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' },