diff --git a/.changelog/13686.txt b/.changelog/13686.txt new file mode 100644 index 000000000..e42ee475c --- /dev/null +++ b/.changelog/13686.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +ui: Add new CopyableCode component and use it in certain pre-existing areas +``` diff --git a/ui/packages/consul-ui/app/components/certificate/README.mdx b/ui/packages/consul-ui/app/components/certificate/README.mdx deleted file mode 100644 index 34dd1bb35..000000000 --- a/ui/packages/consul-ui/app/components/certificate/README.mdx +++ /dev/null @@ -1,31 +0,0 @@ -# Certificate - -```hbs preview-template - -``` - -### Arguments - -| Argument | Type | Default | Description | -| --- | --- | --- | --- | -| `item` | `String` | | The certificate as a string to be displayed and copied | -| `name` | `String` | | The 'Name' of the certificate to be displayed and copied. Mainly used for giving feedback to the user. | - -This component has the following: -- a copy button -- a visibility button to show and hide certificate -- a hidden and visible display of the certificate - -### See - -- [Component Source Code](./index.js) -- [Template Source Code](./index.hbs) - ---- diff --git a/ui/packages/consul-ui/app/components/certificate/index.hbs b/ui/packages/consul-ui/app/components/certificate/index.hbs deleted file mode 100644 index 8981db774..000000000 --- a/ui/packages/consul-ui/app/components/certificate/index.hbs +++ /dev/null @@ -1,14 +0,0 @@ -
- - -{{#if this.show}} - {{@item}} -{{else}} -
-{{/if}} -
\ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/certificate/index.js b/ui/packages/consul-ui/app/components/certificate/index.js deleted file mode 100644 index 3a8fdd17e..000000000 --- a/ui/packages/consul-ui/app/components/certificate/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; - -export default class Certificate extends Component { - // =attributes - @tracked show = false; - - // =actions - @action - setVisibility() { - this.show = !this.show; - } -} diff --git a/ui/packages/consul-ui/app/components/certificate/index.scss b/ui/packages/consul-ui/app/components/certificate/index.scss deleted file mode 100644 index f4a7ab23a..000000000 --- a/ui/packages/consul-ui/app/components/certificate/index.scss +++ /dev/null @@ -1,28 +0,0 @@ -.certificate { - display: flex; - button.visibility { - height: fit-content; - padding-top: 4px; - margin-right: 4px; - cursor: pointer; - } - button.hide::before { - @extend %with-visibility-hide-icon, %as-pseudo; - } - button.show::before { - @extend %with-visibility-show-icon, %as-pseudo; - } - code { - background-color: rgb(var(--tone-gray-050)); - overflow-wrap: break-word; - max-width: min-content; - padding: 0 12px; - } - hr { - border: 3px dashed rgb(var(--tone-gray-300)); - background-color: rgb(var(--tone-gray-000)); - width: 150px; - margin: auto; - margin-top: 9px; - } -} diff --git a/ui/packages/consul-ui/app/components/consul/auth-method/view/index.hbs b/ui/packages/consul-ui/app/components/consul/auth-method/view/index.hbs index e7f8f319c..6dd576006 100644 --- a/ui/packages/consul-ui/app/components/consul/auth-method/view/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/auth-method/view/index.hbs @@ -13,23 +13,29 @@ {{#if @item.Config.Host}}
{{t 'models.auth-method.Config.Host'}}
- - {{@item.Config.Host}} +
{{/if}} {{#if @item.Config.CACert}}
{{t 'models.auth-method.Config.CACert'}}
- +
{{/if}} {{#if @item.Config.ServiceAccountJWT}}
{{t 'models.auth-method.Config.ServiceAccountJWT'}}
- - - {{@item.Config.ServiceAccountJWT}} - +
{{/if}} @@ -96,25 +102,37 @@ as |item|}} {{#if @item.Config.JWKSURL}}
{{t 'models.auth-method.Config.JWKSURL'}}
- - {{@item.Config.JWKSURL}} +
{{t 'models.auth-method.Config.JWKSCACert'}}
- +
{{/if}} {{#if @item.Config.JWTValidationPubKeys}}
{{t 'models.auth-method.Config.JWTValidationPubKeys'}}
- +
{{/if}} {{#if @item.Config.OIDCDiscoveryURL}}
{{t 'models.auth-method.Config.OIDCDiscoveryURL'}}
- - {{@item.Config.OIDCDiscoveryURL}} +
{{/if}} {{#if @item.Config.JWTSupportedAlgs}} @@ -143,14 +161,20 @@ as |item|}} {{#if @item.Config.OIDCDiscoveryURL}}
{{t 'models.auth-method.Config.OIDCDiscoveryURL'}}
- - {{@item.Config.OIDCDiscoveryURL}} +
{{/if}} {{#if @item.Config.OIDCDiscoveryCACert}}
{{t 'models.auth-method.Config.OIDCDiscoveryCACert'}}
- +
{{/if}} {{#if @item.Config.OIDCClientID}} @@ -167,8 +191,10 @@ as |item|}} diff --git a/ui/packages/consul-ui/app/components/copyable-code/README.mdx b/ui/packages/consul-ui/app/components/copyable-code/README.mdx new file mode 100644 index 000000000..a7cc0caf9 --- /dev/null +++ b/ui/packages/consul-ui/app/components/copyable-code/README.mdx @@ -0,0 +1,50 @@ +# CopyableCode + +CopyableCode is used to display code that is likely to be copied by the user. + +It also has an option to obfuscate the code, that is then toggleable by the user. + +Text within the component is formatted using a `
` tag.
+
+```hbs preview-template
+
+
Without obfuscation
+ +
+``` + +```hbs preview-template +
+
With obfuscation
+ +
+``` + +### Arguments + +| Argument | Type | Default | Description | +| --- | --- | --- | --- | +| `value` | `String` | | The code to display/be copied | +| `name` | `String` | | The 'Name' of the thing to be displayed and copied. Mainly used for giving feedback to the user. | +| `obfuscated` | `boolean` | | Whether to obfuscate the value until the user clicks to view | + +### See + +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/copyable-code/index.hbs b/ui/packages/consul-ui/app/components/copyable-code/index.hbs new file mode 100644 index 000000000..00ae9ea8c --- /dev/null +++ b/ui/packages/consul-ui/app/components/copyable-code/index.hbs @@ -0,0 +1,45 @@ +
+{{#if @obfuscated}} + + + + + +
{{@value}}
+
+ + {{#if (not details.expanded)}} +
+ {{/if}} +
+
+ + + +{{else}} +
{{@value}}
+ +{{/if}} + +
\ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/copyable-code/index.scss b/ui/packages/consul-ui/app/components/copyable-code/index.scss new file mode 100644 index 000000000..7745aadb6 --- /dev/null +++ b/ui/packages/consul-ui/app/components/copyable-code/index.scss @@ -0,0 +1,65 @@ +.copyable-code { + & { + display: flex; + align-items: flex-start; + position: relative; + width: 100%; + padding: 8px 14px; + padding-bottom: 3px; + + border: var(--decor-border-100); + border-color: rgb(var(--tone-gray-200)); + border-radius: var(--decor-radius-200); + } + &.obfuscated { + padding-left: 4px; + } + &::after { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 100%; + display: block; + content: ''; + background-color: rgb(var(--tone-gray-050)); + } + .copy-button { + position: absolute; + top: 7px; + right: 12px; + } + button[aria-expanded] { + margin-top: 1px; + margin-right: 4px; + cursor: pointer; + } + button[aria-expanded]::before { + content: ''; + --icon-size: icon-000; + --icon-color: rgb(var(--tone-gray-500)); + } + button[aria-expanded=true]::before { + --icon-name: icon-eye-off; + } + button[aria-expanded=false]::before { + --icon-name: icon-eye; + } + pre { + padding-right: 30px; + } + code { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + } + hr { + width: calc(100% - 80px); + margin: 0; + margin-top: 8px; + margin-bottom: 13px; + border: 3px dashed rgb(var(--tone-gray-300)); + background-color: rgb(var(--tone-gray-000)); + } +} diff --git a/ui/packages/consul-ui/app/components/definition-table/README.mdx b/ui/packages/consul-ui/app/components/definition-table/README.mdx index 971b59ee7..390a49ed9 100644 --- a/ui/packages/consul-ui/app/components/definition-table/README.mdx +++ b/ui/packages/consul-ui/app/components/definition-table/README.mdx @@ -4,7 +4,6 @@ class: css # definition-table Simple CSS component to render a `dl` similar to a table with column headers. -Contents of the `dd` are currently inline-block'ed for CopyButton reasons. ```hbs preview-template
@@ -12,7 +11,12 @@ Contents of the `dd` are currently inline-block'ed for CopyButton reasons.
Title 1
Value
Title 2
-
Value
+
+ +
``` diff --git a/ui/packages/consul-ui/app/components/definition-table/layout.scss b/ui/packages/consul-ui/app/components/definition-table/layout.scss index 3173fe175..db0c27e90 100644 --- a/ui/packages/consul-ui/app/components/definition-table/layout.scss +++ b/ui/packages/consul-ui/app/components/definition-table/layout.scss @@ -6,10 +6,3 @@ %definition-table > dl { margin-bottom: 1.4em; } -/* TODO: We currently have one instance of nested dls */ -/* and that is for nesting a bucket list */ -/* we should probably think about changing this to possibly inline flex */ -/* or individually styling the contents */ -%definition-table > dl > dd > *:not(dl) { - display: inline-block; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/index.hbs b/ui/packages/consul-ui/app/components/secret-button/index.hbs deleted file mode 100644 index 539810f73..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.hbs +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/secret-button/index.js b/ui/packages/consul-ui/app/components/secret-button/index.js deleted file mode 100644 index 557064773..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({}); diff --git a/ui/packages/consul-ui/app/components/secret-button/index.scss b/ui/packages/consul-ui/app/components/secret-button/index.scss deleted file mode 100644 index aafd0b942..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.scss +++ /dev/null @@ -1,23 +0,0 @@ -@import './skin'; -@import './layout'; -.type-reveal { - @extend %secret-button; -} -%secret-button { - position: relative; -} -%secret-button span { - visibility: hidden; - position: absolute; - --icon-color: rgb(var(--tone-gray-500)); -} -%secret-button em { - margin-left: 22px; -} -%secret-button span::before { - @extend %with-visibility-show-mask, %as-pseudo; - visibility: visible; -} -%secret-button input:checked + span::before { - @extend %with-visibility-hide-mask; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/layout.scss b/ui/packages/consul-ui/app/components/secret-button/layout.scss deleted file mode 100644 index 1393e5efe..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/layout.scss +++ /dev/null @@ -1,23 +0,0 @@ -%secret-button { - cursor: pointer; -} -%secret-button input { - display: none; -} -%secret-button input ~ em { - visibility: hidden; - font-style: normal; -} -%secret-button input:checked ~ em { - @extend %user-select-text; - visibility: visible; - cursor: auto; -} -%secret-button input ~ em::before { - display: inline; - visibility: visible; - content: '■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■'; -} -%secret-button input:checked ~ em::before { - display: none; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/skin.scss b/ui/packages/consul-ui/app/components/secret-button/skin.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/packages/consul-ui/app/components/tabular-dl/layout.scss b/ui/packages/consul-ui/app/components/tabular-dl/layout.scss index edeb482a4..3e8d6b422 100644 --- a/ui/packages/consul-ui/app/components/tabular-dl/layout.scss +++ b/ui/packages/consul-ui/app/components/tabular-dl/layout.scss @@ -25,10 +25,6 @@ dd > ul li:not(:last-of-type) { padding-bottom: 12px; } - dd .copy-button button { - padding: 0 !important; - margin: 0 4px 0 0 !important; - } dt.check + dd { padding-top: 16px; } diff --git a/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss b/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss index 4ba418ad6..ecac9fc4a 100644 --- a/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss +++ b/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss @@ -154,8 +154,8 @@ // @import './user-square-fill/index.scss'; // @import './user-square-outline/index.scss'; @import './user-team/index.scss'; -@import './visibility-hide/index.scss'; -@import './visibility-show/index.scss'; +// @import './visibility-hide/index.scss'; +// @import './visibility-show/index.scss'; // @import './webhook/index.scss'; // @import './activity/index.scss'; @import './alert-circle/index.scss'; @@ -316,8 +316,8 @@ // @import './event/index.scss'; // @import './exit-point/index.scss'; // @import './external-link/index.scss'; -// @import './eye/index.scss'; -// @import './eye-off/index.scss'; +@import './eye/index.scss'; +@import './eye-off/index.scss'; // @import './f5/index.scss'; // @import './f5-color/index.scss'; // @import './facebook/index.scss'; diff --git a/ui/packages/consul-ui/app/styles/components.scss b/ui/packages/consul-ui/app/styles/components.scss index 73ed5fcf1..ad39f2418 100644 --- a/ui/packages/consul-ui/app/styles/components.scss +++ b/ui/packages/consul-ui/app/styles/components.scss @@ -33,7 +33,6 @@ @import 'consul-ui/components/popover-select'; @import 'consul-ui/components/progress'; @import 'consul-ui/components/radio-group'; -@import 'consul-ui/components/secret-button'; @import 'consul-ui/components/sliding-toggle'; @import 'consul-ui/components/table'; @import 'consul-ui/components/tile'; @@ -75,7 +74,7 @@ @import 'consul-ui/components/informed-action'; @import 'consul-ui/components/tab-nav'; @import 'consul-ui/components/search-bar'; -@import 'consul-ui/components/certificate'; +@import 'consul-ui/components/copyable-code'; @import 'consul-ui/components/consul/loader'; @import 'consul-ui/components/consul/tomography/graph'; diff --git a/ui/packages/consul-ui/app/styles/debug.scss b/ui/packages/consul-ui/app/styles/debug.scss index 8209e6ac4..66cecc7ed 100644 --- a/ui/packages/consul-ui/app/styles/debug.scss +++ b/ui/packages/consul-ui/app/styles/debug.scss @@ -252,9 +252,6 @@ html.with-route-announcer .route-title { figcaption code { @extend %inline-code; } - pre code { - @extend %block-code; - } figure > [type='text'] { border: 1px solid rgb(var(--tone-gray-999)); width: 100%; diff --git a/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs b/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs index b1480fbb3..63cc8ea66 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs @@ -62,7 +62,10 @@ as |dc partition nspace id item create|}}
Policy ID
- {{item.ID}} +
diff --git a/ui/packages/consul-ui/app/templates/dc/acls/roles/edit.hbs b/ui/packages/consul-ui/app/templates/dc/acls/roles/edit.hbs index 00202a405..8caa4ff09 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/roles/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/roles/edit.hbs @@ -56,7 +56,10 @@ as |dc partition nspace item create|}}
Role ID
- {{item.ID}} +
diff --git a/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs b/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs index 111a1f345..e1f4c7929 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/tokens/edit.hbs @@ -91,11 +91,18 @@ as |dc partition nspace item create|}}
AccessorID
- {{item.AccessorID}} +
Token
- {{item.SecretID}} +
{{#if (and (not (token/is-legacy item)) (not create))}}
Scope
diff --git a/ui/packages/consul-ui/tests/integration/components/secret-button-test.js b/ui/packages/consul-ui/tests/integration/components/secret-button-test.js deleted file mode 100644 index b0f0ee13b..000000000 --- a/ui/packages/consul-ui/tests/integration/components/secret-button-test.js +++ /dev/null @@ -1,33 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render, find } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; - -module('Integration | Component | secret button', function(hooks) { - setupRenderingTest(hooks); - - test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); - - await render(hbs`{{secret-button}}`); - - assert.ok( - find('*') - .textContent.trim() - .indexOf('Reveal') !== -1 - ); - - // Template block usage: - await render(hbs` - {{#secret-button}} - {{/secret-button}} - `); - - assert.ok( - find('*') - .textContent.trim() - .indexOf('Reveal') !== -1 - ); - }); -});