Skip to content

Commit

Permalink
ui: Ensure we clean up javascript based DataSources
Browse files Browse the repository at this point in the history
DataSources added via javascript require cleaning up by assigning it to
an EventSource component in the template, otherwise the blocking query
can stick around when its no longer needed.

We also took the opportunity here to make this consistent with the rest
of the application.

1. Don't use `@model`.
2. Use our <Route /> component.
3. Use extra divs/spans specifically for styling only as a last resort.
  • Loading branch information
John Cowen committed Sep 24, 2021
1 parent 0aef2dc commit fb296aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
7 changes: 6 additions & 1 deletion ui/packages/consul-ui/app/routes/dc/routing-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default class RoutingConfigRoute extends Route {
dc: dc,
nspace: nspace,
slug: name,
chain: await this.data.source(uri => uri`/${nspace}/${dc}/discovery-chain/${params.name}`),
chain: await this.data.source(uri => uri`/${nspace}/${dc}/discovery-chain/${name}`),
};
}

setupController(controller, model) {
super.setupController(...arguments);
controller.setProperties(model);
}
}
4 changes: 2 additions & 2 deletions ui/packages/consul-ui/app/styles/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ html[data-route$='edit'] .app-view > header + div > *:first-child {
}
/* most tabs have margin after the tab bar, unless the tab has a filter bar */
/* if it is a filter bar and the thing after the filter bar is a p then it also */
/* needs a top margun :S */
/* needs a top margin :S */
%app-view-content .tab-section > *:first-child:not(.filter-bar):not(table),
%app-view-content .tab-section > .search-bar + p,
%app-view-content .tab-section .consul-health-check-list,
%app-view-content .container {
html[data-route$='dc.routing-config'] .discovery-chain {
margin-top: 1.25em;
}
.consul-upstream-instance-list,
Expand Down
43 changes: 24 additions & 19 deletions ui/packages/consul-ui/app/templates/dc/routing-config.hbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{{page-title @model.slug}}
<Route
@name={{routeName}}
@title={{slug}}
as |route|>

<AppView>
<BlockSlot @name="breadcrumbs">
<ol>
<li><a data-test-back href={{href-to 'dc.services'}}>All Services</a></li>
</ol>
</BlockSlot>
<BlockSlot @name="header">
<h1>
{{@model.slug}}
</h1>
<Consul::Source @source={{t "routes.dc.routing-config.source"}} @withInfo={{true}} />
</BlockSlot>
<BlockSlot @name="content">
<div class="container">
<EventSource @src={{chain}} />

<AppView>
<BlockSlot @name="breadcrumbs">
<ol>
<li><a data-test-back href={{href-to 'dc.services'}}>All Services</a></li>
</ol>
</BlockSlot>
<BlockSlot @name="header">
<h1>
{{slug}}
</h1>
<Consul::Source @source={{t "routes.dc.routing-config.source"}} @withInfo={{true}} />
</BlockSlot>
<BlockSlot @name="content">
<Consul::DiscoveryChain
@chain={{@model.chain.Chain}}
@chain={{chain.Chain}}
/>
</div>
</BlockSlot>
</AppView>
</BlockSlot>
</AppView>

</Route>

0 comments on commit fb296aa

Please sign in to comment.