Build a Portal Widget
A reusable widget attaches portal-wide scripts, styles or components. It has its own configuration form and version records. It is distinct from an attendee App, even though an app can also be displayed through supported portal component mechanisms.
Create and configure
- Open Developer Hub → Widgets and choose New widget.
- Enter a name, a unique lowercase hyphenated slug and descriptions. Slug uniqueness is checked across widget definitions, not only within your team.
- Open Settings → Config & Code for the current version.
- Author the configuration form for values that each portal should supply.
- Enter JavaScript in Script and a JSON array in Head tags / libraries.
- Choose Save configuration, inspect the response and reload the same current version to verify the form, script and libraries. The editor rejects malformed library JSON or a value that is not an array.
Settings also contains General and Tags. AI enrichment can generate descriptive metadata and keywords from the current configuration; it does not implement the widget's behavior.
Workspace and version selection
The current Widget tabs are Overview, Settings and Publish. The list searches name, slug and description and normally stays within the selected team. List access and creation have separate widget policy checks, so a visible New widget button does not prove creation is allowed. Creation makes version 1 with an empty script and makes it the definition's current version.
Overview shows current-definition context and at most five recent versions. Publish lists all returned versions, but currently provides no create-draft, publish or version-editor links. Its Draft badge checks only is_published; a withdrawn historical release can still have a publication timestamp and remain read-only. Use the established dashboard version editor to inspect or continue that work rather than treating the badge as permission to edit.
Widget Settings always loads the definition's current version. It does not use the Tile editor's version=ROW_ID selection contract, and adding that query parameter does not select an older Widget version. To inspect a particular version, use the dashboard editor path described below, whose version segment is the displayed version number. Record both its number and row ID when handing off so they are not confused.
In Settings, General → Save details and Tags → Save tags update the shared definition. Config & Code → Save configuration updates versioned settings, script and libraries. Saving the description does not save script changes or publish a release. If Config & Code says No version yet, ask the widget owner/platform maintainer to reconcile its current-version selection before authoring; do not create another definition to repair the pointer.
The form editor guards against overwriting populated saved fields with an unexpectedly empty converted form. If it says the form looks empty but the version has saved fields, preserve your source, reload and compare the saved field names before retrying. This can also block an intentional removal of the last field; resolve the intended schema change with the maintainer instead of assuming the error means the saved schema was already cleared.
Script and library contract
The portal inserts a widget's Script as JavaScript inside a function wrapper. Enter JavaScript without wrapping it in an HTML <script> tag. The function receives the resolved widget configuration as a local props object. This wrapper gives the script local variables; it is not a security sandbox. The script runs in the portal window and can access its DOM. Treat widget code and external libraries as trusted portal code.
For a simple non-sensitive test, log that configuration loaded:
console.info('Portal widget initialized', {
enabled: props.enabled !== false
})
Replace this diagnostic with the intended behavior before handoff. Avoid logging credentials or attendee data. If your script installs event handlers or DOM elements, design repeated page visits so it does not duplicate handlers or overlays.
Head libraries support CSS and external scripts, plus supported meta/link entries. For example, this library array adds viewport metadata:
[
{
"tag": "meta",
"name": "viewport",
"content": "width=device-width, initial-scale=1"
}
]
The portal already has its own head configuration, so use this only as an example of the stored shape; do not add duplicate viewport tags to an existing portal. External libraries use { "type": "css", "url": "..." } or { "type": "script", "url": "...", "flags": [] }. Use trusted HTTPS sources that are compatible with your deployment's content security policy.
Head and global-component modes
The version model supports head and global-component types. The hub's Config & Code section edits settings, script and libraries, but it does not offer all legacy version fields or the component-file upload controls. Use the established dashboard widget-version editor for legacy version fields, including the type. On the dashboard host, the editor is /{team}/plugins/widgets/{widget}/versions/{version}: use the owning team slug, widget slug and version number, not the version row ID. A component-file upload alone does not select what the current global-component runtime loads.
For a global component, install the reusable App or Form in the project first, then select that installation through the widget configuration's model value. The current middleware expects a class-and-ID string such as App\Models\ProjectPage:123 or App\Models\ProjectForm:456 (shown as literal text; JSON must escape backslashes). Replace the example ID with the intended installation's ID. It resolves that installed page/form and its App version, configuration, assets and runtime code. A missing installation or one without an associated App/version produces no component. This is distinct from running the widget's Script field. Displaying an App here does not grant it ordinary page-context API access: this path supplies the widget credential to the mounted component. Verify its actual request context and expected denials; selecting a model is not a way to grant project-resource access.
Test where the component actually mounts. Legacy theme runtime global components are mounted in its Private layout; the head-script path is separate. Do not promise that a global component appears on all public and system pages without verifying that theme and installation combination.
Permissions
Authoring requires access to the widget's owning team and the corresponding widget view/update permission. Developer Hub checks ownership before loading or changing an existing definition. Portal attachment and removal require portal update permission; editing an installation checks its update permission. Public/global-default distribution flags are restricted to super administrators, and changing an installation's explicit version is also restricted by the current update rules.
Widget tokens have no independent page context and cannot authorize arbitrary project resources through the base dashboard policy. Do not put a project integration key into widget code to work around that rule. Put data-driven attendee functionality into a properly bound App/page context, or use another supported integration architecture with appropriate authorization.
Publish and install
The current hub Publish page lists versions without publication controls. Open the established dashboard widget-version editor, choose Publishing → Publish Current Version, and verify the version state. The dashboard path can copy script, libraries and settings into the next editable version; a developer create-version endpoint creates a blank script version, so always inspect the new version before editing. The dashboard copy payload does not explicitly carry forward the widget type or component file; verify those fields as well. Developer create-version updates the definition’s current-version pointer, which unpinned portal attachments follow. Plan draft creation against a test portal or an explicitly controlled version selection rather than assuming publication is the only action that changes runtime selection.
Before creating a version, record the currently published number/ID, current pointer and any portal attachment pins. The developer endpoint creates another blank-script row on each successful call; it is not the Tile workflow's reuse-existing-draft action. After an uncertain response, reconcile the version list and current pointer before retrying. A new empty current version can affect unpinned attachments before it is published. Keep an approved source copy of script/libraries/settings and use a controlled portal when verifying the next version.
Developer Hub version saves reject both published versions and versions with a publication timestamp, returning a read-only error. Create a new version for changes. Its publish endpoint marks the selected version published; it does not perform the dashboard's copy-to-next-draft workflow. The current unpublish endpoint refuses to reopen a published version. Do not assume a listing badge or changing a definition's current-version pointer proves every portal is running the intended version.
On the dashboard host, open the target portal at /p/{team}/{project}/portals/{portal} using team/project slugs and the portal ID. In Advanced Settings → Widget List, choose Attach Widget, select the definition, configure its settings and sort order, and verify the selected version/default behavior. The Widget List is gated by the dashboard’s portal_widget_settings feature; if it is absent, check dashboard feature availability and permissions with an administrator. A version pinned by plugin_widget_version_id uses that version; an absent version falls back to the widget definition's current version.
Attachment initially selects the default (zero) version. For an authorized super administrator, open that attached widget's editor in Widget List, then Developer Settings → Plugin Widget Version. Select the intended numbered version, save the attachment and reload to verify its stored/resolved selection. The option stores a version-row ID even though its label displays a version number. Use Published Default sets zero and follows the current pointer; it does not guarantee newest-published selection. If this section is unavailable, ask the responsible administrator to establish/verify the pin before any workflow that moves the definition's pointer.
The installation stores an is_enabled flag, but the reviewed portal widget query, parser and head rendering path do not filter on that flag. Verify behavior in your deployed release before relying on the toggle to stop code. If you need to stop a widget, remove the portal attachment and confirm after a full reload and configuration-cache refresh that its code and libraries are absent.
Normal attachment create/update/delete model events invoke the portal's targeted cache invalidation through the registered widget observer. After a successful removal, confirm the attachment is gone from Widget List, then request a fresh portal document and inspect its response head/runtime configuration for the widget and libraries. A script already running in an open browser is not unloaded merely by deleting its attachment; test a full page reload too. The separate server widget collection cache has a 300-second TTL, but that is not a guarantee that every portal/browser cache refreshes in five minutes. If the fresh response still includes removed configuration, give the operator the team/project/portal and attachment identifiers and request the supported targeted invalidation/investigation. Detailed cache operations stay in operator runbooks; do not broadly flush unrelated portals as an authoring workaround.
Nonempty installation custom_settings supplies props; a nested widgets_settings object is flattened over its root values. Empty installation settings fall back to the older portal-level widget settings. The parser does not automatically merge the version's configuration defaults into this head-script props object, so handle missing optional values explicitly, as in the JavaScript example above. Changing the widget definition does not prove a pinned installation has changed. Explicit version changes are privileged in the current model; involve an authorized administrator when that control is unavailable.
Developer Hub routes
These are administrator-session routes under /{team}/developer/widgets, on the dashboard host in the authenticated, verified-account and team-context group. They are separate from the legacy dashboard version editor and attendee/portal APIs.
| Action | Method and suffix | Checks and effect |
|---|---|---|
| List/create form | GET /, GET /create | Model list/create authorization respectively |
| Create definition | POST / | Create permission, selected team, unique slug; initial version/current pointer |
| Open definition | GET /{widget} | Own-team/view check, then Overview redirect |
| Overview/Settings/Publish | GET /{widget}/overview, /settings, /publish | Own-team/view checks; Settings resolves current version through this widget's versions |
| Save shared metadata/tags | PUT /{widget} | Own-team/update checks; public/global flags stripped for ordinary admins |
| Create version | POST /{widget}/versions | Own-team/update checks; blank script and current-pointer change |
| Save version content | PUT /{widget}/versions/{version} | Own-team/update checks, widget-scoped row ID; published/timestamped content refused |
| Publish/unpublish request | POST /{widget}/versions/{version}/publish or /unpublish | Own-team/update checks and widget-scoped row; publication/reopen behavior described above |
The existence of a developer mutation endpoint does not mean the current Publish page offers that action. Use supported UI workflows and check their returned state rather than inventing a missing button or sending unreviewed version mutations against a live portal.
Test and troubleshoot
Check head content, console errors, external library loading, CSP/network failures, and whether the intended installation is attached. Do not rely on the enabled flag without a deployed check. Test navigation and a full page reload to catch duplicate initialization. For missing components, check type, the configured model installation, its App/version, selected theme layout and widget version. The current shared layout mounts global components in the legacy Private layout; the SFC layout branch does not automatically add those components. For project API denials, inspect the principal type rather than broadening the widget's credential.
For a release check, test the intended portal theme and both signed-in and signed-out surfaces. Confirm the installation settings reach props, libraries load once as expected, a full reload picks up changes, and removing the attachment stops loading the widget. Portal configuration is cached, so a successful save alone is not proof that a previously cached response has changed. These runtime checks remain necessary even when the editor accepts the configuration.
For a save failure, distinguish malformed library JSON or schema-conversion guard from a 422 immutable-version response, a permission denial or a missing current version. Preserve authored code before refreshing; reloading can discard unsaved editor state. Reopen the exact intended legacy version/current Hub context and compare persisted fields, script and libraries after the save. Retain owning team, widget/version identifiers, attachment pin/default, portal/theme, configuration and observed request/result as delivery evidence.
Use controlled accounts to verify allowed authoring and refusals for missing same-team permission, a cross-team definition and another widget's version. Verify signed-out and signed-in portal placement separately, and check that the widget credential cannot read an unrelated project resource. Local parser/example checks do not establish deployed authorization, browser/CSP behavior, cache refresh or successful removal.