@finos/legend-query-builder 4.14.18 → 4.14.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +5 -3
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderConstantExpressionPanel.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderConstantExpressionPanel.js +71 -45
  6. package/lib/components/QueryBuilderConstantExpressionPanel.js.map +1 -1
  7. package/lib/components/QueryBuilderDiffPanel.d.ts.map +1 -1
  8. package/lib/components/QueryBuilderDiffPanel.js +2 -1
  9. package/lib/components/QueryBuilderDiffPanel.js.map +1 -1
  10. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderParametersPanel.js +25 -26
  12. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts +11 -2
  14. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  15. package/lib/components/QueryBuilderPropertyExpressionEditor.js +35 -10
  16. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  17. package/lib/components/QueryBuilderSideBar.d.ts.map +1 -1
  18. package/lib/components/QueryBuilderSideBar.js +6 -1
  19. package/lib/components/QueryBuilderSideBar.js.map +1 -1
  20. package/lib/components/QueryBuilderTextEditor.d.ts.map +1 -1
  21. package/lib/components/QueryBuilderTextEditor.js +3 -3
  22. package/lib/components/QueryBuilderTextEditor.js.map +1 -1
  23. package/lib/components/QueryLoader.d.ts.map +1 -1
  24. package/lib/components/QueryLoader.js +90 -39
  25. package/lib/components/QueryLoader.js.map +1 -1
  26. package/lib/components/QueryUsageViewer.d.ts.map +1 -1
  27. package/lib/components/QueryUsageViewer.js +2 -2
  28. package/lib/components/QueryUsageViewer.js.map +1 -1
  29. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +2 -0
  30. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  31. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +19 -2
  32. package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
  33. package/lib/components/data-access/DataAccessOverview.d.ts.map +1 -1
  34. package/lib/components/data-access/DataAccessOverview.js +6 -1
  35. package/lib/components/data-access/DataAccessOverview.js.map +1 -1
  36. package/lib/components/execution-plan/ExecutionPlanViewer.d.ts.map +1 -1
  37. package/lib/components/execution-plan/ExecutionPlanViewer.js +6 -6
  38. package/lib/components/execution-plan/ExecutionPlanViewer.js.map +1 -1
  39. package/lib/components/explorer/QueryBuilderExplorerPanel.d.ts.map +1 -1
  40. package/lib/components/explorer/QueryBuilderExplorerPanel.js +3 -2
  41. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  42. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  43. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +3 -2
  44. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  45. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.d.ts.map +1 -1
  46. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js +6 -3
  47. package/lib/components/fetch-structure/QueryBuilderGraphFetchTreePanel.js.map +1 -1
  48. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.d.ts.map +1 -1
  49. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +4 -3
  50. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  51. package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
  52. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +11 -22
  53. package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
  54. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.d.ts.map +1 -1
  55. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js +2 -2
  56. package/lib/components/fetch-structure/QueryBuilderTDSWindowPanel.js.map +1 -1
  57. package/lib/components/result/QueryBuilderResultPanel.d.ts.map +1 -1
  58. package/lib/components/result/QueryBuilderResultPanel.js +2 -1
  59. package/lib/components/result/QueryBuilderResultPanel.js.map +1 -1
  60. package/lib/components/result/tds/QueryBuilderTDSGridResult.d.ts.map +1 -1
  61. package/lib/components/result/tds/QueryBuilderTDSGridResult.js +5 -1
  62. package/lib/components/result/tds/QueryBuilderTDSGridResult.js.map +1 -1
  63. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.d.ts.map +1 -1
  64. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js +11 -2
  65. package/lib/components/result/tds/QueryBuilderTDSSimpleGridResult.js.map +1 -1
  66. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
  67. package/lib/components/shared/BasicValueSpecificationEditor.js +25 -22
  68. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
  69. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
  70. package/lib/components/shared/CustomDatePicker.js +8 -5
  71. package/lib/components/shared/CustomDatePicker.js.map +1 -1
  72. package/lib/components/shared/LambdaEditor.d.ts.map +1 -1
  73. package/lib/components/shared/LambdaEditor.js +17 -3
  74. package/lib/components/shared/LambdaEditor.js.map +1 -1
  75. package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +1 -1
  76. package/lib/components/shared/LambdaParameterValuesEditor.js +2 -2
  77. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -1
  78. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts +6 -0
  79. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.d.ts.map +1 -1
  80. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js +40 -3
  81. package/lib/components/shared/QueryBuilderPropertyInfoTooltip.js.map +1 -1
  82. package/lib/components/watermark/QueryBuilderWatermark.d.ts.map +1 -1
  83. package/lib/components/watermark/QueryBuilderWatermark.js +28 -12
  84. package/lib/components/watermark/QueryBuilderWatermark.js.map +1 -1
  85. package/lib/index.css +17 -1
  86. package/lib/index.css.map +1 -1
  87. package/lib/package.json +1 -1
  88. package/lib/stores/QueryBuilderConstantsState.d.ts +1 -0
  89. package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
  90. package/lib/stores/QueryBuilderConstantsState.js +7 -1
  91. package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
  92. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts +24 -1
  93. package/lib/stores/QueryBuilder_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  94. package/lib/stores/QueryLoaderState.d.ts +14 -4
  95. package/lib/stores/QueryLoaderState.d.ts.map +1 -1
  96. package/lib/stores/QueryLoaderState.js +35 -5
  97. package/lib/stores/QueryLoaderState.js.map +1 -1
  98. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts +1 -2
  99. package/lib/stores/watermark/QueryBuilderWatermarkState.d.ts.map +1 -1
  100. package/lib/stores/watermark/QueryBuilderWatermarkState.js +2 -12
  101. package/lib/stores/watermark/QueryBuilderWatermarkState.js.map +1 -1
  102. package/package.json +8 -8
  103. package/src/components/QueryBuilder.tsx +14 -2
  104. package/src/components/QueryBuilderConstantExpressionPanel.tsx +145 -69
  105. package/src/components/QueryBuilderDiffPanel.tsx +10 -2
  106. package/src/components/QueryBuilderParametersPanel.tsx +42 -37
  107. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +87 -24
  108. package/src/components/QueryBuilderSideBar.tsx +20 -0
  109. package/src/components/QueryBuilderTextEditor.tsx +6 -4
  110. package/src/components/QueryLoader.tsx +291 -130
  111. package/src/components/QueryUsageViewer.tsx +7 -1
  112. package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +40 -4
  113. package/src/components/data-access/DataAccessOverview.tsx +9 -1
  114. package/src/components/execution-plan/ExecutionPlanViewer.tsx +11 -8
  115. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +5 -2
  116. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +5 -2
  117. package/src/components/fetch-structure/QueryBuilderGraphFetchTreePanel.tsx +12 -5
  118. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +8 -4
  119. package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +56 -72
  120. package/src/components/fetch-structure/QueryBuilderTDSWindowPanel.tsx +8 -2
  121. package/src/components/result/QueryBuilderResultPanel.tsx +8 -1
  122. package/src/components/result/tds/QueryBuilderTDSGridResult.tsx +6 -3
  123. package/src/components/result/tds/QueryBuilderTDSSimpleGridResult.tsx +14 -4
  124. package/src/components/shared/BasicValueSpecificationEditor.tsx +39 -25
  125. package/src/components/shared/CustomDatePicker.tsx +18 -5
  126. package/src/components/shared/LambdaEditor.tsx +27 -11
  127. package/src/components/shared/LambdaParameterValuesEditor.tsx +4 -1
  128. package/src/components/shared/QueryBuilderPropertyInfoTooltip.tsx +115 -64
  129. package/src/components/watermark/QueryBuilderWatermark.tsx +60 -19
  130. package/src/stores/QueryBuilderConstantsState.ts +12 -0
  131. package/src/stores/QueryBuilder_LegendApplicationPlugin_Extension.ts +39 -1
  132. package/src/stores/QueryLoaderState.ts +64 -12
  133. package/src/stores/watermark/QueryBuilderWatermarkState.ts +2 -12
