@finos/legend-query-builder 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/lib/components/QueryBuilder.d.ts +1 -0
  2. package/lib/components/QueryBuilder.d.ts.map +1 -1
  3. package/lib/components/QueryBuilderDiffPanel.d.ts +1 -0
  4. package/lib/components/QueryBuilderDiffPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderParametersPanel.d.ts +1 -0
  6. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  7. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts +1 -0
  8. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  9. package/lib/components/QueryBuilderResultPanel.d.ts +1 -0
  10. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderResultPanel.js +2 -2
  12. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderSideBar.d.ts +1 -0
  14. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  15. package/lib/components/QueryBuilderTextEditor.d.ts +1 -0
  16. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  17. package/lib/components/QueryBuilderUnsupportedQueryEditor.d.ts +1 -0
  18. package/lib/components/QueryBuilderUnsupportedQueryEditor.d.ts.map +1 -1
  19. package/lib/components/QueryBuilderUnsupportedQueryEditor.js +2 -2
  20. package/lib/components/QueryBuilderUnsupportedQueryEditor.js.map +1 -1
  21. package/lib/components/QuerySetupUtils.d.ts +22 -0
  22. package/lib/components/QuerySetupUtils.d.ts.map +1 -0
  23. package/lib/components/QuerySetupUtils.js +20 -0
  24. package/lib/components/QuerySetupUtils.js.map +1 -0
  25. package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.d.ts +1 -0
  26. package/lib/components/explorer/QueryBuilderFunctionsExplorerPanel.d.ts.map +1 -1
  27. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts +1 -0
  28. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  29. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts +1 -0
  30. package/lib/components/explorer/QueryBuilderPropertySearchPanel.d.ts.map +1 -1
  31. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts +1 -0
  32. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.d.ts.map +1 -1
  33. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js +3 -3
  34. package/lib/components/fetch-structure/QueryBuilderFetchStructurePanel.js.map +1 -1
  35. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts +1 -0
  36. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  37. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts +1 -0
  38. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  39. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +3 -3
  40. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  41. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.d.ts +1 -0
  42. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.d.ts.map +1 -1
  43. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.js +2 -2
  44. package/lib/components/fetch-structure/QueryBuilderProjectionPanel.js.map +1 -1
  45. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts +1 -0
  46. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  47. package/lib/components/filter/QueryBuilderFilterPanel.d.ts +1 -0
  48. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  49. package/lib/components/filter/QueryBuilderFilterPanel.js +2 -2
  50. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  51. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts +1 -0
  52. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts.map +1 -1
  53. package/lib/index.css +1 -1
  54. package/lib/index.d.ts +1 -0
  55. package/lib/index.d.ts.map +1 -1
  56. package/lib/index.js +1 -0
  57. package/lib/index.js.map +1 -1
  58. package/lib/package.json +6 -6
  59. package/lib/stores/QueryBuilderChangeDetectionState.d.ts +1 -0
  60. package/lib/stores/QueryBuilderChangeDetectionState.d.ts.map +1 -1
  61. package/lib/stores/QueryBuilderChangeDetectionState.js +24 -0
  62. package/lib/stores/QueryBuilderChangeDetectionState.js.map +1 -1
  63. package/lib/stores/QueryBuilderParametersState.d.ts +1 -1
  64. package/lib/stores/QueryBuilderParametersState.d.ts.map +1 -1
  65. package/lib/stores/QueryBuilderParametersState.js +1 -1
  66. package/lib/stores/QueryBuilderParametersState.js.map +1 -1
  67. package/lib/stores/QueryBuilderTypeaheadHelper.d.ts.map +1 -1
  68. package/lib/stores/QueryBuilderTypeaheadHelper.js +3 -4
  69. package/lib/stores/QueryBuilderTypeaheadHelper.js.map +1 -1
  70. package/package.json +13 -13
  71. package/src/components/QueryBuilderResultPanel.tsx +3 -2
  72. package/src/components/QueryBuilderUnsupportedQueryEditor.tsx +8 -9
  73. package/src/components/QuerySetupUtils.ts +23 -0
  74. package/src/components/fetch-structure/QueryBuilderFetchStructurePanel.tsx +10 -5
  75. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +5 -4
  76. package/src/components/fetch-structure/QueryBuilderProjectionPanel.tsx +3 -2
  77. package/src/components/filter/QueryBuilderFilterPanel.tsx +3 -2
  78. package/src/index.ts +1 -0
  79. package/src/stores/QueryBuilderChangeDetectionState.ts +31 -0
  80. package/src/stores/QueryBuilderParametersState.ts +3 -1
  81. package/src/stores/QueryBuilderTypeaheadHelper.ts +6 -5
  82. package/tsconfig.json +1 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { LightQuery } from '@finos/legend-graph';
18
+
19
+ export type QueryOption = { label: string; value: LightQuery };
20
+ export const buildQueryOption = (query: LightQuery): QueryOption => ({
21
+ label: query.name,
22
+ value: query,
23
+ });
@@ -15,7 +15,12 @@
15
15
  */
16
16
 
