2021-03-08 12:15:54 +00:00
|
|
|
<Route
|
|
|
|
@name={{routeName}}
|
|
|
|
as |route|>
|
2021-09-15 18:50:11 +00:00
|
|
|
<DataLoader
|
|
|
|
@src={{uri '/${partition}/${nspace}/${dc}/service-instances/for-service/${name}'
|
|
|
|
(hash
|
|
|
|
partition=route.params.partition
|
|
|
|
nspace=route.params.nspace
|
|
|
|
dc=route.params.dc
|
|
|
|
name=route.params.name
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
as |loader|>
|
2020-12-17 16:35:01 +00:00
|
|
|
|
2021-03-08 12:15:54 +00:00
|
|
|
<BlockSlot @name="error">
|
2021-04-06 12:40:40 +00:00
|
|
|
<AppError
|
|
|
|
@error={{loader.error}}
|
|
|
|
@login={{route.model.app.login.open}}
|
|
|
|
/>
|
2021-03-08 12:15:54 +00:00
|
|
|
</BlockSlot>
|
2020-12-17 16:35:01 +00:00
|
|
|
|
2021-03-08 12:15:54 +00:00
|
|
|
<BlockSlot @name="disconnected" as |Notification|>
|
|
|
|
{{#if (eq loader.error.status "404")}}
|
|
|
|
<Notification @sticky={{true}}>
|
|
|
|
<p data-notification role="alert" class="warning notification-update">
|
|
|
|
<strong>Warning!</strong>
|
|
|
|
This service has been deregistered and no longer exists in the catalog.
|
|
|
|
</p>
|
|
|
|
</Notification>
|
|
|
|
{{else if (eq loader.error.status "403")}}
|
|
|
|
<Notification @sticky={{true}}>
|
|
|
|
<p data-notification role="alert" class="error notification-update">
|
|
|
|
<strong>Error!</strong>
|
|
|
|
You no longer have access to this service
|
|
|
|
</p>
|
|
|
|
</Notification>
|
|
|
|
{{else}}
|
|
|
|
<Notification @sticky={{true}}>
|
|
|
|
<p data-notification role="alert" class="warning notification-update">
|
|
|
|
<strong>Warning!</strong>
|
|
|
|
An error was returned whilst loading this data, refresh to try again.
|
|
|
|
</p>
|
|
|
|
</Notification>
|
2020-12-17 16:35:01 +00:00
|
|
|
{{/if}}
|
2021-03-08 12:15:54 +00:00
|
|
|
</BlockSlot>
|
|
|
|
|
|
|
|
<BlockSlot @name="loaded">
|
2021-09-15 18:50:11 +00:00
|
|
|
{{#let
|
|
|
|
loader.data
|
|
|
|
loader.data.firstObject
|
|
|
|
route.model.dc
|
|
|
|
as |items item dc|}}
|
|
|
|
|
|
|
|
{{#if item.IsOrigin}}
|
|
|
|
<DataSource
|
|
|
|
@src={{uri '/${partition}/${nspace}/${dc}/proxies/for-service/${name}'
|
|
|
|
(hash
|
|
|
|
partition=route.params.partition
|
|
|
|
nspace=route.params.nspace
|
|
|
|
dc=route.params.dc
|
|
|
|
name=route.params.name
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
@onchange={{action (mut proxies) value="data"}}
|
|
|
|
/>
|
|
|
|
{{! currently we use the discovery chain endpoint to understand whether }}
|
|
|
|
{{! connect is enabled/disabled. We get a 500 error when its disabled }}
|
|
|
|
{{! and use this to set MeshEnabled on the Datacenter }}
|
|
|
|
{{! if once chain is set, i.e. we've checked this dc we remove the DataSource }}
|
|
|
|
{{! which will mark it for closure, which possibly could be reopened if }}
|
2021-10-26 18:26:04 +00:00
|
|
|
{{! the user clicks the routing/disco-chain tab}}
|
2021-09-15 18:50:11 +00:00
|
|
|
{{#if (not chain)}}
|
|
|
|
<DataSource
|
|
|
|
@src={{uri '/${partition}/${nspace}/${dc}/discovery-chain/${name}'
|
|
|
|
(hash
|
|
|
|
partition=route.params.partition
|
|
|
|
nspace=route.params.nspace
|
|
|
|
dc=route.params.dc
|
|
|
|
name=route.params.name
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
@onchange={{action (mut chain) value="data"}}
|
|
|
|
/>
|
|
|
|
{{/if}}
|
2021-10-26 18:26:04 +00:00
|
|
|
{{did-insert (set this 'chain' undefined) route.params.dc}}
|
2021-09-15 18:50:11 +00:00
|
|
|
{{/if}}
|
|
|
|
{{#let
|
|
|
|
(hash
|
|
|
|
topology=(and dc.MeshEnabled item.IsMeshOrigin (or (gt proxies.length 0) (eq item.Service.Kind 'ingress-gateway')))
|
|
|
|
services=(eq item.Service.Kind 'terminating-gateway')
|
|
|
|
upstreams=(eq item.Service.Kind 'ingress-gateway')
|
|
|
|
instances=true
|
ui: Ensure we check intention service prefix permissions for per service (#11409)
Port of: Ensure we check intention service prefix permissions for per service (#11270)
Previously, when showing some action buttons for 'per service intentions' we used a global 'can I do something with any intention' permission to decide whether to show a certain button or not. If a user has a token that does not have 'global' intention permissions, but does have intention permissions on one or more specific services (for example via service / service_prefix), this meant that we did not show them certain buttons required to create/edit the intentions for this specific service.
This PR adds that extra permissions check so we now check the intentions permissions per service instead of using the 'global' "can I edit intentions" question/request.
**Notes:**
- If a HTML button is `disabled` this means tippy.js doesn't adopt the
popover properly and subsequently hide it from the user, so aswell as
just disabling the button so you can't active the popover, we also don't
even put the popover on the page
- If `ability.item` or `ability.item.Resources` are empty then assume no access
**We don't try to disable service > right hand side intention actions here**
Whether you can create intentions for a service depends on the
_destination_ of the intention you would like to create. For the
topology view going from the LHS to the center, this is straightforwards
as we only need to know the permissions for the central service, as when
you are going from the LHS to the center, the center is the
_destination_.
When going from the center to the RHS the _destination[s]_ are on the
RHS. This means we need to know the permissions for potentially 1000s of
services all in one go in order to know when to show a button or not.
We can't realistically discover the permissions for service > RHS
services as we'd have either make a HTTP request per right hand service,
or potentially make an incredibly large POST request for all the
potentially 1000s of services on the right hand side (more preferable to
1000s of HTTP requests).
Therefore for the moment at least we keep the old functionality (thin client)
for the middle to RHS here. If you do go to click on the button and you
don't have permissions to update the intention you will still not be
able to update it, only you won't know this until you click the button
(at which point you'll get a UI visible 403 error)
Note: We reversed the conditional here between 1.10 and 1.11
So this make 100% sense that the port is different here to 1.11
2021-11-04 12:10:28 +00:00
|
|
|
intentions=(and (not-eq item.Service.Kind 'terminating-gateway') (can 'read intention for service' item=item.Service))
|
2021-09-15 18:50:11 +00:00
|
|
|
routing=(and dc.MeshEnabled item.IsOrigin)
|
|
|
|
tags=(not item.Service.Kind)
|
|
|
|
)
|
|
|
|
as |tabs|}}
|
2021-03-08 12:15:54 +00:00
|
|
|
<AppView>
|
|
|
|
<BlockSlot @name="notification" as |status type item error|>
|
|
|
|
<TopologyMetrics::Notifications
|
|
|
|
@type={{type}}
|
|
|
|
@status={{status}}
|
|
|
|
@error={{error}}
|
|
|
|
/>
|
|
|
|
</BlockSlot>
|
|
|
|
<BlockSlot @name="breadcrumbs">
|
|
|
|
<ol>
|
|
|
|
<li><a data-test-back href={{href-to 'dc.services'}}>All Services</a></li>
|
|
|
|
</ol>
|
|
|
|
</BlockSlot>
|
|
|
|
<BlockSlot @name="header">
|
|
|
|
<h1>
|
2021-09-15 18:50:11 +00:00
|
|
|
<route.Title @title={{item.Service.Service}} />
|
2021-03-08 12:15:54 +00:00
|
|
|
</h1>
|
2021-11-10 21:54:12 +00:00
|
|
|
<Consul::ExternalSource @item={{item.Service}} @withInfo={{true}} />
|
2021-03-08 12:15:54 +00:00
|
|
|
<Consul::Kind @item={{item.Service}} @withInfo={{true}} />
|
|
|
|
</BlockSlot>
|
|
|
|
<BlockSlot @name="nav">
|
|
|
|
{{#if (not-eq item.Service.Kind 'mesh-gateway')}}
|
|
|
|
<TabNav @items={{
|
|
|
|
compact
|
2021-09-15 18:50:11 +00:00
|
|
|
(array
|
|
|
|
(if tabs.topology
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Topology" href=(href-to "dc.services.show.topology") selected=(is-href "dc.services.show.topology"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.services
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Linked Services" href=(href-to "dc.services.show.services") selected=(is-href "dc.services.show.services"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.upstreams
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Upstreams" href=(href-to "dc.services.show.upstreams") selected=(is-href "dc.services.show.upstreams"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.instances
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Instances" href=(href-to "dc.services.show.instances") selected=(is-href "dc.services.show.instances"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.intentions
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Intentions" href=(href-to "dc.services.show.intentions") selected=(is-href "dc.services.show.intentions"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.routing
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Routing" href=(href-to "dc.services.show.routing") selected=(is-href "dc.services.show.routing"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
(if tabs.tags
|
2021-03-08 12:15:54 +00:00
|
|
|
(hash label="Tags" href=(href-to "dc.services.show.tags") selected=(is-href "dc.services.show.tags"))
|
2021-09-15 18:50:11 +00:00
|
|
|
'')
|
|
|
|
)
|
2021-03-08 12:15:54 +00:00
|
|
|
}}/>
|
|
|
|
{{/if}}
|
|
|
|
</BlockSlot>
|
|
|
|
<BlockSlot @name="actions">
|
2021-09-15 18:50:11 +00:00
|
|
|
<DataSource
|
|
|
|
@src={{uri '/${partition}/${nspace}/${dc}/ui-config'
|
|
|
|
(hash
|
|
|
|
partition=route.params.partition
|
|
|
|
nspace=route.params.nspace
|
|
|
|
dc=route.params.dc
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
as |config|>
|
|
|
|
{{#if config.data.dashboard_url_templates.service}}
|
|
|
|
<a href={{render-template config.data.dashboard_url_templates.service (hash
|
2021-03-08 12:15:54 +00:00
|
|
|
Datacenter=dc.Name
|
|
|
|
Service=(hash Name=item.Service.Service)
|
|
|
|
)}}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2021-09-15 18:50:11 +00:00
|
|
|
data-test-dashboard-anchor
|
|
|
|
>
|
2021-11-03 16:29:50 +00:00
|
|
|
Open dashboard
|
2021-03-08 12:15:54 +00:00
|
|
|
</a>
|
|
|
|
{{/if}}
|
2021-09-15 18:50:11 +00:00
|
|
|
</DataSource>
|
2021-03-08 12:15:54 +00:00
|
|
|
</BlockSlot>
|
|
|
|
<BlockSlot @name="content">
|
2021-09-15 18:50:11 +00:00
|
|
|
{{! if its not an origin service we don't care as to whether connect }}
|
|
|
|
{{! is enabled or not (we figure that out using the chain var) }}
|
|
|
|
{{#if (or (not item.IsOrigin) chain)}}
|
2021-03-08 12:15:54 +00:00
|
|
|
<Outlet
|
|
|
|
@name={{routeName}}
|
2021-09-15 18:50:11 +00:00
|
|
|
@model={{assign (hash
|
|
|
|
items=items
|
ui: Ensure we check intention service prefix permissions for per service (#11409)
Port of: Ensure we check intention service prefix permissions for per service (#11270)
Previously, when showing some action buttons for 'per service intentions' we used a global 'can I do something with any intention' permission to decide whether to show a certain button or not. If a user has a token that does not have 'global' intention permissions, but does have intention permissions on one or more specific services (for example via service / service_prefix), this meant that we did not show them certain buttons required to create/edit the intentions for this specific service.
This PR adds that extra permissions check so we now check the intentions permissions per service instead of using the 'global' "can I edit intentions" question/request.
**Notes:**
- If a HTML button is `disabled` this means tippy.js doesn't adopt the
popover properly and subsequently hide it from the user, so aswell as
just disabling the button so you can't active the popover, we also don't
even put the popover on the page
- If `ability.item` or `ability.item.Resources` are empty then assume no access
**We don't try to disable service > right hand side intention actions here**
Whether you can create intentions for a service depends on the
_destination_ of the intention you would like to create. For the
topology view going from the LHS to the center, this is straightforwards
as we only need to know the permissions for the central service, as when
you are going from the LHS to the center, the center is the
_destination_.
When going from the center to the RHS the _destination[s]_ are on the
RHS. This means we need to know the permissions for potentially 1000s of
services all in one go in order to know when to show a button or not.
We can't realistically discover the permissions for service > RHS
services as we'd have either make a HTTP request per right hand service,
or potentially make an incredibly large POST request for all the
potentially 1000s of services on the right hand side (more preferable to
1000s of HTTP requests).
Therefore for the moment at least we keep the old functionality (thin client)
for the middle to RHS here. If you do go to click on the button and you
don't have permissions to update the intention you will still not be
able to update it, only you won't know this until you click the button
(at which point you'll get a UI visible 403 error)
Note: We reversed the conditional here between 1.10 and 1.11
So this make 100% sense that the port is different here to 1.11
2021-11-04 12:10:28 +00:00
|
|
|
item=item
|
2021-09-15 18:50:11 +00:00
|
|
|
tabs=tabs
|
|
|
|
) route.model}}
|
2021-03-08 12:15:54 +00:00
|
|
|
as |o|>
|
|
|
|
{{outlet}}
|
|
|
|
</Outlet>
|
2021-09-15 18:50:11 +00:00
|
|
|
{{/if}}
|
2021-03-08 12:15:54 +00:00
|
|
|
</BlockSlot>
|
|
|
|
</AppView>
|
2021-09-15 18:50:11 +00:00
|
|
|
{{/let}}
|
|
|
|
{{/let}}
|
2021-03-08 12:15:54 +00:00
|
|
|
</BlockSlot>
|
|
|
|
</DataLoader>
|
2021-09-15 18:50:11 +00:00
|
|
|
</Route>
|