@@ -25,7 +25,6 @@ import {
25
25
  CustomSelectorInput,
26
26
  Dialog,
27
27
  InfoCircleIcon,
28
- InputWithInlineValidation,
29
28
  Modal,
30
29
  ModalBody,
31
30
  ModalFooter,
@@ -43,7 +42,10 @@ import {
43
42
  Multiplicity,
44
43
  isValidIdentifier,
45
44
  } from '@finos/legend-graph';
46
- import { generateEnumerableNameFromToken } from '@finos/legend-shared';
45
+ import {
46
+ deepClone,
47
+ generateEnumerableNameFromToken,
48
+ } from '@finos/legend-shared';
47
49
  import { observer } from 'mobx-react-lite';
48
50
  import { DEFAULT_CONSTANT_VARIABLE_NAME } from '../stores/QueryBuilderConfig.js';
49
51
  import type { QueryBuilderState } from '../stores/QueryBuilderState.js';
@@ -51,37 +53,69 @@ import {
51
53
  type QueryBuilderConstantExpressionState,
52
54
  QueryBuilderSimpleConstantExpressionState,
53
55
  QueryBuilderCalculatedConstantExpressionState,
56
+ cloneQueryBuilderConstantLambdaEditorState,
54
57
  } from '../stores/QueryBuilderConstantsState.js';
55
58
  import { buildDefaultInstanceValue } from '../stores/shared/ValueSpecificationEditorHelper.js';
56
59
  import { BasicValueSpecificationEditor } from './shared/BasicValueSpecificationEditor.js';
57
60
  import { QUERY_BUILDER_TEST_ID } from '../__lib__/QueryBuilderTesting.js';
58
61
  import { QUERY_BUILDER_DOCUMENTATION_KEY } from '../__lib__/QueryBuilderDocumentation.js';
59
- import React, { useEffect, useState } from 'react';
62
+ import React, { useEffect, useMemo, useState } from 'react';
60
63
  import { variableExpression_setName } from '../stores/shared/ValueSpecificationModifierHelper.js';
61
64
  import { LambdaEditor } from './shared/LambdaEditor.js';
62
65
  import { VariableViewer } from './shared/QueryBuilderVariableSelector.js';
63
66
  import { flowResult } from 'mobx';
64
67
 
68
+ const getConstantNameValidationMessage = (
69
+ constantInput: string,
70
+ allVariableNames: string[],
71
+ currentConstantName: string,
72
+ ): string | undefined =>
73
+ !constantInput
74
+ ? `Constant name can't be empty`
75
+ : isValidIdentifier(constantInput) === false
76
+ ? 'Constant name must be text with no spaces and not start with an uppercase letter or number'
77
+ : allVariableNames.filter((e) => e === constantInput).length > 0 &&
78
+ constantInput !== currentConstantName
79
+ ? 'Constant name already exists'
80
+ : undefined;
81
+
65
82
  // NOTE: We currently only allow constant variables for primitive types of multiplicity ONE.
66
83
  // This is why we don't show multiplicity in the editor.
67
84
  const QueryBuilderSimpleConstantExpressionEditor = observer(
68
85
  (props: { constantState: QueryBuilderSimpleConstantExpressionState }) => {
86
+ // Read current state
69
87
  const { constantState } = props;
88
+ const varExpression = constantState.variable;
70
89
  const queryBuilderState = constantState.queryBuilderState;
71
90
  const applicationStore = queryBuilderState.applicationStore;
72
91
  const variableState = queryBuilderState.constantState;
73
- const varExpression = constantState.variable;
74
- const variableName = varExpression.name;
75
92
  const allVariableNames = queryBuilderState.allVariableNames;
76
93
  const isCreating = !variableState.constants.includes(constantState);
77
- const valueSpec = constantState.value;
78
- const variableType =
79
- constantState.value.genericType?.value.rawType ?? PrimitiveType.STRING;
80
- const selectedType = buildElementOption(variableType);
81
94
 
95
+ // Name
96
+ const stateName = varExpression.name;
97
+ const [selectedName, setSelectedName] = useState(stateName);
98
+ const [isNameValid, setIsNameValid] = useState<boolean>(true);
99
+
100
+ // Value
101
+ const stateValue = constantState.value;
102
+ const [selectedValue, setSelectedValue] = useState(deepClone(stateValue));
103
+
104
+ // Type
105
+ const stateType =
106
+ constantState.value.genericType?.value.rawType ?? PrimitiveType.STRING;
107
+ const [selectedType, setSelectedType] = useState(
108
+ buildElementOption(stateType),
109
+ );
82
110
  const changeType = (val: PackageableElementOption<Type>): void => {
83
- if (variableType !== val.value) {
84
- constantState.changeValSpecType(val.value);
111
+ if (val.value !== selectedType.value) {
112
+ setSelectedType(val);
113
+ const newValSpec = buildDefaultInstanceValue(
114
+ queryBuilderState.graphManagerState.graph,
115
+ val.value,
116
+ queryBuilderState.observerContext,
117
+ );
118
+ setSelectedValue(newValSpec);
85
119
  }
86
120
  };
87
121
  const typeOptions: PackageableElementOption<Type>[] =
@@ -93,41 +127,34 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
93
127
  ),
94
128
  );
95
129
 
96
- const [isNameValid, setIsNameValid] = useState<boolean>(true);
97
-
98
- const getValidationMessage = (constantInput: string): string | undefined =>
99
- !constantInput
100
- ? `Constant name can't be empty`
101
- : isValidIdentifier(constantInput) === false
102
- ? 'Constant name must be text with no spaces and not start with an uppercase letter or number'
103
- : allVariableNames.filter((e) => e === constantInput).length >
104
- (isCreating ? 0 : 1)
105
- ? 'Constant name already exists'
106
- : undefined;
107
-
108
- const close = (): void => {
130
+ // Modal lifecycle actions
131
+ const handleCancel = (): void => {
109
132
  variableState.setSelectedConstant(undefined);
110
133
  };
111
134
 
112
- const onAction = (): void => {
135
+ const handleApply = (): void => {
136
+ variableExpression_setName(varExpression, selectedName);
137
+ constantState.changeValSpecType(selectedType.value);
138
+ constantState.setValueSpec(selectedValue);
113
139
  if (isCreating) {
114
140
  variableState.addConstant(constantState);
115
141
  }
116
- close();
142
+ handleCancel();
117
143
  };
144
+
118
145
  const resetConstantValue = (): void => {
119
146
  const valSpec = buildDefaultInstanceValue(
120
147
  queryBuilderState.graphManagerState.graph,
121
- variableType,
148
+ selectedType.value,
122
149
  queryBuilderState.observerContext,
123
150
  );
124
- constantState.setValueSpec(valSpec);
151
+ setSelectedValue(valSpec);
125
152
  };
126
153
 
127
154
  return (
128
155
  <Dialog
129
156
  open={Boolean(constantState)}
130
- onClose={close}
157
+ onClose={handleCancel}
131
158
  classes={{
132
159
  root: 'editor-modal__root-container',
133
160
  container: 'editor-modal__container',
@@ -135,7 +162,9 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
135
162
  }}
136
163
  >
137
164
  <Modal
138
- darkMode={true}
165
+ darkMode={
166
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
167
+ }
139
168
  className="editor-modal query-builder__variables__modal"
140
169
  >
141
170
  <ModalHeader
@@ -146,11 +175,17 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
146
175
  name="Constant Name"
147
176
  prompt="Name of constant. Should be descriptive of its purpose."
148
177
  update={(value: string | undefined): void => {
149
- variableExpression_setName(varExpression, value ?? '');
178
+ setSelectedName(value ?? '');
150
179
  }}
151
- validate={getValidationMessage}
180
+ validate={(constantInput: string) =>
181
+ getConstantNameValidationMessage(
182
+ constantInput,
183
+ allVariableNames,
184
+ stateName,
185
+ )
186
+ }
152
187
  onValidate={(issue: string | undefined) => setIsNameValid(!issue)}
153
- value={variableName}
188
+ value={selectedName}
154
189
  isReadOnly={false}
155
190
  />
156
191
  <PanelFormSection>
@@ -182,15 +217,15 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
182
217
  </div>
183
218
  <div className="query-builder__variable-editor">
184
219
  <BasicValueSpecificationEditor
185
- valueSpecification={valueSpec}
220
+ valueSpecification={selectedValue}
186
221
  setValueSpecification={(val: ValueSpecification): void => {
187
- constantState.setValueSpec(val);
222
+ setSelectedValue(deepClone(val));
188
223
  }}
189
224
  graph={queryBuilderState.graphManagerState.graph}
190
225
  obseverContext={queryBuilderState.observerContext}
191
226
  typeCheckOption={{
192
- expectedType: variableType,
193
- match: variableType === PrimitiveType.DATETIME,
227
+ expectedType: selectedType.value,
228
+ match: selectedType.value === PrimitiveType.DATETIME,
194
229
  }}
195
230
  resetValue={resetConstantValue}
196
231
  />
@@ -198,14 +233,16 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
198
233
  </PanelFormSection>
199
234
  </ModalBody>
200
235
  <ModalFooter>
201
- {isCreating && (
202
- <ModalFooterButton
203
- text="Create"
204
- disabled={!isNameValid}
205
- onClick={onAction}
206
- />
207
- )}
208
- <ModalFooterButton text="Close" onClick={close} />
236
+ <ModalFooterButton
237
+ text={isCreating ? 'Create' : 'Apply'}
238
+ disabled={!isNameValid}
239
+ onClick={handleApply}
240
+ />
241
+ <ModalFooterButton
242
+ text="Cancel"
243
+ onClick={handleCancel}
244
+ type="secondary"
245
+ />
209
246
  </ModalFooter>
210
247
  </Modal>
211
248
  </Dialog>
@@ -215,28 +252,45 @@ const QueryBuilderSimpleConstantExpressionEditor = observer(
215
252
 
216
253
  const QuerryBuilderCalculatedConstantExpressionEditor = observer(
217
254
  (props: { constantState: QueryBuilderCalculatedConstantExpressionState }) => {
255
+ // Read current state
218
256
  const { constantState } = props;
219
257
  const queryBuilderState = constantState.queryBuilderState;
220
258
  const lambdaState = constantState.lambdaState;
221
- const close = (): void =>
222
- queryBuilderState.constantState.setSelectedConstant(undefined);
223
259
  const applicationStore = queryBuilderState.applicationStore;
224
- const changeConstantName: React.ChangeEventHandler<HTMLInputElement> = (
225
- event,
226
- ) => {
227
- variableExpression_setName(constantState.variable, event.target.value);
260
+ const allVariableNames = queryBuilderState.allVariableNames;
261
+ const stateName = constantState.variable.name;
262
+
263
+ // Set up temporary state for modal lifecycle
264
+ const [name, setName] = useState(stateName);
265
+ const [isNameValid, setIsNameValid] = useState<boolean>(true);
266
+ const lambdaStateCopy = useMemo(
267
+ () => cloneQueryBuilderConstantLambdaEditorState(lambdaState),
268
+ [lambdaState],
269
+ );
270
+
271
+ // Modal lifecycle actions
272
+ const handleCancel = (): void => {
273
+ queryBuilderState.constantState.setSelectedConstant(undefined);
228
274
  };
275
+
276
+ const handleApply = (): void => {
277
+ variableExpression_setName(constantState.variable, name);
278
+ constantState.lambdaState = lambdaStateCopy;
279
+ handleCancel();
280
+ };
281
+
229
282
  useEffect(() => {
230
283
  flowResult(
231
- lambdaState.convertLambdaObjectToGrammarString({
284
+ lambdaStateCopy.convertLambdaObjectToGrammarString({
232
285
  pretty: true,
233
286
  }),
234
287
  ).catch(applicationStore.alertUnhandledError);
235
- }, [applicationStore, lambdaState]);
288
+ }, [applicationStore, lambdaStateCopy]);
289
+
236
290
  return (
237
291
  <Dialog
238
292
  open={true}
239
- onClose={close}
293
+ onClose={handleCancel}
240
294
  classes={{
241
295
  root: 'editor-modal__root-container',
242
296
  container: 'editor-modal__container',
@@ -244,16 +298,18 @@ const QuerryBuilderCalculatedConstantExpressionEditor = observer(
244
298
  }}
245
299
  >
246
300
  <Modal
247
- darkMode={true}
301
+ darkMode={
302
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
303
+ }
248
304
  className={clsx('editor-modal query-builder__constants__modal', {
249
305
  'query-builder__constants__modal--has-error': Boolean(
250
- lambdaState.parserError,
306
+ lambdaStateCopy.parserError,
251
307
  ),
252
308
  })}
253
309
  >
254
310
  <ModalHeader>
255
311
  <div className="modal__title">Update Calculated Constants</div>
256
- {lambdaState.parserError && (
312
+ {lambdaStateCopy.parserError && (
257
313
  <div className="modal__title__error-badge">
258
314
  Failed to parse query
259
315
  </div>
@@ -262,37 +318,56 @@ const QuerryBuilderCalculatedConstantExpressionEditor = observer(
262
318
  <ModalBody>
263
319
  <div
264
320
  className={clsx('query-builder__constants__modal__content', {
265
- backdrop__element: Boolean(lambdaState.parserError),
321
+ backdrop__element: Boolean(lambdaStateCopy.parserError),
266
322
  })}
267
323
  >
268
324
  <div className="query-builder__constants__modal__name">
269
- <InputWithInlineValidation
325
+ <PanelFormValidatedTextField
326
+ value={name}
327
+ isReadOnly={false}
270
328
  className="query-builder__constants__modal__name__input input--dark"
271
- spellCheck={false}
272
- value={constantState.variable.name}
273
- onChange={changeConstantName}
274
329
  placeholder="Constant Name"
330
+ update={(value: string | undefined): void => {
331
+ setName(value ?? '');
332
+ }}
333
+ validate={(constantInput: string) =>
334
+ getConstantNameValidationMessage(
335
+ constantInput,
336
+ allVariableNames,
337
+ stateName,
338
+ )
339
+ }
340
+ onValidate={(issue: string | undefined) =>
341
+ setIsNameValid(!issue)
342
+ }
275
343
  />
276
344
  </div>
277
345
  <LambdaEditor
278
346
  className="query-builder__constants__lambda-editor"
279
347
  disabled={
280
- lambdaState.convertingLambdaToStringState.isInProgress
348
+ lambdaStateCopy.convertingLambdaToStringState.isInProgress
281
349
  }
282
- lambdaEditorState={lambdaState}
350
+ lambdaEditorState={lambdaStateCopy}
283
351
  forceBackdrop={false}
284
352
  autoFocus={true}
285
353
  />
286
354
  </div>
287
355
  </ModalBody>
288
356
  <ModalFooter>
289
- <button
357
+ <ModalFooterButton
358
+ className="btn btn--dark"
359
+ onClick={handleApply}
360
+ disabled={Boolean(lambdaStateCopy.parserError) || !isNameValid}
361
+ >
362
+ Apply
363
+ </ModalFooterButton>
364
+ <ModalFooterButton
290
365
  className="btn btn--dark"
291
- onClick={close}
292
- disabled={Boolean(lambdaState.parserError)}
366
+ onClick={handleCancel}
367
+ type="secondary"
293
368
  >
294
- Close
295
- </button>
369
+ Cancel
370
+ </ModalFooterButton>
296
371
  </ModalFooter>
297
372
  </Modal>
298
373
  </Dialog>
@@ -352,6 +427,7 @@ export const QueryBuilderConstantExpressionPanel = observer(
352
427
  }
353
428
  return null;
354
429
  };
430
+
355
431
  const getExtraContextMenu = (
356
432
  val: QueryBuilderConstantExpressionState,
357
433
  ):
@@ -121,6 +121,8 @@ export const QueryBuilderDiffViewPanel = observer(
121
121
  export const QueryBuilderDiffViewPanelDiaglog = observer(
122
122
  (props: { diffViewState: QueryBuilderDiffViewState }) => {
123
123
  const { diffViewState } = props;
124
+ const applicationStore =
125
+ diffViewState.changeDetectionState.querybuilderState.applicationStore;
124
126
  const close = (): void =>
125
127
  diffViewState.changeDetectionState.hideDiffViewPanel();
126
128
  return (
@@ -134,7 +136,9 @@ export const QueryBuilderDiffViewPanelDiaglog = observer(
134
136
  }}
135
137
  >
136
138
  <Modal
137
- darkMode={true}
139
+ darkMode={
140
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
141
+ }
138
142
  className={clsx('editor-modal query-builder-text-mode__modal')}
139
143
  >
140
144
  <ModalHeader>
@@ -153,7 +157,11 @@ export const QueryBuilderDiffViewPanelDiaglog = observer(
153
157
  <QueryBuilderDiffViewPanel diffViewState={diffViewState} />
154
158
  </ModalBody>
155
159
  <ModalFooter className="query-builder__diff-panel__actions">
156
- <ModalFooterButton title="Close Modal" onClick={close}>
160
+ <ModalFooterButton
161
+ title="Close Modal"
162
+ onClick={close}
163
+ type="secondary"
164
+ >
157
165
  Close
158
166
  </ModalFooterButton>
159
167
  </ModalFooter>
@@ -78,13 +78,12 @@ const VariableExpressionEditor = observer(
78
78
  const isCreating =
79
79
  !queryParametersState.parameterStates.includes(lambdaParameterState);
80
80
  const varState = lambdaParameterState.parameter;
81
- const multiplity = varState.multiplicity;
82
81
 
83
82
  // type
84
- const variableType =
85
- lambdaParameterState.variableType ?? PrimitiveType.STRING;
86
- const selectedType = buildElementOption(variableType);
87
- const selectedMultiplicity = buildMultiplicityOption(multiplity);
83
+ const stateType = lambdaParameterState.variableType ?? PrimitiveType.STRING;
84
+ const [selectedType, setSelectedType] = useState(
85
+ buildElementOption(stateType),
86
+ );
88
87
  const typeOptions: PackageableElementOption<Type>[] =
89
88
  queryBuilderState.graphManagerState.graph.primitiveTypes
90
89
  .map(buildElementOption)
@@ -94,12 +93,14 @@ const VariableExpressionEditor = observer(
94
93
  ),
95
94
  );
96
95
  const changeType = (val: PackageableElementOption<Type>): void => {
97
- if (variableType !== val.value) {
98
- lambdaParameterState.changeVariableType(val.value);
99
- }
96
+ setSelectedType(val);
100
97
  };
101
98
 
102
99
  // multiplicity
100
+ const stateMultiplicity = varState.multiplicity;
101
+ const [selectedMultiplicity, setSelectedMultiplicity] = useState(
102
+ buildMultiplicityOption(stateMultiplicity),
103
+ );
103
104
  const validParamMultiplicityList = [
104
105
  Multiplicity.ONE,
105
106
  Multiplicity.ZERO_ONE,
@@ -108,46 +109,46 @@ const VariableExpressionEditor = observer(
108
109
  const multilicityOptions: MultiplicityOption[] =
109
110
  validParamMultiplicityList.map(buildMultiplicityOption);
110
111
  const changeMultiplicity = (val: MultiplicityOption): void => {
111
- lambdaParameterState.changeMultiplicity(varState, val.value);
112
+ setSelectedMultiplicity(val);
112
113
  };
113
114
 
114
- const parameterNameValue = varState.name;
115
-
115
+ // name
116
+ const stateName = varState.name;
117
+ const [selectedName, setSelectedName] = useState(stateName);
116
118
  const [isNameValid, setIsNameValid] = useState<boolean>(true);
117
119
 
118
120
  const getValidationMessage = (input: string): string | undefined =>
119
121
  !input
120
122
  ? `Parameter name can't be empty`
121
- : allVariableNames.filter((e) => e === input).length >
122
- (isCreating ? 0 : 1)
123
- ? 'Parameter name already exists'
124
- : (isCreating &&
125
- queryParametersState.parameterStates.find(
126
- (p) => p.parameter.name === input,
127
- )) ||
128
- (!isCreating &&
129
- queryParametersState.parameterStates.filter(
130
- (p) => p.parameter.name === input,
131
- ).length > 1)
123
+ : allVariableNames.filter((e) => e === input).length > 0 &&
124
+ input !== stateName
132
125
  ? 'Parameter name already exists'
133
126
  : isValidIdentifier(input, true) === false
134
127
  ? 'Parameter name must be text with no spaces and not start with an uppercase letter or number'
135
128
  : undefined;
136
129
 
137
- const close = (): void => {
130
+ // modal lifecycle actions
131
+ const handleCancel = (): void => {
138
132
  queryParametersState.setSelectedParameter(undefined);
139
133
  };
140
- const onAction = (): void => {
134
+
135
+ const handleApply = (): void => {
136
+ lambdaParameterState.changeVariableType(selectedType.value);
137
+ lambdaParameterState.changeMultiplicity(
138
+ varState,
139
+ selectedMultiplicity.value,
140
+ );
141
+ variableExpression_setName(varState, selectedName);
141
142
  if (isCreating) {
142
143
  queryParametersState.addParameter(lambdaParameterState);
143
144
  }
144
- close();
145
+ handleCancel();
145
146
  };
146
147
 
147
148
  return (
148
149
  <Dialog
149
150
  open={Boolean(lambdaParameterState)}
150
- onClose={close}
151
+ onClose={handleCancel}
151
152
  classes={{
152
153
  root: 'editor-modal__root-container',
153
154
  container: 'editor-modal__container',
@@ -155,7 +156,9 @@ const VariableExpressionEditor = observer(
155
156
  }}
156
157
  >
157
158
  <Modal
158
- darkMode={true}
159
+ darkMode={
160
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
161
+ }
159
162
  className="editor-modal query-builder__variables__modal"
160
163
  >
161
164
  <ModalHeader
@@ -165,9 +168,9 @@ const VariableExpressionEditor = observer(
165
168
  <PanelFormValidatedTextField
166
169
  name="Parameter Name"
167
170
  prompt="Name of the parameter. Should be descriptive of its purpose."
168
- value={parameterNameValue}
171
+ value={selectedName}
169
172
  update={(value: string | undefined): void => {
170
- variableExpression_setName(varState, value ?? '');
173
+ setSelectedName(value ?? '');
171
174
  }}
172
175
  validate={getValidationMessage}
173
176
  onValidate={(issue: string | undefined) => setIsNameValid(!issue)}
@@ -222,14 +225,16 @@ const VariableExpressionEditor = observer(
222
225
  </div>
223
226
  </ModalBody>
224
227
  <ModalFooter>
225
- {isCreating && (
226
- <ModalFooterButton
227
- text="Create"
228
- disabled={!isNameValid}
229
- onClick={onAction}
230
- />
231
- )}
232
- <ModalFooterButton onClick={close} text="Close" />
228
+ <ModalFooterButton
229
+ text={isCreating ? 'Create' : 'Update'}
230
+ disabled={!isNameValid}
231
+ onClick={handleApply}
232
+ />
233
+ <ModalFooterButton
234
+ onClick={handleCancel}
235
+ text="Cancel"
236
+ type="secondary"
237
+ />
233
238
  </ModalFooter>
234
239
  </Modal>
235
240
  </Dialog>