mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
develop
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
821a3d4991 |
feat[3/6]: Chain a button action's result into the ones after it (#1722) (#5951)
* feat: chain a button action's result into the actions after it
A click runs its whole sequence in one request, so each action's result is
kept on the dispatch context and read back by a new `previous_action` data
provider. The builder needs a cache keyed by a dispatch id because its
browser dispatches one action at a time, and automation reads results from
workflow history; neither applies here.
The store lives in the context's cache rather than on the context itself.
`clone()` rebuilds the context through `__init__` and only copies the cache
dict, so a plain attribute would give every clone its own empty one.
`start_action` deliberately leaves it alone: the row is re-read per action,
results are what the rest of the sequence chains from.
* feat: remap a previous action reference on import
A chained reference names an action by id, so duplicating a field, a table or
an application has to point it at the imported copy. The action id is remapped
through the import mapping and the rest of the path handed to that action's
service, the way the builder and automation already do.
A reference to an action outside the import is left as it is rather than
raising, so a partial import stays loadable.
* feat: reference an earlier action's result from the button editor
The data explorer offers an action what the actions before it return, and
`open_url` can build a URL from one. An action is only ever offered what
precedes it in the list, so a reference always points backwards.
An action that has never been saved carries no service schema, so its output
is derived from the target table's fields, which the action forms now report
up to the sub-form. It is referenced by its client id until the save, and the
creates go out in list order rewriting those ids to the real ones as they are
handed out, so no client id ever reaches the API.
A dispatch result is keyed by field name, and the browser has no way to map a
`field_<id>` onto a table that is not the clicked row's, so each result now
carries the names of the fields it returned.
* fix: let a button's URL reference an earlier action
The form names its own data providers, which overrides what the sub-form
injects, so the URL field never offered `previous_action` and the chained
URL could not be configured at all. The unit tests covered the provider and
the click path but never the form, which is what let it through.
Naming the fields of a result costs a table model per action, so it is only
done when there is a client action to read them.
* feat: mark a button action the click would fail on
Chaining multiplies the ways a configuration can be wrong, and until now
nothing said so until the button was clicked. An action with no table, a URL
action with no URL, and one referencing an action that no longer runs before
it are each marked, with a warning on the list.
A stale reference is marked rather than cleared, following ADR 006 section 8:
moving the action back makes it valid again, and clearing would throw away a
formula the user wrote.
It stays a warning rather than a validation gate, since a half configured
action is a normal state while editing and the field already saves either way.
* chore: drop the button field's url_formula column
Phase 2e stopped reading and writing it and backfilled every value into an
`open_url` action. Nothing has read the attribute since, so the column goes.
Safe to drop now rather than a release later: no released version has it.
2.3.3 carries no button field at all, and phases 1 to 3 go out together, so
there is no older process still writing the column during a rolling deploy.
The backfill helper stays where it is, since migration 0216 imports it and
has to keep running from scratch. Its test goes: it wrote to the column with
raw SQL, which there is now no column for.
* docs: record the phase 3 decisions in ADR 006
Section 2 gains why the frontend-last execution split is safe under chaining:
the explorer is scoped by list position, so an action can only ever name one
that has already run.
Section 4 gains where results live and why it differs from the other two
modules, and the field name mapping the response carries for a frontend-only
action that references a table it has no fields for.
Section 2's url_formula paragraph now says the column is gone rather than
pending, with the reason it could go a release early.
* test: cover context chaining end to end
Nine cases on the existing button field suite, chosen for spanning something
no unit test reaches: a URL built from a row a server action just created, the
data explorer through the whole provide chain, two brand new actions chained
in one save, a saved action pointed at one created beside it, a forward
reference marked and healed, and a failing action refusing to navigate.
Two backend cases go with them, both from shapes the suite seeds: a reference
to an action whose service has no table, and one pointing forwards.
Dragging an action is verified rather than assumed. How far the pointer has to
travel depends on how tall the target's form is, so the helper drops once,
checks the order really changed, and tries a different landing point if not.
The derived schema now names the row id "Id" like the backend's does, instead
of "Row ID", so the node stops renaming itself the first time an action is
saved.
* test: cover a three deep chain and a duplicated one
The third action reads the first, skipping the one between, which an
off-by-one in the position scoping still satisfies with only two actions.
The duplication test gains the chained case rather than duplicating this wide
table a second time: the copy's URL action has to name the copy's create row
action, and the copy has to still be clickable, which remapping alone does not
prove.
The test that saves a built chain gets a button field of its own, so it no
longer shares one with the test that builds a chain and throws it away.
* test: match a table name whole when picking one
"Tickets" also matched the "Tickets 2" that the duplication test leaves behind,
so the dropdown resolved to two items and Playwright refused to click either.
It only showed up in a full run, since duplication happens earlier in the file
than the test that picks a table.
* test: a write only field is not offered out of a created row
The derived schema filters them, but nothing asserted it. Verified alongside
the dispatch result masking a password to a boolean rather than the hash,
which is what the decision to document rather than rebuild the exposure
machinery rests on.
* fix: fail a chained read of a field that no longer exists
Reading a deleted field resolved to nothing and the click carried on, writing
a blank over whatever the target row held. The provider raised when the
referenced action was missing but not when the field was, so the two halves
disagreed, and the row provider already raises in the same situation.
A key absent from the result means the field is gone and now raises. A key
present holding null is a legitimately empty cell and still resolves to null.
Reading any path out of an action that produced no row at all, a delete for
instance, raises for the same reason.
Found working through the phase 3 verification checklist, item R12.
* test: cover explorer scoping for reorder, deletion and open_url
Four cases the desktop browser cannot show, because the field editor's popup
runs past the bottom of the viewport whatever the window size: the third action
seeing the first two, reordering changing what each is offered with no save,
a deleted middle action leaving the tree, and a URL action between two others
contributing nothing.
* test: cover reordering unsaved actions, and drain rows between tests
An action added, pointed at another added beside it, then dragged in front of
both, so the creates go out in an order the list no longer matches. The saved
formula has to name the middle action rather than the one dragged past it.
`resetRows` deleted a single page. `listRows` caps at 200, so once the shared
table grew past that, resets left a backlog and later lookups returned old rows
instead of the ones a test had just created. It drains in pages now. That is
what the intermittent failures in the chained tests were, not contention.
The viewport widens again for the two fields this adds; the grid renders only
the columns that fit, so a column past the edge never appears at all.
* fix: keep a button's buffered actions when a reference cannot be resolved
An unresolved reference threw a bare error. `notifyIf` presents an error only
when it carries a handler and rethrows anything else, so the throw escaped
before the caller could flag the failure. The editor then closed and reset,
discarding every buffered action edit, with no toast to say why. The guard that
exists to keep those edits on screen never ran.
The error now carries a handler that raises a toast, so a save that cannot
resolve a reference fails the way any other failed save does and the user keeps
what they were editing.
Adopting the ids handed out before a failure now rewrites the references to
them as well. Without that a retry met a client id whose action was no longer
being created, so nothing mapped it and the save could never succeed.
* fix: refuse a broken chained reference in the browser too
The backend raises for a reference to an action that did not run or a field
missing from its result. The browser resolved the same reference to nothing,
and a URL built from it opened with a hole in it, which is the failure this
phase exists to avoid. It now refuses them the way the backend does, so the
click reports an unusable URL instead of navigating.
Only a real click carries results. The editor resolves formulas for its own
preview before anything has run, so that path still resolves to nothing.
Naming a result's fields is skipped for an action that returned no row, a
delete for instance. It cost a table model per click to build a mapping the
browser could never resolve anything against.
* fix: describe the table an action points at now, not the one it was saved with
The editor buffers a table change without clearing the schema the API returned,
so the explorer kept offering the previous table's fields. Picking one wrote a
field reference that no longer existed anywhere, and the click then failed. The
fetched fields describe the table selected right now, so they win; the saved
schema is only a fallback for an action whose form has not fetched anything.
A reference was matched anywhere the words appeared, string literals included,
so a URL ending `/docs/previous_action.html` captured `html`, failed the check
that a reference resolves to a number, and left the field impossible to save
behind a toast about an action order that was never the problem. A path opens
straight after its quote, so requiring one keeps the match off ordinary text.
The list-returning branch of the provider indexed into its result before
checking it was one. No action type reaches it yet, and the guard is a line.
* refactor: type an unsaved action's fields, and match the base argument order
Every field of an action that had never been saved was typed as a string, so a
file or link row field showed as a leaf with nothing under it and then changed
shape the moment the real schema arrived. Only the types that decide whether a
node can have children are worth deriving, and they are taken from a schema the
backend generated rather than guessed: a number field really is a string there,
because the API returns it as one.
`getDataSchema` took its arguments the other way round from the base class and
from the builder's types. It has one caller, so nothing was wrong today, but
anything reaching for it through the base signature would have read a schema
off the wrong object and quietly returned nothing.
* fix: mark a reference to an action that no longer returns a result
Changing an earlier action to Open URL or Delete row kept its id and its
place, so nothing warned, yet the dispatch fails the whole click on a
read of it.
* fix: fail a previous action read outside a click, rather than crash
Both database providers share a registry, so an AI prompt formula could
reach this one through a context that carries no cache.
* perf: name a table's fields once per click
Every dispatched action rebuilt the table model to name the same fields,
which on a wide table is the expensive part of the response.
* fix: only offer a client action what really ran before it
Client actions run last whatever their place, so the response carried
every server result and the browser resolved references the dispatch
would have refused. The result now says where its action sat.
* perf: check each action's configuration once per render
Every rendered row asked for its error twice, and the warning banner once
more per action, each walking the whole config.
* test: say so when rows cannot be drained between tests
Falling through at the pass cap left behind the very rows the loop
exists to remove, so a suite failed later on a stale lookup.
* feat: collapse a button field's actions, one card at a time
The list showed every action's form at once, so a button with three of them
did not fit the editor and the data explorer opened over the list rather
than under the input it belongs to. Cards now open one at a time, the way
the builder's event list does.
The form is hidden rather than unmounted: it registers into this form's
chain and emits its defaults on mount, so tearing it down on collapse would
change what a save sends. A misconfigured action's message stays outside the
collapsible part, so it can be found without opening every card.
* fix: read an action reference only where a formula asks for one
A quoted literal that begins with the same word, such as the second argument
of concat('https://example.com/', 'previous_action.tmp.id'), was counted as a
reference to an action named tmp, which has no id and so blocked the save.
The pattern now anchors on the get( the reference must sit inside.
The walk also no longer descends into schema, context_data and
context_data_schema. Those formulas describe the selected table rather than
anything the user typed.
* fix: hold back a new action's error until the form is touched
An action is invalid the moment its type is picked, since it is configured
afterwards, so the warning appeared while the user was still filling it in.
The rest of the form only reports errors once touched, and this now follows:
Save, Create, or adding another action reveals them.
What the editor loaded is marked on sight, because an error there describes
config that is already saved.
* fix: keep a field's editor open when its actions fail to save
The field is created before its workflow actions can be, so a failure there left a field behind and closed the editor on the configuration. The editor now stays open on the edits and a retry saves them against the field that was made.
* test: cover retrying a new field whose actions failed to save
* fix: refuse a previous action reference that names no action
get('previous_action') has nothing to read. The API now rejects it while validating the formula, and the provider fails as a formula error rather than crashing on an empty path, so one saved earlier reports a dispatch failure instead of a 500.
* fix: fail a reference to a field the previous action no longer has
A path names a field as field_<id>, and the service turns that into the field's name. A field the reference outlived is left as it is, so a field named literally field_<id> answered for it and the click wrote the wrong value.
* test: cover a click that references a field the chain no longer has
* fix: tell two actions sharing an order apart by where they ran
Concurrent creates can hand two actions the same order, which execution then breaks by id. A client action compared orders to decide which results it may read, so it dropped one it was entitled to. The dispatch now returns the position each action ran at, on both the results and the client actions.
* docs: describe an action's dispatch position in the API schema
* fix: stop a click's client actions once one could not run
Open URL reported an unusable URL with a toast and returned, so the action after it still ran and could navigate away, taking the message with it. It now says whether it ran, and the loop stops when it did not.
* fix: open the card that is blocking a save, and reach it by keyboard
A collapsed action blocked the save with nothing on screen, since an invalid formula renders no error element to scroll to. Submitting now opens the first card whose form refuses what it holds. The collapse control and the drag handle also take focus, and the handle reorders with the arrow keys, which was mouse only.
* test: name a provider that really is unknown, and cover the url_formula upgrade
The duplication test used previous_action, which this branch registers, so duplication remapped the id and the test failed on its own. It now names a provider nothing registers. The helper level migration tests are replaced by one that runs 0215 to 0217 and proves every url_formula shape becomes an Open URL action before the column is dropped.
* test: expect the open url action to report that it did not run
* test: cover the lazy warning for a newly chosen row action
* test: cover a chained reference through a mapping and through a first save
A field mapping's value is a formula the service does not remap itself, and a reference between two never saved actions is rewritten from the ids the server hands out. Both were only covered end to end.
* perf: stop every formula input rebuilding its explorer on each keystroke
The action form copied the context it was given, which read the parent's getters and made the actions list a dependency of the provided object, so the object changed identity on every edit. It now delegates to the parent instead. The function nodes, which come from the registry rather than from anything being edited, are also built once per input rather than on every rebuild.
* fix: describe a composite field down to its children in the explorer
* refactor: drop a field name cache the table model already provides
* refactor: let the service type name its own missing table
* fix: fail a click that reads a result no action was recorded for
* fix: wrap an action's error instead of cutting the sentence short
* fix: point an imported path's tail at the action its head was remapped to
The remapped id was written straight over action_id, so when the lookup that
follows found no such action the path came back naming the imported copy with
the field id of the original. That field does not exist in the copy, and every
click on it failed.
* fix: report the field a retry patched, not the one it started from
A successful retry hid the editor without clearing createdField, so onHidden
ran as though the retry had been abandoned: it reset the form a second time
and handed the parent the copy taken when the field was first made, before the
retry patched its name, label and type.
* fix: keep two actions the server forgot from sharing one id
An action deleted by someone else is created again, and came from the server
with no client id. Both were keyed by that same undefined, so the second
create overwrote the first and every clientId-less action then adopted the one
id left, which the next save reconciled as two updates to one action.
* fix: forget a table whose fields could not be fetched
A failed fetch left the table unregistered, so the explorer fell back to the
schema of the last save, which describes whichever table the action pointed at
before. It went on offering those fields for as long as the fetch kept
failing, and a formula built from one fails the click.
* perf: read an action's references without copying it
Checking a reference ran the action through _.omit, which copies what it keeps
all the way down, so every keystroke cloned the saved schema of every action on
the field. The walk only reads, so it now visits the same keys where they are.
* test: cover a re-run of the url_formula move, and a reversed empty one
Two cases the helper level tests had were lost when they were replaced. The
column stores its keys in either order depending on whether it was written
from a string or a dict, and a re-applied migration must not stack a second
action on a field it already moved.
* fix: let a service that cannot name its fields answer for its own path
Only a table service defines get_table_field_objects. Any other kind reaching
this check raised an AttributeError, which is not a formula error, so the click
would have 500ed rather than reporting itself. Guarded the way the sibling that
makes the same call already is.
* docs: say that a dispatch position can be absent
Both sides of the response take their position from a dict that is empty when
the click ran no sequence, so both can be null. The schema promised an integer,
and a generated client reads null as a type error.
* fix: raise for any segment a previous action's result does not carry
The frontend provider only raised for a `field_` segment, so any other one
resolved to nothing, left a hole in the URL and opened it anyway. The backend
raises for whatever the result does not carry, and the explorer shows field
names, so a formula naming one was easy to write and silently wrong.
* fix: refuse a composite value in an open url formula
A previous action's result comes back raw, so a single select, link row or file
resolved to an object. `concat` turned it into JSON, and the URL parser read the
result as a relative path, so the click opened a URL built out of a field's
internal shape.
* test: cover a path that reaches inside a composite value
Only the leaf reaches the URL, so a deeper path is not itself a composite and
must keep resolving.
* fix: stop a cancelled edit hiding a saved action's error
The list stays mounted between opens and its pristine flag is keyed by a saved
action's id, so retyping an action and then cancelling brought it back as it was
stored with its own error still suppressed.
* fix: mark a table whose fields could not be fetched
Registering an empty list said two other things by accident: that the table has
no fields, and that whatever another action had fetched for the same table was
gone. A marker keeps those apart, and a failed fetch no longer overwrites a list
that arrived fine.
* fix: read a previous action reference from the parse tree
A regex cannot tell a reference from a string that reads like one, and it only
matched a lowercase get. An uppercase GET was a working reference the editor
never saw, so a stale one went unmarked and a client id reached the API. The
tree says which get() calls are real, and the ids are spliced by offset so the
rest of the formula is untouched.
An unparseable formula falls back to the regex for the save guard only, which
errs towards refusing the save rather than letting a client id through.
* fix: finish a retried field creation the way the first attempt would
Three things the retry path did differently from the create it continues. The
patch went out under no undo group, so undoing the create trashed the field and
left the patch nothing to undo. The field was committed straight away instead of
through a callback, so the parent never refreshed its rows, which shows when the
retry also changes the type. And dismissing the popup mid save reported the
field a second time.
* fix: address review findings on the button field editor
A close that lands while a save is running is now held and reported once
the save settles. Before, `@hidden` was dropped and never fired again, so
a failed save left the field with no owner and the context still holding
it: the next create patched that field instead of making a new one.
An action the server has forgotten keeps the id it had while it is created
again, so the actions naming it follow it to its new id rather than
pointing at nothing. The card the user has open follows the same way, so a
save that stops part way no longer closes it.
The previous action provider now refuses a write-only field the way the
row provider does, and says a context runs no sequence rather than
reporting the reference as one that has not run yet.
|