Browse Source

ui: Ensure we show a special readonly page for intentions (#11767)

pull/11822/head
John Cowen 3 years ago committed by GitHub
parent
commit
be23aab001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .changelog/11767.txt
  2. 8
      ui/packages/consul-ui/app/components/consul/intention/form/index.hbs
  3. 5
      ui/packages/consul-ui/app/components/consul/intention/view/index.hbs
  4. 2
      ui/packages/consul-ui/mock-api/v1/connect/intentions/exact
  5. 15
      ui/packages/consul-ui/tests/acceptance/dc/intentions/read-only.feature
  6. 10
      ui/packages/consul-ui/tests/acceptance/steps/dc/intentions/read-only-steps.js

3
.changelog/11767.txt

@ -0,0 +1,3 @@
```release-note:bug
ui: Ensure we show a readonly designed page for readonly intentions
```

8
ui/packages/consul-ui/app/components/consul/intention/form/index.hbs

@ -56,7 +56,10 @@ as |api|>
</BlockSlot>
<BlockSlot @name="form">
{{#let api.data as |item|}}
{{#let
api.data
(not (can 'write intention' item=api.data))
as |item readonly|}}
{{#if (not readonly)}}
{{#let (changeset-get item 'Action') as |newAction|}}
@ -193,6 +196,7 @@ as |api|>
</div>
</form>
{{else}}
{{#if item.IsManagedByCRD}}
<Notice
class="crd"
@ -215,8 +219,10 @@ as |api|>
</notice.Footer>
</Notice>
{{/if}}
<Consul::Intention::View
@item={{item}}
data-test-readonly
/>
{{/if}}
{{/let}}

5
ui/packages/consul-ui/app/components/consul/intention/view/index.hbs

@ -1,4 +1,7 @@
<div class="consul-intention-view">
<div
class="consul-intention-view"
...attributes
>
<div class="definition-table">
<dl>

2
ui/packages/consul-ui/mock-api/v1/connect/intentions/exact

@ -81,7 +81,7 @@ ${fake.helpers.randomize([
],
`:``}
"Precedence": ${fake.random.number({min: 1, max: 100})},
${ !legacy && fake.random.number({min: 1, max: 10}) > 2 ? `
${ (!legacy || source[1] === "external-source") && fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"external-source": "${fake.helpers.randomize(['kubernetes', 'consul-api-gateway'])}"
},

15
ui/packages/consul-ui/tests/acceptance/dc/intentions/read-only.feature

@ -0,0 +1,15 @@
@setupApplicationTest
Feature: dc / intentions / read-only
Scenario: Viewing a readonly intention
Given 1 datacenter model with the value "dc1"
And 1 intention model from yaml:
---
Meta:
external-source: kubernetes
---
When I visit the intention page for yaml
---
dc: dc1
intention: default:external-source:web:default:external-source:db
---
Then I see the "[data-test-readonly]" element

10
ui/packages/consul-ui/tests/acceptance/steps/dc/intentions/read-only-steps.js

@ -0,0 +1,10 @@
import steps from '../../steps';
// step definitions that are shared between features should be moved to the
// tests/acceptance/steps/steps.js file
export default function(assert) {
return steps(assert).then('I should find a file', function() {
assert.ok(true, this.step);
});
}
Loading…
Cancel
Save