Skip to content

Give template connection pages a clear layout - #422

Merged
tnkuehne merged 4 commits into
mainfrom
connection-pages-ui
Nov 26, 2026
Merged

tnkuehne merged 4 commits into
mainfrom
connection-pages-ui

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A template's connection page is the first thing people see when they open the app, and it was hard to read: five equally weighted paragraphs ("Personal connection", "Widefleet user: …", the API description, two explanations), then Reconnect, the approval radios and Disconnect stacked without grouping, and "After connecting, return to your app" even when the account was already connected. The setup state mixed instructions for administrators into running text addressed to everyone.

Changes

Each template writes its page and its approval levels itself; the generator copies only the code that generated methods call.

  • templates/*/src/page.ts: each OAuth template writes its own page: the service's logo and what it offers, then one block for the current state:
    • Setup required: numbered steps for the administrator in the provider's own terms, with the callback URL or domain to copy and only the missing secrets. A saved account stays listed below them with Disconnect and its approval level; only Reconnect waits for the settings.
    • Not connected: one sentence and a primary "Connect " button.
    • Connected: the account with Reconnect and Disconnect, a note on what disconnecting does, then the approval levels as one grouped list.
  • templates/*/src/layout.ts: each template's page shell and Widefleet's color tokens for light and dark.
  • templates/*/src/approval-levels.ts (new): the levels a template offers, its default, and each level's name and what it asks about in that service, such as Ask except for drafts and labels in Gmail or Ask except for new files and folders in Google Drive. Strava, Teams and WHOOP create nothing without asking, so they offer only Always ask and Never ask, on the page and through setApprovalLevel, and default to always asking. Agents show the template's level names when they ask to loosen the level.
  • templates/*/src/approval-page.ts: owned by each template, reads its levels; saving behavior is unchanged.
  • Garmin Connect keeps its Personal API key form on the same layout: the account with Disconnect, then the key form ("Replace key" once connected).
  • Generator: copies only selection.ts, input.ts, the API client files and, for templates that change data, approval.ts and approval-methods.ts, which now read the template's approval-levels.ts. connectionPage no longer takes the user's name, which the page no longer shows.
  • Tests: Strava, Garmin Connect, Qonto and WHOOP assertions read the new markup; Strava, Teams and WHOOP check that they offer no level between always and never and reject it when saved.

Screenshots

Gmail stands in for the OAuth templates.

Before After
Gmail connected before Gmail connected after
Gmail not connected before Gmail not connected after
Gmail setup before Gmail setup after
Garmin Connect connected before Garmin Connect connected after

Failed connection at 390 px, connected in dark mode at 390 px, and Garmin Connect before connecting:

Strava, with only two levels, and Google Drive at 390 px:

A secret removed after someone connected:

