[ui] Copyable server and client attribute values (#16548)
* Copyable server and client attribute values * Changelog
This commit is contained in:
parent
5892839c83
commit
11de45d17b
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:improvement
|
||||||
|
ui: Added copy-to-clipboard buttons to server and client pages
|
||||||
|
```
|
|
@ -1,10 +1,11 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { task, timeout } from 'ember-concurrency';
|
import { task, timeout } from 'ember-concurrency';
|
||||||
import { classNames } from '@ember-decorators/component';
|
import { classNames, classNameBindings } from '@ember-decorators/component';
|
||||||
import classic from 'ember-classic-decorator';
|
import classic from 'ember-classic-decorator';
|
||||||
|
|
||||||
@classic
|
@classic
|
||||||
@classNames('copy-button')
|
@classNames('copy-button')
|
||||||
|
@classNameBindings('inset')
|
||||||
export default class CopyButton extends Component {
|
export default class CopyButton extends Component {
|
||||||
clipboardText = null;
|
clipboardText = null;
|
||||||
state = null;
|
state = null;
|
||||||
|
|
|
@ -51,6 +51,11 @@
|
||||||
{{~@key}}
|
{{~@key}}
|
||||||
</td>
|
</td>
|
||||||
<td title="{{@value}}">
|
<td title="{{@value}}">
|
||||||
|
<CopyButton
|
||||||
|
@inset={{true}}
|
||||||
|
@compact={{true}}
|
||||||
|
@clipboardText={{@value}}
|
||||||
|
/>
|
||||||
<span data-test-value>{{@value}}</span>
|
<span data-test-value>{{@value}}</span>
|
||||||
{{#if @editable}}
|
{{#if @editable}}
|
||||||
<button class="button is-light is-compact edit-existing-metadata-button" type="button"
|
<button class="button is-light is-compact edit-existing-metadata-button" type="button"
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
|
||||||
|
&.inset {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ $button-box-shadow-standard: 0 2px 0 0 rgba($grey, 0.2);
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.is-inset {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
&.is-disabled {
|
&.is-disabled {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|
|
@ -808,6 +808,7 @@
|
||||||
data-test-attributes
|
data-test-attributes
|
||||||
@attributePairs={{this.model.attributes.structured}}
|
@attributePairs={{this.model.attributes.structured}}
|
||||||
@class="attributes-table"
|
@class="attributes-table"
|
||||||
|
@copyable={{true}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<AttributesSection @prefix={{if this.prefix (concat this.prefix "." key) key}} @attributes={{value}}
|
<AttributesSection @prefix={{if this.prefix (concat this.prefix "." key) key}} @attributes={{value}}
|
||||||
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} />
|
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} @copyable={{@copyable}} />
|
||||||
{{else}}
|
{{else}}
|
||||||
<MetadataKv @prefix={{this.prefix}}
|
<MetadataKv @prefix={{this.prefix}}
|
||||||
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} />
|
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} @copyable={{@copyable}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each-in}}
|
{{/each-in}}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
@editable={{@editable}}
|
@editable={{@editable}}
|
||||||
@onKVEdit={{@onKVEdit}}
|
@onKVEdit={{@onKVEdit}}
|
||||||
@onKVSave={{@onKVSave}}
|
@onKVSave={{@onKVSave}}
|
||||||
|
@copyable={{@copyable}}
|
||||||
/>
|
/>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,20 +1,28 @@
|
||||||
{{#if (eq this.state 'success')}}
|
{{#if (eq this.state 'success')}}
|
||||||
<div class='button is-small is-static {{if @compact "is-compact"}} {{unless @border "is-borderless"}}'>
|
<div class='button is-small is-static {{if @compact "is-compact"}} {{unless @border "is-borderless"}}'>
|
||||||
<span class="tooltip text-center always-active" role="tooltip" aria-label="Copied!">
|
{{#if @inset}}
|
||||||
{{x-icon 'copy-success'}}
|
<span aria-label="Copied!">{{x-icon 'copy-success'}}</span>
|
||||||
</span>
|
{{else}}
|
||||||
|
<span class="tooltip text-center always-active" role="tooltip" aria-label="Copied!">
|
||||||
|
{{x-icon 'copy-success'}}
|
||||||
|
</span>
|
||||||
|
{{/if}}
|
||||||
{{yield}}
|
{{yield}}
|
||||||
</div>
|
</div>
|
||||||
{{else if (eq this.state 'error')}}
|
{{else if (eq this.state 'error')}}
|
||||||
<div class='button is-small is-static {{if @compact "is-compact"}} {{unless @border "is-borderless"}}'>
|
<div class='button is-small is-static {{if @compact "is-compact"}} {{unless @border "is-borderless"}}'>
|
||||||
<span class="tooltip text-center" role="tooltip" aria-label="Error copying">
|
{{#if @inset}}
|
||||||
{{x-icon 'alert-triangle'}}
|
<span aria-label="Error copying">{{x-icon 'alert-triangle'}}</span>
|
||||||
</span>
|
{{else}}
|
||||||
|
<span class="tooltip text-center" role="tooltip" aria-label="Error copying">
|
||||||
|
{{x-icon 'alert-triangle'}}
|
||||||
|
</span>
|
||||||
|
{{/if}}
|
||||||
{{yield}}
|
{{yield}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<AddonCopyButton
|
<AddonCopyButton
|
||||||
@class="button is-small {{if @compact "is-compact"}} {{unless @border "is-borderless"}}"
|
@class="button is-small {{if @compact "is-compact"}} {{unless @border "is-borderless"}} {{if @inset "is-inset"}}"
|
||||||
@clipboardText={{this.clipboardText}}
|
@clipboardText={{this.clipboardText}}
|
||||||
@success={{perform this.indicateSuccess}}
|
@success={{perform this.indicateSuccess}}
|
||||||
@error={{action (mut this.state) "error"}}
|
@error={{action (mut this.state) "error"}}
|
||||||
|
|
|
@ -34,7 +34,14 @@
|
||||||
<t.body as |row|>
|
<t.body as |row|>
|
||||||
<tr data-test-server-tag>
|
<tr data-test-server-tag>
|
||||||
<td>{{row.model.name}}</td>
|
<td>{{row.model.name}}</td>
|
||||||
<td>{{row.model.value}}</td>
|
<td>
|
||||||
|
<CopyButton
|
||||||
|
@inset={{true}}
|
||||||
|
@compact={{true}}
|
||||||
|
@clipboardText={{row.model.value}}
|
||||||
|
/>
|
||||||
|
{{row.model.value}}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</t.body>
|
</t.body>
|
||||||
</ListTable>
|
</ListTable>
|
||||||
|
|
Loading…
Reference in New Issue