@grafana/k6-test-builder 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChangeEventHandler, FocusEventHandler, AnchorHTMLAttributes, ReactNode, ElementType, ReactElement, FunctionComponent } from "react";
1
+ import { FocusEventHandler, AnchorHTMLAttributes, ReactNode, ElementType, ReactElement, FunctionComponent } from "react";
2
2
  import { InvalidArchiveError } from "har-to-k6";
3
3
  import { ThemeOptions } from "@material-ui/core/styles/createTheme";
4
4
  /** @todo move this type */
@@ -276,10 +276,11 @@ interface ConstrainedRange {
276
276
  value: string;
277
277
  }
278
278
  declare const CONSTRAINED_RANGE_BODY = "CONSTRAINED_RANGE_BODY";
279
- type ScriptEditorMode = 'test' | 'scenario';
279
+ type ScriptEditorMode = 'test' | 'scenario' | 'body.json' | 'body.text';
280
+ type ValueChangeHandler = (value: string) => void;
280
281
  /** @todo Create interface that fits cloud app and plugin */
281
282
  export interface ScriptEditorProps {
282
- mode?: ScriptEditorMode;
283
+ mode: ScriptEditorMode;
283
284
  scenario?: ScriptScenarioConfig;
284
285
  imports?: string[];
285
286
  filename?: string;
@@ -288,12 +289,13 @@ export interface ScriptEditorProps {
288
289
  value: string;
289
290
  template?: string;
290
291
  constrainedRanges?: ConstrainedRange[];
291
- onChange?: ChangeEventHandler<HTMLTextAreaElement> | ConstrainedRangeChange;
292
- onBodyChange?: (value: string) => void;
292
+ onChange?: ValueChangeHandler;
293
+ onBodyChange?: ConstrainedRangeChange;
293
294
  onBlur?: FocusEventHandler<HTMLTextAreaElement>;
294
295
  error?: Error;
295
296
  readOnly?: boolean;
296
297
  onImportsChange?: (imports: string[]) => void;
298
+ nodeId?: string;
297
299
  }
298
300
  interface DocsLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
299
301
  article: DocsArticleLink;
@@ -330,8 +332,9 @@ interface TestBuilderStandaloneProps {
330
332
  StagesVirtualizationComponent?: (props: StagesVirtualizationComponentProps) => ReactElement;
331
333
  ScriptEditorComponent?: (props: ScriptEditorProps) => ReactElement;
332
334
  TestBuilderIconComponent?: typeof TestBuilderIcon;
335
+ readonlyScriptScenarios?: boolean;
333
336
  }
334
- export function TestBuilder({ loading, saving, k6Test, hasCloudExecution, availableLoadZones, DocsLinkComponent, onViewChange, StagesVirtualizationComponent, ScriptEditorComponent, TestBuilderIconComponent }: TestBuilderStandaloneProps): JSX.Element;
337
+ export function TestBuilder({ loading, saving, k6Test, hasCloudExecution, availableLoadZones, DocsLinkComponent, onViewChange, StagesVirtualizationComponent, ScriptEditorComponent, TestBuilderIconComponent, readonlyScriptScenarios, }: TestBuilderStandaloneProps): JSX.Element;
335
338
  interface TestMetaInformationProps {
336
339
  className?: string;
337
340
  }
package/dist/index.js CHANGED
@@ -551,15 +551,9 @@ function $40f0f8d1d1c69699$export$18972e718224868c(template, constrainedRanges)
551
551
  }
552
552
 
553
553
 
554
- function $ab0bf6ee71c94953$export$32efa5142ae8aa01({ value: value , onChange: onChange , onBlur: onBlur , error: error , mode: mode = "test" , template: template = "" , constrainedRanges: constrainedRanges }) {
555
- const [proxyValue, setProxyValue] = (0, $gkIgo$react.useState)(value || "");
554
+ function $ab0bf6ee71c94953$export$32efa5142ae8aa01({ value: value , onChange: onChange , onBlur: onBlur , error: error , mode: mode = "test" , template: template = "" , constrainedRanges: constrainedRanges , readOnly: readOnly = false }) {
556
555
  const [script, setScript] = (0, $gkIgo$react.useState)("");
557
556
  if (!onChange && !onBlur) (0, $1c4cc247633c6592$export$af88d00dbe7f521).warn("Using fallback ScriptEditor");
558
- (0, $gkIgo$react.useEffect)(()=>{
559
- if (value !== proxyValue) setProxyValue(value);
560
- }, [
561
- value
562
- ]);
563
557
  (0, $gkIgo$react.useEffect)(()=>{
564
558
  if (mode === "scenario") {
565
559
  if (constrainedRanges && typeof template === "string") setScript((0, $40f0f8d1d1c69699$export$18972e718224868c)(template, constrainedRanges));
@@ -569,9 +563,9 @@ function $ab0bf6ee71c94953$export$32efa5142ae8aa01({ value: value , onChange: on
569
563
  constrainedRanges,
570
564
  template
571
565
  ]);
572
- const editorValue = mode === "scenario" ? script : proxyValue;
566
+ const editorValue = mode === "scenario" ? script : value;
573
567
  const handleOnChange = (event)=>{
574
- setProxyValue(event.target.value);
568
+ if (mode !== "scenario") onChange && onChange(event.target.value);
575
569
  };
576
570
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsxs)((0, $gkIgo$reactjsxruntime.Fragment), {
577
571
  children: [
@@ -591,7 +585,7 @@ function $ab0bf6ee71c94953$export$32efa5142ae8aa01({ value: value , onChange: on
591
585
  /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $10c3bf49b890a81c$export$ad9254163fa4ee24), {
592
586
  defaultValue: editorValue,
593
587
  onChange: handleOnChange,
594
- readOnly: true
588
+ readOnly: readOnly
595
589
  })
596
590
  ]
597
591
  });
@@ -1397,52 +1391,27 @@ const $37e9b7f5f658460f$export$a86f095b9b6dae = /*#__PURE__*/ (0, ($parcel$inter
1397
1391
  })([
1398
1392
  "grid-column:1 / span 3;position:sticky;bottom:-10px;"
1399
1393
  ]);
1400
- const $37e9b7f5f658460f$export$50590ad6c03e5bd7 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents)))($37e9b7f5f658460f$export$f86d68f7ed25f5bb).withConfig({
1401
- displayName: "styled__AdvancedSettingsContainer",
1402
- componentId: "sc-78krzf-7"
1403
- })([
1404
- ""
1405
- ]);
1406
- const $37e9b7f5f658460f$export$e5c1a6ed3fbdc322 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents))).div.withConfig({
1407
- displayName: "styled__LabelColumn",
1408
- componentId: "sc-78krzf-8"
1409
- })([
1410
- "display:flex;flex-direction:column;"
1411
- ]);
1412
- const $37e9b7f5f658460f$export$ce4908ada21f6533 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents)))($37e9b7f5f658460f$export$e5c1a6ed3fbdc322).withConfig({
1413
- displayName: "styled__InputColumn",
1414
- componentId: "sc-78krzf-9"
1415
- })([
1416
- "flex:1 1 100%;"
1417
- ]);
1418
1394
  const $37e9b7f5f658460f$export$b04be29aa201d4f5 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents)))((0, $8c4e1b935d327ac5$export$842aba50ed0ce9d7)).withConfig({
1419
1395
  displayName: "styled__Label",
1420
- componentId: "sc-78krzf-10"
1396
+ componentId: "sc-78krzf-7"
1421
1397
  })([
1422
1398
  "display:flex;justify-self:right;align-self:center;"
1423
1399
  ]);
1424
- const $37e9b7f5f658460f$export$e7a98f51c6efe634 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents)))($37e9b7f5f658460f$export$b04be29aa201d4f5).withConfig({
1425
- displayName: "styled__ErrorLabel",
1426
- componentId: "sc-78krzf-11"
1427
- })([
1428
- "opacity:1;color:",
1429
- ";"
1430
- ], ({ theme: theme })=>theme.palette.error.main);
1431
1400
  const $37e9b7f5f658460f$export$3f6e3839f387b50 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents))).div.withConfig({
1432
1401
  displayName: "styled__RequestInputContainer",
1433
- componentId: "sc-78krzf-12"
1402
+ componentId: "sc-78krzf-8"
1434
1403
  })([
1435
1404
  "display:flex;position:relative;& > :nth-child(1){flex-basis:150px;}"
1436
1405
  ]);
