Rename note to moveWarning for automation host moves

Clarifies that the field specifically warns when an automation would move to another host, replacing the plain storage line.
This commit is contained in:
Jinjing
2026-08-27 19:32:39 -07:00
parent 0cbf60acd6
commit 29ef10877a
5 changed files with 19 additions and 13 deletions
@@ -62,11 +62,11 @@ const LEGACY_ENTRY: AutomationHostCatalogEntry = {
function control(
projects: Repo[],
entries: AutomationHostCatalogEntry[] = [ENTRY],
note?: string
moveWarning?: string
): AutomationCreateDestinationControl {
return {
entries,
note,
moveWarning,
resolution: {
status: 'ready',
authority: OWNER.authority,
@@ -78,11 +78,15 @@ function control(
}
}
function render(projects: Repo[], entries?: AutomationHostCatalogEntry[], note?: string): void {
function render(
projects: Repo[],
entries?: AutomationHostCatalogEntry[],
moveWarning?: string
): void {
act(() => {
root.render(
<TooltipProvider>
<AutomationDestinationField control={control(projects, entries, note)} />
<AutomationDestinationField control={control(projects, entries, moveWarning)} />
</TooltipProvider>
)
})
@@ -109,8 +113,10 @@ describe('AutomationDestinationField', () => {
it('names the hosts a server update would let create, instead of hiding them', () => {
render([{ id: 'repo-1' } as Repo], [ENTRY, LEGACY_ENTRY])
const note = container.querySelector('[data-testid="automation-create-update-required"]')
expect(note?.textContent).toContain('legacy-box')
const updateRequired = container.querySelector(
'[data-testid="automation-create-update-required"]'
)
expect(updateRequired?.textContent).toContain('legacy-box')
})
it('says nothing about updates when every offered host is eligible', () => {
@@ -79,11 +79,11 @@ export function AutomationDestinationField({
'No projects are set up on {host}. Add one there, or choose another host.'
).replace('{host}', selected.label)}
</p>
) : control.note ? (
) : control.moveWarning ? (
// Replaces the storedOn line: both name the same host, and the move is
// the consequential half.
<p className="text-xs text-destructive" data-testid="automation-host-move">
{control.note}
{control.moveWarning}
</p>
) : (
<p className="text-xs text-muted-foreground">
@@ -464,7 +464,7 @@ describe('AutomationsPage edit destination', () => {
expect(mocks.editorDialog?.editDestination?.entries.map((entry) => entry.stableKey)).toContain(
RUNTIME_SELF_KEY
)
expect(mocks.editorDialog?.editDestination?.note).toBeFalsy()
expect(mocks.editorDialog?.editDestination?.moveWarning).toBeFalsy()
})
it('moves the record across authorities by creating there and deleting here', async () => {
@@ -484,7 +484,7 @@ describe('AutomationsPage edit destination', () => {
mocks.editorDialog?.editDestination?.onSelect(RUNTIME_SELF_KEY)
})
expect(mocks.editorDialog?.editDestination?.note).toBeTruthy()
expect(mocks.editorDialog?.editDestination?.moveWarning).toBeTruthy()
await act(async () => {
mocks.editorDialog?.onDraftChange((current) => ({
@@ -1143,7 +1143,7 @@ export default function AutomationsPage(): React.JSX.Element {
onSelect: handleEditHostChange,
projects: editHostProjects,
// Replacer fn: a literal replacement would expand `$` patterns in host labels.
note: editMoveTargetEntry
moveWarning: editMoveTargetEntry
? translate(
'auto.components.automations.createDestination.move',
'Saving creates this automation on {host} and deletes the original and its run history.'
@@ -35,8 +35,8 @@ export type AutomationCreateDestinationControl = {
onSelect: (stableKey: string) => void
/** Projects the resolved destination can hold; the whole list until one resolves. */
projects: readonly Repo[]
/** Stated consequence of saving here, when it is not the plain one. */
note?: string | null
/** Set when saving would move the record to another host; replaces the plain line. */
moveWarning?: string | null
}
export type AutomationCreateDestinationCheck =