Skip to content

Commit fc91ec1

Browse files
authored
Dim plus sign on disabled button (#2256)
* Add logic to dim button when in a disabled state * small test improvement * refactor CreateButton, tests
1 parent 39b4491 commit fc91ec1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

app/ui/lib/CreateButton.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright Oxide Computer Company
77
*/
88

9+
import cn from 'classnames'
910
import { Link, type LinkProps } from 'react-router-dom'
1011

1112
import { AddRoundel12Icon } from '@oxide/design-system/icons/react'
@@ -14,7 +15,11 @@ import { Button, buttonStyle, type ButtonProps } from '~/ui/lib/Button'
1415

1516
export const CreateButton = ({ children, ...props }: ButtonProps) => (
1617
<Button size="sm" className="shrink-0" {...props}>
17-
<AddRoundel12Icon className="mr-2 text-accent-secondary" />
18+
<AddRoundel12Icon
19+
// dim the icon color from the default (text accent) because it looks a
20+
// lot brighter than text, but default disabled color is fine
21+
className={cn('mr-2', { 'text-accent-secondary': !props.disabled })}
22+
/>
1823
{children}
1924
</Button>
2025
)

test/e2e/instance-networking.e2e.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ test('Instance networking tab — NIC table', async ({ page }) => {
3535
'/projects/mock-project/vpcs/mock-vpc'
3636
)
3737

38+
const addNicButton = page.getByRole('button', { name: 'Add network interface' })
39+
40+
// Ensure that the 'Add network interface' button is disabled when the instance is running
41+
await expect(addNicButton).toBeDisabled()
42+
3843
// Have to stop instance to edit NICs
3944
await stopInstance(page)
4045

41-
await page.click('role=button[name="Add network interface"]')
46+
await expect(addNicButton).toBeEnabled()
47+
await addNicButton.click()
4248

4349
// Add network interface
4450
// TODO: modal title is not getting hooked up, IDs are wrong

0 commit comments

Comments
 (0)