1437
1406
  const $37e9b7f5f658460f$export$93e9fa14a08d2dd1 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents))).span.withConfig({
1438
1407
  displayName: "styled__EndAdornmentContainer",
1439
- componentId: "sc-78krzf-13"
1408
+ componentId: "sc-78krzf-9"
1440
1409
  })([
1441
1410
  "padding-left:8px;"
1442
1411
  ]);
1443
1412
  const $37e9b7f5f658460f$export$e7e6b99c949fd18a = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents)))((0, ($parcel$interopDefault($gkIgo$materialuicoreSelect)))).withConfig({
1444
1413
  displayName: "styled__StyledSelect",
1445
- componentId: "sc-78krzf-14"
1414
+ componentId: "sc-78krzf-10"
1446
1415
  })([
1447
1416
  "align-self:stretch;display:flex;align-items:center;[class*='MuiSelect-icon']{color:currentColor;}[class*='MuiInputBase-root']{height:auto;}[class*='MuiOutlinedInput-input']{padding:0 10px;color:#fff !important;}[class*='MuiOutlinedInput-root']{border:0 !important;}",
1448
1417
  ";"
@@ -1456,14 +1425,14 @@ const $37e9b7f5f658460f$export$e7e6b99c949fd18a = /*#__PURE__*/ (0, ($parcel$int
1456
1425
  });
1457
1426
  const $37e9b7f5f658460f$export$2191b9da168c6cf0 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents))).span.withConfig({
1458
1427
  displayName: "styled__ValidationError",
1459
- componentId: "sc-78krzf-15"
1428
+ componentId: "sc-78krzf-11"
1460
1429
  })([
1461
1430
  "font-size:13px;color:",
1462
1431
  ";"
1463
1432
  ], ({ theme: theme })=>theme.palette.error.main);
1464
1433
  const $37e9b7f5f658460f$export$d7a2349e1b0bdcb7 = /*#__PURE__*/ (0, ($parcel$interopDefault($gkIgo$styledcomponents))).div.withConfig({
1465
1434
  displayName: "styled__NodeContainer",
1466
- componentId: "sc-78krzf-16"
1435
+ componentId: "sc-78krzf-12"
1467
1436
  })([
1468
1437
  "display:flex;flex-direction:column;position:relative;"
1469
1438
  ]);
@@ -5196,6 +5165,7 @@ function $cdee3562a1fa264f$export$9cc0a26cbe829bcb() {
5196
5165
  }
5197
5166
  };
5198
5167
  }, [
5168
+ dispatch,
5199
5169
  tab
5200
5170
  ]);
5201
5171
  }
