Skip to content

Commit f2edee4

Browse files
committed
VersionList::Row: Replace yank button with a dropdown menu
1 parent c158b36 commit f2edee4

File tree

8 files changed

+64
-10
lines changed

8 files changed

+64
-10
lines changed

app/components/version-list/row.hbs

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

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

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

238-
.yank-button {
239-
position: relative;
240-
margin-left: var(--space-xs);
238+
.dropdown {
239+
line-height: 1rem;
240+
}
241241

242-
@media only screen and (max-width: 550px) {
243-
display: none;
242+
.icon {
243+
width: 1.4em;
244+
height: auto;
245+
}
246+
247+
.trigger {
248+
background: none;
249+
border: none;
250+
padding: 0;
251+
}
252+
253+
.menu {
254+
right: 0;
255+
min-width: max-content;
256+
}
257+
258+
.menu-button {
259+
align-items: center;
260+
gap: var(--space-2xs);
261+
cursor: pointer;
262+
text-transform: capitalize;
263+
264+
/* This duplicates the styles in .button[disabled] as there's no
265+
* obvious way to compose them, given the target selectors. */
266+
&[disabled] {
267+
background: linear-gradient(to bottom, var(--bg-color-top-light) 0%, var(--bg-color-bottom-light) 100%);
268+
color: var(--disabled-text-color) !important;
269+
cursor: not-allowed;
244270
}
245271
}

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
5252
await expect(page.locator('[data-test-disable-admin-actions]')).toHaveCount(0);
5353
await expect(page.locator('[data-test-enable-admin-actions]')).toBeVisible();
5454

55+
await page.locator('[data-test-actions-toggle]').click();
56+
5557
// Test that the fieldset is present and disabled.
5658
await expect(page.locator('[data-test-placeholder-fieldset]')).toBeVisible();
5759
// NOTE: `toBeDisabled()` is not working as expected because the element is not a form control element.
@@ -93,6 +95,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
9395
});
9496
expect(seen).toBe(1);
9597

98+
await page.locator('[data-test-actions-toggle]').click();
99+
96100
// Test that the fieldset is not present.
97101
await expect(page.locator('[data-test-placeholder-fieldset]')).toHaveCount(0);
98102
await expect(page.locator('[data-test-version-yank-button="0.1.0"]')).toBeVisible();
@@ -106,6 +110,8 @@ test.describe('Acceptance | sudo', { tag: '@acceptance' }, () => {
106110
await page.locator('[data-test-user-menu]').getByRole('button').click();
107111
await page.getByRole('button', { name: 'Enable admin actions' }).click();
108112

113+
await page.locator('[data-test-actions-toggle]').click();
114+
109115
const yankButton = page.locator('[data-test-version-yank-button="0.1.0"]');
110116
const unyankButton = page.locator('[data-test-version-unyank-button="0.1.0"]');
111117

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module('Acceptance | sudo', function (hooks) {
5757
assert.dom('[data-test-disable-admin-actions]').doesNotExist();
5858
assert.dom('[data-test-enable-admin-actions]').exists();
5959

60+
await click('[data-test-actions-toggle]');
61+
6062
// Test that the fieldset is present and disabled.
6163
assert.dom('[data-test-placeholder-fieldset]').exists().isDisabled();
6264

@@ -90,6 +92,8 @@ module('Acceptance | sudo', function (hooks) {
9092
}
9193
assert.strictEqual(seen, 1);
9294

95+
await click('[data-test-actions-toggle]');
96+
9397
// Test that the fieldset is not present.
9498
assert.dom('[data-test-placeholder-fieldset]').doesNotExist();
9599
assert.dom('[data-test-version-yank-button="0.1.0"]').exists();
@@ -101,6 +105,8 @@ module('Acceptance | sudo', function (hooks) {
101105
await visit('/crates/foo/versions');
102106
await click('[data-test-enable-admin-actions]');
103107

108+
await click('[data-test-actions-toggle]');
109+
104110
await click('[data-test-version-yank-button="0.1.0"]');
105111

106112
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)