Script Action Bar
Help ID: guide.script-action-bar
The Script Action Bar is a shared WPF UserControl that hosts an editable Apply/Undo T-SQL preview above a single Actions ▾ dropdown and a Validate button. Every surface that generates change scripts — the Permissions Matrix, the Security Consolidator, and the Permission Trace database drilldown — opens it through PermissionsChangePreviewWindow so the user sees the same editor, the same destination targets strip, and the same action menu regardless of which feature produced the script.
What it contains
- Targets strip across the top. One chip per
(server, database)the originating feature marked as a destination. Each chip has a checkbox so the user can deselect targets before dispatching the script. The strip hides when there are no targets (e.g. a script opened purely to save to the Library). - Section pane down the left side when the payload carries more than one change. See Section pane below.
- APPLY / UNDO tabs holding the forward script and its reverse. Both tabs are now editable — the editor is two-way bound, so hand-edits in either tab flow to every downstream action.
- Status line immediately under the tabs. Short status messages render in colour:
✓green for success,✗red for failure, muted grey for neutral or working states. The full text is available via tooltip when it's trimmed with an ellipsis. - Actions ▾ dropdown containing every destination for the script:
- Deploy Now — queue into
Deploy.CodewithBeginAt = DateTime.Now. - Schedule… — queue into
Deploy.Codewith user-picked begin/end window, retries, and alert-on-failure severity. - Minion.Agent Job — forward the script to Minion.Agent (wiring is pending; today it opens an informational dialog).
- Package — open the Query Pilot Script Package window prefilled with this script, defaults, and the target server list.
- Save as .sql — write the current tab's SQL to a file through the standard save dialog.
- Save to Script Library — open the Script Library manager with the script, title, category and description prefilled.
- Open in Query Pilot — open a new Query Pilot tab seeded with a
/* MINION EXEC POLICY */header so the target servers and databases come ticked automatically. See Open in Query Pilot for the header format.
- Deploy Now — queue into
- Validate sits beside the dropdown. It runs a local
TSql180Parser(ScriptDom) pass against the current tab's SQL and reports ✓ Syntax OK or ✗ Line N: — no server round-trip, no principal binding noise.
Section pane
Features that queue many small changes at once — the Consolidator's Build all, chiefly — push an optional Sections list onto the payload, one entry per suggestion with its own Title, ApplySql and UndoSql. The Script Action Bar surfaces that list as a 240px pane down the left side of the editor:
- All combined at the top. The editor is bound to this row's text through
DisplayApplySql/DisplayUndoSql, which round-trip to the VM's editableApplySql/UndoSql. Edits here are what every downstream action runs. - One row per suggestion below. Clicking a row swaps the editor to that suggestion's slice, read-only (
ReadOnlybound toIsDisplayReadOnly). Use these to read each change on its own without scrolling through the combined blob.
The pane hides entirely when Payload.Sections is empty, so single-change flows (the Matrix cell drilldown, Perm Trace drilldown, Open-in-QP) keep their original edge-to-edge APPLY/UNDO layout.
Editable editor
The Apply and Undo text boxes are SqlEditorControl bound two-way with UpdateSourceTrigger=PropertyChanged. Every keystroke updates the view model's _applySql / _undoSql backing fields and marks the status as Script edited.
When EffectivePayload() builds the payload passed to each action, it swaps the live edits in place of the originals. One subtle rule: if the user has edited the Apply text, the pre-built per-statement list that the originating feature produced is dropped (Statements = null, RecommendSplit = false). The split-per-statement path would otherwise queue stale statements under the user's current edits. The whole edited blob queues as a single row instead.
Payload.ApplySql / Payload.UndoSql are left untouched so a future diff view can compare original vs edited text.
Hosts and overrides
The bar is driven by ScriptActionBarVm, which wires every dropdown command to a method on IScriptActionHost. The baseline implementation, DefaultScriptActionHost, lives in Services/Scripting/DefaultScriptActionHost.cs and handles every action generically. Any feature that needs to customise one or more actions can subclass it; see PermissionsChangePreviewWindow for the normal way to wire a custom host.
Hosts receive a ScriptActionPayload with Title, Subtitle, Category, ApplySql, UndoSql, Targets, an optional Statements list (one entry per real SQL statement) and a RecommendSplit boolean. Features that already know their change decomposes into individual statements (the Consolidator, mostly) populate Statements so DefaultScriptActionHost.OpenPushOptionsAsync can queue one Deploy.Code row per statement per target when the user ticks Split into per-statement rows.
See Consolidator for how per-statement split is used in practice, and Deploys for how the resulting rows look in the queue.
Status brush
ScriptActionBarVm.StatusBrush is a computed property driven off the first character of the status message. Hosts don't need a separate severity field: start a status with ✓ for success and ✗ for failure and the status line colours itself. Any other first character — including letters, digits, or none — maps to muted grey. The brush never returns null, which matters because the editable editor's status binding runs under WPF's Binding.Foreground, where a null brush throws at paint time.
Validate
DefaultScriptActionHost.ValidateAsync instantiates TSql180Parser(initialQuotedIdentifiers: false) and returns the first error with the count of any remaining ones. It intentionally does not go to a server — our previous server-side SET PARSEONLY ON approach generated dozens of false negatives against the central Minion database because REVOKE/GRANT statements bind their principals at parse time, and the principals we were revoking frequently didn't exist on the central DB. Server-level checks happen when Deploy actually runs.
Why centralise
Before the action bar, every change-script dialog (Matrix, Consolidator, Perm Trace drilldown) grew its own button strip, its own target picker, its own validate path, and its own queue call. Behaviour drifted — Matrix would queue a Deploy.Code row that Consolidator wouldn't, and vice versa. Collapsing everything through ScriptActionBar + PermissionsChangePreviewWindow + DefaultScriptActionHost gives one audit path for every T-SQL change the GUI dispatches. A fix in the action bar (e.g. coloured status, editable scripts, Open in Query Pilot) reaches every feature at once.
Related: Consolidator · Deploys · Open in Query Pilot · Permissions Matrix · Permission Trace drilldown.
Documentation revision: E126ED7257B0EA23