17
17
  import { observer } from 'mobx-react-lite';
18
- import { clsx, BlankPanelContent } from '@finos/legend-art';
18
+ import {
19
+ clsx,
20
+ BlankPanelContent,
21
+ Panel,
22
+ PanelContent,
23
+ } from '@finos/legend-art';
19
24
  import type { QueryBuilderState } from '../../stores/QueryBuilderState.js';
20
25
  import { prettyCONSTName } from '@finos/legend-shared';
21
26
  import { QueryBuilderProjectionPanel } from './QueryBuilderProjectionPanel.js';
@@ -47,7 +52,7 @@ const QueryBuilderFetchStructureEditor = observer(
47
52
  );
48
53
  }
49
54
  return (
50
- <div className="panel__content">
55
+ <PanelContent>
51
56
  <BlankPanelContent>
52
57
  <div className="query-builder__unsupported-view__main">
53
58
  <div className="query-builder__unsupported-view__summary">
@@ -55,7 +60,7 @@ const QueryBuilderFetchStructureEditor = observer(
55
60
  </div>
56
61
  </div>
57
62
  </BlankPanelContent>
58
- </div>
63
+ </PanelContent>
59
64
  );
60
65
  },
61
66
  );
@@ -78,7 +83,7 @@ export const QueryBuilderFetchStructurePanel = observer(
78
83
  };
79
84
 
80
85
  return (
81
- <div className="panel">
86
+ <Panel>
82
87
  <div className="panel__header">
83
88
  <div className="panel__header__title">
84
89
  <div className="panel__header__title__label">fetch structure</div>
@@ -106,7 +111,7 @@ export const QueryBuilderFetchStructurePanel = observer(
106
111
  <QueryBuilderFetchStructureEditor
107
112
  queryBuilderState={queryBuilderState}
108
113
  />
109
- </div>
114
+ </Panel>
110
115
  );
111
116
  },
112
117
  );
@@ -52,6 +52,7 @@ import {
52
52
  PanelEntryDropZonePlaceholder,
53
53
  useDragPreviewLayer,
54
54
  BlankPanelContent,
55
+ PanelContent,
55
56
  } from '@finos/legend-art';
56
57
  import {
57
58
  type Type,
@@ -1035,7 +1036,7 @@ const QueryBuilderPostFilterPanelContent = observer(
1035
1036
  </button>
1036
1037
  </div>
1037
1038
  </div>
1038
- <div className="panel__content">
1039
+ <PanelContent>
1039
1040
  <PanelDropZone
1040
1041
  isDragOver={isDragOver}
1041
1042
  dropTargetConnector={dropTargetConnector}
@@ -1058,7 +1059,7 @@ const QueryBuilderPostFilterPanelContent = observer(
1058
1059
  </>
1059
1060
  )}
1060
1061
  </PanelDropZone>
1061
- </div>
1062
+ </PanelContent>
1062
1063
  </div>
1063
1064
  );
1064
1065
  },
@@ -1090,11 +1091,11 @@ export const QueryBuilderPostFilterPanel = observer(
1090
1091
  <div className="panel__header__title__label">post-filter</div>
1091
1092
  </div>
1092
1093
  </div>
1093
- <div className="panel__content">
1094
+ <PanelContent>
1094
1095
  <BlankPanelContent>
1095
1096
  Post-filter is not supported for the current fetch-structure
1096
1097
  </BlankPanelContent>
1097
- </div>
1098
+ </PanelContent>
1098
1099
  </>
1099
1100
  )}
1100
1101
  </div>
@@ -34,6 +34,7 @@ import {
34
34
  useDragPreviewLayer,
35
35
  OptionsIcon,
36
36
  PlusIcon,
37
+ PanelContent,
37
38
  } from '@finos/legend-art';
38
39
  import {
39
40
  type QueryBuilderExplorerTreeDragSource,
@@ -583,7 +584,7 @@ export const QueryBuilderProjectionPanel = observer(
583
584
  }, [applicationStore, projectionState]);
584
585
 
585
586
  return (
586
- <div className="panel__content">
587
+ <PanelContent>
587
588
  <div className="query-builder__projection__toolbar">
588
589
  <button
589
590
  className="panel__header__action"
@@ -639,7 +640,7 @@ export const QueryBuilderProjectionPanel = observer(
639
640
  <QueryResultModifierModal projectionState={projectionState} />
640
641
  </PanelDropZone>
641
642
  </div>
642
- </div>
643
+ </PanelContent>
643
644
  );
644
645
  },
645
646
  );
@@ -42,6 +42,7 @@ import {
42
42
  DragPreviewLayer,
43
43
  PanelEntryDropZonePlaceholder,
44
44
  useDragPreviewLayer,
45
+ PanelContent,
45
46
  } from '@finos/legend-art';
