@quillsql/admin 1.4.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/Admin.d.ts +4 -1
  2. package/dist/cjs/Admin.d.ts.map +1 -1
  3. package/dist/cjs/Admin.js +122 -77
  4. package/dist/cjs/AdminProvider.d.ts +1 -1
  5. package/dist/cjs/AdminProvider.d.ts.map +1 -1
  6. package/dist/cjs/AdminProvider.js +9 -9
  7. package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
  8. package/dist/cjs/api/ConnectionClient.js +13 -0
  9. package/dist/cjs/components/UiComponents.d.ts +2 -1
  10. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  11. package/dist/cjs/components/UiComponents.js +9 -7
  12. package/dist/cjs/forms/client_onboard/CreateSqlViews.js +1 -1
  13. package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
  14. package/dist/cjs/forms/sql_views/CreateEditSqlView.js +19 -6
  15. package/dist/cjs/modals/NewDashboardModal.js +1 -1
  16. package/dist/cjs/modals/ReorderDashboardModal.d.ts.map +1 -1
  17. package/dist/cjs/modals/ReorderDashboardModal.js +178 -63
  18. package/dist/cjs/primitives/ModalPrimitive.d.ts.map +1 -1
  19. package/dist/cjs/primitives/ModalPrimitive.js +1 -2
  20. package/dist/cjs/public_components/DashboardBuilder.d.ts.map +1 -1
  21. package/dist/cjs/public_components/DashboardBuilder.js +92 -30
  22. package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
  23. package/dist/cjs/public_components/DashboardManager.js +164 -160
  24. package/dist/cjs/public_components/SQLViewManager.d.ts.map +1 -1
  25. package/dist/cjs/public_components/SQLViewManager.js +23 -4
  26. package/dist/cjs/utils/constants.d.ts +4 -4
  27. package/dist/cjs/utils/constants.js +2 -2
  28. package/dist/esm/Admin.d.ts +4 -1
  29. package/dist/esm/Admin.d.ts.map +1 -1
  30. package/dist/esm/Admin.js +124 -79
  31. package/dist/esm/AdminProvider.d.ts +1 -1
  32. package/dist/esm/AdminProvider.d.ts.map +1 -1
  33. package/dist/esm/AdminProvider.js +10 -10
  34. package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
  35. package/dist/esm/api/ConnectionClient.js +13 -0
  36. package/dist/esm/components/UiComponents.d.ts +2 -1
  37. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  38. package/dist/esm/components/UiComponents.js +9 -7
  39. package/dist/esm/forms/client_onboard/CreateSqlViews.js +2 -2
  40. package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
  41. package/dist/esm/forms/sql_views/CreateEditSqlView.js +19 -6
  42. package/dist/esm/modals/NewDashboardModal.js +1 -1
  43. package/dist/esm/modals/ReorderDashboardModal.d.ts.map +1 -1
  44. package/dist/esm/modals/ReorderDashboardModal.js +178 -63
  45. package/dist/esm/primitives/ModalPrimitive.d.ts.map +1 -1
  46. package/dist/esm/primitives/ModalPrimitive.js +1 -2
  47. package/dist/esm/public_components/DashboardBuilder.d.ts.map +1 -1
  48. package/dist/esm/public_components/DashboardBuilder.js +93 -31
  49. package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
  50. package/dist/esm/public_components/DashboardManager.js +164 -160
  51. package/dist/esm/public_components/SQLViewManager.d.ts.map +1 -1
  52. package/dist/esm/public_components/SQLViewManager.js +23 -4
  53. package/dist/esm/utils/constants.d.ts +4 -4
  54. package/dist/esm/utils/constants.js +2 -2
  55. package/package.json +1 -1
@@ -1,19 +1,23 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // @ts-nocheck
3
3
  import { useEffect, useState } from 'react';
4
4
  import { useAdmin } from '../AdminProvider';
5
- import { ReorderableList } from '../Admin';
6
5
  import { QUILL_SERVER } from '../utils/constants';
