Skip to content

Commit de3ac56

Browse files
authored
Merge pull request #11366 from eth3lbert/version-actions-menu
Replace yank button with a drop down menu
2 parents c708d73 + 249b7cb commit de3ac56

File tree

9 files changed

+87
-18
lines changed

9 files changed

+87
-18
lines changed

app/components/privileged-action.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{{#if this.isPrivileged}}
2-
<div>
2+
<div ...attributes>
33
{{yield}}
44
</div>
55
{{else if this.canBePrivileged}}
66
{{#if (has-block 'placeholder')}}
7-
<div>
7+
<div ...attributes>
88
{{yield to='placeholder'}}
99
</div>
1010
{{else}}
11-
<div local-class='placeholder'>
11+
<div local-class='placeholder' ...attributes>
1212
<fieldset data-test-placeholder-fieldset disabled="disabled">
1313
{{yield}}
1414
</fieldset>
@@ -18,7 +18,7 @@
1818
</div>
1919
{{/if}}
2020
{{else}}
21-
<div>
21+
<div ...attributes>
2222
{{#if (has-block 'unprivileged')}}
2323
{{yield to='unprivileged'}}
2424
{{/if}}

app/components/version-list/row.hbs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,18 @@
117117
{{/if}}
118118
</div>
119119

120-
<PrivilegedAction @userAuthorised={{this.isOwner}}>
121-
<YankButton @version={{@version}} local-class="yank-button" />
120+
<PrivilegedAction @userAuthorised={{this.isOwner}} local-class="actions">
121+
<Dropdown local-class="dropdown" data-test-actions-menu as |dd|>
122+
<dd.Trigger @hideArrow={{true}} local-class="trigger" data-test-actions-toggle>
123+
{{svg-jar "ellipsis-circle" local-class="icon"}}
124+
<span class="sr-only">Actions</span>
125+
</dd.Trigger>
126+
127+
<dd.Menu local-class="menu" as |menu|>
128+
<menu.Item>
129+
<YankButton @version={{@version}} class="button-reset" local-class="menu-button" />
130+
</menu.Item>
131+
</dd.Menu>
132+
</Dropdown>
122133
</PrivilegedAction>
123134
</div>

app/components/version-list/row.module.css

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,52 @@
235235
margin-top: var(--space-2xs);
236236
}
237237

238-
.yank-button {
239-
position: relative;
240-
margin-left: var(--space-xs);
238+
.actions {
239+
display: flex;
240+
}
241241

242-
@media only screen and (max-width: 550px) {
243-
display: none;
242+
.dropdown {
243+
display: flex;
244+
font-size: initial;
245+
line-height: 1rem;
246+
}
247+
248+
.icon {
249+
width: 2em;
250+
height: auto;
251+
}
252+
253+
.trigger {
254+
background: none;
255+
border: none;
256+
padding: 0;
257+
border-radius: 99999px;
258+
color: var(--grey600);
259+
260+
:hover {
261+
border-radius: 99999px;
262+
color: var(--grey900);
263+
background-color: white;
264+
}
265+
}
266+
267+
.menu {
268+
top: 100%;
269+
right: 0;
270+
min-width: max-content;
271+
}
272+
273+
.menu-button {
274+
align-items: center;
275+
gap: var(--space-2xs);
276+
cursor: pointer;
277+
text-transform: capitalize;
278+
279+
/* This duplicates the styles in .button[disabled] as there's no
280+
* obvious way to compose them, given the target selectors. */
281+
&[disabled] {
282+
background: linear-gradient(to bottom, var(--bg-color-top-light) 0%, var(--bg-color-bottom-light) 100%);
283+
color: var(--disabled-text-color) !important;
284+
cursor: not-allowed;
244285
}
245286
}

app/components/yank-button.hbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{{#if @version.yanked}}
22
<button
33
type="button"
4-
class="button button--small"
54
...attributes
65
data-test-version-unyank-button={{@version.num}}
76
disabled={{@version.unyankTask.isRunning}}
@@ -16,7 +15,6 @@
1615
{{else}}
1716
<button
1817
type="button"
19-
class="button button--small"
2018
...attributes
2119
data-test-version-yank-button={{@version.num}}
2220
disabled={{@version.yankTask.isRunning}}

e2e/acceptance/sudo.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
3636
await expect(page.locator('[data-test-disable-admin-actions]')).toHaveCount(0);
3737
await expect(page.locator('[data-test-enable-admin-actions]')).toHaveCount(0);
3838

39+
// Assert that there's no dropdown menu toggle, disabled, enabled, or in any state.
40+
await expect(page.locator('[data-test-actions-toggle]')).toHaveCount(0);
3941
// Assert that there's no yank button, disabled, enabled, or in any state.
4042
await expect(page.locator('[data-test-version-yank-button="0.1.0"]')).toHaveCount(0);
4143
});
@@ -53,14 +55,13 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
5355
await expect(page.locator('[data-test-enable-admin-actions]')).toBeVisible();
5456

5557
// Test that the fieldset is present and disabled.
56-
await expect(page.locator('[data-test-placeholder-fieldset]')).toBeVisible();
58+
await expect(page.locator('[data-test-placeholder-fieldset]').first()).toBeVisible();
5759
// NOTE: `toBeDisabled()` is not working as expected because the element is not a form control element.
5860
// Ref: https://github.com/microsoft/playwright/issues/13583#issuecomment-1101704985
59-
await expect(page.locator('[data-test-placeholder-fieldset]')).toHaveAttribute('disabled', 'disabled');
61+
await expect(page.locator('[data-test-placeholder-fieldset]').first()).toHaveAttribute('disabled', 'disabled');
6062

61-
// From the perspective of the actual button, it isn't disabled, even though
62-
// the fieldset effectively makes it unclickable.
63-
await expect(page.locator('[data-test-version-yank-button="0.1.0"]')).toBeVisible();
63+
await expect(page.locator('[data-test-actions-toggle]')).toBeDisabled();
64+
await expect(page.locator('[data-test-version-yank-button="0.1.0"]')).toBeHidden();
6465
});
6566

6667
test('admin user can enter sudo mode', async ({ page, msw }) => {
@@ -93,6 +94,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
9394
});
9495
expect(seen).toBe(1);
9596

97+
await page.locator('[data-test-actions-toggle]').click();
98+
9699
// Test that the fieldset is not present.
97100
await expect(page.locator('[data-test-placeholder-fieldset]')).toHaveCount(0);
98101
await expect(page.locator('[data-test-version-yank-button="0.1.0"]')).toBeVisible();
@@ -106,6 +109,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
106109
await page.locator('[data-test-user-menu]').getByRole('button').click();
107110
await page.getByRole('button', { name: 'Enable admin actions' }).click();
108111

112+
await page.locator('[data-test-actions-toggle]').click();
113+
109114
const yankButton = page.locator('[data-test-version-yank-button="0.1.0"]');
110115
const unyankButton = page.locator('[data-test-version-unyank-button="0.1.0"]');
111116

e2e/acceptance/versions.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ test.describe('Acceptance | crate versions page', { tag: '@acceptance' }, () =>
5252
await expect(v020).not.toHaveClass(/.*latest/);
5353
await expect(v020).not.toHaveClass(/.yanked/);
5454

55+
await v021.locator('[data-test-actions-toggle]').click();
56+
5557
// yanking
5658
await page.locator('[data-test-version-yank-button="0.2.1"]').click();
5759
await expect(v021).not.toHaveClass(/.*latest/);

public/assets/ellipsis-circle.svg

Lines changed: 3 additions & 0 deletions
Loading

tests/acceptance/sudo-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module('Acceptance | sudo', function (hooks) {
4343
assert.dom('[data-test-disable-admin-actions]').doesNotExist();
4444
assert.dom('[data-test-enable-admin-actions]').doesNotExist();
4545

46+
// Assert that there's no dropdown menu toggle, disabled, enabled, or in any state.
47+
assert.dom('[data-test-actions-toggle]').doesNotExist();
4648
// Assert that there's no yank button, disabled, enabled, or in any state.
4749
assert.dom('[data-test-version-yank-button="0.1.0"]').doesNotExist();
4850
});
@@ -62,6 +64,7 @@ module('Acceptance | sudo', function (hooks) {
6264

6365
// From the perspective of the actual button, it isn't disabled, even though
6466
// the fieldset effectively makes it unclickable.
67+
assert.dom('[data-test-actions-toggle]').exists();
6568
assert.dom('[data-test-version-yank-button="0.1.0"]').exists();
6669
});
6770

@@ -90,6 +93,8 @@ module('Acceptance | sudo', function (hooks) {
9093
}
9194
assert.strictEqual(seen, 1);
9295

96+
await click('[data-test-actions-toggle]');
97+
9398
// Test that the fieldset is not present.
9499
assert.dom('[data-test-placeholder-fieldset]').doesNotExist();
95100
assert.dom('[data-test-version-yank-button="0.1.0"]').exists();
@@ -101,6 +106,8 @@ module('Acceptance | sudo', function (hooks) {
101106
await visit('/crates/foo/versions');
102107
await click('[data-test-enable-admin-actions]');
103108

109+
await click('[data-test-actions-toggle]');
110+
104111
await click('[data-test-version-yank-button="0.1.0"]');
105112

106113
await waitFor('[data-test-version-unyank-button="0.1.0"]');

tests/acceptance/versions-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module('Acceptance | crate versions page', function (hooks) {
5757
.hasNoClass(/.*latest/)
5858
.hasNoClass(/.yanked/);
5959

60+
await click('[data-test-actions-toggle]');
61+
6062
// yanking
6163
await click('[data-test-version-yank-button="0.2.1"]');
6264
assert

0 commit comments

Comments
 (0)