fix(ui-schedule): keep Pause/Resume enabled-looking while the Host answers
Co-authored-by: winewill <[email protected]>
This commit is contained in:
1 parent
4d4a7c36ad
commit
612663dc04
2 files changed
+19
-2
No files matched your search
@@ -321,8 +321,11 @@ function TaskDetailView(props: TaskDetailProps): ReactNode {
|
||||
</div>}
|
||||
<div className={css.detailActions}>
|
||||
{task !== undefined && <><Tooltip label={t(task.status === 'active' ? 'host.pause' : 'host.resume')} side="bottom" delayMs={500} portal>
|
||||
<span><Button size="sm" className={css.detailIconButton} disabled={busy || dirty || executionActive || task.status === 'ended' || !props.authoritative}
|
||||
aria-label={t(task.status === 'active' ? 'host.pause' : 'host.resume')} onClick={() => { void setActive(task) }}>
|
||||
{/* While busy, the toggle uses aria-disabled: native disabling under the pointer would flash
|
||||
the not-allowed cursor and dimmed style between two enabled states. */}
|
||||
<span><Button size="sm" className={css.detailIconButton} disabled={dirty || executionActive || task.status === 'ended' || !props.authoritative}
|
||||
aria-disabled={busy || undefined} aria-label={t(task.status === 'active' ? 'host.pause' : 'host.resume')}
|
||||
onClick={() => { if (!busy) void setActive(task) }}>
|
||||
{task.status === 'active' ? <IconPauseOutlineRegular /> : <IconPlayOutlineRegular />}
|
||||
</Button></span>
|
||||
</Tooltip>
|
||||
|
||||
@@ -1027,6 +1027,20 @@ describe('Host task actions', () => {
|
||||
expect(screen.getByRole('button', { name: en['host.pause'] }).hasAttribute('disabled')).toBe(false)
|
||||
})
|
||||
|
||||
it('holds Pause without native disabling while the Host answers', async () => {
|
||||
const answer = Promise.withResolvers<'saved'>()
|
||||
const h = mount([task], { hostActions: hostActions({ edit: vi.fn<HostTaskActions['edit']>(() => answer.promise) }) })
|
||||
fireEvent.click(screen.getByRole('button', { name: task.title }))
|
||||
const pause = screen.getByRole('button', { name: en['host.pause'] })
|
||||
fireEvent.click(pause)
|
||||
expect(pause.hasAttribute('disabled')).toBe(false)
|
||||
expect(pause.getAttribute('aria-disabled')).toBe('true')
|
||||
fireEvent.click(pause)
|
||||
expect(h.props.hostActions.edit).toHaveBeenCalledTimes(1)
|
||||
await act(async () => { answer.resolve('saved'); await answer.promise })
|
||||
expect(pause.hasAttribute('aria-disabled')).toBe(false)
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ name: 'queues a run now', outcome: 'queued' as const, alert: null, notice: null },
|
||||
{ name: 'states a refused run as a wait instead of an error', outcome: { failed: 'host.executionPending' as const },
|
||||
|
||||
Reference in new issue
Block a user