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: Add copy button for client/allocation UUIDs #5926

Merged
merged 28 commits into from Jul 15, 2019
Merged

Conversation

backspace
Copy link
Contributor

@backspace backspace commented Jul 4, 2019

You can try this by visiting the preview deployment client list and choosing a client (direct linking isn’t possible because of randomised Mirage data).

Here’s a GIF of it for an allocation UUID:

demonstration

backspace added a commit that referenced this pull request Jul 5, 2019
I found while working on #5926 that x-icon already adds
assertion-compatible selectors, so these wrappers are
unnecessary.
This shouldn’t really be a button, I just wanted it to have the
same spacing and size as the button.
I’m trying out this UX as seen on GitHub PR pages. Easily
removed if undesirable!
If there are no uses where it should be hidden until hover,
I’ll just entirely remove that.
backspace added a commit that referenced this pull request Jul 8, 2019
I found while working on #5926 that x-icon already adds
assertion-compatible selectors, so these wrappers are
unnecessary.
@backspace backspace changed the title UI: Add copy button for client UUID UI: Add copy button for client/allocation UUIDs Jul 8, 2019
@backspace backspace marked this pull request as ready for review July 8, 2019 17:25
@backspace backspace requested review from DingoEatingFuzz and a team July 8, 2019 17:31
@hashicorp hashicorp deleted a comment from backspace Jul 8, 2019
Copy link
Member

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

Looks good to me, except for the isDestroyed check mentioned inline 👇

this.set('state', 'success');

run.later(() => {
this.set('state', null);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need a this.isDestroyed check here. Otherwise, if the user navigates away during this 2 second timeout, we'll try to set a value on a destroyed object.

(This is one reason I really like using ember-concurrency for things like this: free task cancelation on unrender.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer, I converted it to a task, and gave it a more descriptive name while I was at it.


yield run.later(() => {
this.set('state', null);
}, 2000);
Copy link
Member

@alisdair alisdair Jul 15, 2019

Choose a reason for hiding this comment

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

Unfortunately, I think this implementation is still subject to the same bug. I just reproduced it on the Netlify preview, at least:

image

Here's one way to avoid the issue:

import { task, timeout} from 'ember-concurrency';

export default Component.extend({
  // …
  indicateSuccess: task(function*() {
    this.set('state', 'success');
    yield timeout(2000);
    this.set('state', null);
  }).restartable(),
});

This works because on cancelation, the timeout is aborted, and the rest of the task is not executed.

Edit: the run.later approach doesn't work because it's not cancellable: once the work is scheduled on the queue, you can't remove it.

(I also added restartable to make sure we don't have multiple concurrent version of this task running if the user clicks a few times.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

goodness, yes, much better, thanks!

Copy link
Member

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

✨ 👍

@backspace backspace merged commit 596b5aa into master Jul 15, 2019
@backspace backspace deleted the f-ui/client-uuid-copy branch July 15, 2019 17:14
@github-actions
Copy link

github-actions bot commented Feb 7, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants