@perses-dev/plugin-system 0.46.0 → 0.47.0-rc0
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.
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +70 -99
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -1
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +49 -19
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +1 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +10 -71
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +408 -376
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
- package/dist/cjs/components/Variables/variable-model.js +24 -22
- package/dist/cjs/context/ProjectStoreProvider.js +7 -4
- package/dist/cjs/context/ValidationProvider.js +69 -0
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/runtime/QueryCountProvider.js +83 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/cjs/runtime/builtin-variables.js +1 -1
- package/dist/cjs/runtime/datasources.js +22 -13
- package/dist/cjs/runtime/index.js +3 -2
- package/dist/cjs/runtime/plugin-registry.js +33 -22
- package/dist/cjs/runtime/time-series-queries.js +3 -3
- package/dist/cjs/runtime/trace-queries.js +5 -1
- package/dist/cjs/runtime/{template-variables.js → variables.js} +19 -19
- package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +8 -8
- package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
- package/dist/cjs/test/mock-data.js +25 -4
- package/dist/cjs/test/render.js +1 -9
- package/dist/cjs/test/test-plugins/bert/index.js +20 -19
- package/dist/cjs/utils/variables.js +23 -23
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +71 -100
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -3
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -20
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -0
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +411 -379
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +25 -23
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
- package/dist/context/ProjectStoreProvider.js +7 -4
- package/dist/context/ProjectStoreProvider.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +19 -0
- package/dist/context/ValidationProvider.d.ts.map +1 -0
- package/dist/context/ValidationProvider.js +52 -0
- package/dist/context/ValidationProvider.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/QueryCountProvider.d.ts +9 -0
- package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
- package/dist/{validation/duration.js → runtime/QueryCountProvider.js} +13 -4
- package/dist/runtime/QueryCountProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +1 -1
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +22 -13
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +33 -22
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +2 -2
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +3 -3
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +5 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
- package/dist/runtime/variables.d.ts.map +1 -0
- package/dist/runtime/{template-variables.js → variables.js} +18 -17
- package/dist/runtime/variables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +12 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/index.js +2 -2
- package/dist/stories/shared-utils/decorators/index.js.map +1 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +25 -4
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +1 -9
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +20 -19
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/utils/variables.d.ts +4 -4
- package/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +18 -18
- package/dist/utils/variables.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/validation/datasource.js +0 -30
- package/dist/cjs/validation/duration.js +0 -25
- package/dist/cjs/validation/index.js +0 -34
- package/dist/cjs/validation/resource.js +0 -24
- package/dist/cjs/validation/role.js +0 -86
- package/dist/cjs/validation/rolebinding.js +0 -55
- package/dist/cjs/validation/secret.js +0 -176
- package/dist/cjs/validation/user.js +0 -46
- package/dist/cjs/validation/variable.js +0 -48
- package/dist/runtime/template-variables.d.ts.map +0 -1
- package/dist/runtime/template-variables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
- package/dist/validation/datasource.d.ts +0 -19
- package/dist/validation/datasource.d.ts.map +0 -1
- package/dist/validation/datasource.js +0 -22
- package/dist/validation/datasource.js.map +0 -1
- package/dist/validation/duration.d.ts +0 -3
- package/dist/validation/duration.d.ts.map +0 -1
- package/dist/validation/duration.js.map +0 -1
- package/dist/validation/index.d.ts +0 -6
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js +0 -19
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/resource.d.ts +0 -3
- package/dist/validation/resource.d.ts.map +0 -1
- package/dist/validation/resource.js +0 -16
- package/dist/validation/resource.js.map +0 -1
- package/dist/validation/role.d.ts +0 -228
- package/dist/validation/role.d.ts.map +0 -1
- package/dist/validation/role.js +0 -67
- package/dist/validation/role.js.map +0 -1
- package/dist/validation/rolebinding.d.ts +0 -137
- package/dist/validation/rolebinding.d.ts.map +0 -1
- package/dist/validation/rolebinding.js +0 -47
- package/dist/validation/rolebinding.js.map +0 -1
- package/dist/validation/secret.d.ts +0 -964
- package/dist/validation/secret.d.ts.map +0 -1
- package/dist/validation/secret.js +0 -157
- package/dist/validation/secret.js.map +0 -1
- package/dist/validation/user.d.ts +0 -93
- package/dist/validation/user.d.ts.map +0 -1
- package/dist/validation/user.js +0 -38
- package/dist/validation/user.js.map +0 -1
- package/dist/validation/variable.d.ts +0 -96
- package/dist/validation/variable.d.ts.map +0 -1
- package/dist/validation/variable.js +0 -40
- package/dist/validation/variable.js.map +0 -1
|
@@ -26,13 +26,11 @@ const _material = require("@mui/material");
|
|
|
26
26
|
const _components = require("@perses-dev/components");
|
|
27
27
|
const _reacthookform = require("react-hook-form");
|
|
28
28
|
const _zod = require("@hookform/resolvers/zod");
|
|
29
|
-
const _useimmer = require("use-immer");
|
|
30
29
|
const _utils = require("../../../utils");
|
|
31
30
|
const _variablemodel = require("../variable-model");
|
|
32
31
|
const _PluginEditor = require("../../PluginEditor");
|
|
33
|
-
const
|
|
32
|
+
const _context = require("../../../context");
|
|
34
33
|
const _VariablePreview = require("./VariablePreview");
|
|
35
|
-
const _variableeditorformmodel = require("./variable-editor-form-model");
|
|
36
34
|
function _getRequireWildcardCache(nodeInterop) {
|
|
37
35
|
if (typeof WeakMap !== "function") return null;
|
|
38
36
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -79,55 +77,401 @@ function FallbackPreview() {
|
|
|
79
77
|
children: "Error previewing values"
|
|
80
78
|
});
|
|
81
79
|
}
|
|
80
|
+
function TextVariableEditorForm({ action, control }) {
|
|
81
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
84
|
+
py: 1,
|
|
85
|
+
variant: "subtitle1",
|
|
86
|
+
children: "Text Options"
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
89
|
+
spacing: 2,
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
92
|
+
control: control,
|
|
93
|
+
name: "spec.value",
|
|
94
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
95
|
+
var _fieldState_error;
|
|
96
|
+
var _field_value;
|
|
97
|
+
return (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
100
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
|
|
101
|
+
values: [
|
|
102
|
+
field.value
|
|
103
|
+
]
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
107
|
+
...field,
|
|
108
|
+
label: "Value",
|
|
109
|
+
InputLabelProps: {
|
|
110
|
+
shrink: action === 'read' ? true : undefined
|
|
111
|
+
},
|
|
112
|
+
InputProps: {
|
|
113
|
+
readOnly: action === 'read'
|
|
114
|
+
},
|
|
115
|
+
error: !!fieldState.error,
|
|
116
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
117
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
118
|
+
onChange: (event)=>{
|
|
119
|
+
field.onChange(event);
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
127
|
+
control: control,
|
|
128
|
+
name: "spec.constant",
|
|
129
|
+
render: ({ field })=>/*#__PURE__*/ {
|
|
130
|
+
var _field_value;
|
|
131
|
+
return (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
132
|
+
label: "Constant",
|
|
133
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
134
|
+
...field,
|
|
135
|
+
checked: !!field.value,
|
|
136
|
+
readOnly: action === 'read',
|
|
137
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
|
|
138
|
+
onChange: (event)=>{
|
|
139
|
+
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
140
|
+
field.onChange(event);
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function ListVariableEditorForm({ action, control }) {
|
|
152
|
+
const form = (0, _reacthookform.useFormContext)();
|
|
153
|
+
/** We use `previewSpec` to know when to explicitly update the
|
|
154
|
+
* spec that will be used for preview. The reason why we do this is to avoid
|
|
155
|
+
* having to re-fetch the values when the user is still editing the spec.
|
|
156
|
+
*/ const [previewSpec, setPreviewSpec] = (0, _react.useState)(form.getValues());
|
|
157
|
+
const refreshPreview = ()=>{
|
|
158
|
+
setPreviewSpec(form.getValues());
|
|
159
|
+
};
|
|
160
|
+
const kind = (0, _reacthookform.useWatch)({
|
|
161
|
+
control: control,
|
|
162
|
+
name: 'spec.plugin.kind'
|
|
163
|
+
});
|
|
164
|
+
const _allowAllValue = (0, _reacthookform.useWatch)({
|
|
165
|
+
control: control,
|
|
166
|
+
name: 'spec.allowAllValue'
|
|
167
|
+
});
|
|
168
|
+
// When variable kind is selected we need to provide default values
|
|
169
|
+
// TODO: check if react-hook-form has a better way to do this
|
|
170
|
+
const values = form.getValues();
|
|
171
|
+
if (values.spec.allowAllValue === undefined) {
|
|
172
|
+
form.setValue('spec.allowAllValue', false);
|
|
173
|
+
}
|
|
174
|
+
if (values.spec.allowMultiple === undefined) {
|
|
175
|
+
form.setValue('spec.allowMultiple', false);
|
|
176
|
+
}
|
|
177
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
178
|
+
children: [
|
|
179
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
180
|
+
py: 1,
|
|
181
|
+
variant: "subtitle1",
|
|
182
|
+
children: "List Options"
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
185
|
+
spacing: 2,
|
|
186
|
+
mb: 2,
|
|
187
|
+
children: [
|
|
188
|
+
kind ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
189
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
190
|
+
FallbackComponent: FallbackPreview,
|
|
191
|
+
resetKeys: [
|
|
192
|
+
previewSpec
|
|
193
|
+
],
|
|
194
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariableListPreview, {
|
|
195
|
+
definition: previewSpec,
|
|
196
|
+
onRefresh: refreshPreview
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
|
|
200
|
+
isLoading: true
|
|
201
|
+
}),
|
|
202
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
203
|
+
children: [
|
|
204
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ClickAwayListener, {
|
|
205
|
+
onClickAway: ()=>refreshPreview(),
|
|
206
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {})
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
209
|
+
FallbackComponent: _components.ErrorAlert,
|
|
210
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
211
|
+
control: control,
|
|
212
|
+
name: "spec.plugin",
|
|
213
|
+
render: ({ field })=>/*#__PURE__*/ {
|
|
214
|
+
var _field_value, _field_value1;
|
|
215
|
+
var _field_value_kind, _field_value_spec;
|
|
216
|
+
return (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
|
|
217
|
+
width: "100%",
|
|
218
|
+
pluginTypes: [
|
|
219
|
+
'Variable'
|
|
220
|
+
],
|
|
221
|
+
pluginKindLabel: "Source",
|
|
222
|
+
value: {
|
|
223
|
+
selection: {
|
|
224
|
+
type: 'Variable',
|
|
225
|
+
kind: (_field_value_kind = (_field_value = field.value) === null || _field_value === void 0 ? void 0 : _field_value.kind) !== null && _field_value_kind !== void 0 ? _field_value_kind : 'StaticListVariable'
|
|
226
|
+
},
|
|
227
|
+
spec: (_field_value_spec = (_field_value1 = field.value) === null || _field_value1 === void 0 ? void 0 : _field_value1.spec) !== null && _field_value_spec !== void 0 ? _field_value_spec : {
|
|
228
|
+
values: []
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
isReadonly: action === 'read',
|
|
232
|
+
onChange: (v)=>{
|
|
233
|
+
field.onChange({
|
|
234
|
+
kind: v.selection.kind,
|
|
235
|
+
spec: v.spec
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
]
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
245
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
246
|
+
control: control,
|
|
247
|
+
name: "spec.capturingRegexp",
|
|
248
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
249
|
+
var _fieldState_error;
|
|
250
|
+
var _field_value;
|
|
251
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
252
|
+
...field,
|
|
253
|
+
label: "Capturing Regexp Filter",
|
|
254
|
+
InputLabelProps: {
|
|
255
|
+
shrink: action === 'read' ? true : undefined
|
|
256
|
+
},
|
|
257
|
+
InputProps: {
|
|
258
|
+
readOnly: action === 'read'
|
|
259
|
+
},
|
|
260
|
+
error: !!fieldState.error,
|
|
261
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
262
|
+
onChange: (event)=>{
|
|
263
|
+
if (event.target.value === '') {
|
|
264
|
+
field.onChange(undefined);
|
|
265
|
+
} else {
|
|
266
|
+
field.onChange(event);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
}),
|
|
274
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
275
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
276
|
+
control: control,
|
|
277
|
+
name: "spec.sort",
|
|
278
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
279
|
+
var _fieldState_error;
|
|
280
|
+
var _field_value;
|
|
281
|
+
return (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
282
|
+
select: true,
|
|
283
|
+
...field,
|
|
284
|
+
fullWidth: true,
|
|
285
|
+
label: "Sort",
|
|
286
|
+
InputLabelProps: {
|
|
287
|
+
shrink: action === 'read' ? true : undefined
|
|
288
|
+
},
|
|
289
|
+
InputProps: {
|
|
290
|
+
readOnly: action === 'read'
|
|
291
|
+
},
|
|
292
|
+
error: !!fieldState.error,
|
|
293
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
294
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'none',
|
|
295
|
+
onChange: (event)=>{
|
|
296
|
+
field.onChange(event);
|
|
297
|
+
},
|
|
298
|
+
children: [
|
|
299
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
300
|
+
value: "none",
|
|
301
|
+
children: "None"
|
|
302
|
+
}),
|
|
303
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
304
|
+
value: "alphabetical-asc",
|
|
305
|
+
children: "Alphabetical, asc"
|
|
306
|
+
}),
|
|
307
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
308
|
+
value: "alphabetical-desc",
|
|
309
|
+
children: "Alphabetical, desc"
|
|
310
|
+
}),
|
|
311
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
312
|
+
value: "numerical-asc",
|
|
313
|
+
children: "Numerical, asc"
|
|
314
|
+
}),
|
|
315
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
316
|
+
value: "numerical-desc",
|
|
317
|
+
children: "Numerical, desc"
|
|
318
|
+
}),
|
|
319
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
320
|
+
value: "alphabetical-ci-asc",
|
|
321
|
+
children: "Alphabetical, case-insensitive, asc"
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
324
|
+
value: "alphabetical-ci-desc",
|
|
325
|
+
children: "Alphabetical, case-insensitive, desc"
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
]
|
|
333
|
+
}),
|
|
334
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {}),
|
|
335
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
336
|
+
py: 1,
|
|
337
|
+
variant: "subtitle1",
|
|
338
|
+
children: "Dropdown Options"
|
|
339
|
+
}),
|
|
340
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
341
|
+
spacing: "2",
|
|
342
|
+
children: [
|
|
343
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
344
|
+
children: [
|
|
345
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
346
|
+
control: control,
|
|
347
|
+
name: "spec.allowMultiple",
|
|
348
|
+
render: ({ field })=>/*#__PURE__*/ {
|
|
349
|
+
var _field_value;
|
|
350
|
+
return (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
351
|
+
label: "Allow Multiple Values",
|
|
352
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
353
|
+
...field,
|
|
354
|
+
checked: !!field.value,
|
|
355
|
+
readOnly: action === 'read',
|
|
356
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
|
|
357
|
+
onChange: (event)=>{
|
|
358
|
+
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
359
|
+
field.onChange(event);
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
366
|
+
variant: "caption",
|
|
367
|
+
children: "Enables multiple values to be selected at the same time"
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}),
|
|
371
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
372
|
+
children: [
|
|
373
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
374
|
+
control: control,
|
|
375
|
+
name: "spec.allowAllValue",
|
|
376
|
+
render: ({ field })=>/*#__PURE__*/ {
|
|
377
|
+
var _field_value;
|
|
378
|
+
return (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
379
|
+
label: "Allow All option",
|
|
380
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
381
|
+
...field,
|
|
382
|
+
checked: !!field.value,
|
|
383
|
+
readOnly: action === 'read',
|
|
384
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
|
|
385
|
+
onChange: (event)=>{
|
|
386
|
+
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
387
|
+
field.onChange(event);
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
394
|
+
mb: 1,
|
|
395
|
+
variant: "caption",
|
|
396
|
+
children: "Enables an option to include all variable values"
|
|
397
|
+
}),
|
|
398
|
+
_allowAllValue && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
399
|
+
control: control,
|
|
400
|
+
name: "spec.customAllValue",
|
|
401
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
402
|
+
var _fieldState_error;
|
|
403
|
+
var _field_value;
|
|
404
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
405
|
+
...field,
|
|
406
|
+
fullWidth: true,
|
|
407
|
+
label: "Custom All Value",
|
|
408
|
+
InputLabelProps: {
|
|
409
|
+
shrink: action === 'read' ? true : undefined
|
|
410
|
+
},
|
|
411
|
+
InputProps: {
|
|
412
|
+
readOnly: action === 'read'
|
|
413
|
+
},
|
|
414
|
+
error: !!fieldState.error,
|
|
415
|
+
helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
|
|
416
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
417
|
+
onChange: (event)=>{
|
|
418
|
+
if (event.target.value === '') {
|
|
419
|
+
field.onChange(undefined);
|
|
420
|
+
} else {
|
|
421
|
+
field.onChange(event);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
})
|
|
429
|
+
]
|
|
430
|
+
})
|
|
431
|
+
]
|
|
432
|
+
});
|
|
433
|
+
}
|
|
82
434
|
function VariableEditorForm(props) {
|
|
83
435
|
const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
|
|
84
|
-
const initialState = (0, _variableeditorformmodel.getInitialState)(initialVariableDefinition);
|
|
85
|
-
const [state, setState] = (0, _useimmer.useImmer)(initialState);
|
|
86
436
|
const [isDiscardDialogOpened, setDiscardDialogOpened] = (0, _react.useState)(false);
|
|
87
|
-
const [previewKey, setPreviewKey] = (0, _react.useState)(0);
|
|
88
437
|
const [action, setAction] = (0, _react.useState)(initialAction);
|
|
89
|
-
const refreshPreview = ()=>{
|
|
90
|
-
setPreviewKey((prev)=>prev + 1);
|
|
91
|
-
};
|
|
92
|
-
/** We use the `previewKey` that we increment to know when to explicitly update the
|
|
93
|
-
* spec that will be used for preview. The reason why we do this is to avoid
|
|
94
|
-
* having to re-fetch the values when the user is still editing the spec.
|
|
95
|
-
*/ const previewSpec = (0, _react.useMemo)(()=>{
|
|
96
|
-
return (0, _variableeditorformmodel.getVariableDefinitionFromState)(state);
|
|
97
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
-
}, [
|
|
99
|
-
previewKey
|
|
100
|
-
]);
|
|
101
438
|
const titleAction = (0, _utils.getTitleAction)(action, isDraft);
|
|
102
439
|
const submitText = (0, _utils.getSubmitText)(action, isDraft);
|
|
440
|
+
const { variableEditorSchema } = (0, _context.useValidationSchemas)();
|
|
103
441
|
const form = (0, _reacthookform.useForm)({
|
|
104
|
-
resolver: (0, _zod.zodResolver)(
|
|
442
|
+
resolver: (0, _zod.zodResolver)(variableEditorSchema),
|
|
105
443
|
mode: 'onBlur',
|
|
106
|
-
defaultValues:
|
|
444
|
+
defaultValues: initialVariableDefinition
|
|
107
445
|
});
|
|
108
|
-
const
|
|
446
|
+
const kind = (0, _reacthookform.useWatch)({
|
|
447
|
+
control: form.control,
|
|
448
|
+
name: 'kind'
|
|
449
|
+
});
|
|
450
|
+
function clearFormData(data) {
|
|
451
|
+
var _result_spec_display, _result_spec_display1, _result_spec_display2;
|
|
452
|
+
const result = {
|
|
453
|
+
...data
|
|
454
|
+
};
|
|
455
|
+
if (((_result_spec_display = result.spec.display) === null || _result_spec_display === void 0 ? void 0 : _result_spec_display.name) === undefined && ((_result_spec_display1 = result.spec.display) === null || _result_spec_display1 === void 0 ? void 0 : _result_spec_display1.description) === undefined && ((_result_spec_display2 = result.spec.display) === null || _result_spec_display2 === void 0 ? void 0 : _result_spec_display2.hidden) === undefined) {
|
|
456
|
+
delete result.spec.display;
|
|
457
|
+
}
|
|
458
|
+
return result;
|
|
459
|
+
}
|
|
460
|
+
const processForm = (data)=>{
|
|
109
461
|
// reset display attributes to undefined when empty, because we don't want to save empty strings
|
|
110
|
-
onSave((
|
|
111
|
-
...state,
|
|
112
|
-
title: state.title === '' ? undefined : state.title,
|
|
113
|
-
description: state.description === '' ? undefined : state.description
|
|
114
|
-
}));
|
|
462
|
+
onSave(clearFormData(data));
|
|
115
463
|
};
|
|
116
464
|
// When user click on cancel, several possibilities:
|
|
117
465
|
// - create action: ask for discard approval
|
|
118
466
|
// - update action: ask for discard approval if changed
|
|
119
467
|
// - read action: don´t ask for discard approval
|
|
120
|
-
|
|
121
|
-
if (JSON.stringify(
|
|
468
|
+
function handleCancel() {
|
|
469
|
+
if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {
|
|
122
470
|
setDiscardDialogOpened(true);
|
|
123
471
|
} else {
|
|
124
472
|
onClose();
|
|
125
473
|
}
|
|
126
|
-
}
|
|
127
|
-
initialState,
|
|
128
|
-
state,
|
|
129
|
-
onClose
|
|
130
|
-
]);
|
|
474
|
+
}
|
|
131
475
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacthookform.FormProvider, {
|
|
132
476
|
...form,
|
|
133
477
|
children: [
|
|
@@ -220,10 +564,12 @@ function VariableEditorForm(props) {
|
|
|
220
564
|
item: true,
|
|
221
565
|
xs: 8,
|
|
222
566
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
223
|
-
|
|
224
|
-
|
|
567
|
+
control: form.control,
|
|
568
|
+
name: "spec.name",
|
|
569
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
225
570
|
var _fieldState_error;
|
|
226
|
-
|
|
571
|
+
var _field_value;
|
|
572
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
227
573
|
...field,
|
|
228
574
|
required: true,
|
|
229
575
|
fullWidth: true,
|
|
@@ -237,12 +583,9 @@ function VariableEditorForm(props) {
|
|
|
237
583
|
},
|
|
238
584
|
error: !!fieldState.error,
|
|
239
585
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
240
|
-
value:
|
|
586
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
241
587
|
onChange: (event)=>{
|
|
242
588
|
field.onChange(event);
|
|
243
|
-
setState((draft)=>{
|
|
244
|
-
draft.name = event.target.value;
|
|
245
|
-
});
|
|
246
589
|
}
|
|
247
590
|
});
|
|
248
591
|
}
|
|
@@ -252,10 +595,11 @@ function VariableEditorForm(props) {
|
|
|
252
595
|
item: true,
|
|
253
596
|
xs: 4,
|
|
254
597
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
255
|
-
|
|
598
|
+
control: form.control,
|
|
599
|
+
name: "spec.display.name",
|
|
256
600
|
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
257
601
|
var _fieldState_error;
|
|
258
|
-
var
|
|
602
|
+
var _field_value;
|
|
259
603
|
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
260
604
|
...field,
|
|
261
605
|
fullWidth: true,
|
|
@@ -268,12 +612,9 @@ function VariableEditorForm(props) {
|
|
|
268
612
|
},
|
|
269
613
|
error: !!fieldState.error,
|
|
270
614
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
271
|
-
value: (
|
|
615
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
272
616
|
onChange: (event)=>{
|
|
273
617
|
field.onChange(event);
|
|
274
|
-
setState((draft)=>{
|
|
275
|
-
draft.title = event.target.value;
|
|
276
|
-
});
|
|
277
618
|
}
|
|
278
619
|
});
|
|
279
620
|
}
|
|
@@ -283,10 +624,11 @@ function VariableEditorForm(props) {
|
|
|
283
624
|
item: true,
|
|
284
625
|
xs: 8,
|
|
285
626
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
286
|
-
|
|
627
|
+
control: form.control,
|
|
628
|
+
name: "spec.display.description",
|
|
287
629
|
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
288
630
|
var _fieldState_error;
|
|
289
|
-
var
|
|
631
|
+
var _field_value;
|
|
290
632
|
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
291
633
|
...field,
|
|
292
634
|
fullWidth: true,
|
|
@@ -299,12 +641,9 @@ function VariableEditorForm(props) {
|
|
|
299
641
|
},
|
|
300
642
|
error: !!fieldState.error,
|
|
301
643
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
302
|
-
value: (
|
|
644
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
303
645
|
onChange: (event)=>{
|
|
304
646
|
field.onChange(event);
|
|
305
|
-
setState((draft)=>{
|
|
306
|
-
draft.description = event.target.value;
|
|
307
|
-
});
|
|
308
647
|
}
|
|
309
648
|
});
|
|
310
649
|
}
|
|
@@ -314,10 +653,12 @@ function VariableEditorForm(props) {
|
|
|
314
653
|
item: true,
|
|
315
654
|
xs: 4,
|
|
316
655
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
656
|
+
control: form.control,
|
|
317
657
|
name: "kind",
|
|
318
|
-
render: ({ field, fieldState })
|
|
658
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
319
659
|
var _fieldState_error;
|
|
320
|
-
|
|
660
|
+
var _field_value;
|
|
661
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
321
662
|
select: true,
|
|
322
663
|
...field,
|
|
323
664
|
fullWidth: true,
|
|
@@ -330,12 +671,9 @@ function VariableEditorForm(props) {
|
|
|
330
671
|
},
|
|
331
672
|
error: !!fieldState.error,
|
|
332
673
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
333
|
-
value:
|
|
674
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'TextVariable',
|
|
334
675
|
onChange: (event)=>{
|
|
335
676
|
field.onChange(event);
|
|
336
|
-
setState((draft)=>{
|
|
337
|
-
draft.kind = event.target.value;
|
|
338
|
-
});
|
|
339
677
|
},
|
|
340
678
|
children: _variablemodel.VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
341
679
|
value: v.kind,
|
|
@@ -348,325 +686,19 @@ function VariableEditorForm(props) {
|
|
|
348
686
|
]
|
|
349
687
|
}),
|
|
350
688
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {}),
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}),
|
|
358
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
359
|
-
spacing: 2,
|
|
360
|
-
children: [
|
|
361
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
362
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
|
|
363
|
-
values: [
|
|
364
|
-
state.textVariableFields.value
|
|
365
|
-
]
|
|
366
|
-
})
|
|
367
|
-
}),
|
|
368
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
369
|
-
name: "textVariableFields.value",
|
|
370
|
-
render: ({ field, fieldState })=>{
|
|
371
|
-
var _fieldState_error;
|
|
372
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
373
|
-
...field,
|
|
374
|
-
label: "Value",
|
|
375
|
-
InputLabelProps: {
|
|
376
|
-
shrink: action === 'read' ? true : undefined
|
|
377
|
-
},
|
|
378
|
-
InputProps: {
|
|
379
|
-
readOnly: action === 'read'
|
|
380
|
-
},
|
|
381
|
-
error: !!fieldState.error,
|
|
382
|
-
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
383
|
-
value: state.textVariableFields.value,
|
|
384
|
-
onChange: (event)=>{
|
|
385
|
-
field.onChange(event);
|
|
386
|
-
setState((draft)=>{
|
|
387
|
-
draft.textVariableFields.value = event.target.value;
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
}),
|
|
393
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
394
|
-
name: "textVariableFields.constant",
|
|
395
|
-
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
396
|
-
label: "Constant",
|
|
397
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
398
|
-
...field,
|
|
399
|
-
checked: !!field.value,
|
|
400
|
-
readOnly: action === 'read',
|
|
401
|
-
value: state.textVariableFields.constant,
|
|
402
|
-
onChange: (event)=>{
|
|
403
|
-
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
404
|
-
field.onChange(event);
|
|
405
|
-
setState((draft)=>{
|
|
406
|
-
draft.textVariableFields.constant = event.target.checked;
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
})
|
|
410
|
-
})
|
|
411
|
-
})
|
|
412
|
-
]
|
|
413
|
-
})
|
|
414
|
-
]
|
|
689
|
+
kind === 'TextVariable' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
690
|
+
FallbackComponent: _components.ErrorAlert,
|
|
691
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(TextVariableEditorForm, {
|
|
692
|
+
action: action,
|
|
693
|
+
control: form.control
|
|
694
|
+
})
|
|
415
695
|
}),
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}),
|
|
423
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
424
|
-
spacing: 2,
|
|
425
|
-
mb: 2,
|
|
426
|
-
children: [
|
|
427
|
-
state.listVariableFields.plugin.kind ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
428
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
429
|
-
FallbackComponent: FallbackPreview,
|
|
430
|
-
resetKeys: [
|
|
431
|
-
previewSpec
|
|
432
|
-
],
|
|
433
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariableListPreview, {
|
|
434
|
-
definition: previewSpec,
|
|
435
|
-
onRefresh: refreshPreview
|
|
436
|
-
})
|
|
437
|
-
})
|
|
438
|
-
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
|
|
439
|
-
isLoading: true
|
|
440
|
-
}),
|
|
441
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
442
|
-
children: [
|
|
443
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ClickAwayListener, {
|
|
444
|
-
onClickAway: ()=>refreshPreview(),
|
|
445
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {})
|
|
446
|
-
}),
|
|
447
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
448
|
-
name: "listVariableFields.plugin",
|
|
449
|
-
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
|
|
450
|
-
width: "100%",
|
|
451
|
-
pluginTypes: [
|
|
452
|
-
'Variable'
|
|
453
|
-
],
|
|
454
|
-
pluginKindLabel: "Source",
|
|
455
|
-
isReadonly: action === 'read',
|
|
456
|
-
value: {
|
|
457
|
-
selection: {
|
|
458
|
-
kind: state.listVariableFields.plugin.kind,
|
|
459
|
-
type: 'Variable'
|
|
460
|
-
},
|
|
461
|
-
spec: state.listVariableFields.plugin.spec
|
|
462
|
-
},
|
|
463
|
-
onChange: (val)=>{
|
|
464
|
-
field.onChange({
|
|
465
|
-
spec: val.spec,
|
|
466
|
-
kind: val.selection.kind
|
|
467
|
-
});
|
|
468
|
-
setState((draft)=>{
|
|
469
|
-
draft.listVariableFields.plugin.kind = val.selection.kind;
|
|
470
|
-
draft.listVariableFields.plugin.spec = val.spec;
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
})
|
|
474
|
-
})
|
|
475
|
-
]
|
|
476
|
-
}),
|
|
477
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
478
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
479
|
-
name: "listVariableFields.capturingRegexp",
|
|
480
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
481
|
-
var _fieldState_error;
|
|
482
|
-
var _state_listVariableFields_capturingRegexp;
|
|
483
|
-
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
484
|
-
...field,
|
|
485
|
-
label: "Capturing Regexp Filter",
|
|
486
|
-
InputLabelProps: {
|
|
487
|
-
shrink: action === 'read' ? true : undefined
|
|
488
|
-
},
|
|
489
|
-
InputProps: {
|
|
490
|
-
readOnly: action === 'read'
|
|
491
|
-
},
|
|
492
|
-
error: !!fieldState.error,
|
|
493
|
-
value: (_state_listVariableFields_capturingRegexp = state.listVariableFields.capturingRegexp) !== null && _state_listVariableFields_capturingRegexp !== void 0 ? _state_listVariableFields_capturingRegexp : '',
|
|
494
|
-
onChange: (event)=>{
|
|
495
|
-
field.onChange(event);
|
|
496
|
-
setState((draft)=>{
|
|
497
|
-
if (event.target.value) {
|
|
498
|
-
// TODO: do a better fix, if empty string => it should skip the filter
|
|
499
|
-
draft.listVariableFields.capturingRegexp = event.target.value;
|
|
500
|
-
} else {
|
|
501
|
-
draft.listVariableFields.capturingRegexp = undefined;
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
},
|
|
505
|
-
helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
})
|
|
509
|
-
}),
|
|
510
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
511
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
512
|
-
name: "listVariableFields.sort",
|
|
513
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
514
|
-
var _fieldState_error;
|
|
515
|
-
var _state_listVariableFields_sort;
|
|
516
|
-
return (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
517
|
-
select: true,
|
|
518
|
-
...field,
|
|
519
|
-
fullWidth: true,
|
|
520
|
-
label: "Sort",
|
|
521
|
-
InputLabelProps: {
|
|
522
|
-
shrink: action === 'read' ? true : undefined
|
|
523
|
-
},
|
|
524
|
-
InputProps: {
|
|
525
|
-
readOnly: action === 'read'
|
|
526
|
-
},
|
|
527
|
-
error: !!fieldState.error,
|
|
528
|
-
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
529
|
-
value: (_state_listVariableFields_sort = state.listVariableFields.sort) !== null && _state_listVariableFields_sort !== void 0 ? _state_listVariableFields_sort : 'none',
|
|
530
|
-
onChange: (event)=>{
|
|
531
|
-
field.onChange(event);
|
|
532
|
-
setState((draft)=>{
|
|
533
|
-
draft.listVariableFields.sort = event.target.value;
|
|
534
|
-
});
|
|
535
|
-
},
|
|
536
|
-
children: [
|
|
537
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
538
|
-
value: "none",
|
|
539
|
-
children: "None"
|
|
540
|
-
}),
|
|
541
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
542
|
-
value: "alphabetical-asc",
|
|
543
|
-
children: "Alphabetical, asc"
|
|
544
|
-
}),
|
|
545
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
546
|
-
value: "alphabetical-desc",
|
|
547
|
-
children: "Alphabetical, desc"
|
|
548
|
-
}),
|
|
549
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
550
|
-
value: "numerical-asc",
|
|
551
|
-
children: "Numerical, asc"
|
|
552
|
-
}),
|
|
553
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
554
|
-
value: "numerical-desc",
|
|
555
|
-
children: "Numerical, desc"
|
|
556
|
-
}),
|
|
557
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
558
|
-
value: "alphabetical-ci-asc",
|
|
559
|
-
children: "Alphabetical, case-insensitive, asc"
|
|
560
|
-
}),
|
|
561
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
562
|
-
value: "alphabetical-ci-desc",
|
|
563
|
-
children: "Alphabetical, case-insensitive, desc"
|
|
564
|
-
})
|
|
565
|
-
]
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
})
|
|
569
|
-
})
|
|
570
|
-
]
|
|
571
|
-
}),
|
|
572
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {}),
|
|
573
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
574
|
-
py: 1,
|
|
575
|
-
variant: "subtitle1",
|
|
576
|
-
children: "Dropdown Options"
|
|
577
|
-
}),
|
|
578
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
579
|
-
spacing: "2",
|
|
580
|
-
children: [
|
|
581
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
582
|
-
children: [
|
|
583
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
584
|
-
name: "listVariableFields.allowMultiple",
|
|
585
|
-
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
586
|
-
label: "Allow Multiple Values",
|
|
587
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
588
|
-
...field,
|
|
589
|
-
checked: !!field.value,
|
|
590
|
-
readOnly: action === 'read',
|
|
591
|
-
value: state.listVariableFields.allowMultiple,
|
|
592
|
-
onChange: (event)=>{
|
|
593
|
-
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
594
|
-
field.onChange(event);
|
|
595
|
-
setState((draft)=>{
|
|
596
|
-
draft.listVariableFields.allowMultiple = event.target.checked;
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
})
|
|
600
|
-
})
|
|
601
|
-
}),
|
|
602
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
603
|
-
variant: "caption",
|
|
604
|
-
children: "Enables multiple values to be selected at the same time"
|
|
605
|
-
})
|
|
606
|
-
]
|
|
607
|
-
}),
|
|
608
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
609
|
-
children: [
|
|
610
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
611
|
-
name: "listVariableFields.allowAllValue",
|
|
612
|
-
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
613
|
-
label: "Allow All option",
|
|
614
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
615
|
-
...field,
|
|
616
|
-
checked: !!field.value,
|
|
617
|
-
readOnly: action === 'read',
|
|
618
|
-
value: state.listVariableFields.allowAllValue,
|
|
619
|
-
onChange: (event)=>{
|
|
620
|
-
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
621
|
-
field.onChange(event);
|
|
622
|
-
setState((draft)=>{
|
|
623
|
-
draft.listVariableFields.allowAllValue = event.target.checked;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
})
|
|
627
|
-
})
|
|
628
|
-
}),
|
|
629
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
630
|
-
mb: 1,
|
|
631
|
-
variant: "caption",
|
|
632
|
-
children: "Enables an option to include all variable values"
|
|
633
|
-
}),
|
|
634
|
-
state.listVariableFields.allowAllValue && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
635
|
-
name: "listVariableFields.customAllValue",
|
|
636
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
637
|
-
var _fieldState_error;
|
|
638
|
-
var _state_listVariableFields_customAllValue;
|
|
639
|
-
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
640
|
-
...field,
|
|
641
|
-
fullWidth: true,
|
|
642
|
-
label: "Custom All Value",
|
|
643
|
-
InputLabelProps: {
|
|
644
|
-
shrink: action === 'read' ? true : undefined
|
|
645
|
-
},
|
|
646
|
-
InputProps: {
|
|
647
|
-
readOnly: action === 'read'
|
|
648
|
-
},
|
|
649
|
-
error: !!fieldState.error,
|
|
650
|
-
helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
|
|
651
|
-
value: (_state_listVariableFields_customAllValue = state.listVariableFields.customAllValue) !== null && _state_listVariableFields_customAllValue !== void 0 ? _state_listVariableFields_customAllValue : '',
|
|
652
|
-
onChange: (event)=>{
|
|
653
|
-
field.onChange(event);
|
|
654
|
-
setState((draft)=>{
|
|
655
|
-
if (event.target.value) {
|
|
656
|
-
draft.listVariableFields.customAllValue = event.target.value;
|
|
657
|
-
} else {
|
|
658
|
-
draft.listVariableFields.customAllValue = undefined;
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
})
|
|
665
|
-
]
|
|
666
|
-
})
|
|
667
|
-
]
|
|
668
|
-
})
|
|
669
|
-
]
|
|
696
|
+
kind === 'ListVariable' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
697
|
+
FallbackComponent: _components.ErrorAlert,
|
|
698
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ListVariableEditorForm, {
|
|
699
|
+
action: action,
|
|
700
|
+
control: form.control
|
|
701
|
+
})
|
|
670
702
|
})
|
|
671
703
|
]
|
|
672
704
|
}),
|