@@ -5205,6 +5175,7 @@ function $cdee3562a1fa264f$export$e3a1a4f1e85dc208() {
5205
5175
  (0, $gkIgo$react.useEffect)(()=>{
5206
5176
  dispatch((0, $eeeed770fbbe0766$export$f89a1b8f393b8bb6)(Boolean(hasCloudExecution)));
5207
5177
  }, [
5178
+ dispatch,
5208
5179
  hasCloudExecution
5209
5180
  ]);
5210
5181
  (0, $gkIgo$react.useEffect)(()=>{
@@ -5218,11 +5189,13 @@ function $cdee3562a1fa264f$export$e3a1a4f1e85dc208() {
5218
5189
  const [firstScenario] = scenarios;
5219
5190
  if (firstScenario) dispatch((0, $eeeed770fbbe0766$export$78fa5045d0400717)(`scenario/${firstScenario.id}`));
5220
5191
  }, [
5192
+ dispatch,
5221
5193
  k6Test
5222
5194
  ]);
5223
5195
  (0, $gkIgo$react.useEffect)(()=>{
5224
5196
  dispatch((0, $eeeed770fbbe0766$export$9f9f33201c1586de)(availableLoadZones));
5225
5197
  }, [
5198
+ dispatch,
5226
5199
  availableLoadZones
5227
5200
  ]);
5228
5201
  }
@@ -6433,7 +6406,9 @@ function $d760132412dc68e3$export$fb4216da1f591b95({ name: name = (0, $gkIgo$red
6433
6406
  null
6434
6407
  ] , checked: checked , onChange: onChange , className: className , disabled: disabled = false }) {
6435
6408
  const [labelOff, labelOn] = labels;
6436
- const id = (0, $gkIgo$react.useMemo)(()=>`id_${name}`, []);
6409
+ const id = (0, $gkIgo$react.useMemo)(()=>`id_${name}`, [
6410
+ name
6411
+ ]);
6437
6412
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsxs)($d760132412dc68e3$var$StyledWrapper, {
6438
6413
  className: className,
6439
6414
  $disabled: disabled,
@@ -7273,13 +7248,13 @@ const $ac2f6d2ef648627b$var$LoadZoneItem = /*#__PURE__*/ (0, ($parcel$interopDef
7273
7248
  })([
7274
7249
  "display:inline-flex;align-items:center;> svg{margin-right:8px;}"
7275
7250
  ]);
7276
- function $ac2f6d2ef648627b$export$a977df6ccef00812({ disabledValues: disabledValues = [] , ...props }) {
7251
+ function $ac2f6d2ef648627b$export$a977df6ccef00812({ disabledValues: disabledValues , ...props }) {
7277
7252
  const { availableLoadZones: availableLoadZones } = (0, $b0053bc75d27f892$export$8bcb3cb1ba0d67a7)();
7278
7253
  const options = (0, $gkIgo$react.useMemo)(()=>{
7279
7254
  return availableLoadZones.map((loadZone)=>{
7280
7255
  const { k6_load_zone_id: k6_load_zone_id , city: city , country: country } = loadZone;
7281
7256
  return {
7282
- disabled: disabledValues.includes(k6_load_zone_id),
7257
+ disabled: (disabledValues || []).includes(k6_load_zone_id),
7283
7258
  value: k6_load_zone_id,
7284
7259
  label: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsxs)($ac2f6d2ef648627b$var$LoadZoneItem, {
7285
7260
  children: [
@@ -7296,6 +7271,7 @@ function $ac2f6d2ef648627b$export$a977df6ccef00812({ disabledValues: disabledVal
7296
7271
  };
7297
7272
  });
7298
7273
  }, [
7274
+ disabledValues,
7299
7275
  availableLoadZones
7300
7276
  ]);
7301
7277
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $df621c65e95d0d5b$export$ef9b1a59e592288f), {
@@ -7794,7 +7770,10 @@ const $4efcda42d6ce57af$export$9a75ed5a99cf0511 = (props)=>{
7794
7770
  // Set URL to default '' if the request with the selected URL has been deleted/modified
7795
7771
  if (url !== "" && url !== "all" && !requestsURLs.includes(url)) dispatch((0, $f51ad74c1a393c6c$export$7a98fbd10fd8a51f)(index, "url", ""));
7796
7772
  }, [
7797
- requestsURLs
7773
+ dispatch,
7774
+ index,
7775
+ requestsURLs,
7776
+ url
7798
7777
  ]);
7799
7778
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsxs)((0, $gkIgo$reactjsxruntime.Fragment), {
7800
7779
  children: [
@@ -8515,9 +8494,7 @@ class $f7cba0d85787755d$export$410b0c854570d131 extends (0, $gkIgo$react.Compone
8515
8494
  const $047232ddaddc0727$export$b7aa9722688888e1 = ({ id: id })=>{
8516
8495
  const getGroupMeta = (0, $gkIgo$react.useMemo)(()=>{
8517
8496
  return (0, $c5bb589de61e43ba$export$169ad5bffc8504d4)();
8518
- }, [
8519
- id
8520
- ]);
8497
+ }, []);
8521
8498
  const scenarioId = (0, $cdee3562a1fa264f$export$9b8881d67105457d)((0, $c5bb589de61e43ba$export$3f88dbdbd24ab19e));
8522
8499
  const { requestCount: requestCount , sleepAmount: sleepAmount } = (0, $cdee3562a1fa264f$export$9b8881d67105457d)((state)=>getGroupMeta(state, {
8523
8500
  scenarioId: scenarioId,
@@ -9457,13 +9434,15 @@ const $aa77c4b166f6d3da$export$909904bdb4cb4458 = ({ value: value = "" , suggest
9457
9434
  placeholder: placeholder,
9458
9435
  inputProps: params.inputProps,
9459
9436
  variant: theme.keyValueInputVariant
9460
- }), []);
9437
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
9438
+ []);
9461
9439
  const normalizedValue = String(currentValue).toLowerCase();
9462
9440
  const filteredOptions = (0, $gkIgo$react.useMemo)(()=>{
9463
9441
  return suggestions.filter((suggestion, index)=>normalizedSuggestions[index].includes(normalizedValue) && suggestion !== normalizedValue);
9464
9442
  }, [
9465
- normalizedValue,
9466
- normalizedSuggestions
9443
+ suggestions,
9444
+ normalizedSuggestions,
9445
+ normalizedValue
9467
9446
  ]);
9468
9447
  const handleOnBlur = ({ target: target })=>{
9469
9448
  if (onBlur) onBlur(target.value);
@@ -10421,15 +10400,13 @@ const $ab4876a2c16b3c35$export$f348fa2be2f68942 = /*#__PURE__*/ (0, ($parcel$int
10421
10400
 
10422
10401
  const $473b9ed3fed6b67a$export$73be308c62ac8dac = ({ labelMap: labelMap , index: index , variable: variable , onChange: onChange , deleteCheck: deleteCheck , showAttributeColumn: showAttributeColumn })=>{
10423
10402
  const [itemState, setItemState] = (0, $bc2668a655363c50$export$64bcfd5faff4adc3)(variable);
10424
- (0, $gkIgo$react.useEffect)(()=>{
10425
- updateVariable();
10403
+ const hasChanged = (0, $gkIgo$react.useCallback)(()=>{
10404
+ return !(0, $gkIgo$lodashes.isEqual)(variable, itemState);
10426
10405
  }, [
10427
- itemState.attribute
10406
+ itemState,
10407
+ variable
10428
10408
  ]);
10429
- const hasChanged = ()=>{
10430
- return !(0, $gkIgo$lodashes.isEqual)(variable, itemState);
10431
- };
10432
- const updateVariable = ()=>{
10409
+ const updateVariable = (0, $gkIgo$react.useCallback)(()=>{
10433
10410
  if (hasChanged()) {
10434
10411
  const newAttribute = {
10435
10412
  ...itemState
@@ -10437,7 +10414,18 @@ const $473b9ed3fed6b67a$export$73be308c62ac8dac = ({ labelMap: labelMap , index:
10437
10414
  if (newAttribute.attribute === undefined) delete newAttribute.attribute;
10438
10415
  onChange(index, newAttribute);
10439
10416
  }
10440
- };
10417
+ }, [
10418
+ hasChanged,
10419
+ index,
10420
+ itemState,
10421
+ onChange
10422
+ ]);
10423
+ (0, $gkIgo$react.useEffect)(()=>{
10424
+ updateVariable();
10425
+ }, [
10426
+ itemState.attribute,
10427
+ updateVariable
10428
+ ]);
10441
10429
  const handleDelete = ()=>{
10442
10430
  deleteCheck(index);
10443
10431
  };
@@ -10769,16 +10757,24 @@ const $736e8da9e5879b4f$export$c0ee4c2a5005a714 = /*#__PURE__*/ (0, ($parcel$int
10769
10757
 
10770
10758
 
10771
10759
 
10772
- const $e4daa807821f8f92$export$e287c41c9a585ac7 = ({ data: data , onChange: onChange })=>{
10760
+
10761
+ const $e4daa807821f8f92$export$e287c41c9a585ac7 = ({ data: data , onChange: onChange , nodeId: nodeId })=>{
10773
10762
  const value = data || "{}";
10774
- const handleChange = (event)=>{
10763
+ const { ScriptEditorComponent: ScriptEditorComponent } = (0, $b0053bc75d27f892$export$8bcb3cb1ba0d67a7)();
10764
+ const handleChange = (editorValue)=>{
10775
10765
  onChange({
10776
10766
  type: "json",
10777
- data: event.target.value
10767
+ data: editorValue
10778
10768
  });
10779
10769
  };
10770
+ if (!ScriptEditorComponent) {
10771
+ (0, $1c4cc247633c6592$export$af88d00dbe7f521).error("ScriptEditor was not defined in TestBuilderContext");
10772
+ return null;
10773
+ }
10780
10774
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $736e8da9e5879b4f$export$c0ee4c2a5005a714), {
10781
- children: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $ab0bf6ee71c94953$export$32efa5142ae8aa01), {
10775
+ children: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)(ScriptEditorComponent, {
10776
+ nodeId: nodeId,
10777
+ mode: "body.json",
10782
10778
  value: value,
10783
10779
  onChange: handleChange
10784
10780
  })
@@ -10789,16 +10785,30 @@ const $e4daa807821f8f92$export$e287c41c9a585ac7 = ({ data: data , onChange: onCh
10789
10785
 
10790
10786
 
10791
10787
 
10792
- const $e5fb49fa16a50d9e$export$54d6c984d47f87b5 = ({ data: data , onChange: onChange })=>{
10788
+
10789
+
10790
+ const $e5fb49fa16a50d9e$export$54d6c984d47f87b5 = ({ data: data , onChange: onChange , nodeId: nodeId })=>{
10793
10791
  const value = data || "";
10794
- const handleChange = (event)=>{
10795
- onChange({
10796
- type: "text",
10797
- data: event.target.value
10798
- });
10799
- };
10792
+ const { ScriptEditorComponent: ScriptEditorComponent } = (0, $b0053bc75d27f892$export$8bcb3cb1ba0d67a7)();
10793
+ const handleChange = (0, $gkIgo$react.useMemo)(()=>{
10794
+ return (editorValue)=>{
10795
+ if (value !== editorValue) onChange({
10796
+ type: "text",
10797
+ data: editorValue
10798
+ });
10799
+ };
10800
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10801
+ }, [
10802
+ onChange
10803
+ ]);
10804
+ if (!ScriptEditorComponent) {
10805
+ (0, $1c4cc247633c6592$export$af88d00dbe7f521).error("ScriptEditor was not defined in TestBuilderContext");
10806
+ return null;
10807
+ }
10800
10808
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $736e8da9e5879b4f$export$c0ee4c2a5005a714), {
10801
- children: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $ab0bf6ee71c94953$export$32efa5142ae8aa01), {
10809
+ children: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)(ScriptEditorComponent, {
10810
+ nodeId: nodeId,
10811
+ mode: "body.text",
10802
10812
  value: value,
10803
10813
  onChange: handleChange
10804
10814
  })
@@ -11084,10 +11094,11 @@ const $a4a08906aac0fd62$export$c6874ada35a1ff76 = ({ data: data , onChange: onCh
11084
11094
  };
11085
11095
 
11086
11096
 
11087
- const $bd95d9b208b0b55f$export$6a3b5760ae228af1 = ({ postData: postData , onChange: onChange })=>{
11097
+ const $bd95d9b208b0b55f$export$6a3b5760ae228af1 = ({ nodeId: nodeId , postData: postData , onChange: onChange })=>{
11088
11098
  switch(postData.type){
11089
11099
  case "json":
11090
11100
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $e4daa807821f8f92$export$e287c41c9a585ac7), {
11101
+ nodeId: nodeId,
11091
11102
  data: postData.data,
11092
11103
  onChange: onChange
11093
11104
  });
@@ -11103,6 +11114,7 @@ const $bd95d9b208b0b55f$export$6a3b5760ae228af1 = ({ postData: postData , onChan
11103
11114
  });
11104
11115
  default:
11105
11116
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $e5fb49fa16a50d9e$export$54d6c984d47f87b5), {
11117
+ nodeId: nodeId,
11106
11118
  data: postData.data,
11107
11119
  onChange: onChange
11108
11120
  });
@@ -11182,12 +11194,15 @@ const $c85189fe5ae8daca$export$dff7993a3790e254 = ({ node: node })=>{
11182
11194
  setModalOpen(true);
11183
11195
  });
11184
11196
  };
11185
- const handleChange = (newData)=>{
11197
+ const handleChange = (0, $gkIgo$react.useCallback)((newData)=>{
11186
11198
  dispatch((0, $1dc6187db9ccd62b$export$6bb6f70f4b0d3a5e)({
11187
11199
  nodeId: node.id,
11188
11200
  postData: newData
11189
11201
  }));
11190
- };
11202
+ }, [
11203
+ dispatch,
11204
+ node.id
11205
+ ]);
11191
11206
  const [modalOpen, setModalOpen] = (0, $gkIgo$react.useState)(false);
11192
11207
  const handleOnClose = ()=>{
11193
11208
  setModalOpen(false);
@@ -11256,6 +11271,7 @@ const $c85189fe5ae8daca$export$dff7993a3790e254 = ({ node: node })=>{
11256
11271
  })
11257
11272
  }),
11258
11273
  /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $bd95d9b208b0b55f$export$6a3b5760ae228af1), {
11274
+ nodeId: node.id,
11259
11275
  postData: postData,
11260
11276
  onChange: handleChange
11261
11277
  }, node.id)
@@ -11290,7 +11306,7 @@ function $d1015cc70984f4e6$export$41c187750335d211({ node: node }) {
11290
11306
  if (advancedOptionsTab.active === "body" && !enableBodyTag) advancedOptionsTab.changeTab("");
11291
11307
  }, [
11292
11308
  enableBodyTag,
11293
- advancedOptionsTab.active
11309
+ advancedOptionsTab
11294
11310
  ]);
11295
11311
  const ActiveTab = $d1015cc70984f4e6$var$tabMap[advancedOptionsTab.active] || (0, $feaa0c3a4375cb8c$export$152722cb1db8279d);
11296
11312
  const headersCount = (0, $2e34f056aa056dbe$export$cf7368191a3143bd)(node.request.headers);
@@ -11499,7 +11515,9 @@ const $81db16838431060c$export$970c2db48345af40 = ({ scenarioId: scenarioId , no
11499
11515
  if (!node) return;
11500
11516
  dispatch((0, $fb13d3d78074f465$export$ecdadd8158499ba9)(scenarioId, node.id, key, value));
11501
11517
  }, [
11502
- node
11518
+ dispatch,
11519
+ node,
11520
+ scenarioId
11503
11521
  ]);
11504
11522
  const NodeComponent = (0, $gkIgo$react.useMemo)(()=>{
11505
11523
  if (!node) return;
@@ -11624,11 +11642,12 @@ function $cb1d23fc6fcde89c$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11624
11642
  ]);
11625
11643
  (0, $gkIgo$react.useEffect)(()=>{
11626
11644
  setEditableRange($cb1d23fc6fcde89c$var$createConstrainedRanges(functionDefinition, scenario.body));
11645
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11627
11646
  }, [
11628
11647
  scriptTemplate,
11629
11648
  scenario.body
11630
11649
  ]);
11631
- const onChange = (changeMap)=>{
11650
+ const onBodyChange = (changeMap)=>{
11632
11651
  const value = changeMap[$cb1d23fc6fcde89c$var$CONSTRAINED_RANGE_BODY];
11633
11652
  if (value === undefined) {
11634
11653
  (0, $1c4cc247633c6592$export$af88d00dbe7f521).warn("ScenarioScript.tsx:onBodyChange should not receive `undefined` as value for key `CONSTRAINED_RANGE_BODY`.");
@@ -11650,6 +11669,7 @@ function $cb1d23fc6fcde89c$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11650
11669
  children: "Script (readonly)"
11651
11670
  }),
11652
11671
  /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)(ScriptEditorComponent, {
11672
+ mode: "scenario",
11653
11673
  readOnly: true,
11654
11674
  value: (0, $40f0f8d1d1c69699$export$18972e718224868c)(scriptTemplate, editableRange)
11655
11675
  })
@@ -11663,12 +11683,12 @@ function $cb1d23fc6fcde89c$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11663
11683
  /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)(ScriptEditorComponent, {
11664
11684
  scenario: scenario,
11665
11685
  mode: "scenario",
11666
- imports: importJS,
11686
+ imports: scenario.imports,
11667
11687
  template: scriptTemplate,
11668
11688
  value: scenario.body,
11669
11689
  functionName: functionName,
11670
11690
  constrainedRanges: editableRange,
11671
- onChange: onChange,
11691
+ onBodyChange: onBodyChange,
11672
11692
  onImportsChange: handleImportsChange
11673
11693
  })
11674
11694
  ]
@@ -12902,7 +12922,6 @@ function $efe94139ad83ff2c$export$9fcfd118dd8900ea({ options: options , errorMap
12902
12922
  default:
12903
12923
  return null;
12904
12924
  }
12905
- return null;
12906
12925
  }
12907
12926
 
12908
12927
 
@@ -13254,8 +13273,10 @@ function $fc44f623ed4abf47$export$9debbb9998750ca4() {
13254
13273
  ]
13255
13274
  }),
13256
13275
  /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)(ScriptEditorComponent, {
13276
+ mode: "test",
13257
13277
  value: script,
13258
- error: scriptError
13278
+ error: scriptError,
13279
+ readOnly: true
13259
13280
  })
13260
13281
  ]
13261
13282
  });
@@ -13268,15 +13289,19 @@ function $51462fa9d6a79d0b$export$daf800c33be5eb7e({ loading: loading , saving:
13268
13289
  const dispatch = (0, $cdee3562a1fa264f$export$371624ce4da5e319)();
13269
13290
  (0, $gkIgo$react.useEffect)(()=>{
13270
13291
  dispatch((0, $eeeed770fbbe0766$export$2cd8252107eb640b)());
13271
- }, []);
13292
+ }, [
13293
+ dispatch
13294
+ ]);
13272
13295
  (0, $gkIgo$react.useEffect)(()=>{
13273
13296
  dispatch((0, $eeeed770fbbe0766$export$9eaa806651dd33f0)(loading));
13274
13297
  }, [
13298
+ dispatch,
13275
13299
  loading
13276
13300
  ]);
13277
13301
  (0, $gkIgo$react.useEffect)(()=>{
13278
13302
  dispatch((0, $eeeed770fbbe0766$export$ad10cacbaf4608fe)(saving));
13279
13303
  }, [
13304
+ dispatch,
13280
13305
  saving
13281
13306
  ]);
13282
13307
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $gkIgo$reactjsxruntime.Fragment), {
@@ -13347,7 +13372,7 @@ function $00b916e228a936f5$export$f290710bbb710efa({ loading: loading , saving:
13347
13372
  k6_load_zone_id: "amazon:us:ashburn",
13348
13373
  city: "Ashburn"
13349
13374
  }
13350
- ] , DocsLinkComponent: DocsLinkComponent = (0, $cd402c1b3ca4b836$export$e816d7af81d48a79) , onViewChange: onViewChange , StagesVirtualizationComponent: StagesVirtualizationComponent , ScriptEditorComponent: ScriptEditorComponent = (0, $ab0bf6ee71c94953$export$32efa5142ae8aa01) , TestBuilderIconComponent: TestBuilderIconComponent = (0, $924f96bd0d5c630d$export$cc0ae9a5c96bcd6f) }) {
13375
+ ] , DocsLinkComponent: DocsLinkComponent = (0, $cd402c1b3ca4b836$export$e816d7af81d48a79) , onViewChange: onViewChange , StagesVirtualizationComponent: StagesVirtualizationComponent , ScriptEditorComponent: ScriptEditorComponent = (0, $ab0bf6ee71c94953$export$32efa5142ae8aa01) , TestBuilderIconComponent: TestBuilderIconComponent = (0, $924f96bd0d5c630d$export$cc0ae9a5c96bcd6f) , readonlyScriptScenarios: readonlyScriptScenarios = true }) {
13351
13376
  // create test builder context
13352
13377
  const context = {
13353
13378
  k6Test: k6Test,
@@ -13357,7 +13382,8 @@ function $00b916e228a936f5$export$f290710bbb710efa({ loading: loading , saving:
13357
13382
  onViewChange: onViewChange,
13358
13383
  StagesVirtualizationComponent: StagesVirtualizationComponent,
13359
13384
  ScriptEditorComponent: ScriptEditorComponent,
13360
- TestBuilderIconComponent: TestBuilderIconComponent
13385
+ TestBuilderIconComponent: TestBuilderIconComponent,
13386
+ readonlyScriptScenarios: readonlyScriptScenarios
13361
13387
  };
13362
13388
  return /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $1ae39e1e435a2397$export$9bb8a8c9de09825e), {
13363
13389
  children: /*#__PURE__*/ (0, $gkIgo$reactjsxruntime.jsx)((0, $b0053bc75d27f892$export$b224d382e54e6ba1), {
package/dist/module.js CHANGED
@@ -530,15 +530,9 @@ function $7f2d99330ea6daa2$export$18972e718224868c(template, constrainedRanges)
530
530
  }
531
531
 
532
532
 
533
- function $b60f5acc8283b9c9$export$32efa5142ae8aa01({ value: value , onChange: onChange , onBlur: onBlur , error: error , mode: mode = "test" , template: template = "" , constrainedRanges: constrainedRanges }) {
534
- const [proxyValue, setProxyValue] = (0, $b7VBt$useState)(value || "");
533
+ function $b60f5acc8283b9c9$export$32efa5142ae8aa01({ value: value , onChange: onChange , onBlur: onBlur , error: error , mode: mode = "test" , template: template = "" , constrainedRanges: constrainedRanges , readOnly: readOnly = false }) {
535
534
  const [script, setScript] = (0, $b7VBt$useState)("");
536
535
  if (!onChange && !onBlur) (0, $77857f570335d7ae$export$af88d00dbe7f521).warn("Using fallback ScriptEditor");
537
- (0, $b7VBt$useEffect)(()=>{
538
- if (value !== proxyValue) setProxyValue(value);
539
- }, [
540
- value
541
- ]);
542
536
  (0, $b7VBt$useEffect)(()=>{
543
537
  if (mode === "scenario") {
544
538
  if (constrainedRanges && typeof template === "string") setScript((0, $7f2d99330ea6daa2$export$18972e718224868c)(template, constrainedRanges));
@@ -548,9 +542,9 @@ function $b60f5acc8283b9c9$export$32efa5142ae8aa01({ value: value , onChange: on
548
542
  constrainedRanges,
549
543
  template
550
544
  ]);
551
- const editorValue = mode === "scenario" ? script : proxyValue;
545
+ const editorValue = mode === "scenario" ? script : value;
552
546
  const handleOnChange = (event)=>{
553
- setProxyValue(event.target.value);
547
+ if (mode !== "scenario") onChange && onChange(event.target.value);
554
548
  };
555
549
  return /*#__PURE__*/ (0, $b7VBt$jsxs)((0, $b7VBt$Fragment), {
556
550
  children: [
@@ -570,7 +564,7 @@ function $b60f5acc8283b9c9$export$32efa5142ae8aa01({ value: value , onChange: on
570
564
  /*#__PURE__*/ (0, $b7VBt$jsx)((0, $c1a62b9f39018e78$export$ad9254163fa4ee24), {
571
565
  defaultValue: editorValue,
572
566
  onChange: handleOnChange,
573
- readOnly: true
567
+ readOnly: readOnly
574
568
  })
575
569
  ]
576
570
  });
@@ -1376,52 +1370,27 @@ const $0af4923191cf0fd3$export$a86f095b9b6dae = /*#__PURE__*/ (0, $b7VBt$styledc
1376
1370
  })([
1377
1371
  "grid-column:1 / span 3;position:sticky;bottom:-10px;"
1378
1372
  ]);
1379
- const $0af4923191cf0fd3$export$50590ad6c03e5bd7 = /*#__PURE__*/ (0, $b7VBt$styledcomponents)($0af4923191cf0fd3$export$f86d68f7ed25f5bb).withConfig({
1380
- displayName: "styled__AdvancedSettingsContainer",
1381
- componentId: "sc-78krzf-7"
1382
- })([
1383
- ""
1384
- ]);
1385
- const $0af4923191cf0fd3$export$e5c1a6ed3fbdc322 = /*#__PURE__*/ (0, $b7VBt$styledcomponents).div.withConfig({
1386
- displayName: "styled__LabelColumn",
1387
- componentId: "sc-78krzf-8"
1388
- })([
1389
- "display:flex;flex-direction:column;"
1390
- ]);
1391
- const $0af4923191cf0fd3$export$ce4908ada21f6533 = /*#__PURE__*/ (0, $b7VBt$styledcomponents)($0af4923191cf0fd3$export$e5c1a6ed3fbdc322).withConfig({
1392
- displayName: "styled__InputColumn",
1393
- componentId: "sc-78krzf-9"
1394
- })([
1395
- "flex:1 1 100%;"
1396
- ]);
1397
1373
  const $0af4923191cf0fd3$export$b04be29aa201d4f5 = /*#__PURE__*/ (0, $b7VBt$styledcomponents)((0, $8e10f6d2c60dae58$export$842aba50ed0ce9d7)).withConfig({
1398
1374
  displayName: "styled__Label",
1399
- componentId: "sc-78krzf-10"
1375
+ componentId: "sc-78krzf-7"
1400
1376
  })([
1401
1377
  "display:flex;justify-self:right;align-self:center;"
1402
1378
  ]);
1403
- const $0af4923191cf0fd3$export$e7a98f51c6efe634 = /*#__PURE__*/ (0, $b7VBt$styledcomponents)($0af4923191cf0fd3$export$b04be29aa201d4f5).withConfig({
1404
- displayName: "styled__ErrorLabel",
1405
- componentId: "sc-78krzf-11"
1406
- })([
1407
- "opacity:1;color:",
1408
- ";"
1409
- ], ({ theme: theme })=>theme.palette.error.main);
1410
1379
  const $0af4923191cf0fd3$export$3f6e3839f387b50 = /*#__PURE__*/ (0, $b7VBt$styledcomponents).div.withConfig({
1411
1380
  displayName: "styled__RequestInputContainer",
1412
- componentId: "sc-78krzf-12"
1381
+ componentId: "sc-78krzf-8"
1413
1382
  })([
1414
1383
  "display:flex;position:relative;& > :nth-child(1){flex-basis:150px;}"
1415
1384
  ]);
1416
1385
  const $0af4923191cf0fd3$export$93e9fa14a08d2dd1 = /*#__PURE__*/ (0, $b7VBt$styledcomponents).span.withConfig({
1417
1386
  displayName: "styled__EndAdornmentContainer",
1418
- componentId: "sc-78krzf-13"
1387
+ componentId: "sc-78krzf-9"
1419
1388
  })([
1420
1389
  "padding-left:8px;"
1421
1390
  ]);
1422
1391
  const $0af4923191cf0fd3$export$e7e6b99c949fd18a = /*#__PURE__*/ (0, $b7VBt$styledcomponents)((0, $b7VBt$materialuicoreSelect)).withConfig({
1423
1392
  displayName: "styled__StyledSelect",
1424
- componentId: "sc-78krzf-14"
1393
+ componentId: "sc-78krzf-10"
1425
1394
  })([
1426
1395
  "align-self:stretch;display:flex;align-items:center;[class*='MuiSelect-icon']{color:currentColor;}[class*='MuiInputBase-root']{height:auto;}[class*='MuiOutlinedInput-input']{padding:0 10px;color:#fff !important;}[class*='MuiOutlinedInput-root']{border:0 !important;}",
1427
1396
  ";"
@@ -1435,14 +1404,14 @@ const $0af4923191cf0fd3$export$e7e6b99c949fd18a = /*#__PURE__*/ (0, $b7VBt$style
1435
1404
  });
1436
1405
  const $0af4923191cf0fd3$export$2191b9da168c6cf0 = /*#__PURE__*/ (0, $b7VBt$styledcomponents).span.withConfig({
1437
1406
  displayName: "styled__ValidationError",
1438
- componentId: "sc-78krzf-15"
1407
+ componentId: "sc-78krzf-11"
1439
1408
  })([
1440
1409
  "font-size:13px;color:",
1441
1410
  ";"
1442
1411
  ], ({ theme: theme })=>theme.palette.error.main);
1443
1412
  const $0af4923191cf0fd3$export$d7a2349e1b0bdcb7 = /*#__PURE__*/ (0, $b7VBt$styledcomponents).div.withConfig({
1444
1413
  displayName: "styled__NodeContainer",
1445
- componentId: "sc-78krzf-16"
1414
+ componentId: "sc-78krzf-12"
1446
1415
  })([
1447
1416
  "display:flex;flex-direction:column;position:relative;"
1448
1417
  ]);
@@ -5175,6 +5144,7 @@ function $f33bf9327a1ab3ee$export$9cc0a26cbe829bcb() {
5175
5144
  }
5176
5145
  };
5177
5146
  }, [
5147
+ dispatch,
5178
5148
  tab
5179
5149
  ]);
5180
5150
  }
@@ -5184,6 +5154,7 @@ function $f33bf9327a1ab3ee$export$e3a1a4f1e85dc208() {
5184
5154
  (0, $b7VBt$useEffect)(()=>{
5185
5155
  dispatch((0, $8592aa8dcb3902ac$export$f89a1b8f393b8bb6)(Boolean(hasCloudExecution)));
5186
5156
  }, [
5157
+ dispatch,
5187
5158
  hasCloudExecution
5188
5159
  ]);
5189
5160
  (0, $b7VBt$useEffect)(()=>{
@@ -5197,11 +5168,13 @@ function $f33bf9327a1ab3ee$export$e3a1a4f1e85dc208() {
5197
5168
  const [firstScenario] = scenarios;
5198
5169
  if (firstScenario) dispatch((0, $8592aa8dcb3902ac$export$78fa5045d0400717)(`scenario/${firstScenario.id}`));
5199
5170
  }, [
5171
+ dispatch,
5200
5172
  k6Test
5201
5173
  ]);
5202
5174
  (0, $b7VBt$useEffect)(()=>{
5203
5175
  dispatch((0, $8592aa8dcb3902ac$export$9f9f33201c1586de)(availableLoadZones));
5204
5176
  }, [
5177
+ dispatch,
5205
5178
  availableLoadZones
5206
5179
  ]);
5207
5180
  }
@@ -6412,7 +6385,9 @@ function $5912e581c38b22dd$export$fb4216da1f591b95({ name: name = (0, $b7VBt$nan
6412
6385
  null
6413
6386
  ] , checked: checked , onChange: onChange , className: className , disabled: disabled = false }) {
6414
6387
  const [labelOff, labelOn] = labels;
6415
- const id = (0, $b7VBt$useMemo)(()=>`id_${name}`, []);
6388
+ const id = (0, $b7VBt$useMemo)(()=>`id_${name}`, [
6389
+ name
6390
+ ]);
6416
6391
  return /*#__PURE__*/ (0, $b7VBt$jsxs)($5912e581c38b22dd$var$StyledWrapper, {
6417
6392
  className: className,
6418
6393
  $disabled: disabled,
@@ -7252,13 +7227,13 @@ const $d11389a8752f23d8$var$LoadZoneItem = /*#__PURE__*/ (0, $b7VBt$styledcompon
7252
7227
  })([
7253
7228
  "display:inline-flex;align-items:center;> svg{margin-right:8px;}"
7254
7229
  ]);
7255
- function $d11389a8752f23d8$export$a977df6ccef00812({ disabledValues: disabledValues = [] , ...props }) {
7230
+ function $d11389a8752f23d8$export$a977df6ccef00812({ disabledValues: disabledValues , ...props }) {
7256
7231
  const { availableLoadZones: availableLoadZones } = (0, $4cf6d05a57acd1d1$export$8bcb3cb1ba0d67a7)();
7257
7232
  const options = (0, $b7VBt$useMemo)(()=>{
7258
7233
  return availableLoadZones.map((loadZone)=>{
7259
7234
  const { k6_load_zone_id: k6_load_zone_id , city: city , country: country } = loadZone;
7260
7235
  return {
7261
- disabled: disabledValues.includes(k6_load_zone_id),
7236
+ disabled: (disabledValues || []).includes(k6_load_zone_id),
7262
7237
  value: k6_load_zone_id,
7263
7238
  label: /*#__PURE__*/ (0, $b7VBt$jsxs)($d11389a8752f23d8$var$LoadZoneItem, {
7264
7239
  children: [
@@ -7275,6 +7250,7 @@ function $d11389a8752f23d8$export$a977df6ccef00812({ disabledValues: disabledVal
7275
7250
  };
7276
7251
  });
7277
7252
  }, [
7253
+ disabledValues,
7278
7254
  availableLoadZones
7279
7255
  ]);
7280
7256
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $7b2e34940da063e7$export$ef9b1a59e592288f), {
@@ -7773,7 +7749,10 @@ const $d221d46810783302$export$9a75ed5a99cf0511 = (props)=>{
7773
7749
  // Set URL to default '' if the request with the selected URL has been deleted/modified
7774
7750
  if (url !== "" && url !== "all" && !requestsURLs.includes(url)) dispatch((0, $a6a312292842f1bc$export$7a98fbd10fd8a51f)(index, "url", ""));
7775
7751
  }, [
7776
- requestsURLs
7752
+ dispatch,
7753
+ index,
7754
+ requestsURLs,
7755
+ url
7777
7756
  ]);
7778
7757
  return /*#__PURE__*/ (0, $b7VBt$jsxs)((0, $b7VBt$Fragment), {
7779
7758
  children: [
@@ -8494,9 +8473,7 @@ class $2c990e9e09ef6ae6$export$410b0c854570d131 extends (0, $b7VBt$Component) {
8494
8473
  const $c8e4ca4b91cb140c$export$b7aa9722688888e1 = ({ id: id })=>{
8495
8474
  const getGroupMeta = (0, $b7VBt$useMemo)(()=>{
8496
8475
  return (0, $d7b1b7c6f96b1d0a$export$169ad5bffc8504d4)();
8497
- }, [
8498
- id
8499
- ]);
8476
+ }, []);
8500
8477
  const scenarioId = (0, $f33bf9327a1ab3ee$export$9b8881d67105457d)((0, $d7b1b7c6f96b1d0a$export$3f88dbdbd24ab19e));
8501
8478
  const { requestCount: requestCount , sleepAmount: sleepAmount } = (0, $f33bf9327a1ab3ee$export$9b8881d67105457d)((state)=>getGroupMeta(state, {
8502
8479
  scenarioId: scenarioId,
@@ -9436,13 +9413,15 @@ const $791a660a9528967f$export$909904bdb4cb4458 = ({ value: value = "" , suggest
9436
9413
  placeholder: placeholder,
9437
9414
  inputProps: params.inputProps,
9438
9415
  variant: theme.keyValueInputVariant
9439
- }), []);
9416
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
9417
+ []);
9440
9418
  const normalizedValue = String(currentValue).toLowerCase();
9441
9419
  const filteredOptions = (0, $b7VBt$useMemo)(()=>{
9442
9420
  return suggestions.filter((suggestion, index)=>normalizedSuggestions[index].includes(normalizedValue) && suggestion !== normalizedValue);
9443
9421
  }, [
9444
- normalizedValue,
9445
- normalizedSuggestions
9422
+ suggestions,
9423
+ normalizedSuggestions,
9424
+ normalizedValue
9446
9425
  ]);
9447
9426
  const handleOnBlur = ({ target: target })=>{
9448
9427
  if (onBlur) onBlur(target.value);
@@ -10400,15 +10379,13 @@ const $bc03e5cfae4eab78$export$f348fa2be2f68942 = /*#__PURE__*/ (0, $b7VBt$style
10400
10379
 
10401
10380
  const $811fb252c4c3a84c$export$73be308c62ac8dac = ({ labelMap: labelMap , index: index , variable: variable , onChange: onChange , deleteCheck: deleteCheck , showAttributeColumn: showAttributeColumn })=>{
10402
10381
  const [itemState, setItemState] = (0, $7e9300d00e06714c$export$64bcfd5faff4adc3)(variable);
10403
- (0, $b7VBt$useEffect)(()=>{
10404
- updateVariable();
10382
+ const hasChanged = (0, $b7VBt$useCallback)(()=>{
10383
+ return !(0, $b7VBt$isEqual)(variable, itemState);
10405
10384
  }, [
10406
- itemState.attribute
10385
+ itemState,
10386
+ variable
10407
10387
  ]);
10408
- const hasChanged = ()=>{
10409
- return !(0, $b7VBt$isEqual)(variable, itemState);
10410
- };
10411
- const updateVariable = ()=>{
10388
+ const updateVariable = (0, $b7VBt$useCallback)(()=>{
10412
10389
  if (hasChanged()) {
10413
10390
  const newAttribute = {
10414
10391
  ...itemState
@@ -10416,7 +10393,18 @@ const $811fb252c4c3a84c$export$73be308c62ac8dac = ({ labelMap: labelMap , index:
10416
10393
  if (newAttribute.attribute === undefined) delete newAttribute.attribute;
10417
10394
  onChange(index, newAttribute);
10418
10395
  }
10419
- };
10396
+ }, [
10397
+ hasChanged,
10398
+ index,
10399
+ itemState,
10400
+ onChange
10401
+ ]);
10402
+ (0, $b7VBt$useEffect)(()=>{
10403
+ updateVariable();
10404
+ }, [
10405
+ itemState.attribute,
10406
+ updateVariable
10407
+ ]);
10420
10408
  const handleDelete = ()=>{
10421
10409
  deleteCheck(index);
10422
10410
  };
@@ -10748,16 +10736,24 @@ const $f2ecedac970556da$export$c0ee4c2a5005a714 = /*#__PURE__*/ (0, $b7VBt$style
10748
10736
 
10749
10737
 
10750
10738
 
10751
- const $8c981c823427f6dd$export$e287c41c9a585ac7 = ({ data: data , onChange: onChange })=>{
10739
+
10740
+ const $8c981c823427f6dd$export$e287c41c9a585ac7 = ({ data: data , onChange: onChange , nodeId: nodeId })=>{
10752
10741
  const value = data || "{}";
10753
- const handleChange = (event)=>{
10742
+ const { ScriptEditorComponent: ScriptEditorComponent } = (0, $4cf6d05a57acd1d1$export$8bcb3cb1ba0d67a7)();
10743
+ const handleChange = (editorValue)=>{
10754
10744
  onChange({
10755
10745
  type: "json",
10756
- data: event.target.value
10746
+ data: editorValue
10757
10747
  });
10758
10748
  };
10749
+ if (!ScriptEditorComponent) {
10750
+ (0, $77857f570335d7ae$export$af88d00dbe7f521).error("ScriptEditor was not defined in TestBuilderContext");
10751
+ return null;
10752
+ }
10759
10753
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $f2ecedac970556da$export$c0ee4c2a5005a714), {
10760
- children: /*#__PURE__*/ (0, $b7VBt$jsx)((0, $b60f5acc8283b9c9$export$32efa5142ae8aa01), {
10754
+ children: /*#__PURE__*/ (0, $b7VBt$jsx)(ScriptEditorComponent, {
10755
+ nodeId: nodeId,
10756
+ mode: "body.json",
10761
10757
  value: value,
10762
10758
  onChange: handleChange
10763
10759
  })
@@ -10768,16 +10764,30 @@ const $8c981c823427f6dd$export$e287c41c9a585ac7 = ({ data: data , onChange: onCh
10768
10764
 
10769
10765
 
10770
10766
 
10771
- const $153fe8a8bfbab7dd$export$54d6c984d47f87b5 = ({ data: data , onChange: onChange })=>{
10767
+
10768
+
10769
+ const $153fe8a8bfbab7dd$export$54d6c984d47f87b5 = ({ data: data , onChange: onChange , nodeId: nodeId })=>{
10772
10770
  const value = data || "";
10773
- const handleChange = (event)=>{
10774
- onChange({
10775
- type: "text",
10776
- data: event.target.value
10777
- });
10778
- };
10771
+ const { ScriptEditorComponent: ScriptEditorComponent } = (0, $4cf6d05a57acd1d1$export$8bcb3cb1ba0d67a7)();
10772
+ const handleChange = (0, $b7VBt$useMemo)(()=>{
10773
+ return (editorValue)=>{
10774
+ if (value !== editorValue) onChange({
10775
+ type: "text",
10776
+ data: editorValue
10777
+ });
10778
+ };
10779
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10780
+ }, [
10781
+ onChange
10782
+ ]);
10783
+ if (!ScriptEditorComponent) {
10784
+ (0, $77857f570335d7ae$export$af88d00dbe7f521).error("ScriptEditor was not defined in TestBuilderContext");
10785
+ return null;
10786
+ }
10779
10787
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $f2ecedac970556da$export$c0ee4c2a5005a714), {
10780
- children: /*#__PURE__*/ (0, $b7VBt$jsx)((0, $b60f5acc8283b9c9$export$32efa5142ae8aa01), {
10788
+ children: /*#__PURE__*/ (0, $b7VBt$jsx)(ScriptEditorComponent, {
10789
+ nodeId: nodeId,
10790
+ mode: "body.text",
10781
10791
  value: value,
10782
10792
  onChange: handleChange
10783
10793
  })
@@ -11063,10 +11073,11 @@ const $af761f16d5ba2843$export$c6874ada35a1ff76 = ({ data: data , onChange: onCh
11063
11073
  };
11064
11074
 
11065
11075
 
11066
- const $830434c708449e62$export$6a3b5760ae228af1 = ({ postData: postData , onChange: onChange })=>{
11076
+ const $830434c708449e62$export$6a3b5760ae228af1 = ({ nodeId: nodeId , postData: postData , onChange: onChange })=>{
11067
11077
  switch(postData.type){
11068
11078
  case "json":
11069
11079
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $8c981c823427f6dd$export$e287c41c9a585ac7), {
11080
+ nodeId: nodeId,
11070
11081
  data: postData.data,
11071
11082
  onChange: onChange
11072
11083
  });
@@ -11082,6 +11093,7 @@ const $830434c708449e62$export$6a3b5760ae228af1 = ({ postData: postData , onChan
11082
11093
  });
11083
11094
  default:
11084
11095
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $153fe8a8bfbab7dd$export$54d6c984d47f87b5), {
11096
+ nodeId: nodeId,
11085
11097
  data: postData.data,
11086
11098
  onChange: onChange
11087
11099
  });
@@ -11161,12 +11173,15 @@ const $225f70896300809f$export$dff7993a3790e254 = ({ node: node })=>{
11161
11173
  setModalOpen(true);
11162
11174
  });
11163
11175
  };
11164
- const handleChange = (newData)=>{
11176
+ const handleChange = (0, $b7VBt$useCallback)((newData)=>{
11165
11177
  dispatch((0, $2f4834fb0198982c$export$6bb6f70f4b0d3a5e)({
11166
11178
  nodeId: node.id,
11167
11179
  postData: newData
11168
11180
  }));
11169
- };
11181
+ }, [
11182
+ dispatch,
11183
+ node.id
11184
+ ]);
11170
11185
  const [modalOpen, setModalOpen] = (0, $b7VBt$useState)(false);
11171
11186
  const handleOnClose = ()=>{
11172
11187
  setModalOpen(false);
@@ -11235,6 +11250,7 @@ const $225f70896300809f$export$dff7993a3790e254 = ({ node: node })=>{
11235
11250
  })
11236
11251
  }),
11237
11252
  /*#__PURE__*/ (0, $b7VBt$jsx)((0, $830434c708449e62$export$6a3b5760ae228af1), {
11253
+ nodeId: node.id,
11238
11254
  postData: postData,
11239
11255
  onChange: handleChange
11240
11256
  }, node.id)
@@ -11269,7 +11285,7 @@ function $de850654afaf3319$export$41c187750335d211({ node: node }) {
11269
11285
  if (advancedOptionsTab.active === "body" && !enableBodyTag) advancedOptionsTab.changeTab("");
11270
11286
  }, [
11271
11287
  enableBodyTag,
11272
- advancedOptionsTab.active
11288
+ advancedOptionsTab
11273
11289
  ]);
11274
11290
  const ActiveTab = $de850654afaf3319$var$tabMap[advancedOptionsTab.active] || (0, $7ab4a1d499d86854$export$152722cb1db8279d);
11275
11291
  const headersCount = (0, $7ca6f2ffa5b7437e$export$cf7368191a3143bd)(node.request.headers);
@@ -11478,7 +11494,9 @@ const $afaadb717d6ddc79$export$970c2db48345af40 = ({ scenarioId: scenarioId , no
11478
11494
  if (!node) return;
11479
11495
  dispatch((0, $406997178a55b94e$export$ecdadd8158499ba9)(scenarioId, node.id, key, value));
11480
11496
  }, [
11481
- node
11497
+ dispatch,
11498
+ node,
11499
+ scenarioId
11482
11500
  ]);
11483
11501
  const NodeComponent = (0, $b7VBt$useMemo)(()=>{
11484
11502
  if (!node) return;
@@ -11603,11 +11621,12 @@ function $e03f8d47f42842f8$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11603
11621
  ]);
11604
11622
  (0, $b7VBt$useEffect)(()=>{
11605
11623
  setEditableRange($e03f8d47f42842f8$var$createConstrainedRanges(functionDefinition, scenario.body));
11624
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11606
11625
  }, [
11607
11626
  scriptTemplate,
11608
11627
  scenario.body
11609
11628
  ]);
11610
- const onChange = (changeMap)=>{
11629
+ const onBodyChange = (changeMap)=>{
11611
11630
  const value = changeMap[$e03f8d47f42842f8$var$CONSTRAINED_RANGE_BODY];
11612
11631
  if (value === undefined) {
11613
11632
  (0, $77857f570335d7ae$export$af88d00dbe7f521).warn("ScenarioScript.tsx:onBodyChange should not receive `undefined` as value for key `CONSTRAINED_RANGE_BODY`.");
@@ -11629,6 +11648,7 @@ function $e03f8d47f42842f8$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11629
11648
  children: "Script (readonly)"
11630
11649
  }),
11631
11650
  /*#__PURE__*/ (0, $b7VBt$jsx)(ScriptEditorComponent, {
11651
+ mode: "scenario",
11632
11652
  readOnly: true,
11633
11653
  value: (0, $7f2d99330ea6daa2$export$18972e718224868c)(scriptTemplate, editableRange)
11634
11654
  })
@@ -11642,12 +11662,12 @@ function $e03f8d47f42842f8$export$a1713ae2a4cf01b3({ scenario: scenario }) {
11642
11662
  /*#__PURE__*/ (0, $b7VBt$jsx)(ScriptEditorComponent, {
11643
11663
  scenario: scenario,
11644
11664
  mode: "scenario",
11645
- imports: importJS,
11665
+ imports: scenario.imports,
11646
11666
  template: scriptTemplate,
11647
11667
  value: scenario.body,
11648
11668
  functionName: functionName,
11649
11669
  constrainedRanges: editableRange,
11650
- onChange: onChange,
11670
+ onBodyChange: onBodyChange,
11651
11671
  onImportsChange: handleImportsChange
11652
11672
  })
11653
11673
  ]
@@ -12881,7 +12901,6 @@ function $6d89f95b52119dea$export$9fcfd118dd8900ea({ options: options , errorMap
12881
12901
  default:
12882
12902
  return null;
12883
12903
  }
12884
- return null;
12885
12904
  }
12886
12905
 
12887
12906
 
@@ -13233,8 +13252,10 @@ function $02c83340f381657e$export$9debbb9998750ca4() {
13233
13252
  ]
13234
13253
  }),
13235
13254
  /*#__PURE__*/ (0, $b7VBt$jsx)(ScriptEditorComponent, {
13255
+ mode: "test",
13236
13256
  value: script,
13237
- error: scriptError
13257
+ error: scriptError,
13258
+ readOnly: true
13238
13259
  })
13239
13260
  ]
13240
13261
  });
@@ -13247,15 +13268,19 @@ function $dfa81ce2249b0d37$export$daf800c33be5eb7e({ loading: loading , saving:
13247
13268
  const dispatch = (0, $f33bf9327a1ab3ee$export$371624ce4da5e319)();
13248
13269
  (0, $b7VBt$useEffect)(()=>{
13249
13270
  dispatch((0, $8592aa8dcb3902ac$export$2cd8252107eb640b)());
13250
- }, []);
13271
+ }, [
13272
+ dispatch
13273
+ ]);
13251
13274
  (0, $b7VBt$useEffect)(()=>{
13252
13275
  dispatch((0, $8592aa8dcb3902ac$export$9eaa806651dd33f0)(loading));
13253
13276
  }, [
13277
+ dispatch,
13254
13278
  loading
13255
13279
  ]);
13256
13280
  (0, $b7VBt$useEffect)(()=>{
13257
13281
  dispatch((0, $8592aa8dcb3902ac$export$ad10cacbaf4608fe)(saving));
13258
13282
  }, [
13283
+ dispatch,
13259
13284
  saving
13260
13285
  ]);
13261
13286
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $b7VBt$Fragment), {
@@ -13326,7 +13351,7 @@ function $045b658c7184976c$export$f290710bbb710efa({ loading: loading , saving:
13326
13351
  k6_load_zone_id: "amazon:us:ashburn",
13327
13352
  city: "Ashburn"
13328
13353
  }
13329
- ] , DocsLinkComponent: DocsLinkComponent = (0, $a2bbc3b49e805484$export$e816d7af81d48a79) , onViewChange: onViewChange , StagesVirtualizationComponent: StagesVirtualizationComponent , ScriptEditorComponent: ScriptEditorComponent = (0, $b60f5acc8283b9c9$export$32efa5142ae8aa01) , TestBuilderIconComponent: TestBuilderIconComponent = (0, $a80b21e889559c22$export$cc0ae9a5c96bcd6f) }) {
13354
+ ] , DocsLinkComponent: DocsLinkComponent = (0, $a2bbc3b49e805484$export$e816d7af81d48a79) , onViewChange: onViewChange , StagesVirtualizationComponent: StagesVirtualizationComponent , ScriptEditorComponent: ScriptEditorComponent = (0, $b60f5acc8283b9c9$export$32efa5142ae8aa01) , TestBuilderIconComponent: TestBuilderIconComponent = (0, $a80b21e889559c22$export$cc0ae9a5c96bcd6f) , readonlyScriptScenarios: readonlyScriptScenarios = true }) {
13330
13355
  // create test builder context
13331
13356
  const context = {
13332
13357
  k6Test: k6Test,
@@ -13336,7 +13361,8 @@ function $045b658c7184976c$export$f290710bbb710efa({ loading: loading , saving:
13336
13361
  onViewChange: onViewChange,
13337
13362
  StagesVirtualizationComponent: StagesVirtualizationComponent,
13338
13363
  ScriptEditorComponent: ScriptEditorComponent,
13339
- TestBuilderIconComponent: TestBuilderIconComponent
13364
+ TestBuilderIconComponent: TestBuilderIconComponent,
13365
+ readonlyScriptScenarios: readonlyScriptScenarios
13340
13366
  };
13341
13367
  return /*#__PURE__*/ (0, $b7VBt$jsx)((0, $59eb99f127c45ea7$export$9bb8a8c9de09825e), {
13342
13368
  children: /*#__PURE__*/ (0, $b7VBt$jsx)((0, $4cf6d05a57acd1d1$export$b224d382e54e6ba1), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/k6-test-builder",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "license": "AGPL-3.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/module.js",