@yadsh/dsh-qa-integrations 0.8.2 → 0.8.3

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/lib/client.js CHANGED
@@ -10212,6 +10212,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10212
10212
  else if (!HTTP_URL.test(baseUrl)) missing.push("абсолютный адрес http(s)://");
10213
10213
  return missing;
10214
10214
  }
10215
+ /** What a profile row is still missing; empty when the Host would take it. */
10216
+ function profileDraftMissing(row) {
10217
+ const missing = [];
10218
+ const id = row.id.trim();
10219
+ if (id === "") missing.push("id");
10220
+ else if (!ROW_ID.test(id)) missing.push("id строчными латинскими буквами, цифрами и дефисом");
10221
+ if (row.provider.trim() === "") missing.push("провайдер");
10222
+ if (row.instance.trim() === "") missing.push("инстанс");
10223
+ if (!row.resources.some(([key, value]) => key.trim() !== "" && value.trim() !== "")) missing.push("ограничение ресурсов");
10224
+ return missing;
10225
+ }
10215
10226
  /**
10216
10227
  * What the card says about a row it has not committed: the missing fields, or —
10217
10228
  * when nothing is missing and the Host still did not take the row — that the
@@ -10485,8 +10496,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10485
10496
  function InstanceListField(props) {
10486
10497
  const deployments = props.deployments;
10487
10498
  const [drafts, setDrafts] = (0, react.useState)(() => props.instances.map((row) => ({ ...row })));
10499
+ const storedCount = (0, react.useRef)(props.instances.length);
10488
10500
  (0, react.useEffect)(() => {
10489
- setDrafts((current) => [...props.instances.map((row) => ({ ...row })), ...current.slice(props.instances.length)]);
10501
+ setDrafts((current) => {
10502
+ const accepted = Math.max(0, props.instances.length - storedCount.current);
10503
+ const pending = current.slice(storedCount.current + accepted);
10504
+ storedCount.current = props.instances.length;
10505
+ return [...props.instances.map((row) => ({ ...row })), ...pending];
10506
+ });
10490
10507
  }, [props.instances]);
10491
10508
  /**
10492
10509
  * Writes the rows the Host can take — every stored row, plus the drafts that
@@ -10494,11 +10511,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10494
10511
  * to make the Host refuse the whole array, which is why «добавить» looked
10495
10512
  * like it did nothing.
10496
10513
  */
10497
- const commit = (next) => {
10514
+ const commit = (next, unsetWhenEmpty = next.length === 0) => {
10498
10515
  setDrafts(next);
10499
- const takeable = next.filter((row, at) => at < props.instances.length || instanceDraftMissing(row).length === 0);
10516
+ const takeable = next.filter((row, at) => at < storedCount.current || instanceDraftMissing(row).length === 0);
10500
10517
  if (takeable.length === 0) {
10501
- if (next.length === 0) props.unset(props.path);
10518
+ if (unsetWhenEmpty) props.unset(props.path);
10502
10519
  return;
10503
10520
  }
10504
10521
  props.write(props.path, takeable.map((row) => ({ ...row })));
@@ -10517,7 +10534,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10517
10534
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
10518
10535
  className: "qai-op__instances",
10519
10536
  children: drafts.map((row, index) => {
10520
- const stored = props.instances[index];
10537
+ const stored = index < storedCount.current ? props.instances[index] : void 0;
10521
10538
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
10522
10539
  className: "qai-op__instance",
10523
10540
  children: [
@@ -10613,11 +10630,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10613
10630
  className: "qai-op__row-remove",
10614
10631
  disabled: props.disabled,
10615
10632
  onClick: () => {
10616
- commit(drafts.filter((_, at) => at !== index));
10633
+ const removedStored = index < storedCount.current;
10634
+ if (removedStored) storedCount.current -= 1;
10635
+ commit(drafts.filter((_, at) => at !== index), removedStored);
10617
10636
  },
10618
10637
  children: "убрать"
10619
10638
  }),
10620
- index >= props.instances.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10639
+ index >= storedCount.current ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10621
10640
  className: "qai-op__pending",
10622
10641
  children: draftNote(instanceDraftMissing(row))
10623
10642
  }) : null
@@ -11016,34 +11035,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11016
11035
  */
11017
11036
  function ServiceProfilesField(props) {
11018
11037
  const [drafts, setDrafts] = (0, react.useState)(props.profiles);
11038
+ const storedCount = (0, react.useRef)(props.profiles.length);
11019
11039
  (0, react.useEffect)(() => {
11020
- setDrafts(props.profiles);
11040
+ setDrafts((current) => {
11041
+ const accepted = Math.max(0, props.profiles.length - storedCount.current);
11042
+ const pending = current.slice(storedCount.current + accepted);
11043
+ storedCount.current = props.profiles.length;
11044
+ return [...props.profiles, ...pending];
11045
+ });
11021
11046
  }, [props.profiles]);
11022
- const commit = (next) => {
11047
+ const commit = (next, unsetWhenEmpty = next.length === 0) => {
11023
11048
  setDrafts(next);
11024
- if (next.length === 0) {
11025
- props.unset(["managedServiceCredentials", "profiles"]);
11049
+ const persisted = next.slice(0, storedCount.current);
11050
+ if (persisted.some((row) => profileDraftMissing(row).length > 0)) return;
11051
+ const takeable = [...persisted, ...next.slice(storedCount.current).filter((row) => profileDraftMissing(row).length === 0)];
11052
+ if (takeable.length === 0) {
11053
+ if (unsetWhenEmpty) props.unset(["managedServiceCredentials", "profiles"]);
11026
11054
  return;
11027
11055
  }
11028
- props.write(["managedServiceCredentials", "profiles"], next.map(profileWire));
11056
+ props.write(["managedServiceCredentials", "profiles"], takeable.map(profileWire));
11029
11057
  };
11030
11058
  const edit = (index, patch) => {
11031
- commit(props.profiles.map((row, at) => at === index ? {
11059
+ commit(drafts.map((row, at) => at === index ? {
11032
11060
  ...row,
11033
11061
  ...patch
11034
11062
  } : row));
11035
11063
  };
11036
11064
  const commitRecord = (index, key, rows) => {
11037
11065
  if (rows.length === 0) {
11038
- commit(props.profiles.map((row, at) => at === index ? {
11066
+ commit(drafts.map((row, at) => at === index ? {
11039
11067
  ...row,
11040
11068
  [key]: []
11041
11069
  } : row));
11042
11070
  return;
11043
11071
  }
11044
- commit(props.profiles.map((row, at) => at === index ? {
11072
+ commit(drafts.map((row, at) => at === index ? {
11045
11073
  ...row,
11046
- [key]: key === "resources" ? resourceRecord(rows) : Object.fromEntries(rows.map(([operation]) => [operation, "deny"]))
11074
+ [key]: rows
11047
11075
  } : row));
11048
11076
  };
11049
11077
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11058,7 +11086,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11058
11086
  }),
11059
11087
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
11060
11088
  className: "qai-op__profiles",
11061
- children: props.profiles.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
11089
+ children: drafts.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
11062
11090
  className: "qai-op__profile",
11063
11091
  children: [
11064
11092
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11082,7 +11110,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11082
11110
  className: "qai-op__row-remove",
11083
11111
  disabled: props.disabled,
11084
11112
  onClick: () => {
11085
- commit(props.profiles.filter((_, at) => at !== index));
11113
+ const removedStored = index < storedCount.current;
11114
+ if (removedStored) storedCount.current -= 1;
11115
+ commit(drafts.filter((_, at) => at !== index), removedStored);
11086
11116
  },
11087
11117
  children: "убрать"
11088
11118
  })
@@ -11109,9 +11139,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11109
11139
  } : draft));
11110
11140
  },
11111
11141
  onBlur: () => {
11112
- const id = row.id.trim();
11113
11142
  const next = drafts[index]?.id.trim() ?? "";
11114
- if (next !== "" && next !== id) edit(index, { id: next });
11143
+ edit(index, { id: next });
11115
11144
  }
11116
11145
  })]
11117
11146
  }),
@@ -11151,9 +11180,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11151
11180
  } : draft));