6
+ import { arrayMove, rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable, } from '@dnd-kit/sortable';
7
+ import { CSS } from '@dnd-kit/utilities';
8
+ import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, TouchSensor, } from '@dnd-kit/core';
9
+ import { Chart } from '@quillsql/react';
7
10
  export default function ReorderDashboardModal({ isOpen, setIsOpen, client, onSave, ModalComponent, ButtonComponent, selectedDashboard, organizationId, }) {
8
11
  // const [client] = useContext(ClientContext);
9
12
  const [dashboardItems, setDashboardItems] = useState([]);
10
13
  const [loading, setLoading] = useState(false);
11
- const [chartType, setChartType] = useState('metric');
12
14
  const [doesDashboardHaveTables, setDoesDashboardHaveTables] = useState(false);
13
15
  const [doesDashboardHaveCharts, setDoesDashboardHaveCharts] = useState(false);
14
16
  const [doesDashboardHaveMetrics, setDoesDashboardHaveMetrics] = useState(false);
15
- const [orderArray, setOrderArray] = useState([]);
16
17
  const [itemMap, setItemMap] = useState(null);
18
+ const [metrics, setMetrics] = useState([]);
19
+ const [charts, setCharts] = useState([]);
20
+ const [tables, setTables] = useState([]);
17
21
  const { state, dispatch } = useAdmin();
18
22
  useEffect(() => {
19
23
  async function getDashboardItems() {
@@ -38,6 +42,9 @@ export default function ReorderDashboardModal({ isOpen, setIsOpen, client, onSav
38
42
  flattened = flattened.concat(responseData.sections[key]);
39
43
  }
40
44
  setDashboardItems(flattened);
45
+ setMetrics(flattened.filter((elem) => elem.chartType === 'metric'));
46
+ setTables(flattened.filter((elem) => elem.chartType === 'table'));
47
+ setCharts(flattened.filter((elem) => !['metric', 'table'].includes(elem.chartType)));
41
48
  setLoading(false);
42
49
  }
43
50
  if (selectedDashboard && state.client) {
@@ -60,65 +67,173 @@ export default function ReorderDashboardModal({ isOpen, setIsOpen, client, onSav
60
67
  });
61
68
  setItemMap(itemMap);
62
69
  }, [dashboardItems]);
63
- const closeModal = () => {
64
- setIsOpen(false);
70
+ const handleSaveChanges = async () => {
71
+ if (!client)
72
+ return;
73
+ if (!dashboardItems.length)
74
+ return;
75
+ try {
76
+ const response = await fetch(`${QUILL_SERVER}/dashorder/`, {
77
+ method: 'POST',
78
+ headers: {
79
+ 'Content-Type': 'application/json',
80
+ },
81
+ body: JSON.stringify({
82
+ publicKey: client._id,
83
+ orderArray: [...metrics, ...charts, ...tables],
84
+ }),
85
+ });
86
+ if (!response.ok) {
87
+ const errorData = await response.json();
88
+ throw new Error(`Error: ${errorData.error || 'Unknown error'}`);
89
+ }
90
+ await response.json();
91
+ onSave();
92
+ setIsOpen(false);
93
+ }
94
+ catch (error) {
95
+ console.error('An unknown error occurred in ReorderDashboardModal');
96
+ console.error(error.message);
97
+ }
65
98
  };
66
- return (_jsx(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: _jsxs("div", { style: {
99
+ return (_jsxs(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), style: {
100
+ gap: 20,
101
+ display: 'flex',
102
+ flexDirection: 'column',
103
+ width: 'calc(100vw - 80px)',
104
+ height: 'calc(100vh - 80px)',
105
+ }, children: [_jsx("h1", { style: { fontSize: 22, fontWeight: 600, width: '100%' }, children: "Reorder Items" }), loading ? _jsx("div", { children: "Loading..." }) : null, _jsx("div", { style: {
106
+ display: 'flex',
107
+ flexDirection: 'column',
108
+ gap: 20,
109
+ overflowY: 'auto',
110
+ width: '100%',
111
+ height: 'calc(100% - 20px)',
112
+ zIndex: 100,
113
+ }, children: _jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 20 }, children: dashboardItems.length > 0 && itemMap.size > 0 && (_jsxs(_Fragment, { children: [doesDashboardHaveMetrics && (_jsx(ReorderableGrid, { type: 'metrics', items: metrics, setItems: setMetrics })), doesDashboardHaveCharts && (_jsx(ReorderableGrid, { type: 'charts', items: charts, setItems: setCharts })), doesDashboardHaveTables && (_jsx(ReorderableGrid, { type: 'tables', items: tables, setItems: setTables }))] })) }) }), _jsx("div", { style: {
114
+ width: '100%',
115
+ display: 'flex',
116
+ flexDirection: 'row',
117
+ justifyContent: 'right',
118
+ }, children: _jsx(ButtonComponent, { onClick: handleSaveChanges, label: "Save changes" }) })] }));
119
+ }
120
+ const SortableItem = (props) => {
121
+ const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: props.id });
122
+ const style = {
123
+ transform: CSS.Translate.toString(transform),
124
+ transition,
125
+ display: 'flex',
126
+ width: props.chartType === 'table' ? '100%' : '100%',
127
+ justifyContent: 'space-between',
128
+ alignItems: 'center',
129
+ borderRadius: '10px',
130
+ border: '1px solid #E7E7E7',
131
+ boxShadow: '0px 2px 8px 0px rgba(56, 65, 81, 0.08)',
132
+ cursor: 'grab',
133
+ userSelect: 'none',
134
+ background: 'white',
135
+ };
136
+ return (_jsx("div", { ref: setNodeRef, style: style, ...attributes, children: _jsx("div", { style: {
137
+ cursor: 'pointer',
138
+ width: '100%',
67
139
  display: 'flex',
68
- flexDirection: 'column',
69
- position: 'relative',
70
- minWidth: 700,
71
- maxWidth: 700,
72
- minHeight: 700,
73
- zIndex: 100,
74
- // overflowY: "scroll",
75
- }, children: [loading ? _jsx("div", { children: 'Loading...' }) : null, dashboardItems.length > 0 && itemMap.size > 0 && (_jsx(ReorderableList, { itemMap: itemMap, client: client, initialItems: dashboardItems.filter((elem) => chartType === 'chart'
76
- ? elem.chartType !== 'metric' && elem.chartType !== 'table'
77
- : elem.chartType === chartType), ButtonComponent: ButtonComponent, closeModal: closeModal, onSave: onSave })), _jsxs("div", { style: {
78
- height: 80,
79
- background: 'white',
80
- width: 700,
81
- position: 'absolute',
82
- top: -20,
83
- left: 0,
84
- right: 20,
85
- paddingTop: 20,
86
- display: 'flex',
87
- flexDirection: 'row',
88
- alignItems: 'center',
89
- justifyContent: 'space-between',
90
- }, children: [_jsx("h1", { style: { fontSize: 22, fontWeight: 600 }, children: "Reorder items" }), _jsxs("div", { style: {
91
- background: '#f7f7f7',
92
- borderRadius: 6,
93
- height: 32,
94
- display: 'flex',
95
- flexDirection: 'row',
96
- alignItems: 'center',
97
- paddingLeft: 4,
98
- paddingRight: 4,
99
- }, children: [doesDashboardHaveMetrics && (_jsx("button", { style: {
100
- background: chartType === 'metric' ? 'white' : undefined,
101
- color: chartType === 'metric' ? '#384151' : '#677389',
102
- fontWeight: chartType === 'metric' ? '600' : '500',
103
- borderRadius: 4,
104
- paddingLeft: 6,
105
- paddingRight: 6,
106
- fontSize: 16,
107
- }, onClick: () => setChartType('metric'), children: "Metrics" })), doesDashboardHaveCharts && (_jsx("button", { style: {
108
- background: chartType === 'chart' ? 'white' : undefined,
109
- color: chartType === 'chart' ? '#384151' : '#677389',
110
- fontWeight: chartType === 'chart' ? '600' : '500',
111
- borderRadius: 4,
112
- paddingLeft: 6,
113
- paddingRight: 6,
114
- fontSize: 16,
115
- }, onClick: () => setChartType('chart'), children: "Charts" })), doesDashboardHaveTables && (_jsx("button", { style: {
116
- background: chartType === 'table' ? 'white' : undefined,
117
- color: chartType === 'table' ? '#384151' : '#677389',
118
- fontWeight: chartType === 'table' ? '600' : '500',
119
- borderRadius: 4,
120
- paddingLeft: 6,
121
- paddingRight: 6,
122
- fontSize: 16,
123
- }, onClick: () => setChartType('table'), children: "Tables" }))] })] })] }) }));
140
+ flexDirection: 'row',
141
+ alignItems: 'center',
142
+ justifyContent: 'space-between',
143
+ }, ...listeners, children: _jsxs("div", { style: {
144
+ display: 'flex',
145
+ flexDirection: 'column',
146
+ justifyContent: 'space-between',
147
+ padding: 20,
148
+ width: '100%',
149
+ }, children: [_jsxs("div", { style: {
150
+ display: 'flex',
151
+ flexDirection: 'row',
152
+ paddingBottom: props.chartType === 'table' ? 10 : 0,
153
+ }, children: [_jsx("h1", { style: {
154
+ fontSize: 18,
155
+ fontWeight: '500',
156
+ flexGrow: 1,
157
+ }, children: props.value }), _jsx(HandleButton, {})] }), _jsx(Chart, { chartId: props.id, containerStyle: {
158
+ padding: 10,
159
+ height: props.chartType === 'metric' ? 80 : 250,
160
+ width: 'calc(100% - 20px)',
161
+ } })] }) }) }));
162
+ };
163
+ function ReorderableGrid({ type, items, setItems }) {
164
+ const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
165
+ coordinateGetter: sortableKeyboardCoordinates,
166
+ }), useSensor(TouchSensor, {
167
+ activationConstraint: '',
168
+ }));
169
+ const handleDragEnd = (event) => {
170
+ const { active, over } = event;
171
+ if (!active || !over)
172
+ return;
173
+ if (active.id !== over.id) {
174
+ setItems((itemList) => {
175
+ const oldIndex = itemList.findIndex((item) => item._id === active.id);
176
+ const newIndex = itemList.findIndex((item) => item._id === over.id);
177
+ return arrayMove(itemList, oldIndex, newIndex);
178
+ });
179
+ }
180
+ };
181
+ return (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: _jsx("div", { style: type === 'tables'
182
+ ? {
183
+ display: 'flex',
184
+ flexDirection: 'row',
185
+ flexWrap: 'wrap',
186
+ gap: 20,
187
+ }
188
+ : {
189
+ boxSizing: 'content-box',
190
+ width: '100%',
191
+ listStyleType: 'none',
192
+ display: 'grid',
193
+ gap: 20,
194
+ gridTemplateColumns: `repeat(auto-fill,minmax(400px, 1fr))`,
195
+ gridTemplateRows: `repeat(${170}px)`,
196
+ }, children: _jsx(SortableContext, { items: items.map((item) => item._id), strategy: rectSortingStrategy, children: items.map((item) => (_jsx(SortableItem, { handle: true, id: item._id, chartType: items.find((itm) => itm._id === item._id)?.chartType ?? 'chart', value: items.find((itm) => itm._id === item._id)?.name ?? item._id }, item._id))) }) }) }));
197
+ }
198
+ function HandleButton() {
199
+ return (_jsxs("div", { style: {
200
+ display: 'flex',
201
+ gap: 2,
202
+ flexDirection: 'row',
203
+ paddingTop: 8,
204
+ paddingBottom: 8,
205
+ paddingLeft: 8,
206
+ paddingRight: 8,
207
+ borderRadius: 4,
208
+ }, className: "handle", children: [_jsx("style", { children: `.handle{background:white;} .handle:hover{background:rgba(0,0,0,0.03);}` }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
209
+ width: 3,
210
+ height: 3,
211
+ borderRadius: 3,
212
+ background: '#9CA0A7',
213
+ } }), _jsx("div", { style: {
214
+ width: 3,
215
+ height: 3,
216
+ borderRadius: 3,
217
+ background: '#9CA0A7',
218
+ } }), _jsx("div", { style: {
219
+ width: 3,
220
+ height: 3,
221
+ borderRadius: 3,
222
+ background: '#9CA0A7',
223
+ } })] }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
224
+ width: 3,
225
+ height: 3,
226
+ borderRadius: 3,
227
+ background: '#9CA0A7',
228
+ } }), _jsx("div", { style: {
229
+ width: 3,
230
+ height: 3,
231
+ borderRadius: 3,
232
+ background: '#9CA0A7',
233
+ } }), _jsx("div", { style: {
234
+ width: 3,
235
+ height: 3,
236
+ borderRadius: 3,
237
+ background: '#9CA0A7',
238
+ } })] })] }));
124
239
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModalPrimitive.d.ts","sourceRoot":"","sources":["../../../src/primitives/ModalPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAE7D,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+DjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"ModalPrimitive.d.ts","sourceRoot":"","sources":["../../../src/primitives/ModalPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAE7D,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8DjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -32,8 +32,6 @@ const ModalPrimitive = ({ isOpen, close, children, style, theme = defaultTheme,
32
32
  maxHeight: '90vh',
33
33
  minWidth: 462,
34
34
  display: 'flex',
35
- justifyContent: 'center',
36
- alignItems: 'center',
37
35
  transform: 'translateX(-50%) translateY(-50%)',
38
36
  background: 'white',
39
37
  borderRadius: 8,
@@ -41,6 +39,7 @@ const ModalPrimitive = ({ isOpen, close, children, style, theme = defaultTheme,
41
39
  borderWidth: 1,
42
40
  borderColor: '#e7e7e7',
43
41
  padding: 30,
42
+ overflow: 'auto',
44
43
  ...style,
45
44
  }, children: children })] }));
