Skip to content

Commit 7707198

Browse files
authored
feat: add dashboard modified to DashboardTileMergeEvent (#222)
* feat: add dashboard modified to DashboardTileMergeEvent Additional parameter indicating that a dashboard is modified has been added to the DashboardTileMergeEvent message. This allows the embedding application to warn the user that they may lose data if they proceed.
1 parent 968a56c commit 7707198

30 files changed

Lines changed: 87 additions & 51 deletions

demo/demo_merge_edit_frame.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
2525
*/
2626

27-
import type { ILookerConnection, ILookerEmbedSDK } from '../src/index'
27+
import type {
28+
CancellableEventResponse,
29+
DashboardTileMergeEvent,
30+
ILookerConnection,
31+
ILookerEmbedSDK,
32+
} from '../src/index'
2833
import { getEmbedSDK } from '../src/index'
2934
import type { RuntimeConfig } from './demo_config'
3035
import { getConfiguration, loadConfiguration } from './demo_config'
@@ -71,17 +76,31 @@ const initializeControls = () => {
7176
* The default behavior is for the edit merge query page to be opened in a top
7277
* level window.
7378
*/
74-
const openMergeQuery = (event: any): any => {
75-
window.open(`/merge_edit?merge_url=${encodeURI(event.url)}`)
76-
updateStatus('Merge query edit opened in a new window')
79+
const openMergeQuery = (
80+
event: DashboardTileMergeEvent
81+
): CancellableEventResponse => {
82+
let doMergeEdit = false
83+
if (!event.dashboard_modified) {
84+
doMergeEdit = true
85+
} else {
86+
doMergeEdit = window.confirm(
87+
'The dashboard has unsaved changes which may be lost if the merge query is edited. Proceed?'
88+
)
89+
}
90+
if (doMergeEdit) {
91+
window.open(`/merge_edit?merge_url=${encodeURIComponent(event.url)}`)
92+
updateStatus('Merge query edit opened in a new window')
93+
} else {
94+
updateStatus('Merge query edit cancelled')
95+
}
7796
return { cancel: true }
7897
}
7998

8099
/**
81100
* The merge edit url is stored in history state
82101
*/
83102
const getEmbedMergeEditUrl = () => {
84-
const embedUrl = decodeURI(history.state?.merge_url || '')
103+
const embedUrl = decodeURIComponent(history.state?.merge_url || '')
85104
return embedUrl || '/embed/preload'
86105
}
87106

demo/demo_single_frame.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
// IDs for content to demonstrate can be configured in the .env file or in demo_config.ts
2828

2929
import type {
30+
CancellableEventResponse,
31+
DashboardTileMergeEvent,
3032
ILookerConnection,
3133
ILookerEmbedSDK,
3234
PageChangedEvent,
@@ -121,9 +123,23 @@ const updateStatus = (status: string) => {
121123
* The default behavior is for the edit merge query page to be opened in a top
122124
* level window.
123125
*/
124-
const openMergeQuery = (event: any): any => {
125-
window.open(`/merge_edit?merge_url=${encodeURI(event.url)}`)
126-
updateStatus('Merge query edit opened in a new window')
126+
const openMergeQuery = (
127+
event: DashboardTileMergeEvent
128+
): CancellableEventResponse => {
129+
let doMergeEdit = false
130+
if (!event.dashboard_modified) {
131+
doMergeEdit = true
132+
} else {
133+
doMergeEdit = window.confirm(
134+
'The dashboard has unsaved changes which may be lost if the merge query is edited. Proceed?'
135+
)
136+
}
137+
if (doMergeEdit) {
138+
window.open(`/merge_edit?merge_url=${encodeURIComponent(event.url)}`)
139+
updateStatus('Merge query edit opened in a new window')
140+
} else {
141+
updateStatus('Merge query edit cancelled')
142+
}
127143
return { cancel: true }
128144
}
129145

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/interfaces/AddFilterJson.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>AddFilterJson | @looker/embed-sdk</title><meta name="description" content="Documentation for @looker/embed-sdk"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@looker/embed-sdk</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@looker/embed-sdk</a></li><li><a href="AddFilterJson.html">AddFilterJson</a></li></ul><h1>Interface AddFilterJson </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
22
<p>Drill menu addFilterJson data</p>
3-
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">AddFilterJson</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#add" class="tsd-kind-icon">add</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#field" class="tsd-kind-icon">field</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#rendered" class="tsd-kind-icon">rendered</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="add" class="tsd-anchor"></a><h3 class="tsd-anchor-link">add<a href="#add" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">add<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1218">src/types.ts:1218</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="field" class="tsd-anchor"></a><h3 class="tsd-anchor-link">field<a href="#field" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">field<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1217">src/types.ts:1217</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="rendered" class="tsd-anchor"></a><h3 class="tsd-anchor-link">rendered<a href="#rendered" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">rendered<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1216">src/types.ts:1216</a></li></ul></aside></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="AddFilterJson.html" class="tsd-kind-icon">Add<wbr/>Filter<wbr/>Json</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#add" class="tsd-kind-icon">add</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#field" class="tsd-kind-icon">field</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#rendered" class="tsd-kind-icon">rendered</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>
3+
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">AddFilterJson</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#add" class="tsd-kind-icon">add</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#field" class="tsd-kind-icon">field</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#rendered" class="tsd-kind-icon">rendered</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="add" class="tsd-anchor"></a><h3 class="tsd-anchor-link">add<a href="#add" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">add<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1219">src/types.ts:1219</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="field" class="tsd-anchor"></a><h3 class="tsd-anchor-link">field<a href="#field" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">field<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1218">src/types.ts:1218</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="rendered" class="tsd-anchor"></a><h3 class="tsd-anchor-link">rendered<a href="#rendered" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">rendered<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/looker-open-source/embed-sdk/blob/master/src/types.ts#L1217">src/types.ts:1217</a></li></ul></aside></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="AddFilterJson.html" class="tsd-kind-icon">Add<wbr/>Filter<wbr/>Json</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#add" class="tsd-kind-icon">add</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#field" class="tsd-kind-icon">field</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="AddFilterJson.html#rendered" class="tsd-kind-icon">rendered</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>

0 commit comments

Comments
 (0)