11152
11181
  },
11153
11182
  onBlur: () => {
11154
- const instance = row.instance.trim();
11155
11183
  const next = drafts[index]?.instance.trim() ?? "";
11156
- if (next !== "" && next !== instance) edit(index, { instance: next });
11184
+ edit(index, { instance: next });
11157
11185
  }
11158
11186
  })]
11159
11187
  }),
@@ -11175,9 +11203,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11175
11203
  } : draft));
11176
11204
  },
11177
11205
  onBlur: () => {
11178
- const label = row.label.trim();
11179
11206
  const next = drafts[index]?.label.trim() ?? "";
11180
- if (next !== "" && next !== label) edit(index, { label: next });
11207
+ edit(index, { label: next });
11181
11208
  }
11182
11209
  })]
11183
11210
  }),
@@ -11199,9 +11226,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11199
11226
  } : draft));
11200
11227
  },
11201
11228
  onBlur: () => {
11202
- const secretFile = row.secretFile.trim();
11203
11229
  const next = drafts[index]?.secretFile.trim() ?? "";
11204
- if (next !== "" && next !== secretFile) edit(index, { secretFile: next });
11230
+ edit(index, { secretFile: next });
11205
11231
  }
11206
11232
  })]
11207
11233
  }),
@@ -11223,9 +11249,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11223
11249
  } : draft));
11224
11250
  },
11225
11251
  onBlur: () => {
11226
- const secretEnv = row.secretEnv.trim();
11227
11252
  const next = drafts[index]?.secretEnv.trim() ?? "";
11228
- if (next !== "" && next !== secretEnv) edit(index, { secretEnv: next });
11253
+ edit(index, { secretEnv: next });
11229
11254
  }
11230
11255
  })]
11231
11256
  })
@@ -11262,7 +11287,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11262
11287
  commitRecord(index, "policy", []);
11263
11288
  },
11264
11289
  overridden: props.overridden
11265
- })
11290
+ }),
11291
+ index >= storedCount.current || profileDraftMissing(row).length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11292
+ className: "qai-op__pending",
11293
+ children: draftNote(profileDraftMissing(row))
11294
+ }) : null
11266
11295
  ]
11267
11296
  }, `${index}:${row.id}`))
11268
11297
  }),
@@ -11271,7 +11300,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11271
11300
  className: "qai-op__button",
11272
11301
  disabled: props.disabled,
11273
11302
  onClick: () => {
11274
- commit([...props.profiles, {
11303
+ commit([...drafts, {
11275
11304
  id: "",
11276
11305
  provider: "gitlab",
11277
11306
  instance: "",
@@ -11451,7 +11480,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11451
11480
  disabled: !writable,
11452
11481
  write,
11453
11482
  overridden: overridden(path)
11454
- });
11483
+ }, path.join("."));
11455
11484
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardShell, {
11456
11485
  title: "Интеграции — конфигурация",
11457
11486
  description: "Операторские настройки подключений: провайдеры, адреса, возможности и сервисные доступы. Правка применяется к запущенному сервису сразу.",