46
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardBuilder.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,OAAO,CAAC;AAS5E,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,EACd,SAAgB,GACjB,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CA0TA"}
1
+ {"version":3,"file":"DashboardBuilder.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,OAAO,CAAC;AAa5E,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,EACd,SAAgB,GACjB,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CA8ZA"}
@@ -3,10 +3,12 @@ import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { useAdmin } from '../AdminProvider';
4
4
  import { convertPostgresColumn } from '../Admin';
5
5
  import { EnvSelectPopover, OrgSelect } from '../components';
6
- import { SQLEditor } from '@quillsql/react';
6
+ import { ReportBuilder, SQLEditor } from '@quillsql/react';
7
7
  import { QUILL_SERVER } from '../utils/constants';
8
8
  import Banner from '../components/Banner';
9
9
  import DatabaseMismatchCard from '../components/DatabaseMismatchCard';
10
+ import { ButtonPrimitive } from '../primitives';
11
+ const modeToggleOptions = ['SQL Editor', 'Report Builder'];
10
12
  export default function DashboardBuilder({ navigateToDashboardManager, containerStyle, sqlEditor = true, }) {
11
13
  const parentRef = useRef(null);
12
14
  const { state, dispatch } = useAdmin();
@@ -27,6 +29,7 @@ export default function DashboardBuilder({ navigateToDashboardManager, container
27
29
  const [fields, setFields] = useState([]);
28
30
  const [errorMessage, setErrorMessage] = useState('');
29
31
  const [sqlResponseLoading, setSqlResponseLoading] = useState(false);
32
+ const [toggleMode, setToggleMode] = useState('SQL Editor');
30
33
  useEffect(() => {
31
34
  if (state.activeQuery) {
32
35
  setIsEditActive(true);
@@ -164,18 +167,57 @@ export default function DashboardBuilder({ navigateToDashboardManager, container
164
167
  alignItems: 'flex-end',
165
168
  justifyContent: 'space-between',
166
169
  width: '100%',
167
- }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("h1", { style: {
168
- fontSize: '14px',
169
- paddingTop: '0px',
170
- marginTop: '0px',
171
- marginBottom: '4px',
172
- fontWeight: '600',
173
- color: state.theme.secondaryTextColor,
174
- fontFamily: state.theme.fontFamily,
175
- userSelect: 'none',
176
- }, children: "Environment" }), _jsx(EnvSelectPopover, { setEnvironment: (env) => {
177
- dispatch({ type: 'SET_ENVIRONMENT', payload: env });
178
- }, environment: state.environment, clients: state.clients, client: state.client, setClient: (client) => dispatch({ type: 'SET_CLIENT', payload: client }), theme: state.theme, showPromote: false })] }), !state.databaseTypeMismatch.show && (_jsx(OrgSelect, { environment: state.environment, setEnvironment: (env) => {
170
+ }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("h1", { style: {
171
+ fontSize: '14px',
172
+ paddingTop: '0px',
173
+ marginTop: '0px',
174
+ marginBottom: '4px',
175
+ fontWeight: '600',
176
+ color: state.theme.secondaryTextColor,
177
+ fontFamily: state.theme.fontFamily,
178
+ userSelect: 'none',
179
+ }, children: "Environment" }), _jsx(EnvSelectPopover, { setEnvironment: (env) => {
180
+ dispatch({ type: 'SET_ENVIRONMENT', payload: env });
181
+ }, environment: state.environment, clients: state.clients, client: state.client, setClient: (client) => dispatch({ type: 'SET_CLIENT', payload: client }), theme: state.theme, showPromote: false })] }), _jsx("div", { style: { display: 'flex', marginTop: 'auto', height: 38 }, children: _jsx("div", { style: {
182
+ display: 'flex',
183
+ flexDirection: 'row',
184
+ alignItems: 'center',
185
+ borderRadius: '0.25rem',
186
+ borderStyle: 'none',
187
+ outlineStyle: 'none',
188
+ background: '#F9FAFB',
189
+ paddingLeft: 3,
190
+ paddingRight: 3,
191
+ paddingTop: 4,
192
+ paddingBottom: 4,
193
+ }, children: modeToggleOptions.map((label) => (_jsx("button", { onClick: () => setToggleMode(label), style: {
194
+ borderRadius: '0.25rem',
195
+ borderWidth: '1px',
196
+ fontSize: '14px',
197
+ outlineStyle: 'none',
198
+ transitionProperty: 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform',
199
+ transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
200
+ transitionDuration: '300ms',
201
+ margin: '0px',
202
+ paddingTop: '0.375rem',
203
+ paddingBottom: '0.375rem',
204
+ paddingLeft: '0.75rem',
205
+ paddingRight: '0.75rem',
206
+ ...(label === toggleMode
207
+ ? {
208
+ fontWeight: 600,
209
+ backgroundColor: '#ffffff',
210
+ boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
211
+ color: '#212121',
212
+ borderColor: '#e7e7e7',
213
+ }
214
+ : {
215
+ borderColor: 'transparent',
216
+ fontWeight: 500,
217
+ backgroundColor: 'transparent',
218
+ color: '#606572',
219
+ }),
220
+ }, children: label }, label))) }) })] }), !state.databaseTypeMismatch.show && (_jsx(OrgSelect, { environment: state.environment, setEnvironment: (env) => {
179
221
  dispatch({ type: 'SET_ENVIRONMENT', payload: env });
180
222
  }, organizations: state.organizations, organizationId: state.organizationId, setOrganizationId: (orgId) => {
181
223
  dispatch({ type: 'SET_ORGANIZATION_ID', payload: orgId });
@@ -185,22 +227,42 @@ export default function DashboardBuilder({ navigateToDashboardManager, container
185
227
  return;
186
228
  dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
187
229
  dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
188
- } })), state.databaseTypeMismatch.show && (_jsx(DatabaseMismatchCard, { environemntName: state.client.name, environemntDatabaseType: state.client.databaseType, backendDatabaseType: state.databaseTypeMismatch.backendDatabaseType })), sqlEditor && !state.databaseTypeMismatch.show && (_jsx(SQLEditor, { chartBuilderEnabled: true, showAccessControlOptions: true, showDateFieldOptions: true, showTableFormatOptions: true, defaultQuery: query, isEditMode: !!state.activeQuery, addToDashboardButtonLabel: state.activeQuery ? 'Save changes' : 'Add to dashboard', chartBuilderTitle: state.activeQuery ? 'Save changes' : 'Add to dashboard', dashboardItem: state.activeQuery ? state.activeEditItem : undefined, onAddToDashboardComplete: () => {
189
- dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
190
- dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
191
- if (state.navigateToDashboardManager) {
192
- dispatch({
193
- type: 'SET_ACTIVE_COMPONENT',
194
- payload: 'Dashboards',
195
- });
196
- state.navigateToDashboardManager();
197
- }
198
- }, containerStyle: {
199
- height: 'calc(100% - 96px)',
200
- width: '100%',
201
- // paddingRight: 25,
202
- // paddingTop: 25,
203
- }, organizationName: state.organizations.find((org) => {
204
- return (org.id && String(org.id) === String(state.organizationId));
205
- })?.name }))] }) }));
230
+ } })), state.databaseTypeMismatch.show && (_jsx(DatabaseMismatchCard, { environemntName: state.client.name, environemntDatabaseType: state.client.databaseType, backendDatabaseType: state.databaseTypeMismatch.backendDatabaseType })), _jsx("div", { style: {
231
+ // Toggle the height of the container so they both stay in the DOM
232
+ // and don't refetch when switching back and forth.
233
+ height: toggleMode === 'Report Builder' ? '100%' : 0,
234
+ overflow: 'hidden',
235
+ }, children: _jsx(ReportBuilder, { admin: true, initialTableName: state.tables.length > 0 && state.tables[0].name, onAddToDashboardComplete: () => {
236
+ dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
237
+ dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
238
+ if (state.navigateToDashboardManager) {
239
+ dispatch({
240
+ type: 'SET_ACTIVE_COMPONENT',
241
+ payload: 'Dashboards',
242
+ });
243
+ state.navigateToDashboardManager();
244
+ }
245
+ }, organizationName: state.organizations.find((org) => {
246
+ return (org.id && String(org.id) === String(state.organizationId));
247
+ })?.name }) }), sqlEditor && !state.databaseTypeMismatch.show && (_jsx("div", { style: {
248
+ height: toggleMode === 'SQL Editor' ? '100%' : 0,
249
+ overflow: 'hidden',
250
+ }, children: _jsx(SQLEditor, { chartBuilderEnabled: true, showAccessControlOptions: true, showDateFieldOptions: true, showTableFormatOptions: true, defaultQuery: query, isEditMode: !!state.activeQuery, addToDashboardButtonLabel: state.activeQuery ? 'Save changes' : 'Add to dashboard', chartBuilderTitle: state.activeQuery ? 'Save changes' : 'Add to dashboard', dashboardItem: state.activeQuery ? state.activeEditItem : undefined, onAddToDashboardComplete: () => {
251
+ dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
252
+ dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
253
+ if (state.navigateToDashboardManager) {
254
+ dispatch({
255
+ type: 'SET_ACTIVE_COMPONENT',
256
+ payload: 'Dashboards',
257
+ });
258
+ state.navigateToDashboardManager();
259
+ }
260
+ }, containerStyle: {
261
+ height: '100%',
262
+ width: '100%',
263
+ // paddingRight: 25,
264
+ // paddingTop: 25,
265
+ }, organizationName: state.organizations.find((org) => {
266
+ return (org.id && String(org.id) === String(state.organizationId));
267
+ })?.name, ButtonComponent: ButtonPrimitive }) }))] }) }));
206
268
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardManager.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;AAgCnE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,GACf,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC,2CAkkBA"}
1
+ {"version":3,"file":"DashboardManager.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;AAiCnE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,GACf,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC,2CAukBA"}