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] Copyable server and client attribute values #16548

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 1 deletion ui/app/components/copy-button.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Component from '@ember/component';
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';

@classic
@classNames('copy-button')
@classNameBindings('inset')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: There are only 6 invocations of the CopyButton component. Rather than persisting ember-classic pattern, this seems like an easy win for us to migrate to Ember Octane via a Glimmer component!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gave it a shot, including upgrading ember-cli-clipboard, and ran into errors. Seems not worth holding up this feature for.

Copy link
Contributor

Choose a reason for hiding this comment

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

I got it up and running pretty immediately. Which errors did you run into? Do you think we'll run into similar errors on the upgrade path to Ember 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please open a PR! All look and feel was fine but no events were firing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Roger dodger!

export default class CopyButton extends Component {
clipboardText = null;
state = null;
Expand Down
5 changes: 5 additions & 0 deletions ui/app/components/metadata-kv.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
{{~@key}}
</td>
<td title="{{@value}}">
<CopyButton
@inset={{true}}
@compact={{true}}
@clipboardText={{@value}}
/>
<span data-test-value>{{@value}}</span>
{{#if @editable}}
<button class="button is-light is-compact edit-existing-metadata-button" type="button"
Expand Down
4 changes: 4 additions & 0 deletions ui/app/styles/components/copy-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
padding-left: 0.5rem;
margin-bottom: 2px;

&.inset {
display: inline-block;
}

.button {
color: inherit;

Expand Down
4 changes: 4 additions & 0 deletions ui/app/styles/core/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ $button-box-shadow-standard: 0 2px 0 0 rgba($grey, 0.2);
box-shadow: none;
}

&.is-inset {
background-color: transparent;
}

&.is-disabled {
opacity: 0.7;
box-shadow: none;
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/clients/client/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@
data-test-attributes
@attributePairs={{this.model.attributes.structured}}
@class="attributes-table"
@copyable={{true}}
/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/components/attributes-section.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</td>
</tr>
<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}}
<MetadataKv @prefix={{this.prefix}}
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} />
@key={{key}} @value={{value}} @editable={{@editable}} @onKVSave={{@onKVSave}} @copyable={{@copyable}} />
{{/if}}
{{/each-in}}
1 change: 1 addition & 0 deletions ui/app/templates/components/attributes-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@editable={{@editable}}
@onKVEdit={{@onKVEdit}}
@onKVSave={{@onKVSave}}
@copyable={{@copyable}}
/>
</tbody>
</table>
22 changes: 15 additions & 7 deletions ui/app/templates/components/copy-button.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{{#if (eq this.state 'success')}}
<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!">
{{x-icon 'copy-success'}}
</span>
{{#if @inset}}
<span aria-label="Copied!">{{x-icon 'copy-success'}}</span>
{{else}}
<span class="tooltip text-center always-active" role="tooltip" aria-label="Copied!">
{{x-icon 'copy-success'}}
</span>
{{/if}}
{{yield}}
</div>
{{else if (eq this.state 'error')}}
<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">
{{x-icon 'alert-triangle'}}
</span>
{{#if @inset}}
<span aria-label="Error copying">{{x-icon 'alert-triangle'}}</span>
{{else}}
<span class="tooltip text-center" role="tooltip" aria-label="Error copying">
{{x-icon 'alert-triangle'}}
</span>
{{/if}}
{{yield}}
</div>
{{else}}
<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}}
@success={{perform this.indicateSuccess}}
@error={{action (mut this.state) "error"}}
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/servers/server/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@
<t.body as |row|>
<tr data-test-server-tag>
<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>
</t.body>
</ListTable>
Expand Down