@finos/legend-query-builder 4.14.19 → 4.14.21
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/QueryLoader.d.ts.map +1 -1
- package/lib/components/QueryLoader.js +85 -36
- package/lib/components/QueryLoader.js.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js +3 -2
- package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
- package/lib/index.css +1 -17
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +7 -4
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +20 -4
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderState.d.ts +4 -2
- package/lib/stores/QueryBuilderState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderState.js +13 -2
- package/lib/stores/QueryBuilderState.js.map +1 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +19 -1
- package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
- package/lib/stores/QueryLoaderState.d.ts +14 -4
- package/lib/stores/QueryLoaderState.d.ts.map +1 -1
- package/lib/stores/QueryLoaderState.js +35 -5
- package/lib/stores/QueryLoaderState.js.map +1 -1
- package/package.json +3 -3
- package/src/components/QueryLoader.tsx +279 -127
- package/src/components/result/QueryBuilderResultPanel.tsx +0 -1
- package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +3 -2
- package/src/stores/QueryBuilderResultState.ts +27 -7
- package/src/stores/QueryBuilderState.ts +19 -2
- package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +30 -1
- package/src/stores/QueryLoaderState.ts +64 -12
@@ -38,8 +38,11 @@ export class QueryLoaderState {
|
|
38
38
|
showCurrentUserQueriesOnly = false; // TODO: if we start having more native filters, we should make them part of `extraFilters`
|
39
39
|
extraFilters = new Map();
|
40
40
|
extraFilterOptions = [];
|
41
|
+
extraQueryFilterOptionsRelatedToTemplateQuery = [];
|
41
42
|
queries = [];
|
43
|
+
curatedTemplateQuerySepcifications = [];
|
42
44
|
isQueryLoaderDialogOpen = false;
|
45
|
+
isCuratedTemplateToggled = false;
|
43
46
|
showingDefaultQueries = true;
|
44
47
|
showPreviewViewer = false;
|
45
48
|
queryPreviewContent;
|
@@ -52,11 +55,14 @@ export class QueryLoaderState {
|
|
52
55
|
showCurrentUserQueriesOnly: observable,
|
53
56
|
showPreviewViewer: observable,
|
54
57
|
searchText: observable,
|
58
|
+
isCuratedTemplateToggled: observable,
|
59
|
+
curatedTemplateQuerySepcifications: observable,
|
55
60
|
setSearchText: action,
|
56
61
|
setQueryLoaderDialogOpen: action,
|
57
62
|
setQueries: action,
|
58
63
|
setShowCurrentUserQueriesOnly: action,
|
59
64
|
setShowPreviewViewer: action,
|
65
|
+
setIsCuratedTemplateToggled: action,
|
60
66
|
searchQueries: flow,
|
61
67
|
getPreviewQueryContent: flow,
|
62
68
|
deleteQuery: flow,
|
@@ -76,6 +82,9 @@ export class QueryLoaderState {
|
|
76
82
|
this.handleFetchDefaultQueriesFailure =
|
77
83
|
options.handleFetchDefaultQueriesFailure;
|
78
84
|
}
|
85
|
+
setIsCuratedTemplateToggled(val) {
|
86
|
+
this.isCuratedTemplateToggled = val;
|
87
|
+
}
|
79
88
|
setSearchText(val) {
|
80
89
|
this.searchText = val;
|
81
90
|
}
|
@@ -93,14 +102,25 @@ export class QueryLoaderState {
|
|
93
102
|
}
|
94
103
|
reset() {
|
95
104
|
this.setShowCurrentUserQueriesOnly(false);
|
105
|
+
this.setIsCuratedTemplateToggled(false);
|
96
106
|
}
|
97
107
|
*initialize(queryBuilderState) {
|
98
108
|
this.queryBuilderState = queryBuilderState;
|
99
109
|
this.extraFilterOptions = this.applicationStore.pluginManager
|
100
110
|
.getApplicationPlugins()
|
101
111
|
.flatMap((plugin) => plugin.getExtraLoadQueryFilterOptions?.() ?? []);
|
112
|
+
this.extraQueryFilterOptionsRelatedToTemplateQuery =
|
113
|
+
this.applicationStore.pluginManager
|
114
|
+
.getApplicationPlugins()
|
115
|
+
.flatMap((plugin) => plugin
|
116
|
+
.getQueryFilterOptionsRelatedToTemplateQuery?.()(guaranteeNonNullable(this.queryBuilderState))
|
117
|
+
.flat() ?? []);
|
102
118
|
const extraFilters = this.extraFilterOptions.map((filterOption) => filterOption.label(guaranteeNonNullable(this.queryBuilderState)));
|
103
119
|
extraFilters.forEach((filter) => filter && this.extraFilters.set(filter, false));
|
120
|
+
this.curatedTemplateQuerySepcifications =
|
121
|
+
this.applicationStore.pluginManager
|
122
|
+
.getApplicationPlugins()
|
123
|
+
.flatMap((plugin) => plugin.getCuratedTemplateQuerySpecifications?.() ?? []);
|
104
124
|
}
|
105
125
|
*searchQueries(searchText) {
|
106
126
|
if (searchText.length < DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH &&
|
@@ -189,13 +209,23 @@ export class QueryLoaderState {
|
|
189
209
|
this.deleteQueryState.fail();
|
190
210
|
}
|
191
211
|
}
|
192
|
-
*getPreviewQueryContent(queryId) {
|
212
|
+
*getPreviewQueryContent(queryId, template) {
|
193
213
|
this.previewQueryState.inProgress();
|
194
214
|
try {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
215
|
+
if (queryId) {
|
216
|
+
const queryInfo = (yield this.graphManagerState.graphManager.getQueryInfo(queryId));
|
217
|
+
this.queryPreviewContent = queryInfo;
|
218
|
+
this.queryPreviewContent.content =
|
219
|
+
(yield this.graphManagerState.graphManager.prettyLambdaContent(queryInfo.content));
|
220
|
+
}
|
221
|
+
else if (template) {
|
222
|
+
this.queryPreviewContent = {
|
223
|
+
name: template.queryName,
|
224
|
+
content: '',
|
225
|
+
};
|
226
|
+
this.queryPreviewContent.content =
|
227
|
+
(yield this.graphManagerState.graphManager.lambdaToPureCode(template.queryContent, true));
|
228
|
+
}
|
199
229
|
this.previewQueryState.pass();
|
200
230
|
}
|
201
231
|
catch (error) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"QueryLoaderState.js","sourceRoot":"","sources":["../../src/stores/QueryLoaderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,8CAA8C,GAE/C,MAAM,2BAA2B,CAAC;AACnC,OAAO,
|
1
|
+
{"version":3,"file":"QueryLoaderState.js","sourceRoot":"","sources":["../../src/stores/QueryLoaderState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,8CAA8C,GAE/C,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GAMpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQhE,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,CAAC;AAEtD,MAAM,OAAO,gBAAgB;IAClB,gBAAgB,CAAgC;IAChD,iBAAiB,CAAyB;IAE1C,kBAAkB,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IAC1C,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IACxC,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IACxC,iBAAiB,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IAEzC,2BAA2B,CAEtB;IAEL,SAAS,CAA8B;IACvC,mBAAmB,CAA6C;IAChE,iCAAiC,CAE5B;IAEL,UAAU,CAAuB;IACjC,cAAc,CAA6C;IAC3D,cAAc,CAA6C;IAC3D,gCAAgC,CAA4B;IAEr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BAAmB,CAC5D,SAAS,CAAC,OAAO,CAClB,CAAW,CAAC;aAChB;iBAAM,IAAI,QAAQ,EAAE;gBACnB,IAAI,CAAC,mBAAmB,GAAG;oBACzB,IAAI,EAAE,QAAQ,CAAC,SAAS;oBACxB,OAAO,EAAE,EAAE;iBACC,CAAC;gBACf,IAAI,CAAC,mBAAmB,CAAC,OAAO;oBAC9B,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,gBAAgB,CACzD,QAAQ,CAAC,YAAY,EACrB,IAAI,CACL,CAAW,CAAC;aAChB;YACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;SAC/B;QAAC,OAAO,KAAK,EAAE;YACd,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC7D,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;SAC/B;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@finos/legend-query-builder",
|
3
|
-
"version": "4.14.
|
3
|
+
"version": "4.14.21",
|
4
4
|
"description": "Legend query builder core",
|
5
5
|
"keywords": [
|
6
6
|
"legend",
|
@@ -44,8 +44,8 @@
|
|
44
44
|
"dependencies": {
|
45
45
|
"@finos/legend-application": "15.0.73",
|
46
46
|
"@finos/legend-art": "7.1.25",
|
47
|
-
"@finos/legend-graph": "31.9.
|
48
|
-
"@finos/legend-lego": "1.2.
|
47
|
+
"@finos/legend-graph": "31.9.7",
|
48
|
+
"@finos/legend-lego": "1.2.20",
|
49
49
|
"@finos/legend-server-depot": "6.0.38",
|
50
50
|
"@finos/legend-shared": "10.0.34",
|
51
51
|
"@finos/legend-storage": "3.0.84",
|
@@ -41,11 +41,12 @@ import {
|
|
41
41
|
ThinChevronRightIcon,
|
42
42
|
InfoCircleIcon,
|
43
43
|
} from '@finos/legend-art';
|
44
|
-
import type { LightQuery } from '@finos/legend-graph';
|
44
|
+
import type { LightQuery, RawLambda } from '@finos/legend-graph';
|
45
45
|
import {
|
46
46
|
debounce,
|
47
47
|
formatDistanceToNow,
|
48
48
|
guaranteeNonNullable,
|
49
|
+
isNonNullable,
|
49
50
|
quantifyList,
|
50
51
|
} from '@finos/legend-shared';
|
51
52
|
import { flowResult } from 'mobx';
|
@@ -110,6 +111,21 @@ export const QueryLoader = observer(
|
|
110
111
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
111
112
|
const queryRenameInputRef = useRef<HTMLInputElement>(null);
|
112
113
|
const results = queryLoaderState.queries;
|
114
|
+
const curatedTemplateQueries =
|
115
|
+
queryLoaderState.curatedTemplateQuerySepcifications
|
116
|
+
.map((s) =>
|
117
|
+
queryLoaderState.queryBuilderState
|
118
|
+
? s.getCuratedTemplateQueries(queryLoaderState.queryBuilderState)
|
119
|
+
: [],
|
120
|
+
)
|
121
|
+
.flat();
|
122
|
+
const loadCuratedTemplateQuery =
|
123
|
+
queryLoaderState.curatedTemplateQuerySepcifications
|
124
|
+
// already using an arrow function suggested by @typescript-eslint/unbound-method
|
125
|
+
// eslint-disable-next-line
|
126
|
+
.map((s) => () => s.loadCuratedTemplateQuery)
|
127
|
+
.filter(isNonNullable)[0];
|
128
|
+
|
113
129
|
const [isMineOnly, setIsMineOnly] = useState(false);
|
114
130
|
const [showQueryNameEditInput, setShowQueryNameEditInput] = useState<
|
115
131
|
number | undefined
|
@@ -173,7 +189,25 @@ export const QueryLoader = observer(
|
|
173
189
|
debouncedLoadQueries.cancel();
|
174
190
|
debouncedLoadQueries(queryLoaderState.searchText);
|
175
191
|
};
|
176
|
-
|
192
|
+
const toggleCuratedTemplate = (): void => {
|
193
|
+
Array.from(queryLoaderState.extraFilters).map(([key, value]) =>
|
194
|
+
queryLoaderState.extraFilters.set(key, false),
|
195
|
+
);
|
196
|
+
queryLoaderState.setShowCurrentUserQueriesOnly(false);
|
197
|
+
setIsMineOnly(false);
|
198
|
+
queryLoaderState.extraQueryFilterOptionsRelatedToTemplateQuery.forEach(
|
199
|
+
(op) =>
|
200
|
+
queryLoaderState.extraFilters.set(
|
201
|
+
op,
|
202
|
+
!queryLoaderState.isCuratedTemplateToggled,
|
203
|
+
),
|
204
|
+
);
|
205
|
+
queryLoaderState.showingDefaultQueries =
|
206
|
+
queryLoaderState.isCuratedTemplateToggled;
|
207
|
+
queryLoaderState.setIsCuratedTemplateToggled(
|
208
|
+
!queryLoaderState.isCuratedTemplateToggled,
|
209
|
+
);
|
210
|
+
};
|
177
211
|
useEffect(() => {
|
178
212
|
flowResult(queryLoaderState.searchQueries('')).catch(
|
179
213
|
applicationStore.alertUnhandledError,
|
@@ -207,10 +241,16 @@ export const QueryLoader = observer(
|
|
207
241
|
}
|
208
242
|
};
|
209
243
|
|
210
|
-
const showPreview = (
|
211
|
-
|
212
|
-
|
213
|
-
|
244
|
+
const showPreview = (
|
245
|
+
queryId: string | undefined,
|
246
|
+
template?: {
|
247
|
+
queryName: string;
|
248
|
+
queryContent: RawLambda;
|
249
|
+
},
|
250
|
+
): void => {
|
251
|
+
flowResult(
|
252
|
+
queryLoaderState.getPreviewQueryContent(queryId, template),
|
253
|
+
).catch(applicationStore.alertUnhandledError);
|
214
254
|
queryLoaderState.setShowPreviewViewer(true);
|
215
255
|
};
|
216
256
|
|
@@ -254,6 +294,12 @@ export const QueryLoader = observer(
|
|
254
294
|
'query-loader__filter__toggler__btn--toggled': isMineOnly,
|
255
295
|
})}
|
256
296
|
onClick={toggleShowCurrentUserQueriesOnly}
|
297
|
+
disabled={queryLoaderState.isCuratedTemplateToggled}
|
298
|
+
title={
|
299
|
+
queryLoaderState.isCuratedTemplateToggled
|
300
|
+
? 'current fitler is disabled when `Curated Template Query` is on'
|
301
|
+
: 'click to add filter'
|
302
|
+
}
|
257
303
|
tabIndex={-1}
|
258
304
|
>
|
259
305
|
Mine Only
|
@@ -267,6 +313,12 @@ export const QueryLoader = observer(
|
|
267
313
|
className={clsx('query-loader__filter__toggler__btn', {
|
268
314
|
'query-loader__filter__toggler__btn--toggled': value,
|
269
315
|
})}
|
316
|
+
disabled={queryLoaderState.isCuratedTemplateToggled}
|
317
|
+
title={
|
318
|
+
queryLoaderState.isCuratedTemplateToggled
|
319
|
+
? 'current fitler is disabled when `Curated Template Query` is on'
|
320
|
+
: 'click to add filter'
|
321
|
+
}
|
270
322
|
onClick={(): void => toggleExtraFilters(key)}
|
271
323
|
tabIndex={-1}
|
272
324
|
>
|
@@ -276,6 +328,21 @@ export const QueryLoader = observer(
|
|
276
328
|
)}
|
277
329
|
</div>
|
278
330
|
)}
|
331
|
+
{queryLoaderState.extraQueryFilterOptionsRelatedToTemplateQuery
|
332
|
+
.length > 0 && (
|
333
|
+
<div className="query-loader__filter__extra__filters">
|
334
|
+
<button
|
335
|
+
className={clsx('query-loader__filter__toggler__btn', {
|
336
|
+
'query-loader__filter__toggler__btn--toggled':
|
337
|
+
queryLoaderState.isCuratedTemplateToggled,
|
338
|
+
})}
|
339
|
+
onClick={toggleCuratedTemplate}
|
340
|
+
tabIndex={-1}
|
341
|
+
>
|
342
|
+
Curated Template Query
|
343
|
+
</button>
|
344
|
+
</div>
|
345
|
+
)}
|
279
346
|
</div>
|
280
347
|
</div>
|
281
348
|
</div>
|
@@ -297,7 +364,20 @@ export const QueryLoader = observer(
|
|
297
364
|
queryLoaderState.generateDefaultQueriesSummaryText?.(
|
298
365
|
results,
|
299
366
|
) ?? 'Refine your search to get better matches'
|
300
|
-
) :
|
367
|
+
) : !queryLoaderState.isCuratedTemplateToggled ? (
|
368
|
+
results.length >= QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT ? (
|
369
|
+
<>
|
370
|
+
{`Found ${QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT}+ matches`}{' '}
|
371
|
+
<InfoCircleIcon
|
372
|
+
title="Some queries are not listed, refine your search to get better matches"
|
373
|
+
className="query-loader__results__summary__info"
|
374
|
+
/>
|
375
|
+
</>
|
376
|
+
) : (
|
377
|
+
`Found ${quantifyList(results, 'match', 'matches')}`
|
378
|
+
)
|
379
|
+
) : curatedTemplateQueries.length >=
|
380
|
+
QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT ? (
|
301
381
|
<>
|
302
382
|
{`Found ${QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT}+ matches`}{' '}
|
303
383
|
<InfoCircleIcon
|
@@ -306,139 +386,211 @@ export const QueryLoader = observer(
|
|
306
386
|
/>
|
307
387
|
</>
|
308
388
|
) : (
|
309
|
-
`Found ${quantifyList(
|
389
|
+
`Found ${quantifyList(
|
390
|
+
curatedTemplateQueries,
|
391
|
+
'match',
|
392
|
+
'matches',
|
393
|
+
)}`
|
310
394
|
)}
|
311
395
|
</div>
|
312
|
-
{
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
<
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
event.
|
333
|
-
|
334
|
-
|
335
|
-
event.
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
396
|
+
{!queryLoaderState.isCuratedTemplateToggled &&
|
397
|
+
results
|
398
|
+
.slice(0, QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT)
|
399
|
+
.map((query, idx) => (
|
400
|
+
<div
|
401
|
+
className="query-loader__result"
|
402
|
+
title={`Click to ${loadActionLabel}...`}
|
403
|
+
key={query.id}
|
404
|
+
onClick={() => queryLoaderState.loadQuery(query)}
|
405
|
+
>
|
406
|
+
<div className="query-loader__result__content">
|
407
|
+
{showQueryNameEditInput === idx ? (
|
408
|
+
<div className="query-loader__result__title__editor">
|
409
|
+
<input
|
410
|
+
className="query-loader__result__title__editor__input input--dark"
|
411
|
+
spellCheck={false}
|
412
|
+
ref={queryRenameInputRef}
|
413
|
+
value={queryNameInputValue}
|
414
|
+
onChange={changeQueryNameInputValue}
|
415
|
+
onKeyDown={(event) => {
|
416
|
+
if (event.code === 'Enter') {
|
417
|
+
event.stopPropagation();
|
418
|
+
renameQuery(query)();
|
419
|
+
} else if (event.code === 'Escape') {
|
420
|
+
event.stopPropagation();
|
421
|
+
hideEditQueryNameInput();
|
422
|
+
}
|
423
|
+
}}
|
424
|
+
onBlur={() => hideEditQueryNameInput()}
|
425
|
+
// avoid clicking on the input causing the call to load query
|
426
|
+
onClick={(event) => event.stopPropagation()}
|
427
|
+
/>
|
428
|
+
</div>
|
429
|
+
) : (
|
430
|
+
<div
|
431
|
+
className="query-loader__result__title"
|
432
|
+
title={query.name}
|
433
|
+
>
|
434
|
+
{query.name}
|
435
|
+
</div>
|
436
|
+
)}
|
437
|
+
<div className="query-loader__result__description">
|
438
|
+
<div className="query-loader__result__description__date__icon">
|
439
|
+
<LastModifiedIcon />
|
440
|
+
</div>
|
441
|
+
<div className="query-loader__result__description__date">
|
442
|
+
{query.lastUpdatedAt
|
443
|
+
? formatDistanceToNow(
|
444
|
+
new Date(query.lastUpdatedAt),
|
445
|
+
{
|
446
|
+
includeSeconds: true,
|
447
|
+
addSuffix: true,
|
448
|
+
},
|
449
|
+
)
|
450
|
+
: '(unknown)'}
|
451
|
+
</div>
|
452
|
+
<div
|
453
|
+
className={clsx(
|
454
|
+
'query-loader__result__description__author__icon',
|
455
|
+
{
|
456
|
+
'query-loader__result__description__author__icon--owner':
|
457
|
+
query.isCurrentUserQuery,
|
458
|
+
},
|
459
|
+
)}
|
460
|
+
>
|
461
|
+
<UserIcon />
|
462
|
+
</div>
|
463
|
+
<div className="query-loader__result__description__author__name">
|
464
|
+
{query.isCurrentUserQuery ? (
|
465
|
+
<div
|
466
|
+
title={query.owner}
|
467
|
+
className="query-loader__result__description__owner"
|
468
|
+
>
|
469
|
+
Me
|
470
|
+
</div>
|
471
|
+
) : (
|
472
|
+
query.owner
|
473
|
+
)}
|
474
|
+
</div>
|
343
475
|
</div>
|
344
|
-
|
476
|
+
</div>
|
477
|
+
<DropdownMenu
|
478
|
+
className="query-loader__result__actions-menu"
|
479
|
+
title="More Actions..."
|
480
|
+
content={
|
481
|
+
<MenuContent>
|
482
|
+
<MenuContentItem
|
483
|
+
onClick={(): void => showPreview(query.id)}
|
484
|
+
>
|
485
|
+
Show Query Preview
|
486
|
+
</MenuContentItem>
|
487
|
+
{!queryLoaderState.isReadOnly && (
|
488
|
+
<MenuContentItem
|
489
|
+
disabled={!query.isCurrentUserQuery}
|
490
|
+
onClick={deleteQuery(query)}
|
491
|
+
>
|
492
|
+
Delete
|
493
|
+
</MenuContentItem>
|
494
|
+
)}
|
495
|
+
{!queryLoaderState.isReadOnly && (
|
496
|
+
<MenuContentItem
|
497
|
+
disabled={!query.isCurrentUserQuery}
|
498
|
+
onClick={showEditQueryNameInput(
|
499
|
+
query.name,
|
500
|
+
idx,
|
501
|
+
)}
|
502
|
+
>
|
503
|
+
Rename
|
504
|
+
</MenuContentItem>
|
505
|
+
)}
|
506
|
+
</MenuContent>
|
507
|
+
}
|
508
|
+
menuProps={{
|
509
|
+
anchorOrigin: {
|
510
|
+
vertical: 'bottom',
|
511
|
+
horizontal: 'left',
|
512
|
+
},
|
513
|
+
transformOrigin: {
|
514
|
+
vertical: 'top',
|
515
|
+
horizontal: 'left',
|
516
|
+
},
|
517
|
+
elevation: 7,
|
518
|
+
}}
|
519
|
+
>
|
520
|
+
<MoreVerticalIcon />
|
521
|
+
</DropdownMenu>
|
522
|
+
<div className="query-loader__result__arrow">
|
523
|
+
<ThinChevronRightIcon />
|
524
|
+
</div>
|
525
|
+
</div>
|
526
|
+
))}
|
527
|
+
{queryLoaderState.queryBuilderState &&
|
528
|
+
queryLoaderState.isCuratedTemplateToggled &&
|
529
|
+
loadCuratedTemplateQuery &&
|
530
|
+
curatedTemplateQueries
|
531
|
+
.slice(0, QUERY_LOADER_TYPEAHEAD_SEARCH_LIMIT)
|
532
|
+
.map((templateQuery, idx) => (
|
533
|
+
<div
|
534
|
+
className="query-loader__result"
|
535
|
+
title={`Click to ${loadActionLabel}...`}
|
536
|
+
key={templateQuery.title}
|
537
|
+
onClick={() => {
|
538
|
+
loadCuratedTemplateQuery()(
|
539
|
+
templateQuery,
|
540
|
+
guaranteeNonNullable(
|
541
|
+
queryLoaderState.queryBuilderState,
|
542
|
+
),
|
543
|
+
);
|
544
|
+
queryLoaderState.setQueryLoaderDialogOpen(false);
|
545
|
+
}}
|
546
|
+
>
|
547
|
+
<div className="query-loader__result__content">
|
345
548
|
<div
|
346
549
|
className="query-loader__result__title"
|
347
|
-
title={
|
348
|
-
>
|
349
|
-
{query.name}
|
350
|
-
</div>
|
351
|
-
)}
|
352
|
-
<div className="query-loader__result__description">
|
353
|
-
<div className="query-loader__result__description__date__icon">
|
354
|
-
<LastModifiedIcon />
|
355
|
-
</div>
|
356
|
-
<div className="query-loader__result__description__date">
|
357
|
-
{query.lastUpdatedAt
|
358
|
-
? formatDistanceToNow(
|
359
|
-
new Date(query.lastUpdatedAt),
|
360
|
-
{
|
361
|
-
includeSeconds: true,
|
362
|
-
addSuffix: true,
|
363
|
-
},
|
364
|
-
)
|
365
|
-
: '(unknown)'}
|
366
|
-
</div>
|
367
|
-
<div
|
368
|
-
className={clsx(
|
369
|
-
'query-loader__result__description__author__icon',
|
370
|
-
{
|
371
|
-
'query-loader__result__description__author__icon--owner':
|
372
|
-
query.isCurrentUserQuery,
|
373
|
-
},
|
374
|
-
)}
|
550
|
+
title={templateQuery.title}
|
375
551
|
>
|
376
|
-
|
552
|
+
{templateQuery.title}
|
377
553
|
</div>
|
378
|
-
<div className="query-
|
379
|
-
{
|
380
|
-
<div
|
381
|
-
title={query.owner}
|
382
|
-
className="query-loader__result__description__owner"
|
383
|
-
>
|
384
|
-
Me
|
385
|
-
</div>
|
386
|
-
) : (
|
387
|
-
query.owner
|
388
|
-
)}
|
554
|
+
<div className="query-loader__result__description">
|
555
|
+
{templateQuery.description}
|
389
556
|
</div>
|
390
557
|
</div>
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
<MenuContent>
|
397
|
-
<MenuContentItem
|
398
|
-
onClick={(): void => showPreview(query.id)}
|
399
|
-
>
|
400
|
-
Show Query Preview
|
401
|
-
</MenuContentItem>
|
402
|
-
{!queryLoaderState.isReadOnly && (
|
403
|
-
<MenuContentItem
|
404
|
-
disabled={!query.isCurrentUserQuery}
|
405
|
-
onClick={deleteQuery(query)}
|
406
|
-
>
|
407
|
-
Delete
|
408
|
-
</MenuContentItem>
|
409
|
-
)}
|
410
|
-
{!queryLoaderState.isReadOnly && (
|
558
|
+
<DropdownMenu
|
559
|
+
className="query-loader__result__actions-menu"
|
560
|
+
title="More Actions..."
|
561
|
+
content={
|
562
|
+
<MenuContent>
|
411
563
|
<MenuContentItem
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
564
|
+
onClick={(): void =>
|
565
|
+
showPreview(undefined, {
|
566
|
+
queryContent: templateQuery.query,
|
567
|
+
queryName: templateQuery.title,
|
568
|
+
})
|
569
|
+
}
|
417
570
|
>
|
418
|
-
|
571
|
+
Show Query Preview
|
419
572
|
</MenuContentItem>
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
573
|
+
</MenuContent>
|
574
|
+
}
|
575
|
+
menuProps={{
|
576
|
+
anchorOrigin: {
|
577
|
+
vertical: 'bottom',
|
578
|
+
horizontal: 'left',
|
579
|
+
},
|
580
|
+
transformOrigin: {
|
581
|
+
vertical: 'top',
|
582
|
+
horizontal: 'left',
|
583
|
+
},
|
584
|
+
elevation: 7,
|
585
|
+
}}
|
586
|
+
>
|
587
|
+
<MoreVerticalIcon />
|
588
|
+
</DropdownMenu>
|
589
|
+
<div className="query-loader__result__arrow">
|
590
|
+
<ThinChevronRightIcon />
|
591
|
+
</div>
|
439
592
|
</div>
|
440
|
-
|
441
|
-
))}
|
593
|
+
))}
|
442
594
|
</>
|
443
595
|
)}
|
444
596
|
{!queryLoaderState.searchQueriesState.hasCompleted && (
|