Verification

  • All 14 templates pass typecheck and test; packages/template-generator tests pass.
  • Format and type-aware lint are clean on the changed files.
  • Rendered with synthetic fixtures at 1280 and 390 px in light and dark: Gmail in all four states plus setup with a saved account, Garmin Connect connected, not connected and with a rejected key, Strava setup with its callback domain, Strava and Google Drive connected.
  • Not checked in a browser against a running app: the OAuth redirect round trip and saving the approval level by clicking. Both paths keep their markup contracts (/connect, /disconnect forms, #approval fieldset) and are covered by the template tests.

Documentation

The approval levels are documented in #423 (draft until this is released).

Confidence Score: 4/5 · Map previously saved approval choices before merging so upgraded accounts keep working.RetriggerView in GreptileConfidence Score: 4/5

Map previously saved approval choices before merging so upgraded accounts keep working.

Findings

  1. P1 Saved approval choices break upgrades ▶

Summary

Reworks template connection pages into clear setup, disconnected and connected sections.

  • Service connection pages group setup steps, account actions, and service details.
  • Approval choices explain service actions and use names that agents show.

Reviews (4) · Last reviewed commit: "Let each template write its page and app..." · Reviewed by Greptile

Each template's connection page now shows the service's logo and what it
offers, then one block for the current state: setup steps for the
administrator, a connect button, or the connected account with its actions
and the approval level. The layout lives once in the template generator's
runtime as layout.ts and follows Widefleet's colors in light and dark.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 6ee5aee Nov 26 2026, 04:37 PM

When an administrator removes a client secret after someone connected, the
page shows the setup steps and still lists the saved account with Disconnect
and its approval level. Only Reconnect needs the missing settings.
Each approval level has a short name and a line that says what asks first,
so the difference between asking always and asking except for new items is
visible at once. The footer with the signed-in Widefleet user is gone; the
page no longer needs the user's name.
The generator copies only the code that generated methods call. Each
template's page, look, approvals form and levels now live in its own
files, so every level names what it asks about in that service. Strava,
Teams and WHOOP create nothing without asking and offer only always and
never.
// always and never.
import type { Level } from "./approval.ts";

export const approvalLevels = ["all_changes", "none"] as const satisfies readonly Level[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Saved approval choices break upgrades

Users who previously saved updates_and_deletions now hit an error because approvalLevels no longer includes it. approvals().level() still parses saved values with this narrowed enum, so opening the connection page or running a change fails. Teams and WHOOP have the same problem.

Map the old value to all_changes when reading it, or migrate saved rows before narrowing the enum.

@tnkuehne tnkuehne Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended: installing a template builds its current source once and never replaces the deployed app, so installed apps keep their own approval code and saved levels. A saved updates_and_deletions only meets this code when an owner copies the new template over their app by hand, the same manual step as any other template change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. If updates_and_deletions was never available in a released Strava, Teams, or WHOOP app, there are no existing saved choices to preserve, so a mapping or migration isn't needed. I’ll withdraw this finding.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that distinction matters. I treated this as an automatic upgrade affecting already-deployed apps, but templates are copied into an app once and do not replace its deployed code. Existing apps therefore keep their approval code and saved levels; the mismatch can arise only if an owner manually adopts the new template source. Given that intended update model, this isn’t an automatic-upgrade blocker for the PR.

@tnkuehne
tnkuehne merged commit 26d030d into main Nov 26, 2026
18 checks passed
@tnkuehne
tnkuehne deleted the connection-pages-ui branch November 26, 2026 17:04
tnkuehne added a commit that referenced this pull request Nov 26, 2026
…433)

Adds a Microsoft Dataverse template. Like the other REST templates, it
exposes the vendor API's own shape: every table's rows through the Web
API's entity-set operations, and each action and function of the Web API
as a typed method.

## Changes

- **`packages/template-generator/src/csdl.ts`** (new): turns an OData v4
CSDL `$metadata` document into an OpenAPI description.
- **Rows of any table**: `/{entitySet}` list and create,
`/{entitySet}({id})` get, update and delete, and `$ref` associate and
disassociate.
- **Actions** are POSTs with a JSON body. Parameters are required when
they are not nullable and not optional.
- **Functions** are GETs that write their arguments into the call: enum
literals, unquoted numbers, GUIDs and dates, and quoted strings. Lists,
objects and rows go as `@alias` query parameters.
  - **Bound operations** use their type's entity set.
- **Types**: entity and complex types become schemas, enums become
string enums, and propertyless base entities become any-row objects.
- **OpenAPI server variables**: `{variable}` in a server URL becomes a
required input of every method. The runtime substitutes it and accepts
only a host name, so a value can never add a path, credentials or
another address. Dataverse uses this for `environment`, because every
Web API call names its environment in its address.
- **`runtime/rest.ts`**: server variables, `@alias` query parameters
sent as JSON, and optional OData function parameters left out of the
call. Only parameters the description marks optional
(`optionalPathParameters`) are left out. The file is copied into all
REST templates; their behavior is unchanged.
- **Results**: OData answers collections, primitives and enum members
inside `value`, so those methods return `{ value }`. Complex types keep
their navigation properties, such as the principal in `PrincipalAccess`.
- **`templates/dataverse`**:
- 496 methods, among them `listRows`, `getRow`, `createRow`,
`updateRow`, `deleteRow`, `associateRows`, `disassociateRows`,
`getMetadata`, `callAction` for actions a solution adds, and the typed
actions and functions such as `whoAmI`, `addPrivilegesRole` and
`publishXml`.
- **`listEnvironments`** reads the Global Discovery Service and returns
each environment's host as methods take it.
- **Tokens** are issued per environment from the account's refresh token
and cached encrypted per user and environment.
- A Dataverse 403 without an error body reports `network_required` with
the origin to allow.
- **`createRow`** writes only to an entity set that the environment's
service document lists. OData addresses unbound actions the same way,
and an action must keep its own change class.
- **Change classes**: `create` only adds something new. Operations that
also change what exists, such as granting privileges, adding team
members or importing over existing customizations, are `update`.
- **Login**: connects through the organization's own Entra application
(`MICROSOFT_CLIENT_ID`, `MICROSOFT_CLIENT_SECRET`) with the delegated
Dynamics CRM `user_impersonation` permission. Managed sign-in is not
offered yet. The managed broker would have to issue a token per
environment, and that will come separately.

## Screenshots

New template, so there are no before images. Connected and setup, at
1280 px light and 390 px dark:

<img
src="https://gist.githubusercontent.com/tnkuehne/1b14cca5210b7a44c44f2e03697bc76a/raw/3672f021a5774d216c14ccdd1a6751dee9b2f842/dataverse-connected-1280-light.png"
width="560"> <img
src="https://gist.githubusercontent.com/tnkuehne/1b14cca5210b7a44c44f2e03697bc76a/raw/3672f021a5774d216c14ccdd1a6751dee9b2f842/dataverse-connected-390-dark.png"
width="260">

<img
src="https://gist.githubusercontent.com/tnkuehne/1b14cca5210b7a44c44f2e03697bc76a/raw/3672f021a5774d216c14ccdd1a6751dee9b2f842/dataverse-setup-1280-light.png"
width="560"> <img
src="https://gist.githubusercontent.com/tnkuehne/1b14cca5210b7a44c44f2e03697bc76a/raw/3672f021a5774d216c14ccdd1a6751dee9b2f842/dataverse-setup-390-dark.png"
width="260">

The not-connected and failed states are not shown. They use #422's
layout unchanged.

## Verification

- **Tests**:
- Dataverse template: 9 of 9 pass, including two environments that each
get their own token, discovery and its failure, `network_required`,
rejected tokens, a refresh that finishes after the grant changed,
`createRow` against an action's address, and setup without OAuth.
- Template generator: all tests pass, including new CSDL tests for
operations, bound paths, function arguments and aliases, types, and
server-variable validation.
  - All other REST templates pass with the updated `rest.ts`.
  - `pnpm check` is clean.
- **Live calls** against a Dataverse trial environment with a custom
Entra app returned 200 for `whoAmI`, `retrieveVersion`,
`retrieveUserPrivileges` (bound), `retrieveCurrentOrganization` (an enum
argument) and `getMetadata`.
- **Not checked live**: creating tables and security roles, which needs
the System Administrator role in the environment.

## Known limits

- **`$batch`** (multipart/mixed) is not offered.
- **`getMetadata`** may exceed the 8 MiB response limit in environments
with many Dynamics 365 apps. The trial environment's document is 6.8 MB.




<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge; the
remaining token-caching issue is non-blocking.</rp></ruby><a
href="https://app.greptile.com/api/retrigger?id=121049043&amp;sig=62c1315a5b8963405a26c37b34d971afad06ec912f72e8349ad0f7917ae764a9"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F433&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge; the
remaining token-caching issue is non-blocking.

<h2>Findings</h2>

1. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Parallel refreshes skip caching tokens** <a
href="https://github.com/widefleet/widefleet/pull/433#discussion_r4712226296">▶</a>

<details open><summary><h3>Summary</h3></summary>

Adds a Dataverse template with typed methods generated from CSDL
metadata.
- The generator builds typed API descriptions from OData metadata.
- REST calls now support server variables and OData function arguments.
- Dataverse methods can read and change rows and call Web API
operations.
- Users can connect a Microsoft account and choose a Dataverse
environment.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Dataverse method] --> B[Check connection and request]
  B --> C{createRow?}
  C -->|Yes| D[Read service document]
  D --> E{Request succeeded?}
  E -->|No| F[Return recovery details]
  E -->|Yes| G[Check entity set]
  C -->|No| H[Check approval]
  G --> H
  H --> I[Send request with environment token]
  I --> J[Return data or recovery details]
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (3) · Last reviewed commit: ["Report blocked environments
and
throttli..."](a2aa8fa)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant