Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion embed/embed-dashboards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ Embedded viewers can't create or manage [scheduled deliveries](/explore/create-s

Add a `writeActions` claim to let embedded users save a new chart from Explore, or — through the React SDK — edit an existing dashboard or build a new one. Lightdash performs the write as a configured actor (a service account or user) into the spaces the token names. See [Write actions](/embed/reference#write-actions) for the claim and [`Lightdash.Dashboard` edit mode](/embed/react-sdk#with-edit-mode) for the SDK flow.

In dashboard edit mode, if the token also sets `canExplore: true`, the add-tile menu has **New chart** and tiles whose chart is in a write space have **Edit chart**. Both open Explore in place: a new chart is saved to a write space and added to the dashboard as a tile, and saving an edited chart updates its tile.
In dashboard edit mode, if the token also sets `canExplore: true`, the add-tile menu has **New chart** and tiles whose chart is in a write space have **Edit chart**. Both open Explore in place: a new chart is added to the dashboard as a tile, and saving an edited chart updates its tile.

Charts created with **New chart** or **Save as new chart** are saved to the dashboard itself, the same as [creating a chart from a dashboard](/explore/dashboards#create-a-new-chart) in Lightdash. They don't appear in any space's chart list, and removing their tile and saving the dashboard deletes them. If the dashboard isn't in one of the token's write spaces, Lightdash saves the chart to the first write space instead. With the React SDK, you can save these charts to a write space, or let users choose, with the [`chartSaveDestinations` prop](/embed/react-sdk#choose-where-new-charts-are-saved). Iframe embeds always save them to the dashboard.

Newly saved charts aren't added to the embed allowlist, so they won't be re-embeddable unless you add them explicitly.

Expand Down
24 changes: 24 additions & 0 deletions embed/react-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ type DashboardProps = {
onEditModeChange?: (
isEditMode: boolean,
) => void; // Callback when the embed enters or leaves edit mode
chartSaveDestinations?: ('dashboard' | 'space')[]; // Where "New chart" and "Save as new chart" save (default: ['dashboard'])
onExplore?: (options: {
chart: SavedChart
}) => void; // Handle "Explore from here" in your app instead of the embed
Expand Down Expand Up @@ -259,6 +260,28 @@ function EditableDashboard() {

The dashboard must be in one of the token's write spaces. The add-chart picker lists saved charts from the write spaces and any [source spaces](/embed/reference#add-charts-from-other-spaces); charts from a source space can't be edited from the dashboard. See [Write actions](/embed/reference#write-actions) for the JWT claim.

#### Choose where new charts are saved

When the token sets `canExplore: true`, edit mode offers **New chart** in the add-tile menu and **Save as new chart** when editing a chart. Use `chartSaveDestinations` to control where those new charts are saved:

| Value | Behavior |
|-------|----------|
| `['dashboard']` (default) | The chart is saved to the dashboard. It doesn't appear in any space's chart list, and removing its tile and saving the dashboard deletes it. |
| `['space']` | The chart is saved to a write space, and the dashboard tile references it. |
| `['dashboard', 'space']` | The save dialog lets the user choose between the dashboard and the write spaces. The dashboard is selected by default. |

```tsx
<Lightdash.Dashboard
instanceUrl="https://app.lightdash.cloud"
token={generateToken({ canExplore: true })} // JWT must include writeActions
isEditMode={isEditMode}
onEditModeChange={setIsEditMode}
chartSaveDestinations={['dashboard', 'space']}
/>
```

If the dashboard isn't in one of the token's write spaces, Lightdash saves new charts to the first write space whatever this prop says. Iframe embeds have no equivalent setting and always save to the dashboard.

<a id="lightdashdashboardbuilder" />

### Lightdash.DashboardBuilder
Expand Down Expand Up @@ -289,6 +312,7 @@ type DashboardBuilderProps = {
onEditModeChange?: (
isEditMode: boolean,
) => void; // Callback when the embed enters or leaves edit mode
chartSaveDestinations?: ('dashboard' | 'space')[]; // See "Choose where new charts are saved"
onDashboardReady?: (
dashboard: EmbedDashboard,
) => void; // Called once the empty dashboard has been created
Expand Down
Loading