mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
[VAULT-33969] UI: replace readonly JsonEditor with Hds::CodeBlock (#29720)
* http://localhost:4200/ui/vault/secrets/kubernetes/kubernetes/roles/test/details readOnly JsonEditor to Hds::CodeBlock * http://localhost:4200/ui/vault/policies/acl/create readonly JsonEditor to Hds::CodeBlock * http://localhost:4200/ui/vault/policy/acl/default readonly JsonEditor to Hds::CodeBlock * http://localhost:4200/ui/vault/access/oidc/scopes/test/details readonly JsonEditor to Hds::CodeBlock * http://localhost:4200/ui/vault/access/oidc/scopes/create readonly JsonEditor to Hds::CodeBlock * fix (some) tests * fix remaining tests * add changelog
This commit is contained in:
committed by
GitHub
parent
5828be040a
commit
018674a798
3
changelog/29720.txt
Normal file
3
changelog/29720.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
ui: Use Hds::CodeBlock component to replace readonly JsonEditor instances
|
||||||
|
```
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<p data-test-scope-modal="text">
|
<p data-test-scope-modal="text">
|
||||||
Example of a JSON template for scopes:
|
Example of a JSON template for scopes:
|
||||||
</p>
|
</p>
|
||||||
<JsonEditor @value={{this.exampleTemplate}} @mode="ruby" @readOnly={{true}} @container=".hds-modal" />
|
<Hds::CodeBlock @value={{this.exampleTemplate}} @language="ruby" @hasCopyButton={{true}} />
|
||||||
<p class="has-top-margin-m">
|
<p class="has-top-margin-m">
|
||||||
The full list of template parameters can be found
|
The full list of template parameters can be found
|
||||||
<DocLink @path="/vault/docs/concepts/oidc-provider#scopes">
|
<DocLink @path="/vault/docs/concepts/oidc-provider#scopes">
|
||||||
|
|||||||
@@ -56,12 +56,9 @@
|
|||||||
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
|
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
|
||||||
<InfoTableRow @label="Name" @value={{this.model.name}} />
|
<InfoTableRow @label="Name" @value={{this.model.name}} />
|
||||||
<InfoTableRow @label="Description" @value={{this.model.description}} />
|
<InfoTableRow @label="Description" @value={{this.model.description}} />
|
||||||
<JsonEditor
|
<Hds::CodeBlock @value={{this.model.template}} @language="ruby" @hasCopyButton={{true}} as |CB|>
|
||||||
@title="JSON Template"
|
<CB.Title @tag="h3">
|
||||||
@mode="ruby"
|
JSON Template
|
||||||
@value={{this.model.template}}
|
</CB.Title>
|
||||||
@readOnly={{true}}
|
</Hds::CodeBlock>
|
||||||
class="has-top-margin-xl has-bottom-margin-xl"
|
|
||||||
data-test-oidc-scope-json
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
@@ -46,15 +46,18 @@
|
|||||||
</ToolbarActions>
|
</ToolbarActions>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
<div class="box is-bottomless is-fullwidth is-marginless">
|
<div class="box is-bottomless is-fullwidth is-marginless">
|
||||||
|
{{#if this.model.policy}}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<JsonEditor
|
<Hds::CodeBlock @value={{this.model.policy}} @hasCopyButton={{true}} @maxHeight="300px" @language="ruby" as |CB|>
|
||||||
@title="Policy"
|
<CB.Title @tag="h3">
|
||||||
@subTitle={{if (eq this.policyType "acl") (concat this.uppercase this.model.format " format")}}
|
Policy
|
||||||
@value={{this.model.policy}}
|
</CB.Title>
|
||||||
@readOnly={{true}}
|
<CB.Description>
|
||||||
@mode="ruby"
|
({{if (eq this.policyType "acl") (concat this.uppercase this.model.format " format")}})
|
||||||
/>
|
</CB.Description>
|
||||||
|
</Hds::CodeBlock>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{#if this.model.paths}}
|
{{#if this.model.paths}}
|
||||||
<div class="field box is-shadowless no-bottom-padding is-marginless">
|
<div class="field box is-shadowless no-bottom-padding is-marginless">
|
||||||
<h2 class="title is-6">Paths</h2>
|
<h2 class="title is-6">Paths</h2>
|
||||||
|
|||||||
@@ -54,14 +54,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<JsonEditor
|
<Hds::CodeBlock @value={{get this.policyTemplates @policyType}} @language="ruby" @hasCopyButton={{true}} />
|
||||||
@value={{get this.policyTemplates @policyType}}
|
|
||||||
@mode="ruby"
|
|
||||||
@readOnly={{true}}
|
|
||||||
@showToolbar={{true}}
|
|
||||||
{{! Passed to copy button }}
|
|
||||||
@container={{@container}}
|
|
||||||
/>
|
|
||||||
<div class="has-bottom-margin-m has-top-padding-s">
|
<div class="has-bottom-margin-m has-top-padding-s">
|
||||||
<p>
|
<p>
|
||||||
More information about
|
More information about
|
||||||
|
|||||||
@@ -52,14 +52,11 @@
|
|||||||
{{#if @model.generatedRoleRules}}
|
{{#if @model.generatedRoleRules}}
|
||||||
<div class="has-top-margin-xl" data-test-generated-role-rules>
|
<div class="has-top-margin-xl" data-test-generated-role-rules>
|
||||||
<h2 class="title is-4">Generated role rules</h2>
|
<h2 class="title is-4">Generated role rules</h2>
|
||||||
<JsonEditor
|
<Hds::CodeBlock @value={{@model.generatedRoleRules}} @language="ruby" @hasCopyButton={{true}} as |CB|>
|
||||||
@title="Role rules"
|
<CB.Title @tag="h3">
|
||||||
@value={{@model.generatedRoleRules}}
|
Role rules
|
||||||
@mode="ruby"
|
</CB.Title>
|
||||||
@readOnly={{true}}
|
</Hds::CodeBlock>
|
||||||
@showToolbar={{true}}
|
|
||||||
@theme="hashi auto-height"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|||||||
@@ -155,16 +155,6 @@ module('Integration | Component | oidc/scope-form', function (hooks) {
|
|||||||
const MODAL = (e) => `[data-test-scope-modal="${e}"]`;
|
const MODAL = (e) => `[data-test-scope-modal="${e}"]`;
|
||||||
this.model = this.store.createRecord('oidc/scope');
|
this.model = this.store.createRecord('oidc/scope');
|
||||||
|
|
||||||
// formatting here is purposeful so that it matches formatting in the template modal
|
|
||||||
const exampleTemplate = `{
|
|
||||||
"username": {{identity.entity.aliases.$MOUNT_ACCESSOR.name}},
|
|
||||||
"contact": {
|
|
||||||
"email": {{identity.entity.metadata.email}},
|
|
||||||
"phone_number": {{identity.entity.metadata.phone_number}}
|
|
||||||
},
|
|
||||||
"groups": {{identity.entity.groups.names}}
|
|
||||||
}`;
|
|
||||||
|
|
||||||
await render(hbs`
|
await render(hbs`
|
||||||
<Oidc::ScopeForm
|
<Oidc::ScopeForm
|
||||||
@model={{this.model}}
|
@model={{this.model}}
|
||||||
@@ -176,14 +166,8 @@ module('Integration | Component | oidc/scope-form', function (hooks) {
|
|||||||
await click('[data-test-oidc-scope-example]');
|
await click('[data-test-oidc-scope-example]');
|
||||||
assert.dom(MODAL('title')).hasText('Scope template', 'Modal title renders');
|
assert.dom(MODAL('title')).hasText('Scope template', 'Modal title renders');
|
||||||
assert.dom(MODAL('text')).hasText('Example of a JSON template for scopes:', 'Modal text renders');
|
assert.dom(MODAL('text')).hasText('Example of a JSON template for scopes:', 'Modal text renders');
|
||||||
assert
|
assert.dom('#scope-template-modal .hds-icon-clipboard-copy').exists('Modal copy button exists');
|
||||||
.dom('#scope-template-modal [data-test-copy-button]')
|
assert.dom('.token .string').hasText('"username"', 'Example template json renders');
|
||||||
.hasAttribute(
|
|
||||||
'data-test-copy-button',
|
|
||||||
exampleTemplate,
|
|
||||||
'Modal copy button copies the example template'
|
|
||||||
);
|
|
||||||
assert.dom('.cm-string').hasText('"username"', 'Example template json renders');
|
|
||||||
await click('[data-test-close-modal]');
|
await click('[data-test-close-modal]');
|
||||||
assert.dom('.hds#scope-template-modal').doesNotExist('Modal is hidden');
|
assert.dom('.hds#scope-template-modal').doesNotExist('Modal is hidden');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { setRunOptions } from 'ember-a11y-testing/test-support';
|
|||||||
const SELECTORS = {
|
const SELECTORS = {
|
||||||
policyText: '[data-test-modal-title]',
|
policyText: '[data-test-modal-title]',
|
||||||
policyDescription: (type) => `[data-test-example-modal-text=${type}]`,
|
policyDescription: (type) => `[data-test-example-modal-text=${type}]`,
|
||||||
jsonText: '[data-test-component="code-mirror-modifier"]',
|
jsonText: '.hds-code-block',
|
||||||
informationLink: '[data-test-example-modal-information-link]',
|
informationLink: '[data-test-example-modal-information-link]',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user