46
47
  import {
47
48
  type QueryBuilderFilterConditionDragSource,
@@ -851,7 +852,7 @@ export const QueryBuilderFilterPanel = observer(
851
852
  </button>
852
853
  </div>
853
854
  </div>
854
- <div className="panel__content">
855
+ <PanelContent>
855
856
  <PanelDropZone
856
857
  isDragOver={isDragOver}
857
858
  dropTargetConnector={dropTargetConnector}
@@ -874,7 +875,7 @@ export const QueryBuilderFilterPanel = observer(
874
875
  </>
875
876
  )}
876
877
  </PanelDropZone>
877
- </div>
878
+ </PanelContent>
878
879
  </div>
879
880
  );
880
881
  },
package/src/index.ts CHANGED
@@ -39,3 +39,4 @@ export type { ServiceExecutionAnalysisResult } from './graphManager/action/analy
39
39
  export type { MappingRuntimeCompatibilityAnalysisResult } from './graphManager/action/analytics/MappingRuntimeCompatibilityAnalysis.js';
40
40
  export * from './stores/ServiceInfo.js';
41
41
  export * from './components/ServiceQuerySetupUtils.js';
42
+ export * from './components/QuerySetupUtils.js';
@@ -14,6 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import {
18
+ ActionAlertActionType,
19
+ ActionAlertType,
20
+ } from '@finos/legend-application';
17
21
  import type { RawLambda } from '@finos/legend-graph';
18
22
  import {
19
23
  ActionState,
@@ -136,4 +140,31 @@ export class QueryBuilderChangeDetectionState {
136
140
  this.initialQuery = initialQuery;
137
141
  this.initState.complete();
138
142
  }
143
+
144
+ alertUnsavedChanges(onProceed: () => void): void {
145
+ if (this.hasChanged) {
146
+ this.querybuilderState.applicationStore.setActionAlertInfo({
147
+ message:
148
+ 'Unsaved changes to your query will be lost if you continue. Do you still want to proceed?',
149
+ type: ActionAlertType.CAUTION,
150
+ actions: [
151
+ {
152
+ label: 'Proceed',
153
+ type: ActionAlertActionType.PROCEED_WITH_CAUTION,
154
+ handler:
155
+ this.querybuilderState.applicationStore.guardUnhandledError(
156
+ async () => onProceed(),
157
+ ),
158
+ },
159
+ {
160
+ label: 'Cancel',
161
+ type: ActionAlertActionType.PROCEED,
162
+ default: true,
163
+ },
164
+ ],
165
+ });
166
+ } else {
167
+ onProceed();
168
+ }
169
+ }
139
170
  }
@@ -33,11 +33,13 @@ export class QueryBuilderParametersState
33
33
  extends LambdaParametersState
34
34
  implements Hashable
35
35
  {
36
+ readonly queryBuilderState: QueryBuilderState;
37
+
36
38
  selectedParameter: LambdaParameterState | undefined;
37
- queryBuilderState: QueryBuilderState;
38
39
 
39
40
  constructor(queryBuilderState: QueryBuilderState) {
40
41
  super();
42
+
41
43
  makeObservable(this, {
42
44
  parameterValuesEditorState: observable,
43
45
  parameterStates: observable,
@@ -36,9 +36,10 @@ import {
36
36
  } from './fetch-structure/projection/QueryBuilderProjectionColumnState.js';
37
37
  import type { QueryBuilderState } from './QueryBuilderState.js';
38
38
  import { QueryBuilderProjectionState } from './fetch-structure/projection/QueryBuilderProjectionState.js';
39
-
40
- const TYPEAHEAD_TAKE_LIMIT = 10;
41
- const START_LENGTH = 3;
39
+ import {
40
+ DEFAULT_TYPEAHEAD_SEARCH_LIMIT,
41
+ DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH,
42
+ } from '@finos/legend-application';
42
43
 
43
44
  const initializeQueryBuilderState = (
44
45
  queryBuilderState: QueryBuilderState,
@@ -49,7 +50,7 @@ const initializeQueryBuilderState = (
49
50
  QueryBuilderProjectionState,
50
51
  );
51
52
  projectionState.resultSetModifierState.distinct = true;
52
- projectionState.resultSetModifierState.limit = TYPEAHEAD_TAKE_LIMIT;
53
+ projectionState.resultSetModifierState.limit = DEFAULT_TYPEAHEAD_SEARCH_LIMIT;
53
54
  return builderState;
54
55
  };
55
56
 
@@ -142,7 +143,7 @@ export const performTypeahead = (
142
143
  switch (_type.path) {
143
144
  case PRIMITIVE_TYPE.STRING: {
144
145
  const value = val.values[0] as string;
145
- return value.length >= START_LENGTH;
146
+ return value.length >= DEFAULT_TYPEAHEAD_SEARCH_MINIMUM_SEARCH_LENGTH;
146
147
  }
147
148
  default:
148
149
  return false;
package/tsconfig.json CHANGED
@@ -35,6 +35,7 @@
35
35
  "files": [
36
36
  "./src/index.ts",
37
37
  "./src/components/QueryBuilder_TestID.ts",
38
+ "./src/components/QuerySetupUtils.ts",
38
39
  "./src/graphManager/QueryBuilderHashUtils.ts",
39
40
  "./src/graphManager/QueryBuilderSupportedFunctions.ts",
40
41
  "./src/graphManager/QueryBuilder_GraphManagerPlugin.ts",