Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/11767.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Ensure we show a readonly designed page for readonly intentions
```
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line here was the bugfix, previously the readonly variable just below on line 63 was undefined always 😬

Most of the other change here is to test this so it doesn't happen again

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an opportunity to use cannot?

Suggested change
(not (can 'write intention' item=api.data))
(cannot 'write intention' item=api.data)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the codebase we prefer using not (can "thing"), that way folks always use the same method to flip the conditional no matter if it's using can or some other flippable helper. So I'll probably leave this one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

as |item readonly|}}
{{#if (not readonly)}}

{{#let (changeset-get item 'Action') as |newAction|}}
Expand Down Expand Up @@ -193,6 +196,7 @@ as |api|>
</div>
</form>
{{else}}

{{#if item.IsManagedByCRD}}
<Notice
class="crd"
Expand All @@ -215,8 +219,10 @@ as |api|>
</notice.Footer>
</Notice>
{{/if}}

<Consul::Intention::View
@item={{item}}
data-test-readonly
/>
{{/if}}
{{/let}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="consul-intention-view">
<div
class="consul-intention-view"
...attributes
>

<div class="definition-table">
<dl>
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/mock-api/v1/connect/intentions/exact
Original file line number Diff line number Diff line change
Expand Up @@ -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'])}"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);
});
}
Comment on lines +6 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you end up using this step? Looks like it always passes?

Copy link
Contributor Author

@johncowen johncowen Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is where it's just lack of context into the addon we use for our acceptance tests.

The addon requires these files in order to run (the idea is you write a entire set of steps for every test, which seems like a lot of repetitive work). Instead we have about 25-30 reusable steps that we use for all our tests. Unfortunately the addon requires these files to still exist and generates them exactly like this for each and every acceptance test. If you delete them it breaks. Therefore we have oodles of these files in a nested folder structure that are all exactly the same. It's annoying, but I just pretend they aren't there.

We had a PR a while ago to stop it from doing this which made it much nicer, but unfortunately it didn't go in and has been the root of confusion both previous to that PR and ever since 😹

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, that isn’t ideal. Still, explanation makes sense for the context of this PR.