Package 'blockr.dag'

Title: A Directed Acyclic Graph Extension for 'blockr'
Description: Building on the docking layout manager provided by 'blockr.dock', this provides an extension that allows for visualizing and manipulating a 'blockr' board using a DAG-based user interface powered by the 'g6R' graph visualisation HTML widget.
Authors: David Granjon [aut, cre], Nicolas Bennett [aut], Christoph Sax [aut], Bristol Myers Squibb [fnd]
Maintainer: David Granjon <[email protected]>
License: GPL (>= 3)
Version: 0.1.5.9003
Built: 2026-11-19 08:15:59 UTC
Source: https://github.com/BristolMyersSquibb/blockr.dag

Help Index


DAG layout

Description

How the Workflow extension arranges the board: the layered DAG layout, its flow direction and its spacing. Users change both from the toolbar's layout menu; new_dag_extension() takes the one a board starts with.

Usage

dag_layout(
  direction = c("TB", "LR"),
  spacing = c("normal", "compact", "loose")
)

is_dag_layout(x)

Arguments

direction

"TB" (top to bottom) or "LR" (left to right). A wide board turned sideways grows in height instead.

spacing

"compact", "normal" or "loose": the gaps between blocks and between layers.

x

Object to test.

Value

dag_layout() returns an object of class dag_layout: a list of direction and spacing, plain values only, so it round-trips through serialization.

Examples

dag_layout()
dag_layout(direction = "LR", spacing = "compact")

Context menu functions

Description

Functions for creating and working with context menu entries.

Usage

new_context_menu_entry(
  name,
  js,
  action = NULL,
  condition = TRUE,
  id = tolower(gsub(" +", "_", name)),
  retarget = FALSE
)

is_context_menu_entry(x)

context_menu_items(x)

Arguments

name

Name of the context menu entry.

js

JavaScript code to execute when the entry is selected.

action

Action to perform when the entry is selected.

condition

Condition to determine if the entry should be shown.

id

Unique identifier for the context menu entry. Inferred from name if not provided

retarget

When TRUE, the entry follows the selection while it holds a pinned sidebar panel: selecting another element whose type its condition accepts re-fires the action on that element. Which panel the entry fills is not declared here: blockr.dock stamps the writing action onto the panel as it writes, and blockr.dock::sidebar_owned_by() reads that back. The action must expose its name, as update_action_trigger() does.

x

Object

Details

new_context_menu_entry()

Creates a new context menu entry with the specified name, JavaScript code, action function, and display condition.

is_context_menu_entry()

Tests whether an object is a valid context menu entry.

context_menu_items()

Generic function to extract context menu items from various objects like dock extensions, boards, or lists.

The context_menu_items.dag_extension() method provides the following actions:

  • Create link - Creates connections between workflow nodes.

  • Remove block - Removes individual blocks from the workflow.

  • Remove link - Removes connections between workflow nodes.

  • Append block - Adds a new block after the selected node.

  • Create stack - Creates a new workflow stack.

  • Remove stack - Removes an entire workflow stack.

  • Edit stack - Opens stack editing interface.

  • Add block - Adds a new block to the canvas.

Value

new_context_menu_entry()

A context menu entry object of class "context_menu_entry" containing condition, action, and js functions, with name and id attributes.

is_context_menu_entry()

TRUE if x is a context menu entry, FALSE otherwise.

context_menu_items()

A list of context menu items for the given object.


DAG extension

Description

Visualizes the DAG (directed acyclic graph) underlying a board and provides UI elements to manipulate the board.

Usage

new_dag_extension(positions = NULL, layout = NULL, ...)

Arguments

positions

Optional node positions overlaid on the board-derived nodes, as a named list keyed by block id, each element a list with numeric x and y (e.g. list(a = list(x = 100, y = 200))). Persisted across save / restore. Unknown or stale block ids are ignored. This handle is externally controllable: positions can be set programmatically through the board update lifecycle (⁠update(list(extensions = list(mod = list(<ext_id> = list(positions = ...)))))⁠), which moves the corresponding nodes. Note: the auto-layout currently computes final node placement at cold start, so supplied positions are not yet honored over it (a follow-up will let positions pin over the layout).

layout

The layout's direction and spacing, from dag_layout(); top to bottom with normal spacing when NULL. Users change it from the toolbar's layout menu. Persisted across save / restore and, like positions, externally controllable through the board update lifecycle.

...

Forwarded to blockr.dock::new_dock_extension().

Value

A dag_extension object that extends the dock extension system for visualizing and manipulating DAG workflows.

Options

blockr.dag.svg_renderer: when TRUE, the DAG is rendered with the SVG renderer instead of the default canvas renderer. Canvas is the default because the SVG element reports offsetWidth == 0, which makes the underlying g-lite client/canvas coordinate scaling ignore the page zoom factor and desyncs hit-testing below 100% browser zoom. The SVG renderer keeps every element in the DOM, which the shinytest2 end-to-end tests need to query and screenshot, so they opt in via AppDriver$new(options = list(blockr.dag.svg_renderer = TRUE)).


Toolbar item functions

Description

Functions for creating and working with toolbar items for the DAG interface.

Usage

new_toolbar_item(id, icon, js, action = NULL, tooltip = NULL)

is_toolbar_item(x)

toolbar_items(x)

Arguments

id

Unique identifier for the toolbar item.

icon

Name of an icon to show in the toolbar.

js

JavaScript code to execute when the entry is selected.

action

Action to perform when the entry is selected.

tooltip

Optional tooltip text for the entry.

x

Object

Details

new_toolbar_item()

Creates a new toolbar item with the specified id, icon, JavaScript code, action function, and tooltip text.

is_toolbar_item()

Tests whether an object is a valid toolbar item.

toolbar_items()

Generic function to extract toolbar items from various objects like dock extensions, boards, or lists.

The toolbar_items.dag_extension() method provides the following actions:

  • Zoom in - Increases the graph zoom level.

  • Zoom out - Decreases the graph zoom level.

  • Auto fit - Automatically fits the entire graph within the viewport.

  • Layout - Reapplies the graph layout algorithm to reorganize nodes.

  • Add block - Opens interface to add a new block to the workflow.

  • Add stack - Creates a new workflow stack.

  • Remove selected - Removes currently selected elements from the graph.

Value

new_toolbar_item()

A toolbar item object of class "toolbar_item" containing action and js functions, with id, icon, and tooltip attributes.

is_toolbar_item()

TRUE if x is a toolbar item, FALSE otherwise.

toolbar_items()

A list of toolbar items for the given object.