From a4f67a6b2b3b5ffefb2c193f166b6b10cca541bb Mon Sep 17 00:00:00 2001 From: malinac02 <104539507+malinac02@users.noreply.github.com> Date: Thu, 20 Jul 2023 09:59:52 -0700 Subject: [PATCH] UI: Add example modal to policy form (#21583) * created new JsonTemplate component * used JsonTemplate in modal PolicyTemplate to replace code there * renamed component and fixed when the editor content shows up * changed PolicyForm to render example modal only conditionally. added desription to policy-example.js * fixed bug in policy-example.js & edited description of that file, removed functionality from policy-template.js (it is already in policy-example.js) * changed margin on text to better match Figma design, added example modal for when editing a policy * added tests for PolicyExample in policy-example-tests * added PolicyForm tests for (1) cancelling the creation/edit of policy and (2) properly rendering the policy example modal * add changelog * clean up code by removing unnecessary comments * changed a conditional in policy-form.hbs for better readability (Kianna's comment) * fixed description in policy-example.js, changed wording for RGP example, changed wording in policy-form-test.js * added 2 more asserts in policy-form-test.js. Changed some naming for selectors in the test file * added EGP policy to PolicyExample component, moved some functionality from .hbs to .js file and vise versa * added tests to policy-exammple-test.js and policy-form-test.js to account for new EGP policy * simplified all PolicyExample tests in policy-exmaple-test.js * removed beforeEach hook in policy-exmaple-test.js --- changelog/21583.txt | 3 + .../components/modal-form/policy-template.hbs | 32 +-- .../components/modal-form/policy-template.js | 33 --- ui/app/components/policy-form.hbs | 78 +++++-- ui/app/components/policy-form.js | 3 + .../vault/cluster/policies/create.hbs | 1 + .../templates/vault/cluster/policy/edit.hbs | 1 + ui/lib/core/addon/components/json-editor.hbs | 1 + .../core/addon/components/policy-example.hbs | 50 ++++ .../core/addon/components/policy-example.js | 98 ++++++++ ui/lib/core/app/components/policy-example.js | 1 + .../components/policy-example-test.js | 88 +++++++ .../components/policy-form-test.js | 214 ++++++++++++++++++ 13 files changed, 520 insertions(+), 83 deletions(-) create mode 100644 changelog/21583.txt create mode 100644 ui/lib/core/addon/components/policy-example.hbs create mode 100644 ui/lib/core/addon/components/policy-example.js create mode 100644 ui/lib/core/app/components/policy-example.js create mode 100644 ui/tests/integration/components/policy-example-test.js diff --git a/changelog/21583.txt b/changelog/21583.txt new file mode 100644 index 0000000000..f16fd383d2 --- /dev/null +++ b/changelog/21583.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: add example modal to policy form +``` \ No newline at end of file diff --git a/ui/app/components/modal-form/policy-template.hbs b/ui/app/components/modal-form/policy-template.hbs index 177b7cce0f..afcc1df42b 100644 --- a/ui/app/components/modal-form/policy-template.hbs +++ b/ui/app/components/modal-form/policy-template.hbs @@ -27,37 +27,7 @@ {{/if}} {{#if this.showExamplePolicy}} -
- {{#if (eq this.policy.policyType "acl")}} -

- ACL Policies are written in Hashicorp Configuration Language ( - HCL - ) or JSON and describe which paths in Vault a user or machine is allowed to access. Here is an example policy: -

- {{else}} -

- Role Governing Policies (RGPs) are tied to client tokens or identities which is similar to - ACL policies. They use - Sentinel - as a language framework to enable fine-grained policy decisions. -

-

- Here is an example policy that uses RGP to restrict access to the - admin - policy such that a user named James or has the - Team Lead - role can manage the - admin - policy: -

- {{/if}} -
- + {{else}}