@orchestrator-ui/orchestrator-ui-components 1.4.0 → 1.5.0

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.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/.turbo/turbo-lint.log +7 -1
  3. package/.turbo/turbo-test.log +6 -6
  4. package/CHANGELOG.md +22 -11
  5. package/LICENSE.txt +202 -0
  6. package/README.md +22 -0
  7. package/dist/index.d.ts +130 -28
  8. package/dist/index.js +1317 -1291
  9. package/package.json +21 -2
  10. package/src/api/index.ts +4 -3
  11. package/src/api/types.ts +53 -0
  12. package/src/components/WfoDropdownButton/WfoDropdownButton.tsx +2 -0
  13. package/src/components/WfoForms/AutoFieldLoader.tsx +6 -6
  14. package/src/components/WfoForms/formFields/AcceptField.tsx +2 -1
  15. package/src/components/WfoForms/formFields/BoolField.tsx +2 -1
  16. package/src/components/WfoForms/formFields/DividerField.tsx +1 -1
  17. package/src/components/WfoForms/formFields/ErrorField.tsx +1 -1
  18. package/src/components/WfoForms/formFields/LabelField.tsx +1 -1
  19. package/src/components/WfoForms/formFields/ListAddField.tsx +2 -1
  20. package/src/components/WfoForms/formFields/ListDelField.tsx +2 -1
  21. package/src/components/WfoForms/formFields/LongTextField.tsx +1 -1
  22. package/src/components/WfoForms/formFields/NumField.tsx +1 -1
  23. package/src/components/WfoForms/formFields/ProductField.tsx +8 -7
  24. package/src/components/WfoForms/formFields/RadioField.tsx +1 -1
  25. package/src/components/WfoForms/formFields/SelectField.tsx +4 -2
  26. package/src/components/WfoForms/formFields/SubmitField.tsx +1 -1
  27. package/src/components/WfoForms/formFields/SubscriptionField.tsx +5 -4
  28. package/src/components/WfoForms/formFields/TextField.tsx +1 -1
  29. package/src/components/WfoForms/formFields/{ContactPersonAutocomplete.tsx → deprecated/ContactPersonAutocomplete.tsx} +4 -3
  30. package/src/components/WfoForms/formFields/{ContactPersonNameField.tsx → deprecated/ContactPersonNameField.tsx} +3 -2
  31. package/src/components/WfoForms/formFields/{ImsNodeIdField.tsx → deprecated/ImsNodeIdField.tsx} +4 -3
  32. package/src/components/WfoForms/formFields/{ImsPortIdField.tsx → deprecated/ImsPortIdField.tsx} +7 -4
  33. package/src/components/WfoForms/formFields/{IpNetworkField.tsx → deprecated/IpNetworkField.tsx} +4 -3
  34. package/src/components/WfoForms/formFields/{IpPrefixTableField.tsx → deprecated/IpPrefixTableField.tsx} +5 -4
  35. package/src/components/WfoForms/formFields/{SplitPrefix.tsx → deprecated/SplitPrefix.tsx} +3 -2
  36. package/src/components/WfoForms/formFields/{TimestampField.tsx → deprecated/TimestampField.tsx} +1 -1
  37. package/src/components/WfoForms/formFields/{VlanField.tsx → deprecated/VlanField.tsx} +5 -4
  38. package/src/components/WfoForms/formFields/deprecated/index.ts +13 -0
  39. package/src/components/WfoForms/formFields/{surf → deprecated}/types.ts +1 -1
  40. package/src/components/WfoForms/formFields/index.ts +1 -6
  41. package/src/components/WfoForms/formFields/utils.spec.ts +1 -1
  42. package/src/components/WfoForms/formFields/utils.ts +3 -2
  43. package/src/pages/processes/WfoStartProcessPage.tsx +0 -6
  44. /package/src/components/WfoForms/formFields/{ContactPersonAutocompleteStyles.ts → deprecated/ContactPersonAutocompleteStyles.ts} +0 -0
  45. /package/src/components/WfoForms/formFields/{ImsPortIdFieldStyling.ts → deprecated/ImsPortIdFieldStyling.ts} +0 -0
  46. /package/src/components/WfoForms/formFields/{IpPrefixTableFieldStyling.ts → deprecated/IpPrefixTableFieldStyling.ts} +0 -0
  47. /package/src/components/WfoForms/formFields/{SplitPrefixStyling.ts → deprecated/SplitPrefixStyling.ts} +0 -0
  48. /package/src/components/WfoForms/formFields/{surf → deprecated}/utils.ts +0 -0
  49. /package/src/hooks/{surf → deprecated}/useGetSubscriptionDropdownOptions.ts +0 -0
  50. /package/src/hooks/{surf → deprecated}/useIsTaggedPort.ts +0 -0
package/dist/index.js CHANGED
@@ -48535,8 +48535,9 @@ function UnconnectedSelectField(_a) {
48535
48535
  inputId: `${id}.search`,
48536
48536
  name,
48537
48537
  onChange: (option) => {
48538
+ var _a2;
48538
48539
  if (!readOnly) {
48539
- onChange(option == null ? void 0 : option.value);
48540
+ onChange((_a2 = option == null ? void 0 : option.value) != null ? _a2 : null);
48540
48541
  }
48541
48542
  },
48542
48543
  styles: reactSelectInnerComponentStyles,
@@ -48758,13 +48759,13 @@ function Product(_a) {
48758
48759
  apiClient.products
48759
48760
  );
48760
48761
  const productById = (id, products3) => {
48761
- return products3.find((prod) => prod.productId === id);
48762
+ return products3.find((prod) => prod.product_id === id);
48762
48763
  };
48763
- if (isLoading || error)
48764
+ if (isLoading || error || !data)
48764
48765
  return null;
48765
- const products2 = productIds ? data == null ? void 0 : data.map((id) => productById(id.productId, data)) : data;
48766
+ const products2 = productIds ? productIds == null ? void 0 : productIds.map((id) => productById(id, data)) : data;
48766
48767
  const productLabelLookup = (_a2 = products2 == null ? void 0 : products2.reduce(function(mapping, product) {
48767
- mapping[product.productId] = product.name;
48768
+ mapping[product.product_id] = product.name;
48768
48769
  return mapping;
48769
48770
  }, {})) != null ? _a2 : {};
48770
48771
  return /* @__PURE__ */ jsx113(
@@ -49047,146 +49048,66 @@ function Date2(_a) {
49047
49048
  }
49048
49049
  var DateField = connectField16(Date2, { kind: "leaf" });
49049
49050
 
49050
- // src/components/WfoForms/formFields/TimestampField.tsx
49051
- import moment from "moment-timezone";
49051
+ // src/components/WfoForms/formFields/LocationCodeField.tsx
49052
+ import { useEffect as useEffect8, useState as useState18 } from "react";
49053
+ import { useTranslations as useTranslations29 } from "next-intl";
49052
49054
  import { connectField as connectField17, filterDOMProps as filterDOMProps17 } from "uniforms";
49053
- import { EuiDatePicker, EuiFormRow as EuiFormRow11, EuiText as EuiText20 } from "@elastic/eui";
49054
49055
  import { jsx as jsx119 } from "@emotion/react/jsx-runtime";
49055
- function utcTimestampToLocalMoment(utc_timestamp) {
49056
- var _a;
49057
- return moment.unix(utc_timestamp).tz((_a = moment.tz.guess()) != null ? _a : "Europe/Amsterdam");
49058
- }
49059
- function localMomentToUtcTimestamp(local_moment) {
49060
- return local_moment.unix();
49061
- }
49062
- function Timestamp(_a) {
49063
- var _b = _a, {
49064
- disabled,
49065
- id,
49066
- label,
49067
- description,
49068
- max,
49069
- min,
49070
- showTimeSelect,
49071
- locale,
49072
- dateFormat: dateFormat2,
49073
- timeFormat,
49074
- onChange,
49075
- value,
49076
- error,
49077
- showInlineError,
49078
- errorMessage
49079
- } = _b, props = __objRest(_b, [
49080
- "disabled",
49081
- "id",
49082
- "label",
49083
- "description",
49084
- "max",
49085
- "min",
49086
- "showTimeSelect",
49087
- "locale",
49088
- "dateFormat",
49089
- "timeFormat",
49090
- "onChange",
49091
- "value",
49092
- "error",
49093
- "showInlineError",
49094
- "errorMessage"
49095
- ]);
49096
- return /* @__PURE__ */ jsx119("div", __spreadProps(__spreadValues({}, filterDOMProps17(props)), { children: /* @__PURE__ */ jsx119(
49097
- EuiFormRow11,
49098
- {
49099
- label,
49100
- labelAppend: /* @__PURE__ */ jsx119(EuiText20, { size: "m", children: description }),
49101
- error: showInlineError ? errorMessage : false,
49102
- isInvalid: error,
49103
- id,
49104
- fullWidth: true,
49105
- children: /* @__PURE__ */ jsx119(
49106
- EuiDatePicker,
49107
- {
49108
- disabled,
49109
- selected: value ? utcTimestampToLocalMoment(value) : null,
49110
- value: value ? utcTimestampToLocalMoment(value).toLocaleString() : void 0,
49111
- onChange: (event) => {
49112
- onChange(
49113
- event ? localMomentToUtcTimestamp(event) : void 0
49114
- );
49115
- },
49116
- showTimeSelect,
49117
- dateFormat: dateFormat2 ? dateFormat2 : void 0,
49118
- timeFormat: timeFormat ? timeFormat : void 0,
49119
- locale: locale ? locale : "en-en",
49120
- maxDate: max ? moment.unix(max) : void 0,
49121
- minDate: min ? moment.unix(min) : void 0
49122
- }
49123
- )
49124
- }
49125
- ) }));
49056
+ filterDOMProps17.register("locationCodes");
49057
+ function LocationCode(_a) {
49058
+ var _b = _a, { locationCodes } = _b, props = __objRest(_b, ["locationCodes"]);
49059
+ const t = useTranslations29("pydanticForms");
49060
+ const [codes, setCodes] = useState18(locationCodes != null ? locationCodes : []);
49061
+ const axiosApiClient = useAxiosApiClient();
49062
+ useEffect8(() => {
49063
+ axiosApiClient.axiosFetch("surf/crm/location_codes", {}, {}, false).then((result) => {
49064
+ if (result) {
49065
+ setCodes(result);
49066
+ }
49067
+ }).catch((error) => {
49068
+ if (error) {
49069
+ console.error(error);
49070
+ }
49071
+ setCodes([]);
49072
+ });
49073
+ }, [axiosApiClient]);
49074
+ return /* @__PURE__ */ jsx119(
49075
+ UnconnectedSelectField,
49076
+ __spreadProps(__spreadValues({}, props), {
49077
+ allowedValues: codes,
49078
+ placeholder: t("widgets.locationCode.placeholder")
49079
+ })
49080
+ );
49126
49081
  }
49127
- var TimestampField = connectField17(Timestamp, { kind: "leaf" });
49128
-
49129
- // src/components/WfoForms/formFields/ContactPersonNameField.tsx
49130
- var import_lodash5 = __toESM(require_lodash(), 1);
49131
- var import_get2 = __toESM(require_get(), 1);
49132
- import React26, { useEffect as useEffect9, useState as useState18 } from "react";
49133
- import { useTranslations as useTranslations29 } from "next-intl";
49134
- import {
49135
- connectField as connectField18,
49136
- filterDOMProps as filterDOMProps18,
49137
- joinName as joinName6,
49138
- useField as useField6,
49139
- useForm as useForm6
49140
- } from "uniforms";
49141
- import { EuiFieldText as EuiFieldText2, EuiFormRow as EuiFormRow12, EuiText as EuiText21 } from "@elastic/eui";
49082
+ var LocationCodeField = connectField17(LocationCode, { kind: "leaf" });
49142
49083
 
49143
- // src/components/WfoForms/formFields/ContactPersonAutocomplete.tsx
49144
- import { useEffect as useEffect8, useRef as useRef5 } from "react";
49084
+ // src/components/WfoForms/formFields/deprecated/ContactPersonAutocomplete.tsx
49085
+ import { useEffect as useEffect9, useRef as useRef5 } from "react";
49145
49086
  import scrollIntoView from "scroll-into-view";
49146
49087
  import { EuiFlexItem as EuiFlexItem15 } from "@elastic/eui";
49147
49088
 
49148
- // src/components/WfoForms/formFields/ContactPersonAutocompleteStyles.ts
49149
- import { css as css14 } from "@emotion/react";
49150
- var getStyles9 = (theme) => {
49151
- const contactPersonAutocompleteStyling = css14`
49152
- .autocomplete-container {
49153
- position: relative;
49154
- }
49155
-
49156
- section.autocomplete {
49157
- position: relative;
49158
- z-index: 2000;
49159
- width: 100%;
49160
- border-radius: ${theme.border.radius.medium};
49161
- background-color: ${theme.colors.lightShade};
49162
- margin-bottom: 20px;
49163
-
49164
- table.result {
49165
- z-index: 2000;
49166
-
49167
- tbody tr {
49168
- cursor: pointer;
49089
+ // src/components/WfoForms/formFields/utils.ts
49090
+ import { isDate as isDate2 } from "moment";
49169
49091
 
49170
- td {
49171
- padding: 10px;
49172
- width: 50%;
49173
- vertical-align: middle;
49174
- span.matched {
49175
- font-weight: bold;
49176
- text-decoration: underline;
49177
- }
49178
- }
49179
- }
49180
- }
49181
- }
49182
- `;
49183
- return {
49184
- contactPersonAutocompleteStyling
49185
- };
49186
- };
49092
+ // src/components/WfoForms/formFields/deprecated/types.ts
49093
+ var PortMode = /* @__PURE__ */ ((PortMode2) => {
49094
+ PortMode2["TAGGED"] = "tagged";
49095
+ PortMode2["UNTAGGED"] = "untagged";
49096
+ PortMode2["LINK_MEMBER"] = "link_member";
49097
+ return PortMode2;
49098
+ })(PortMode || {});
49099
+ var ProductTag = /* @__PURE__ */ ((ProductTag2) => {
49100
+ ProductTag2["MSC"] = "MSC";
49101
+ ProductTag2["MSCNL"] = "MSCNL";
49102
+ ProductTag2["IRBSP"] = "IRBSP";
49103
+ ProductTag2["SP"] = "SP";
49104
+ ProductTag2["SPNL"] = "SPNL";
49105
+ ProductTag2["AGGSP"] = "AGGSP";
49106
+ ProductTag2["AGGSPNL"] = "AGGSPNL";
49107
+ return ProductTag2;
49108
+ })(ProductTag || {});
49187
49109
 
49188
49110
  // src/components/WfoForms/formFields/utils.ts
49189
- import { isDate as isDate2 } from "moment";
49190
49111
  var getPortMode = (productBlockInstances) => {
49191
49112
  return productBlockInstances == null ? void 0 : productBlockInstances.reduce(
49192
49113
  (portMode, productBlockInstance) => {
@@ -49232,7 +49153,47 @@ var subscriptionHasTaggedProduct = (subscriptionDetail) => {
49232
49153
  return productsWithTaggedPorts.includes(subscriptionDetail.product.tag) ? true : false;
49233
49154
  };
49234
49155
 
49235
- // src/components/WfoForms/formFields/ContactPersonAutocomplete.tsx
49156
+ // src/components/WfoForms/formFields/deprecated/ContactPersonAutocompleteStyles.ts
49157
+ import { css as css14 } from "@emotion/react";
49158
+ var getStyles9 = (theme) => {
49159
+ const contactPersonAutocompleteStyling = css14`
49160
+ .autocomplete-container {
49161
+ position: relative;
49162
+ }
49163
+
49164
+ section.autocomplete {
49165
+ position: relative;
49166
+ z-index: 2000;
49167
+ width: 100%;
49168
+ border-radius: ${theme.border.radius.medium};
49169
+ background-color: ${theme.colors.lightShade};
49170
+ margin-bottom: 20px;
49171
+
49172
+ table.result {
49173
+ z-index: 2000;
49174
+
49175
+ tbody tr {
49176
+ cursor: pointer;
49177
+
49178
+ td {
49179
+ padding: 10px;
49180
+ width: 50%;
49181
+ vertical-align: middle;
49182
+ span.matched {
49183
+ font-weight: bold;
49184
+ text-decoration: underline;
49185
+ }
49186
+ }
49187
+ }
49188
+ }
49189
+ }
49190
+ `;
49191
+ return {
49192
+ contactPersonAutocompleteStyling
49193
+ };
49194
+ };
49195
+
49196
+ // src/components/WfoForms/formFields/deprecated/ContactPersonAutocomplete.tsx
49236
49197
  import { jsx as jsx120, jsxs as jsxs71 } from "@emotion/react/jsx-runtime";
49237
49198
  var ContactPersonAutocomplete = ({
49238
49199
  query,
@@ -49243,7 +49204,7 @@ var ContactPersonAutocomplete = ({
49243
49204
  }) => {
49244
49205
  const { contactPersonAutocompleteStyling } = useWithOrchestratorTheme(getStyles9);
49245
49206
  const selectedRowRef = useRef5(null);
49246
- useEffect8(() => {
49207
+ useEffect9(() => {
49247
49208
  if (!isEmpty(suggestions) && selectedRowRef.current) {
49248
49209
  scrollIntoView(selectedRowRef.current);
49249
49210
  }
@@ -49276,7 +49237,19 @@ var ContactPersonAutocomplete = ({
49276
49237
  )) }) }) }) });
49277
49238
  };
49278
49239
 
49279
- // src/components/WfoForms/formFields/ContactPersonNameField.tsx
49240
+ // src/components/WfoForms/formFields/deprecated/ContactPersonNameField.tsx
49241
+ var import_lodash5 = __toESM(require_lodash(), 1);
49242
+ var import_get2 = __toESM(require_get(), 1);
49243
+ import React27, { useEffect as useEffect10, useState as useState19 } from "react";
49244
+ import { useTranslations as useTranslations30 } from "next-intl";
49245
+ import {
49246
+ connectField as connectField18,
49247
+ filterDOMProps as filterDOMProps18,
49248
+ joinName as joinName6,
49249
+ useField as useField6,
49250
+ useForm as useForm6
49251
+ } from "uniforms";
49252
+ import { EuiFieldText as EuiFieldText2, EuiFormRow as EuiFormRow11, EuiText as EuiText20 } from "@elastic/eui";
49280
49253
  import { Fragment as Fragment22, jsx as jsx121, jsxs as jsxs72 } from "@emotion/react/jsx-runtime";
49281
49254
  function stop(e) {
49282
49255
  if (e !== void 0 && e !== null) {
@@ -49294,7 +49267,7 @@ function ContactPersonName(_a) {
49294
49267
  var _b = _a, {
49295
49268
  disabled,
49296
49269
  id,
49297
- inputRef = React26.createRef(),
49270
+ inputRef = React27.createRef(),
49298
49271
  label,
49299
49272
  description,
49300
49273
  name,
@@ -49325,7 +49298,7 @@ function ContactPersonName(_a) {
49325
49298
  "customerKey"
49326
49299
  ]);
49327
49300
  const axiosApiClient = useAxiosApiClient();
49328
- const t = useTranslations29("pydanticForms");
49301
+ const t = useTranslations30("pydanticForms");
49329
49302
  const { model, onChange: formOnChange, schema } = useForm6();
49330
49303
  const contactsPersonFieldNameArray = joinName6(null, name).slice(0, -1);
49331
49304
  const emailFieldName = joinName6(contactsPersonFieldNameArray, "email");
@@ -49343,9 +49316,9 @@ function ContactPersonName(_a) {
49343
49316
  customerInitialValue = "";
49344
49317
  }
49345
49318
  const customerIdValue = customerId || contactsField.field.customerId || (0, import_get2.default)(model, customerIdFieldName, customerInitialValue);
49346
- const [displayAutocomplete, setDisplayAutocomplete] = useState18(false);
49347
- const [contactPersons, setContactPersons] = useState18([]);
49348
- const [selectedIndex, setSelectedIndex] = useState18(-1);
49319
+ const [displayAutocomplete, setDisplayAutocomplete] = useState19(false);
49320
+ const [contactPersons, setContactPersons] = useState19([]);
49321
+ const [selectedIndex, setSelectedIndex] = useState19(-1);
49349
49322
  const suggestions = value ? contactPersons.filter(
49350
49323
  (item) => item.name.toLowerCase().indexOf(value.toLowerCase()) > -1
49351
49324
  ).filter(
@@ -49353,7 +49326,7 @@ function ContactPersonName(_a) {
49353
49326
  (person) => person.email === item.email
49354
49327
  )
49355
49328
  ) : [];
49356
- useEffect9(() => {
49329
+ useEffect10(() => {
49357
49330
  if (customerIdValue) {
49358
49331
  axiosApiClient.axiosFetch(
49359
49332
  `/surf/crm/contacts/${customerIdValue}`,
@@ -49369,7 +49342,7 @@ function ContactPersonName(_a) {
49369
49342
  });
49370
49343
  }
49371
49344
  }, [customerIdValue, axiosApiClient]);
49372
- useEffect9(() => {
49345
+ useEffect10(() => {
49373
49346
  var _a2;
49374
49347
  if (!(0, import_lodash5.isFunction)(inputRef)) {
49375
49348
  (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
@@ -49417,10 +49390,10 @@ function ContactPersonName(_a) {
49417
49390
  setTimeout(() => setDisplayAutocomplete(false), 350);
49418
49391
  }
49419
49392
  return /* @__PURE__ */ jsx121("section", __spreadProps(__spreadValues({}, filterDOMProps18(props)), { children: /* @__PURE__ */ jsx121(
49420
- EuiFormRow12,
49393
+ EuiFormRow11,
49421
49394
  {
49422
49395
  label,
49423
- labelAppend: /* @__PURE__ */ jsx121(EuiText21, { size: "m", children: description }),
49396
+ labelAppend: /* @__PURE__ */ jsx121(EuiText20, { size: "m", children: description }),
49424
49397
  error: showInlineError ? errorMessage : false,
49425
49398
  isInvalid: error,
49426
49399
  id,
@@ -49463,10 +49436,10 @@ var ContactPersonNameField = connectField18(ContactPersonName, {
49463
49436
  kind: "leaf"
49464
49437
  });
49465
49438
 
49466
- // src/components/WfoForms/formFields/ImsNodeIdField.tsx
49439
+ // src/components/WfoForms/formFields/deprecated/ImsNodeIdField.tsx
49467
49440
  var import_lodash6 = __toESM(require_lodash(), 1);
49468
- import { useEffect as useEffect10, useState as useState19 } from "react";
49469
- import { useTranslations as useTranslations30 } from "next-intl";
49441
+ import { useEffect as useEffect11, useState as useState20 } from "react";
49442
+ import { useTranslations as useTranslations31 } from "next-intl";
49470
49443
  import { connectField as connectField19, filterDOMProps as filterDOMProps19 } from "uniforms";
49471
49444
  import { jsx as jsx122 } from "@emotion/react/jsx-runtime";
49472
49445
  filterDOMProps19.register("locationCode", "status", "unsubscribedOnly");
@@ -49486,10 +49459,10 @@ function ImsNodeId(_a) {
49486
49459
  ]);
49487
49460
  var _a2;
49488
49461
  const axiosApiClient = useAxiosApiClient();
49489
- const t = useTranslations30("pydanticForms");
49490
- const [loading, setIsLoading] = useState19(true);
49491
- const [nodes, setNodes] = useState19([]);
49492
- useEffect10(() => {
49462
+ const t = useTranslations31("pydanticForms");
49463
+ const [loading, setIsLoading] = useState20(true);
49464
+ const [nodes, setNodes] = useState20([]);
49465
+ useEffect11(() => {
49493
49466
  if (locationCode && status) {
49494
49467
  const imsNodeEndPoint = `/surf/ims/nodes/${locationCode}/${status}?unsubscribed_only=${unsubscribedOnly}`;
49495
49468
  axiosApiClient.axiosFetch(imsNodeEndPoint).then((result) => {
@@ -49521,14 +49494,14 @@ function ImsNodeId(_a) {
49521
49494
  }
49522
49495
  var ImsNodeIdField = connectField19(ImsNodeId, { kind: "leaf" });
49523
49496
 
49524
- // src/components/WfoForms/formFields/ImsPortIdField.tsx
49525
- import { useCallback as useCallback3, useEffect as useEffect11, useState as useState20 } from "react";
49497
+ // src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx
49498
+ import { useCallback as useCallback3, useEffect as useEffect12, useState as useState21 } from "react";
49526
49499
  import ReactSelect2 from "react-select";
49527
- import { useTranslations as useTranslations31 } from "next-intl";
49500
+ import { useTranslations as useTranslations32 } from "next-intl";
49528
49501
  import { connectField as connectField20, filterDOMProps as filterDOMProps20 } from "uniforms";
49529
- import { EuiFlexItem as EuiFlexItem16, EuiFormRow as EuiFormRow13, EuiText as EuiText22 } from "@elastic/eui";
49502
+ import { EuiFlexItem as EuiFlexItem16, EuiFormRow as EuiFormRow12, EuiText as EuiText21 } from "@elastic/eui";
49530
49503
 
49531
- // src/components/WfoForms/formFields/ImsPortIdFieldStyling.ts
49504
+ // src/components/WfoForms/formFields/deprecated/ImsPortIdFieldStyling.ts
49532
49505
  import { css as css15 } from "@emotion/react";
49533
49506
  var imsPortIdFieldStyling = css15`
49534
49507
  section.node-port {
@@ -49546,7 +49519,7 @@ var imsPortIdFieldStyling = css15`
49546
49519
  }
49547
49520
  `;
49548
49521
 
49549
- // src/components/WfoForms/formFields/ImsPortIdField.tsx
49522
+ // src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx
49550
49523
  import { jsx as jsx123, jsxs as jsxs73 } from "@emotion/react/jsx-runtime";
49551
49524
  function nodeToOptionCorelink(node) {
49552
49525
  return {
@@ -49595,21 +49568,22 @@ function ImsPortId(_a) {
49595
49568
  "nodeStatuses"
49596
49569
  ]);
49597
49570
  const apiClient = useAxiosApiClient();
49598
- const t = useTranslations31("pydanticForms");
49571
+ const t = useTranslations32("pydanticForms");
49599
49572
  const { theme } = useOrchestratorTheme();
49600
49573
  const reactSelectInnerComponentStyles = getReactSelectInnerComponentStyles(theme);
49601
- const [nodes, setNodes] = useState20([]);
49602
- const [nodeId, setNodeId] = useState20(
49574
+ const [nodes, setNodes] = useState21([]);
49575
+ const [nodeId, setNodeId] = useState21(
49603
49576
  nodeSubscriptionId
49604
49577
  );
49605
- const [ports, setPorts] = useState20([]);
49606
- const [loading, setLoading] = useState20(true);
49578
+ const [ports, setPorts] = useState21([]);
49579
+ const [loading, setLoading] = useState21(true);
49607
49580
  const onChangeNodes = useCallback3(
49608
49581
  (option) => {
49609
49582
  const value2 = option == null ? void 0 : option.value;
49610
49583
  if (value2 === void 0) {
49611
49584
  return;
49612
49585
  }
49586
+ onChange(void 0);
49613
49587
  setLoading(true);
49614
49588
  setNodeId(value2);
49615
49589
  setPorts([]);
@@ -49624,7 +49598,7 @@ function ImsPortId(_a) {
49624
49598
  },
49625
49599
  [interfaceSpeed, imsPortMode, apiClient]
49626
49600
  );
49627
- useEffect11(() => {
49601
+ useEffect12(() => {
49628
49602
  setLoading(true);
49629
49603
  const nodesPromise = apiClient.nodeSubscriptions(
49630
49604
  nodeStatuses != null ? nodeStatuses : ["active"]
@@ -49661,17 +49635,17 @@ function ImsPortId(_a) {
49661
49635
  })).sort((x, y) => x.label.localeCompare(y.label));
49662
49636
  const port_value = port_options.find((option) => option.value === value);
49663
49637
  return /* @__PURE__ */ jsx123(EuiFlexItem16, { css: imsPortIdFieldStyling, children: /* @__PURE__ */ jsx123("section", __spreadProps(__spreadValues({}, filterDOMProps20(props)), { children: /* @__PURE__ */ jsx123(
49664
- EuiFormRow13,
49638
+ EuiFormRow12,
49665
49639
  {
49666
49640
  label,
49667
- labelAppend: /* @__PURE__ */ jsx123(EuiText22, { size: "m", children: description }),
49641
+ labelAppend: /* @__PURE__ */ jsx123(EuiText21, { size: "m", children: description }),
49668
49642
  error: showInlineError ? errorMessage : false,
49669
49643
  isInvalid: error,
49670
49644
  id,
49671
49645
  fullWidth: true,
49672
49646
  children: /* @__PURE__ */ jsxs73("section", { className: "node-port", children: [
49673
49647
  /* @__PURE__ */ jsx123("div", { className: "node-select", children: /* @__PURE__ */ jsx123(
49674
- EuiFormRow13,
49648
+ EuiFormRow12,
49675
49649
  {
49676
49650
  label: "Node",
49677
49651
  id: `${id}.node`,
@@ -49692,7 +49666,7 @@ function ImsPortId(_a) {
49692
49666
  )
49693
49667
  }
49694
49668
  ) }),
49695
- /* @__PURE__ */ jsx123("div", { className: "port-select", children: /* @__PURE__ */ jsx123(EuiFormRow13, { label: "Port", id, fullWidth: true, children: /* @__PURE__ */ jsx123(
49669
+ /* @__PURE__ */ jsx123("div", { className: "port-select", children: /* @__PURE__ */ jsx123(EuiFormRow12, { label: "Port", id, fullWidth: true, children: /* @__PURE__ */ jsx123(
49696
49670
  ReactSelect2,
49697
49671
  {
49698
49672
  inputId: `${id}.search`,
@@ -49702,7 +49676,7 @@ function ImsPortId(_a) {
49702
49676
  },
49703
49677
  options: port_options,
49704
49678
  placeholder: portPlaceholder,
49705
- value: port_value,
49679
+ value: port_value || null,
49706
49680
  isSearchable: true,
49707
49681
  isDisabled: disabled || readOnly || ports.length === 0,
49708
49682
  styles: reactSelectInnerComponentStyles
@@ -49714,898 +49688,341 @@ function ImsPortId(_a) {
49714
49688
  }
49715
49689
  var ImsPortIdField = connectField20(ImsPortId, { kind: "leaf" });
49716
49690
 
49717
- // src/components/WfoForms/formFields/LocationCodeField.tsx
49718
- import { useEffect as useEffect12, useState as useState21 } from "react";
49719
- import { useTranslations as useTranslations32 } from "next-intl";
49691
+ // src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx
49692
+ import { useState as useState22 } from "react";
49693
+ import { useTranslations as useTranslations33 } from "next-intl";
49720
49694
  import { connectField as connectField21, filterDOMProps as filterDOMProps21 } from "uniforms";
49721
- import { jsx as jsx124 } from "@emotion/react/jsx-runtime";
49722
- filterDOMProps21.register("locationCodes");
49723
- function LocationCode(_a) {
49724
- var _b = _a, { locationCodes } = _b, props = __objRest(_b, ["locationCodes"]);
49725
- const t = useTranslations32("pydanticForms");
49726
- const [codes, setCodes] = useState21(locationCodes != null ? locationCodes : []);
49727
- const axiosApiClient = useAxiosApiClient();
49728
- useEffect12(() => {
49729
- axiosApiClient.axiosFetch("surf/crm/location_codes", {}, {}, false).then((result) => {
49730
- if (result) {
49731
- setCodes(result);
49732
- }
49733
- }).catch((error) => {
49734
- if (error) {
49735
- console.error(error);
49736
- }
49737
- setCodes([]);
49738
- });
49739
- }, [axiosApiClient]);
49740
- return /* @__PURE__ */ jsx124(
49741
- UnconnectedSelectField,
49742
- __spreadProps(__spreadValues({}, props), {
49743
- allowedValues: codes,
49744
- placeholder: t("widgets.locationCode.placeholder")
49745
- })
49746
- );
49747
- }
49748
- var LocationCodeField = connectField21(LocationCode, { kind: "leaf" });
49695
+ import { EuiCallOut as EuiCallOut2, EuiFormRow as EuiFormRow14, EuiText as EuiText23 } from "@elastic/eui";
49749
49696
 
49750
- // src/components/WfoForms/formFields/VlanField.tsx
49751
- var import_get3 = __toESM(require_get(), 1);
49752
- import { useEffect as useEffect13, useState as useState22 } from "react";
49753
- import { useTranslations as useTranslations33 } from "next-intl";
49754
- import { connectField as connectField22, filterDOMProps as filterDOMProps22, joinName as joinName7, useForm as useForm7 } from "uniforms";
49755
- import { EuiFieldText as EuiFieldText3, EuiFormRow as EuiFormRow14, EuiText as EuiText23 } from "@elastic/eui";
49697
+ // src/components/WfoForms/formFields/deprecated/SplitPrefix.tsx
49698
+ var import_lodash7 = __toESM(require_lodash(), 1);
49699
+ import React30 from "react";
49700
+ import ReactSelect3 from "react-select";
49701
+ import { EuiFlexItem as EuiFlexItem17 } from "@elastic/eui";
49756
49702
 
49757
- // src/hooks/surf/useIsTaggedPort.ts
49758
- var useIsTaggedPort = (subscriptionId) => {
49759
- const { data, isFetching } = useGetSubscriptionDetailQuery(
49760
- { subscriptionId },
49761
- { skip: !subscriptionId }
49762
- );
49763
- const subscriptionDetail = data == null ? void 0 : data.subscription;
49764
- const portIsTagged = subscriptionDetail ? subscriptionHasTaggedPortModeInstanceValue(subscriptionDetail) || subscriptionHasTaggedProduct(subscriptionDetail) : false;
49765
- return [!isFetching, portIsTagged];
49766
- };
49703
+ // src/components/WfoForms/formFields/deprecated/SplitPrefixStyling.ts
49704
+ import { css as css16 } from "@emotion/react";
49705
+ var splitPrefixStyling = css16`
49706
+ section.split-prefix {
49707
+ display: flex;
49708
+ flex-direction: column;
49709
+ flex-wrap: wrap;
49710
+ width: 100%;
49711
+ height: 80;
49712
+ }
49713
+ `;
49767
49714
 
49768
- // src/components/WfoForms/formFields/VlanField.tsx
49769
- import { jsx as jsx125 } from "@emotion/react/jsx-runtime";
49770
- function inValidVlan(vlan) {
49771
- const value = vlan || "0";
49772
- const stripped = value.toString().replace(/ /g, "");
49773
- return !/^\d{1,4}(?:-\d{1,4})?(?:,\d{1,4}(?:-\d{1,4})?)*$/.test(stripped) || stripped.split(",").some(inValidRange);
49774
- }
49775
- function inValidRange(range3) {
49776
- if (range3.indexOf("-") > -1) {
49777
- const ranges = range3.split("-");
49778
- return ranges.some(inValidRange) || parseInt(ranges[0], 10) >= parseInt(ranges[1], 10);
49779
- }
49780
- return parseInt(range3, 10) < 2 || parseInt(range3, 10) > 4094;
49781
- }
49782
- function getAllNumbersForVlanRange(vlanRange) {
49783
- if (!vlanRange) {
49784
- return [];
49785
- }
49786
- if (vlanRange !== "0" && inValidVlan(vlanRange)) {
49787
- return [];
49715
+ // src/components/WfoForms/formFields/deprecated/SplitPrefix.tsx
49716
+ import { jsx as jsx124, jsxs as jsxs74 } from "@emotion/react/jsx-runtime";
49717
+ var SplitPrefix = class extends React30.PureComponent {
49718
+ constructor() {
49719
+ super(...arguments);
49720
+ this.state = {
49721
+ subnets: [],
49722
+ desiredPrefixlen: 0
49723
+ };
49724
+ this.changePrefixLength = (e) => {
49725
+ const { subnet, prefixlen } = __spreadValues({}, this.props);
49726
+ const desiredPrefixlen = e == null ? void 0 : e.value;
49727
+ if (desiredPrefixlen) {
49728
+ this.fetchFreePrefixes(subnet, prefixlen, desiredPrefixlen);
49729
+ }
49730
+ };
49731
+ this.selectSubnet = (e) => {
49732
+ var _a;
49733
+ this.props.onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
49734
+ };
49788
49735
  }
49789
- return numbersFromGroupedArray(
49790
- vlanRange.replace(/ /g, "").split(",").map((sl) => sl.split("-").map(Number))
49791
- );
49792
- }
49793
- function numbersFromGroupedArray(list) {
49794
- return list.reduce((acc, boundaries) => {
49795
- const max = boundaries[boundaries.length - 1];
49796
- const min = boundaries[0];
49797
- return acc.concat(
49798
- Array.from(new Array(max - min + 1), (x, i) => min + i)
49799
- );
49800
- }, []);
49801
- }
49802
- function groupedArrayFromNumbers(numbers) {
49803
- numbers = [...numbers].sort((a, b) => a - b);
49804
- const groupedNumbers = numbers.reduce((r, n) => {
49805
- let lastSubArray = r[r.length - 1];
49806
- if (lastSubArray && lastSubArray[lastSubArray.length - 1] === n) {
49807
- return r;
49808
- }
49809
- if (!lastSubArray || lastSubArray[lastSubArray.length - 1] !== n - 1) {
49810
- lastSubArray = [];
49811
- r.push(lastSubArray);
49812
- }
49813
- lastSubArray.push(n);
49814
- return r;
49815
- }, []);
49816
- return groupedNumbers.map(
49817
- (l) => l[0] !== l[l.length - 1] ? [l[0], l[l.length - 1]] : [l[0]]
49818
- );
49819
- }
49820
- function vlanRangeFromNumbers(list) {
49821
- return groupedArrayFromNumbers(list).map((sl) => sl.join("-")).join(",");
49822
- }
49823
- function Vlan(_a) {
49824
- var _b = _a, {
49825
- disabled,
49826
- id,
49827
- label,
49828
- description,
49829
- name,
49830
- onChange,
49831
- readOnly,
49832
- value,
49833
- error,
49834
- showInlineError,
49835
- errorMessage,
49836
- subscriptionFieldName = "subscription_id",
49837
- nsiVlansOnly = false
49838
- } = _b, props = __objRest(_b, [
49839
- "disabled",
49840
- "id",
49841
- "label",
49842
- "description",
49843
- "name",
49844
- "onChange",
49845
- "readOnly",
49846
- "value",
49847
- "error",
49848
- "showInlineError",
49849
- "errorMessage",
49850
- "subscriptionFieldName",
49851
- "nsiVlansOnly"
49852
- ]);
49853
- const t = useTranslations33("pydanticForms");
49854
- const axiosApiClient = useAxiosApiClient();
49855
- const { model, schema } = useForm7();
49856
- const initialValue = schema.getInitialValue(name, {});
49857
- const nameArray = joinName7(null, name);
49858
- const selfName = nameArray.slice(-1);
49859
- const subscriptionIdFieldName = joinName7(
49860
- nameArray.slice(0, -1),
49861
- subscriptionFieldName
49862
- );
49863
- const completeListFieldName = joinName7(nameArray.slice(0, -2));
49864
- const subscriptionId = (0, import_get3.default)(model, subscriptionIdFieldName);
49865
- const [isFetched, portIsTagged] = useIsTaggedPort(subscriptionId);
49866
- const completeList = (0, import_get3.default)(model, completeListFieldName) || [];
49867
- const extraUsedVlans = completeList.filter(
49868
- (_item, index) => index.toString() !== nameArray.slice(-2, -1)[0]
49869
- ).filter((item) => (0, import_get3.default)(item, subscriptionFieldName) === subscriptionId).map((item) => (0, import_get3.default)(item, selfName)).join(",");
49870
- useEffect13(() => {
49871
- if (subscriptionId && isFetched && !portIsTagged && value !== "0") {
49872
- onChange("0");
49873
- } else if (!subscriptionId && value !== "" || subscriptionId && portIsTagged && value === "0") {
49874
- onChange("");
49875
- }
49876
- }, [onChange, subscriptionId, value, isFetched, portIsTagged]);
49877
- const [imsIsLoading, setImsIsLoading] = useState22(false);
49878
- const [usedVlansInIms, setUsedVlansInIms] = useState22([]);
49879
- const [missingInIms, setMissingInIms] = useState22(false);
49880
- useEffect13(() => {
49881
- if (subscriptionId) {
49882
- setImsIsLoading(true);
49883
- axiosApiClient.axiosFetch(
49884
- `surf/subscriptions/vlans-by-service-port/${subscriptionId}?nsi_vlans_only=${nsiVlansOnly}`
49885
- ).then((result) => {
49886
- setUsedVlansInIms(result);
49887
- setMissingInIms(false);
49888
- }).catch((error2) => {
49889
- console.error(error2);
49890
- setMissingInIms(true);
49891
- setUsedVlansInIms([]);
49892
- }).finally(() => setImsIsLoading(false));
49893
- }
49894
- }, [axiosApiClient, nsiVlansOnly, subscriptionId]);
49895
- const currentVlans = getAllNumbersForVlanRange(initialValue);
49896
- const usedVlans = numbersFromGroupedArray(usedVlansInIms).filter(
49897
- (n) => !currentVlans.includes(n)
49898
- );
49899
- const allUsedVlans = usedVlans.concat(getAllNumbersForVlanRange(extraUsedVlans)).sort();
49900
- const validFormat = !value || value === "0" || !inValidVlan(value);
49901
- const vlansInUse = validFormat && !disabled ? getAllNumbersForVlanRange(value).filter(
49902
- (num) => allUsedVlans.includes(num)
49903
- ) : [];
49904
- const placeholder = imsIsLoading ? t("widgets.vlan.loadingIms") : subscriptionId ? t("widgets.vlan.placeholder") : t("widgets.vlan.placeholderNoServicePort");
49905
- const errorMessageExtra = missingInIms ? t("widgets.vlan.missingInIms") : !validFormat ? t("widgets.vlan.invalidVlan") : vlansInUse.length ? vlansInUse.length >= 1 && vlansInUse[0] === 0 ? t("widgets.vlan.untaggedPortInUse") : t("widgets.vlan.vlansInUseError", {
49906
- vlans: vlanRangeFromNumbers(vlansInUse)
49907
- }) : void 0;
49908
- let message = "";
49909
- if (!imsIsLoading) {
49910
- if (missingInIms) {
49911
- message = t("widgets.vlan.missingInIms");
49912
- } else if (portIsTagged && nsiVlansOnly) {
49913
- const initialUsedVlans = schema.getInitialValue("service_ports", {}).map((sp) => sp.vlan);
49914
- const currentUsedVlans = initialUsedVlans.filter(
49915
- (vlan) => vlan !== value && vlan !== extraUsedVlans
49736
+ fetchFreePrefixes(subnet, prefixlen, desiredPrefixlen) {
49737
+ this.context.apiClient.free_subnets(subnet, prefixlen, desiredPrefixlen).then((result) => {
49738
+ const subnets = result.filter(
49739
+ (x) => parseInt(x.split("/")[1], 10) === desiredPrefixlen
49916
49740
  );
49917
- const allAvailableVlans = [
49918
- ...usedVlans.filter(
49919
- (number) => !getAllNumbersForVlanRange(extraUsedVlans).includes(
49920
- number
49921
- )
49922
- ),
49923
- ...currentUsedVlans
49924
- ].sort();
49925
- message = !allAvailableVlans.length ? t("widgets.vlan.nsiNoPortsAvailable") : t("widgets.vlan.nsiVlansAvailable", {
49926
- vlans: vlanRangeFromNumbers(allAvailableVlans)
49927
- });
49928
- } else if (portIsTagged) {
49929
- message = !allUsedVlans.length ? t("widgets.vlan.allPortsAvailable") : t("widgets.vlan.vlansInUse", {
49930
- vlans: vlanRangeFromNumbers(allUsedVlans)
49741
+ this.setState({
49742
+ subnets,
49743
+ desiredPrefixlen,
49744
+ loading: false
49931
49745
  });
49932
- } else {
49933
- message = t("widgets.vlan.taggedOnly");
49746
+ });
49747
+ }
49748
+ componentDidUpdate(prevProps) {
49749
+ if (this.props.subnet !== prevProps.subnet || this.props.prefixlen !== prevProps.prefixlen) {
49750
+ this.fetchFreePrefixes(
49751
+ this.props.subnet,
49752
+ this.props.prefixlen,
49753
+ this.props.prefixMin
49754
+ );
49934
49755
  }
49935
49756
  }
49936
- return /* @__PURE__ */ jsx125("section", __spreadProps(__spreadValues({}, filterDOMProps22(props)), { children: /* @__PURE__ */ jsx125(
49937
- EuiFormRow14,
49938
- {
49939
- label,
49940
- labelAppend: /* @__PURE__ */ jsx125(EuiText23, { size: "m", children: description }),
49941
- error: (error || errorMessageExtra) && showInlineError ? errorMessage || errorMessageExtra : false,
49942
- isInvalid: error,
49943
- helpText: message,
49944
- id,
49945
- fullWidth: true,
49946
- children: /* @__PURE__ */ jsx125(
49947
- EuiFieldText3,
49757
+ componentDidMount() {
49758
+ const { subnet, prefixlen, prefixMin } = __spreadValues({}, this.props);
49759
+ this.fetchFreePrefixes(subnet, prefixlen, prefixMin);
49760
+ }
49761
+ render() {
49762
+ const { id, name, subnet, prefixlen, prefixMin, selectedSubnet } = this.props;
49763
+ const version = subnet.indexOf(":") === -1 ? 4 : 6;
49764
+ const minPrefixLength = version === 4 ? 12 : 32;
49765
+ const minimalSelectablePrefixLength = minPrefixLength > prefixMin ? minPrefixLength : prefixMin;
49766
+ const maximalSelectablePrefixLength = version === 4 ? 32 : minimalSelectablePrefixLength + 12;
49767
+ const { desiredPrefixlen } = this.state;
49768
+ const prefixlengths = (0, import_lodash7.range)(
49769
+ maximalSelectablePrefixLength - minimalSelectablePrefixLength + 1
49770
+ ).map((x) => minimalSelectablePrefixLength + x);
49771
+ const length_options = prefixlengths.map((pl) => ({
49772
+ value: pl,
49773
+ label: pl.toString()
49774
+ }));
49775
+ const length_value = length_options.find(
49776
+ (option) => option.value === desiredPrefixlen
49777
+ );
49778
+ const prefix_options = this.state.subnets.map((sn) => ({
49779
+ label: sn,
49780
+ value: sn
49781
+ }));
49782
+ const prefix_value = prefix_options.find(
49783
+ (option) => option.value === selectedSubnet
49784
+ );
49785
+ return /* @__PURE__ */ jsx124(EuiFlexItem17, { css: splitPrefixStyling, children: /* @__PURE__ */ jsxs74("section", { children: [
49786
+ /* @__PURE__ */ jsxs74("h3", { children: [
49787
+ "Selected prefix: ",
49788
+ subnet,
49789
+ "/",
49790
+ prefixlen
49791
+ ] }),
49792
+ /* @__PURE__ */ jsx124("div", { children: "Desired netmask of the new subnet:" }),
49793
+ /* @__PURE__ */ jsx124(
49794
+ ReactSelect3,
49948
49795
  {
49949
- fullWidth: true,
49950
- disabled: !subscriptionId || disabled || !portIsTagged,
49951
- name,
49952
- isInvalid: error,
49953
- onChange: (event) => onChange(event.target.value),
49954
- placeholder,
49955
- readOnly,
49956
- type: "text",
49957
- value: value != null ? value : ""
49958
- }
49959
- )
49960
- }
49961
- ) }));
49962
- }
49963
- var VlanField = connectField22(Vlan, { kind: "leaf" });
49964
-
49965
- // src/components/WfoForms/formFields/NestField.tsx
49966
- import { connectField as connectField23, filterDOMProps as filterDOMProps23, joinName as joinName8 } from "uniforms";
49967
- import { AutoField as AutoField3 } from "uniforms-unstyled";
49968
- import {
49969
- EuiDescribedFormGroup,
49970
- EuiFlexGroup as EuiFlexGroup12,
49971
- EuiFlexItem as EuiFlexItem17,
49972
- EuiText as EuiText24
49973
- } from "@elastic/eui";
49974
- import { Fragment as Fragment23, jsx as jsx126, jsxs as jsxs74 } from "@emotion/react/jsx-runtime";
49975
- filterDOMProps23.register("properties", "wrap");
49976
- function Nest(_a) {
49977
- var _b = _a, {
49978
- children,
49979
- fields,
49980
- itemProps,
49981
- label,
49982
- description,
49983
- name,
49984
- className = ""
49985
- } = _b, props = __objRest(_b, [
49986
- "children",
49987
- "fields",
49988
- "itemProps",
49989
- "label",
49990
- "description",
49991
- "name",
49992
- "className"
49993
- ]);
49994
- const nameArray = joinName8(null, name);
49995
- const lastNamePart = nameArray[nameArray.length - 1];
49996
- const isInList = !isNaN(parseInt(lastNamePart));
49997
- const itemIndex = isInList ? parseInt(lastNamePart) : 0;
49998
- if (isInList) {
49999
- return /* @__PURE__ */ jsxs74(
50000
- EuiFlexGroup12,
50001
- __spreadProps(__spreadValues({}, filterDOMProps23(props)), {
50002
- className: `${className} nest-field`,
50003
- children: [
50004
- label && /* @__PURE__ */ jsxs74(Fragment23, { children: [
50005
- /* @__PURE__ */ jsx126("label", { className: "euiFormLabel euiFormRow__label", children: label }),
50006
- /* @__PURE__ */ jsx126(EuiText24, { size: "m", children: description })
50007
- ] }),
50008
- children || (fields == null ? void 0 : fields.map((field) => /* @__PURE__ */ jsx126(EuiFlexItem17, { children: /* @__PURE__ */ jsx126(
50009
- AutoField3,
50010
- __spreadProps(__spreadValues({
50011
- name: field
50012
- }, itemProps), {
50013
- label: itemIndex === 0 ? void 0 : false
50014
- })
50015
- ) }, field)))
50016
- ]
50017
- })
50018
- );
50019
- } else {
50020
- return /* @__PURE__ */ jsx126(
50021
- EuiDescribedFormGroup,
50022
- __spreadProps(__spreadValues({}, filterDOMProps23(props)), {
50023
- title: /* @__PURE__ */ jsx126("span", { children: label }),
50024
- description,
50025
- className: `${className} nest-field`,
50026
- children: children || (fields == null ? void 0 : fields.map((field) => /* @__PURE__ */ jsx126(
50027
- AutoField3,
50028
- __spreadProps(__spreadValues({
50029
- name: field
50030
- }, itemProps), {
50031
- label: itemIndex === 0 ? void 0 : false
50032
- }),
50033
- field
50034
- )))
50035
- })
50036
- );
50037
- }
50038
- }
50039
- var NestField = connectField23(Nest);
50040
-
50041
- // src/components/WfoForms/formFields/OptGroupField.tsx
50042
- import { useTranslations as useTranslations34 } from "next-intl";
50043
- import { connectField as connectField24, filterDOMProps as filterDOMProps24, useField as useField7 } from "uniforms";
50044
- import { AutoField as AutoField4 } from "uniforms-unstyled";
50045
- import { EuiDescribedFormGroup as EuiDescribedFormGroup2, EuiFlexItem as EuiFlexItem18, EuiFormRow as EuiFormRow15 } from "@elastic/eui";
50046
- import { Fragment as Fragment24, jsx as jsx127, jsxs as jsxs75 } from "@emotion/react/jsx-runtime";
50047
- filterDOMProps24.register("properties");
50048
- function OptGroup(_a) {
50049
- var _b = _a, {
50050
- fields,
50051
- itemProps,
50052
- name,
50053
- readOnly,
50054
- className = ""
50055
- } = _b, props = __objRest(_b, [
50056
- "fields",
50057
- "itemProps",
50058
- "name",
50059
- "readOnly",
50060
- "className"
50061
- ]);
50062
- const t = useTranslations34("pydanticForms.backendTranslations");
50063
- const enabled = useField7("enabled", {})[0].value;
50064
- return /* @__PURE__ */ jsx127(
50065
- EuiDescribedFormGroup2,
50066
- __spreadProps(__spreadValues({}, filterDOMProps24(props)), {
50067
- title: /* @__PURE__ */ jsx127("span", { children: t(`${name}.title`) }),
50068
- description: t(`${name}.description`),
50069
- className: `${className} optgroup-field`,
50070
- children: /* @__PURE__ */ jsxs75(Fragment24, { children: [
50071
- /* @__PURE__ */ jsx127(EuiFlexItem18, { children: /* @__PURE__ */ jsx127(
50072
- EuiFormRow15,
49796
+ id: `${id}.desired-netmask`,
49797
+ inputId: `${id}.desired-netmask.search`,
49798
+ name: `${name}.desired-netmask`,
49799
+ onChange: this.changePrefixLength,
49800
+ options: length_options,
49801
+ value: length_value
49802
+ }
49803
+ ),
49804
+ this.state.subnets && /* @__PURE__ */ jsxs74("div", { children: [
49805
+ /* @__PURE__ */ jsx124("div", { children: "Desired prefix:" }),
49806
+ /* @__PURE__ */ jsx124(
49807
+ ReactSelect3,
50073
49808
  {
50074
- error: false,
50075
- isInvalid: false,
50076
- id: name,
50077
- children: /* @__PURE__ */ jsx127(BoolField, { name: "enabled", readOnly })
49809
+ id: `${id}.desired-prefix`,
49810
+ inputId: `${id}.desired-prefix.search`,
49811
+ name: `${name}.desired-prefix`,
49812
+ options: prefix_options,
49813
+ onChange: this.selectSubnet,
49814
+ value: prefix_value
50078
49815
  }
50079
- ) }),
50080
- enabled && (fields == null ? void 0 : fields.filter((field) => field !== "enabled").map((field) => /* @__PURE__ */ jsx127(EuiFlexItem18, { children: /* @__PURE__ */ jsx127(AutoField4, __spreadValues({ name: field }, itemProps)) }, field)))
49816
+ )
50081
49817
  ] })
50082
- })
50083
- );
50084
- }
50085
- var OptGroupField = connectField24(OptGroup);
49818
+ ] }) });
49819
+ }
49820
+ };
49821
+ SplitPrefix.contextType = ApiClientContext;
50086
49822
 
50087
- // src/components/WfoForms/formFields/SubscriptionField.tsx
50088
- var import_get4 = __toESM(require_get(), 1);
50089
- import ReactSelect3 from "react-select";
50090
- import { useTranslations as useTranslations35 } from "next-intl";
50091
- import {
50092
- connectField as connectField25,
50093
- filterDOMProps as filterDOMProps25,
50094
- joinName as joinName9,
50095
- useField as useField8,
50096
- useForm as useForm8
50097
- } from "uniforms";
49823
+ // src/components/WfoForms/formFields/deprecated/IpPrefixTableField.tsx
49824
+ import React31 from "react";
49825
+ import ReactSelect4 from "react-select";
50098
49826
  import {
49827
+ EuiBadge as EuiBadge3,
49828
+ EuiButton as EuiButton9,
50099
49829
  EuiButtonIcon as EuiButtonIcon2,
50100
- EuiFlexGroup as EuiFlexGroup13,
50101
- EuiFlexItem as EuiFlexItem19,
50102
- EuiFormRow as EuiFormRow16,
50103
- EuiText as EuiText25
49830
+ EuiCheckbox as EuiCheckbox3,
49831
+ EuiFieldText as EuiFieldText3,
49832
+ EuiFlexGroup as EuiFlexGroup12,
49833
+ EuiFlexItem as EuiFlexItem18,
49834
+ EuiFormRow as EuiFormRow13,
49835
+ EuiInMemoryTable,
49836
+ EuiPanel as EuiPanel3,
49837
+ EuiText as EuiText22
50104
49838
  } from "@elastic/eui";
50105
49839
 
50106
- // src/hooks/surf/useGetSubscriptionDropdownOptions.ts
50107
- import { isError as isError2 } from "react-query";
50108
- var useGetSubscriptionDropdownOptions = (tags = [], statuses = ["active"]) => {
50109
- const tagValue = tags.join("-");
50110
- const statusValue = statuses.join("-");
50111
- const filters = [];
50112
- if (tagValue) {
50113
- filters.push({
50114
- field: "tag",
50115
- value: tagValue
50116
- });
50117
- }
50118
- if (statusValue) {
50119
- filters.push({
50120
- field: "status",
50121
- value: statusValue
50122
- });
50123
- }
50124
- const { data, isFetching, refetch } = useGetSubscriptionsDropdownOptionsQuery({ filterBy: filters });
50125
- const subscriptions = (() => {
50126
- if (!isFetching && !isError2(data) && data) {
50127
- return data.subscriptionDropdownOptions;
50128
- }
50129
- return [];
50130
- })();
50131
- return { isFetching, refetch, subscriptions };
50132
- };
49840
+ // src/components/WfoForms/formFields/types.ts
49841
+ function prop(obj, key) {
49842
+ return obj[key];
49843
+ }
50133
49844
 
50134
- // src/components/WfoForms/formFields/SubscriptionFieldStyling.ts
50135
- import { css as css16 } from "@emotion/react";
50136
- var subscriptionFieldStyling = css16`
50137
- .subscription-field {
50138
- > div {
50139
- display: flex;
49845
+ // src/components/WfoForms/formFields/deprecated/IpPrefixTableFieldStyling.ts
49846
+ import { css as css17 } from "@emotion/react";
49847
+ var DARK_GREY_COLOR = "#333333";
49848
+ var LIGHTER_GREY_COLOR = "#999999";
49849
+ var LIGHT_GOLD_COLOR = "#fca456";
49850
+ var LIGHT_PRIMARY_COLOR = "#0da3f5";
49851
+ var LIGHT_SUCCESS_COLOR = "#68ff1d";
49852
+ function shadeColor(color, percent) {
49853
+ let R = parseInt(color.substring(1, 3), 16);
49854
+ let G = parseInt(color.substring(3, 5), 16);
49855
+ let B = parseInt(color.substring(5, 7), 16);
49856
+ R = parseInt(String(R * (100 + percent) / 100));
49857
+ G = parseInt(String(G * (100 + percent) / 100));
49858
+ B = parseInt(String(B * (100 + percent) / 100));
49859
+ R = R < 255 ? R : 255;
49860
+ G = G < 255 ? G : 255;
49861
+ B = B < 255 ? B : 255;
49862
+ const RR = R.toString(16).length === 1 ? "0" + R.toString(16) : R.toString(16);
49863
+ const GG = G.toString(16).length === 1 ? "0" + G.toString(16) : G.toString(16);
49864
+ const BB = B.toString(16).length === 1 ? "0" + B.toString(16) : B.toString(16);
49865
+ return "#" + RR + GG + BB;
49866
+ }
49867
+ var ipPrefixTableFieldStyling = css17`
49868
+ table.ip-blocks {
49869
+ word-break: break-all;
49870
+ margin-bottom: 20px;
50140
49871
 
50141
- .subscription-field-select {
50142
- width: 100%;
50143
- margin-left: 5px;
49872
+ td,
49873
+ th {
49874
+ text-align: left;
49875
+ }
49876
+ tr {
49877
+ border-bottom: 1px solid ${LIGHTER_GREY_COLOR};
49878
+ }
49879
+ tr.Allocated {
49880
+ cursor: pointer;
49881
+ background-color: ${LIGHT_PRIMARY_COLOR};
49882
+ &:hover {
49883
+ background-color: ${shadeColor(LIGHT_PRIMARY_COLOR, -10)};
50144
49884
  }
50145
49885
  }
50146
-
50147
- .euiFormRow > .euiFormRow__fieldWrapper > div {
50148
- display: flex;
49886
+ tr.Planned {
49887
+ cursor: default;
49888
+ background-color: ${LIGHT_GOLD_COLOR};
50149
49889
  }
50150
- }
50151
-
50152
- // Setup sensible margins for port selectors
50153
- .subscription-field-disabled {
50154
- > div {
50155
- display: flex;
50156
- .subscription-field-select {
50157
- margin-left: 0px;
50158
- margin-top: 5px;
49890
+ tr.Free {
49891
+ cursor: pointer;
49892
+ background-color: ${LIGHT_SUCCESS_COLOR};
49893
+ &:hover {
49894
+ background-color: ${shadeColor(LIGHT_SUCCESS_COLOR, -10)};
49895
+ }
49896
+ }
49897
+ tr.Subnet {
49898
+ background-color: ${shadeColor(LIGHT_PRIMARY_COLOR, -30)};
49899
+ cursor: default;
49900
+ }
49901
+ tr.selected {
49902
+ background-color: ${DARK_GREY_COLOR};
49903
+ color: white;
49904
+ &:hover {
49905
+ background-color: black;
49906
+ }
49907
+ }
49908
+ thead {
49909
+ display: block;
49910
+ th {
49911
+ cursor: pointer;
49912
+ padding: 5px 5px 10px 5px;
49913
+ }
49914
+ th.id {
49915
+ min-width: 8em;
49916
+ }
49917
+ th.prefix {
49918
+ min-width: 15em;
49919
+ }
49920
+ th.description {
49921
+ width: 30em;
49922
+ }
49923
+ th.state {
49924
+ min-width: 25em;
50159
49925
  }
50160
49926
  }
50161
- }
50162
49927
 
50163
- .reload-subscriptions-icon-button {
50164
- margin-left: -7px;
50165
- }
49928
+ tbody {
49929
+ min-width: 1000px;
49930
+ height: 240px;
49931
+ display: block;
49932
+ overflow: auto;
49933
+ td {
49934
+ word-break: break-word;
49935
+ word-wrap: break-word;
49936
+ padding: 15px 5px;
49937
+ }
49938
+ td.id {
49939
+ min-width: 8em;
49940
+ }
49941
+ td.prefix {
49942
+ min-width: 15em;
49943
+ }
49944
+ td.description {
49945
+ width: 30em;
49946
+ }
49947
+ td.state {
49948
+ min-width: 25em;
49949
+ }
49950
+ }
49951
+ }
50166
49952
  `;
50167
49953
 
50168
- // src/components/WfoForms/formFields/SubscriptionField.tsx
50169
- import { jsx as jsx128, jsxs as jsxs76 } from "@emotion/react/jsx-runtime";
50170
- filterDOMProps25.register(
50171
- "productIds",
50172
- "excludedSubscriptionIds",
50173
- "customerId",
50174
- "customerKey",
50175
- "visiblePortMode",
50176
- "bandwidth",
50177
- "bandwidthKey",
50178
- "tags",
50179
- "statuses"
50180
- );
50181
- function SubscriptionFieldDefinition(_a) {
50182
- var _b = _a, {
50183
- disabled,
50184
- id,
50185
- label,
50186
- description,
50187
- name,
50188
- onChange,
50189
- readOnly,
50190
- value,
50191
- error,
50192
- showInlineError,
50193
- errorMessage,
50194
- className = "",
50195
- productIds = [],
50196
- excludedSubscriptionIds = [],
50197
- customerId,
50198
- customerKey,
50199
- visiblePortMode = "all",
50200
- bandwidth,
50201
- bandwidthKey,
50202
- tags,
50203
- statuses
50204
- } = _b, props = __objRest(_b, [
50205
- "disabled",
50206
- "id",
50207
- "label",
50208
- "description",
50209
- "name",
50210
- "onChange",
50211
- "readOnly",
50212
- "value",
50213
- "error",
50214
- "showInlineError",
50215
- "errorMessage",
50216
- "className",
50217
- "productIds",
50218
- "excludedSubscriptionIds",
50219
- "customerId",
50220
- "customerKey",
50221
- "visiblePortMode",
50222
- "bandwidth",
50223
- "bandwidthKey",
50224
- "tags",
50225
- "statuses"
50226
- ]);
50227
- const t = useTranslations35("pydanticForms");
50228
- const { theme } = useOrchestratorTheme();
50229
- const reactSelectInnerComponentStyles = getReactSelectInnerComponentStyles(theme);
50230
- const { refetch, subscriptions, isFetching } = useGetSubscriptionDropdownOptions(tags, statuses);
50231
- const nameArray = joinName9(null, name);
50232
- let parentName = joinName9(nameArray.slice(0, -1));
50233
- if (parentName === "") {
50234
- parentName = name;
50235
- }
50236
- const parent = useField8(parentName, {}, { absoluteName: true })[0];
50237
- const { model, schema } = useForm8();
50238
- const bandWithFromField = bandwidthKey ? (0, import_get4.default)(model, bandwidthKey) || schema.getInitialValue(bandwidthKey, {}) : void 0;
50239
- const usedBandwidth = bandwidth || bandWithFromField;
50240
- const usedCustomerId = customerKey ? (0, import_get4.default)(model, customerKey, "nonExistingOrgToFilterEverything") : customerId;
50241
- const makeLabel = (subscription) => {
50242
- var _a2;
50243
- const description2 = subscription.description || t("widgets.subscription.missingDescription");
50244
- const subscriptionSubstring = subscription.subscriptionId.substring(
50245
- 0,
50246
- 8
50247
- );
50248
- if (["Node"].includes(subscription.product.tag)) {
50249
- const description3 = subscription.description || t("widgets.subscription.missingDescription");
50250
- return `${subscription.subscriptionId.substring(
50251
- 0,
50252
- 8
50253
- )} ${description3.trim()}`;
50254
- } else if ([
50255
- "SP" /* SP */,
50256
- "SPNL" /* SPNL */,
50257
- "AGGSP" /* AGGSP */,
50258
- "AGGSPNL" /* AGGSPNL */,
50259
- "MSC" /* MSC */,
50260
- "MSCNL" /* MSCNL */,
50261
- "IRBSP" /* IRBSP */
50262
- ].includes(subscription.product.tag)) {
50263
- const portMode = getPortMode(subscription.productBlockInstances);
50264
- const subscriptionTitle = subscription.productBlockInstances[0].productBlockInstanceValues.find(
50265
- (item) => item.field === "title"
50266
- );
50267
- if (subscriptionTitle) {
50268
- return `${subscriptionSubstring} - ${description2.trim()} - ${subscriptionTitle.value}`;
50269
- }
50270
- return `${subscriptionSubstring} ${portMode == null ? void 0 : portMode.toUpperCase()} ${description2.trim()} ${(_a2 = subscription.customer) == null ? void 0 : _a2.fullname}`;
50271
- } else {
50272
- return description2.trim();
50273
- }
50274
- };
50275
- const getSubscriptionOptions = () => {
50276
- const filteredSubscriptions = subscriptions == null ? void 0 : subscriptions.filter((subscription) => {
50277
- var _a2;
50278
- if (usedBandwidth) {
50279
- const portSpeedInput = subscription.fixedInputs.find(
50280
- (fixedInput) => fixedInput.field === "port_speed"
50281
- );
50282
- if (portSpeedInput && parseInt(portSpeedInput.value.toString(), 10) < parseInt(usedBandwidth.toString(), 10)) {
50283
- return false;
50284
- }
50285
- }
50286
- if (!usedBandwidth && productIds && productIds.length > 0 && !productIds.includes(subscription.product.productId)) {
50287
- return false;
50288
- }
50289
- if (!usedBandwidth && !productIds && tags && (tags == null ? void 0 : tags.length) > 0 && !tags.includes(subscription.product.tag)) {
50290
- return false;
49954
+ // src/components/WfoForms/formFields/deprecated/utils.ts
49955
+ var ipamStates = ["Free", "Allocated", null, "Planned", null, null];
49956
+
49957
+ // src/components/WfoForms/formFields/deprecated/IpPrefixTableField.tsx
49958
+ import { Fragment as Fragment23, jsx as jsx125, jsxs as jsxs75 } from "@emotion/react/jsx-runtime";
49959
+ var IpPrefixTableField = class extends React31.PureComponent {
49960
+ constructor() {
49961
+ super(...arguments);
49962
+ this.state = {
49963
+ ipBlocks: [],
49964
+ loading: true,
49965
+ filteredIpBlocks: [],
49966
+ filteredPrefixes: [],
49967
+ selectionDone: false,
49968
+ filter: {
49969
+ state: [
49970
+ ipamStates.indexOf("Free"),
49971
+ ipamStates.indexOf("Allocated"),
49972
+ ipamStates.indexOf("Planned"),
49973
+ ipamStates.indexOf("Subnet")
49974
+ ],
49975
+ prefix: void 0
49976
+ },
49977
+ sorted: {
49978
+ name: "prefix",
49979
+ descending: false
49980
+ },
49981
+ manualOverrideVisible: false,
49982
+ manualOverrideValue: ""
49983
+ };
49984
+ this.sort = (name) => (e) => {
49985
+ if (e !== void 0 && e !== null) {
49986
+ e.preventDefault();
49987
+ e.stopPropagation();
50291
49988
  }
50292
- if (excludedSubscriptionIds && excludedSubscriptionIds.length > 0 && excludedSubscriptionIds.includes(subscription.subscriptionId)) {
50293
- return false;
49989
+ const sorted = __spreadValues({}, this.state.sorted);
49990
+ sorted.descending = sorted.name === name ? !sorted.descending : false;
49991
+ sorted.name = name;
49992
+ this.setState({
49993
+ sorted,
49994
+ filteredIpBlocks: this.filterAndSortBlocks()
49995
+ });
49996
+ };
49997
+ this.sortBy = (name) => (a, b) => {
49998
+ const aVal = prop(a, name);
49999
+ const bVal = prop(b, name);
50000
+ try {
50001
+ return typeof aVal === "string" && typeof bVal === "string" ? aVal.toLowerCase().localeCompare(bVal.toLowerCase()) : aVal - bVal;
50002
+ } catch (e) {
50003
+ console.error(e);
50294
50004
  }
50295
- if (visiblePortMode !== "all") {
50296
- const portMode = getPortMode(
50297
- subscription.productBlockInstances
50005
+ return 0;
50006
+ };
50007
+ this.sortColumnIcon = (name, sorted) => {
50008
+ if (sorted.name === name) {
50009
+ return /* @__PURE__ */ jsx125(
50010
+ "i",
50011
+ {
50012
+ className: sorted.descending ? "fas fa-sort-down" : "fas fa-sort-up"
50013
+ }
50298
50014
  );
50299
- if (visiblePortMode === "normal" && !["tagged" /* TAGGED */, "untagged" /* UNTAGGED */, void 0].includes(
50300
- portMode
50301
- )) {
50302
- return false;
50303
- } else if (portMode !== visiblePortMode && visiblePortMode !== "normal") {
50304
- return false;
50305
- }
50306
- }
50307
- if (usedCustomerId && ((_a2 = subscription.customer) == null ? void 0 : _a2.customerId) !== usedCustomerId) {
50308
- return false;
50309
50015
  }
50310
- if (parentName !== name) {
50311
- if (parent.fieldType === Array && // @ts-expect-error Parent field can have the uniqueItems boolean property but this is not part of JSONSchema6 type
50312
- // TODO: Figure out why this is so
50313
- parent.uniqueItems) {
50314
- const allValues = (0, import_get4.default)(model, parentName, []);
50315
- const chosenValues = allValues.filter(
50316
- (_item, index) => index.toString() !== nameArray[nameArray.length - 1]
50317
- );
50318
- if (!chosenValues.includes(subscription.subscriptionId)) {
50319
- return false;
50320
- }
50321
- }
50322
- }
50323
- return true;
50324
- });
50325
- return filteredSubscriptions ? filteredSubscriptions.map((subscription) => ({
50326
- label: makeLabel(subscription),
50327
- value: subscription.subscriptionId
50328
- })) : [];
50329
- };
50330
- const options = getSubscriptionOptions();
50331
- const selectedValue = options.find(
50332
- (option) => option.value === value
50333
- );
50334
- const isDisabled = disabled || readOnly || isFetching;
50335
- return /* @__PURE__ */ jsx128(EuiFlexItem19, { css: subscriptionFieldStyling, grow: 1, children: /* @__PURE__ */ jsx128(
50336
- "section",
50337
- __spreadProps(__spreadValues({}, filterDOMProps25(props)), {
50338
- className: `${className} subscription-field${disabled ? "-disabled" : ""}`,
50339
- children: /* @__PURE__ */ jsx128(
50340
- EuiFormRow16,
50341
- {
50342
- label,
50343
- labelAppend: /* @__PURE__ */ jsx128(EuiText25, { size: "m", children: description }),
50344
- error: showInlineError ? errorMessage : false,
50345
- isInvalid: error,
50346
- id,
50347
- fullWidth: true,
50348
- children: /* @__PURE__ */ jsxs76("div", { children: [
50349
- !disabled && /* @__PURE__ */ jsx128(
50350
- EuiFlexGroup13,
50351
- {
50352
- alignItems: "center",
50353
- gutterSize: "none",
50354
- responsive: false,
50355
- children: /* @__PURE__ */ jsx128(
50356
- EuiButtonIcon2,
50357
- {
50358
- className: "reload-subscriptions-icon-button",
50359
- id: `refresh-icon-${id}`,
50360
- "aria-label": `reload-${label}`,
50361
- iconType: "refresh",
50362
- iconSize: "l",
50363
- disabled: isDisabled,
50364
- onClick: () => {
50365
- !isDisabled ? refetch() : null;
50366
- }
50367
- }
50368
- )
50369
- }
50370
- ),
50371
- /* @__PURE__ */ jsx128(
50372
- ReactSelect3,
50373
- {
50374
- id,
50375
- inputId: `${id}.search`,
50376
- name,
50377
- onChange: (option) => {
50378
- onChange(option == null ? void 0 : option.value);
50379
- },
50380
- options,
50381
- value: selectedValue,
50382
- isSearchable: true,
50383
- isClearable: false,
50384
- placeholder: isFetching ? t("widgets.subscription.loading") : t("widgets.subscription.placeholder"),
50385
- isDisabled,
50386
- styles: reactSelectInnerComponentStyles,
50387
- className: "subscription-field-select"
50388
- }
50389
- )
50390
- ] })
50391
- }
50392
- )
50393
- })
50394
- ) });
50395
- }
50396
- var SubscriptionField = connectField25(SubscriptionFieldDefinition, {
50397
- kind: "leaf"
50398
- });
50399
-
50400
- // src/components/WfoForms/formFields/IpNetworkField.tsx
50401
- import { useState as useState23 } from "react";
50402
- import { useTranslations as useTranslations36 } from "next-intl";
50403
- import { connectField as connectField26, filterDOMProps as filterDOMProps26 } from "uniforms";
50404
- import { EuiCallOut as EuiCallOut2, EuiFormRow as EuiFormRow18, EuiText as EuiText27 } from "@elastic/eui";
50405
-
50406
- // src/components/WfoForms/formFields/IpPrefixTableField.tsx
50407
- import React31 from "react";
50408
- import ReactSelect4 from "react-select";
50409
- import {
50410
- EuiBadge as EuiBadge3,
50411
- EuiButton as EuiButton9,
50412
- EuiButtonIcon as EuiButtonIcon3,
50413
- EuiCheckbox as EuiCheckbox3,
50414
- EuiFieldText as EuiFieldText4,
50415
- EuiFlexGroup as EuiFlexGroup14,
50416
- EuiFlexItem as EuiFlexItem20,
50417
- EuiFormRow as EuiFormRow17,
50418
- EuiInMemoryTable,
50419
- EuiPanel as EuiPanel3,
50420
- EuiText as EuiText26
50421
- } from "@elastic/eui";
50422
-
50423
- // src/components/WfoForms/formFields/IpPrefixTableFieldStyling.ts
50424
- import { css as css17 } from "@emotion/react";
50425
- var DARK_GREY_COLOR = "#333333";
50426
- var LIGHTER_GREY_COLOR = "#999999";
50427
- var LIGHT_GOLD_COLOR = "#fca456";
50428
- var LIGHT_PRIMARY_COLOR = "#0da3f5";
50429
- var LIGHT_SUCCESS_COLOR = "#68ff1d";
50430
- function shadeColor(color, percent) {
50431
- let R = parseInt(color.substring(1, 3), 16);
50432
- let G = parseInt(color.substring(3, 5), 16);
50433
- let B = parseInt(color.substring(5, 7), 16);
50434
- R = parseInt(String(R * (100 + percent) / 100));
50435
- G = parseInt(String(G * (100 + percent) / 100));
50436
- B = parseInt(String(B * (100 + percent) / 100));
50437
- R = R < 255 ? R : 255;
50438
- G = G < 255 ? G : 255;
50439
- B = B < 255 ? B : 255;
50440
- const RR = R.toString(16).length === 1 ? "0" + R.toString(16) : R.toString(16);
50441
- const GG = G.toString(16).length === 1 ? "0" + G.toString(16) : G.toString(16);
50442
- const BB = B.toString(16).length === 1 ? "0" + B.toString(16) : B.toString(16);
50443
- return "#" + RR + GG + BB;
50444
- }
50445
- var ipPrefixTableFieldStyling = css17`
50446
- table.ip-blocks {
50447
- word-break: break-all;
50448
- margin-bottom: 20px;
50449
-
50450
- td,
50451
- th {
50452
- text-align: left;
50453
- }
50454
- tr {
50455
- border-bottom: 1px solid ${LIGHTER_GREY_COLOR};
50456
- }
50457
- tr.Allocated {
50458
- cursor: pointer;
50459
- background-color: ${LIGHT_PRIMARY_COLOR};
50460
- &:hover {
50461
- background-color: ${shadeColor(LIGHT_PRIMARY_COLOR, -10)};
50462
- }
50463
- }
50464
- tr.Planned {
50465
- cursor: default;
50466
- background-color: ${LIGHT_GOLD_COLOR};
50467
- }
50468
- tr.Free {
50469
- cursor: pointer;
50470
- background-color: ${LIGHT_SUCCESS_COLOR};
50471
- &:hover {
50472
- background-color: ${shadeColor(LIGHT_SUCCESS_COLOR, -10)};
50473
- }
50474
- }
50475
- tr.Subnet {
50476
- background-color: ${shadeColor(LIGHT_PRIMARY_COLOR, -30)};
50477
- cursor: default;
50478
- }
50479
- tr.selected {
50480
- background-color: ${DARK_GREY_COLOR};
50481
- color: white;
50482
- &:hover {
50483
- background-color: black;
50484
- }
50485
- }
50486
- thead {
50487
- display: block;
50488
- th {
50489
- cursor: pointer;
50490
- padding: 5px 5px 10px 5px;
50491
- }
50492
- th.id {
50493
- min-width: 8em;
50494
- }
50495
- th.prefix {
50496
- min-width: 15em;
50497
- }
50498
- th.description {
50499
- width: 30em;
50500
- }
50501
- th.state {
50502
- min-width: 25em;
50503
- }
50504
- }
50505
-
50506
- tbody {
50507
- min-width: 1000px;
50508
- height: 240px;
50509
- display: block;
50510
- overflow: auto;
50511
- td {
50512
- word-break: break-word;
50513
- word-wrap: break-word;
50514
- padding: 15px 5px;
50515
- }
50516
- td.id {
50517
- min-width: 8em;
50518
- }
50519
- td.prefix {
50520
- min-width: 15em;
50521
- }
50522
- td.description {
50523
- width: 30em;
50524
- }
50525
- td.state {
50526
- min-width: 25em;
50527
- }
50528
- }
50529
- }
50530
- `;
50531
-
50532
- // src/components/WfoForms/formFields/surf/utils.ts
50533
- var ipamStates = ["Free", "Allocated", null, "Planned", null, null];
50534
-
50535
- // src/components/WfoForms/formFields/types.ts
50536
- function prop(obj, key) {
50537
- return obj[key];
50538
- }
50539
-
50540
- // src/components/WfoForms/formFields/IpPrefixTableField.tsx
50541
- import { Fragment as Fragment25, jsx as jsx129, jsxs as jsxs77 } from "@emotion/react/jsx-runtime";
50542
- var IpPrefixTableField = class extends React31.PureComponent {
50543
- constructor() {
50544
- super(...arguments);
50545
- this.state = {
50546
- ipBlocks: [],
50547
- loading: true,
50548
- filteredIpBlocks: [],
50549
- filteredPrefixes: [],
50550
- selectionDone: false,
50551
- filter: {
50552
- state: [
50553
- ipamStates.indexOf("Free"),
50554
- ipamStates.indexOf("Allocated"),
50555
- ipamStates.indexOf("Planned"),
50556
- ipamStates.indexOf("Subnet")
50557
- ],
50558
- prefix: void 0
50559
- },
50560
- sorted: {
50561
- name: "prefix",
50562
- descending: false
50563
- },
50564
- manualOverrideVisible: false,
50565
- manualOverrideValue: ""
50566
- };
50567
- this.sort = (name) => (e) => {
50568
- if (e !== void 0 && e !== null) {
50569
- e.preventDefault();
50570
- e.stopPropagation();
50571
- }
50572
- const sorted = __spreadValues({}, this.state.sorted);
50573
- sorted.descending = sorted.name === name ? !sorted.descending : false;
50574
- sorted.name = name;
50575
- this.setState({
50576
- sorted,
50577
- filteredIpBlocks: this.filterAndSortBlocks()
50578
- });
50579
- };
50580
- this.sortBy = (name) => (a, b) => {
50581
- const aVal = prop(a, name);
50582
- const bVal = prop(b, name);
50583
- try {
50584
- return typeof aVal === "string" && typeof bVal === "string" ? aVal.toLowerCase().localeCompare(bVal.toLowerCase()) : aVal - bVal;
50585
- } catch (e) {
50586
- console.error(e);
50587
- }
50588
- return 0;
50589
- };
50590
- this.sortColumnIcon = (name, sorted) => {
50591
- if (sorted.name === name) {
50592
- return /* @__PURE__ */ jsx129(
50593
- "i",
50594
- {
50595
- className: sorted.descending ? "fas fa-sort-down" : "fas fa-sort-up"
50596
- }
50597
- );
50598
- }
50599
- return /* @__PURE__ */ jsx129("i", {});
50600
- };
50601
- this.filterState = (e) => {
50602
- const target = e.target;
50603
- const state_filter = parseInt(target.value, 10);
50604
- const { filter } = this.state;
50605
- if (target.checked) {
50606
- filter.state.push(state_filter);
50607
- } else {
50608
- filter.state = filter.state.filter((e2) => e2 !== state_filter);
50016
+ return /* @__PURE__ */ jsx125("i", {});
50017
+ };
50018
+ this.filterState = (e) => {
50019
+ const target = e.target;
50020
+ const state_filter = parseInt(target.value, 10);
50021
+ const { filter } = this.state;
50022
+ if (target.checked) {
50023
+ filter.state.push(state_filter);
50024
+ } else {
50025
+ filter.state = filter.state.filter((e2) => e2 !== state_filter);
50609
50026
  }
50610
50027
  this.setState({
50611
50028
  filter,
@@ -50706,12 +50123,12 @@ var IpPrefixTableField = class extends React31.PureComponent {
50706
50123
  field: "state",
50707
50124
  name: "Status",
50708
50125
  sortable: true,
50709
- render: (prefixState) => /* @__PURE__ */ jsx129(EuiBadge3, { color: prefixState === 3 ? "danger" : "success", children: ipamStates[prefixState] })
50126
+ render: (prefixState) => /* @__PURE__ */ jsx125(EuiBadge3, { color: prefixState === 3 ? "danger" : "success", children: ipamStates[prefixState] })
50710
50127
  },
50711
50128
  {
50712
50129
  field: "Action",
50713
50130
  name: "",
50714
- render: (id2, record) => record.state !== 3 ? /* @__PURE__ */ jsx129(
50131
+ render: (id2, record) => record.state !== 3 ? /* @__PURE__ */ jsx125(
50715
50132
  EuiButton9,
50716
50133
  {
50717
50134
  onClick: this.selectPrefix(record),
@@ -50735,7 +50152,7 @@ var IpPrefixTableField = class extends React31.PureComponent {
50735
50152
  pageSizeOptions: [25, 50, 100, 250]
50736
50153
  };
50737
50154
  if (selected_prefix_id && selectionDone) {
50738
- return /* @__PURE__ */ jsx129(
50155
+ return /* @__PURE__ */ jsx125(
50739
50156
  EuiButton9,
50740
50157
  {
50741
50158
  id: "undo-parent-prefix-choice-button",
@@ -50745,17 +50162,17 @@ var IpPrefixTableField = class extends React31.PureComponent {
50745
50162
  }
50746
50163
  );
50747
50164
  }
50748
- return /* @__PURE__ */ jsxs77(EuiFlexItem20, { css: ipPrefixTableFieldStyling, children: [
50749
- /* @__PURE__ */ jsxs77("div", { children: [
50750
- /* @__PURE__ */ jsxs77(
50751
- EuiFlexGroup14,
50165
+ return /* @__PURE__ */ jsxs75(EuiFlexItem18, { css: ipPrefixTableFieldStyling, children: [
50166
+ /* @__PURE__ */ jsxs75("div", { children: [
50167
+ /* @__PURE__ */ jsxs75(
50168
+ EuiFlexGroup12,
50752
50169
  {
50753
50170
  gutterSize: "s",
50754
50171
  style: { marginTop: "5px", marginBottom: "10px" },
50755
50172
  children: [
50756
- /* @__PURE__ */ jsx129(EuiFlexItem20, { grow: false, children: /* @__PURE__ */ jsx129(EuiText26, { children: /* @__PURE__ */ jsx129("h4", { children: "Manual override?" }) }) }),
50757
- /* @__PURE__ */ jsx129(EuiFlexItem20, { grow: false, children: /* @__PURE__ */ jsx129(
50758
- EuiButtonIcon3,
50173
+ /* @__PURE__ */ jsx125(EuiFlexItem18, { grow: false, children: /* @__PURE__ */ jsx125(EuiText22, { children: /* @__PURE__ */ jsx125("h4", { children: "Manual override?" }) }) }),
50174
+ /* @__PURE__ */ jsx125(EuiFlexItem18, { grow: false, children: /* @__PURE__ */ jsx125(
50175
+ EuiButtonIcon2,
50759
50176
  {
50760
50177
  iconType: manualOverrideVisible ? "arrowDown" : "arrowRight",
50761
50178
  "aria-label": "Toggle manual override",
@@ -50764,20 +50181,20 @@ var IpPrefixTableField = class extends React31.PureComponent {
50764
50181
  })
50765
50182
  }
50766
50183
  ) }),
50767
- /* @__PURE__ */ jsx129(EuiFlexItem20, {})
50184
+ /* @__PURE__ */ jsx125(EuiFlexItem18, {})
50768
50185
  ]
50769
50186
  }
50770
50187
  ),
50771
- manualOverrideVisible && /* @__PURE__ */ jsxs77(EuiPanel3, { style: { marginBottom: "20px" }, children: [
50772
- /* @__PURE__ */ jsx129(
50773
- EuiFormRow17,
50188
+ manualOverrideVisible && /* @__PURE__ */ jsxs75(EuiPanel3, { style: { marginBottom: "20px" }, children: [
50189
+ /* @__PURE__ */ jsx125(
50190
+ EuiFormRow13,
50774
50191
  {
50775
50192
  style: { marginTop: "15px" },
50776
50193
  label: "Manually enter a prefix",
50777
- labelAppend: /* @__PURE__ */ jsx129(EuiText26, { size: "m", children: "Generating free spaces for a big IPv6 root prefix could yield an enormous list. If you know the address of a free subnet you can provide it here. The prefix will be created in the biggest existing prefix above it in one of the root prefixes." }),
50194
+ labelAppend: /* @__PURE__ */ jsx125(EuiText22, { size: "m", children: "Generating free spaces for a big IPv6 root prefix could yield an enormous list. If you know the address of a free subnet you can provide it here. The prefix will be created in the biggest existing prefix above it in one of the root prefixes." }),
50778
50195
  helpText: "Example: 145.145.10/17",
50779
- children: /* @__PURE__ */ jsx129(
50780
- EuiFieldText4,
50196
+ children: /* @__PURE__ */ jsx125(
50197
+ EuiFieldText3,
50781
50198
  {
50782
50199
  value: manualOverrideValue,
50783
50200
  onChange: (e) => this.setState({
@@ -50787,7 +50204,7 @@ var IpPrefixTableField = class extends React31.PureComponent {
50787
50204
  )
50788
50205
  }
50789
50206
  ),
50790
- /* @__PURE__ */ jsx129(
50207
+ /* @__PURE__ */ jsx125(
50791
50208
  EuiButton9,
50792
50209
  {
50793
50210
  onClick: () => this.props.onManualOverride(
@@ -50798,18 +50215,18 @@ var IpPrefixTableField = class extends React31.PureComponent {
50798
50215
  )
50799
50216
  ] })
50800
50217
  ] }),
50801
- !manualOverrideVisible && /* @__PURE__ */ jsxs77(Fragment25, { children: [
50802
- /* @__PURE__ */ jsxs77("div", { children: [
50803
- /* @__PURE__ */ jsxs77(EuiFlexGroup14, { gutterSize: "s", children: [
50804
- /* @__PURE__ */ jsx129(
50805
- EuiFlexItem20,
50218
+ !manualOverrideVisible && /* @__PURE__ */ jsxs75(Fragment23, { children: [
50219
+ /* @__PURE__ */ jsxs75("div", { children: [
50220
+ /* @__PURE__ */ jsxs75(EuiFlexGroup12, { gutterSize: "s", children: [
50221
+ /* @__PURE__ */ jsx125(
50222
+ EuiFlexItem18,
50806
50223
  {
50807
50224
  grow: false,
50808
50225
  style: { marginTop: "6px" },
50809
50226
  children: "State:"
50810
50227
  }
50811
50228
  ),
50812
- /* @__PURE__ */ jsx129(EuiFlexItem20, { grow: false, children: /* @__PURE__ */ jsx129(
50229
+ /* @__PURE__ */ jsx125(EuiFlexItem18, { grow: false, children: /* @__PURE__ */ jsx125(
50813
50230
  EuiCheckbox3,
50814
50231
  {
50815
50232
  id: "checkbox-allocated",
@@ -50822,7 +50239,7 @@ var IpPrefixTableField = class extends React31.PureComponent {
50822
50239
  )
50823
50240
  }
50824
50241
  ) }),
50825
- /* @__PURE__ */ jsx129(EuiFlexItem20, { grow: false, children: /* @__PURE__ */ jsx129(
50242
+ /* @__PURE__ */ jsx125(EuiFlexItem18, { grow: false, children: /* @__PURE__ */ jsx125(
50826
50243
  EuiCheckbox3,
50827
50244
  {
50828
50245
  id: "checkbox-planned",
@@ -50835,7 +50252,7 @@ var IpPrefixTableField = class extends React31.PureComponent {
50835
50252
  )
50836
50253
  }
50837
50254
  ) }),
50838
- /* @__PURE__ */ jsx129(EuiFlexItem20, { grow: false, children: /* @__PURE__ */ jsx129(
50255
+ /* @__PURE__ */ jsx125(EuiFlexItem18, { grow: false, children: /* @__PURE__ */ jsx125(
50839
50256
  EuiCheckbox3,
50840
50257
  {
50841
50258
  id: "checkbox-free",
@@ -50849,178 +50266,664 @@ var IpPrefixTableField = class extends React31.PureComponent {
50849
50266
  }
50850
50267
  ) })
50851
50268
  ] }),
50852
- /* @__PURE__ */ jsx129(
50853
- "div",
50854
- {
50855
- style: {
50856
- marginTop: "4px",
50857
- marginBottom: "4px"
50858
- },
50859
- children: "Root filter"
50860
- }
50861
- ),
50862
- /* @__PURE__ */ jsx129("span", { children: /* @__PURE__ */ jsx129(
50863
- ReactSelect4,
50864
- {
50865
- id: `${id}.root-filter`,
50866
- inputId: `${id}.root-filter.search`,
50867
- name: `${name}.root-filter`,
50868
- options,
50869
- onChange: this.filterParentPrefix,
50870
- value
50871
- }
50872
- ) })
50873
- ] }),
50874
- /* @__PURE__ */ jsx129(
50875
- EuiInMemoryTable,
50269
+ /* @__PURE__ */ jsx125(
50270
+ "div",
50271
+ {
50272
+ style: {
50273
+ marginTop: "4px",
50274
+ marginBottom: "4px"
50275
+ },
50276
+ children: "Root filter"
50277
+ }
50278
+ ),
50279
+ /* @__PURE__ */ jsx125("span", { children: /* @__PURE__ */ jsx125(
50280
+ ReactSelect4,
50281
+ {
50282
+ id: `${id}.root-filter`,
50283
+ inputId: `${id}.root-filter.search`,
50284
+ name: `${name}.root-filter`,
50285
+ options,
50286
+ onChange: this.filterParentPrefix,
50287
+ value
50288
+ }
50289
+ ) })
50290
+ ] }),
50291
+ /* @__PURE__ */ jsx125(
50292
+ EuiInMemoryTable,
50293
+ {
50294
+ id: "test",
50295
+ style: { marginTop: "6px" },
50296
+ itemId: "id",
50297
+ tableCaption: "Prefix table",
50298
+ loading,
50299
+ items: ipBlocks,
50300
+ columns,
50301
+ pagination,
50302
+ sorting: true
50303
+ }
50304
+ )
50305
+ ] })
50306
+ ] });
50307
+ }
50308
+ };
50309
+ IpPrefixTableField.contextType = ApiClientContext;
50310
+
50311
+ // src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx
50312
+ import { jsx as jsx126, jsxs as jsxs76 } from "@emotion/react/jsx-runtime";
50313
+ function IpNetwork(_a) {
50314
+ var _b = _a, {
50315
+ id,
50316
+ label,
50317
+ description,
50318
+ name,
50319
+ onChange,
50320
+ readOnly,
50321
+ value,
50322
+ error,
50323
+ showInlineError,
50324
+ errorMessage,
50325
+ prefixMin
50326
+ } = _b, props = __objRest(_b, [
50327
+ "id",
50328
+ "label",
50329
+ "description",
50330
+ "name",
50331
+ "onChange",
50332
+ "readOnly",
50333
+ "value",
50334
+ "error",
50335
+ "showInlineError",
50336
+ "errorMessage",
50337
+ "prefixMin"
50338
+ ]);
50339
+ var _a2, _b2;
50340
+ const t = useTranslations33("pydanticForms");
50341
+ const [selectedPrefix, setSelectedPrefix] = useState22(
50342
+ void 0
50343
+ );
50344
+ const [manualOverride, setManualOverride] = useState22(false);
50345
+ const usePrefix = (_a2 = selectedPrefix == null ? void 0 : selectedPrefix.prefix) != null ? _a2 : value;
50346
+ const [subnet, netmask] = (_b2 = usePrefix == null ? void 0 : usePrefix.split("/")) != null ? _b2 : ["", ""];
50347
+ const usedPrefixMin = prefixMin != null ? prefixMin : parseInt(netmask, 10) + ((selectedPrefix == null ? void 0 : selectedPrefix.state) === 0 ? 0 : 1);
50348
+ return /* @__PURE__ */ jsx126("section", __spreadProps(__spreadValues({}, filterDOMProps21(props)), { children: /* @__PURE__ */ jsx126(
50349
+ EuiFormRow14,
50350
+ {
50351
+ label,
50352
+ labelAppend: /* @__PURE__ */ jsx126(EuiText23, { size: "m", children: description }),
50353
+ error: showInlineError ? errorMessage : false,
50354
+ isInvalid: error,
50355
+ id,
50356
+ fullWidth: true,
50357
+ children: /* @__PURE__ */ jsx126("section", { className: "ipblock-selector", children: /* @__PURE__ */ jsxs76("div", { id, children: [
50358
+ !prefixMin && /* @__PURE__ */ jsx126(
50359
+ IpPrefixTableField,
50360
+ {
50361
+ id,
50362
+ name,
50363
+ onChange: (prefix) => {
50364
+ if (!readOnly) {
50365
+ if (prefix.state === 0 || prefix.state === 1) {
50366
+ setSelectedPrefix(prefix);
50367
+ }
50368
+ setManualOverride(false);
50369
+ onChange(prefix.prefix);
50370
+ }
50371
+ },
50372
+ onManualOverride: (prefixString) => {
50373
+ if (!readOnly) {
50374
+ setManualOverride(true);
50375
+ onChange(prefixString);
50376
+ }
50377
+ },
50378
+ selected_prefix_id: selectedPrefix == null ? void 0 : selectedPrefix.id
50379
+ }
50380
+ ),
50381
+ usePrefix && !manualOverride && /* @__PURE__ */ jsx126(
50382
+ SplitPrefix,
50383
+ {
50384
+ id,
50385
+ name,
50386
+ subnet,
50387
+ prefixlen: parseInt(netmask, 10),
50388
+ prefixMin: usedPrefixMin,
50389
+ onChange: (prefix) => {
50390
+ if (!readOnly) {
50391
+ onChange(prefix);
50392
+ }
50393
+ },
50394
+ selectedSubnet: usePrefix
50395
+ }
50396
+ ),
50397
+ usePrefix && manualOverride && /* @__PURE__ */ jsx126(
50398
+ EuiCallOut2,
50399
+ {
50400
+ title: t(
50401
+ "widgets.ipvAnyNetworkField.manuallySelectedPrefix"
50402
+ ),
50403
+ color: "primary",
50404
+ iconType: "check",
50405
+ children: /* @__PURE__ */ jsx126("p", { children: value })
50406
+ }
50407
+ )
50408
+ ] }) })
50409
+ }
50410
+ ) }));
50411
+ }
50412
+ var IpNetworkField = connectField21(IpNetwork, { kind: "leaf" });
50413
+
50414
+ // src/components/WfoForms/formFields/deprecated/TimestampField.tsx
50415
+ import moment from "moment-timezone";
50416
+ import { connectField as connectField22, filterDOMProps as filterDOMProps22 } from "uniforms";
50417
+ import { EuiDatePicker, EuiFormRow as EuiFormRow15, EuiText as EuiText24 } from "@elastic/eui";
50418
+ import { jsx as jsx127 } from "@emotion/react/jsx-runtime";
50419
+ function utcTimestampToLocalMoment(utc_timestamp) {
50420
+ var _a;
50421
+ return moment.unix(utc_timestamp).tz((_a = moment.tz.guess()) != null ? _a : "Europe/Amsterdam");
50422
+ }
50423
+ function localMomentToUtcTimestamp(local_moment) {
50424
+ return local_moment.unix();
50425
+ }
50426
+ function Timestamp(_a) {
50427
+ var _b = _a, {
50428
+ disabled,
50429
+ id,
50430
+ label,
50431
+ description,
50432
+ max,
50433
+ min,
50434
+ showTimeSelect,
50435
+ locale,
50436
+ dateFormat: dateFormat2,
50437
+ timeFormat,
50438
+ onChange,
50439
+ value,
50440
+ error,
50441
+ showInlineError,
50442
+ errorMessage
50443
+ } = _b, props = __objRest(_b, [
50444
+ "disabled",
50445
+ "id",
50446
+ "label",
50447
+ "description",
50448
+ "max",
50449
+ "min",
50450
+ "showTimeSelect",
50451
+ "locale",
50452
+ "dateFormat",
50453
+ "timeFormat",
50454
+ "onChange",
50455
+ "value",
50456
+ "error",
50457
+ "showInlineError",
50458
+ "errorMessage"
50459
+ ]);
50460
+ return /* @__PURE__ */ jsx127("div", __spreadProps(__spreadValues({}, filterDOMProps22(props)), { children: /* @__PURE__ */ jsx127(
50461
+ EuiFormRow15,
50462
+ {
50463
+ label,
50464
+ labelAppend: /* @__PURE__ */ jsx127(EuiText24, { size: "m", children: description }),
50465
+ error: showInlineError ? errorMessage : false,
50466
+ isInvalid: error,
50467
+ id,
50468
+ fullWidth: true,
50469
+ children: /* @__PURE__ */ jsx127(
50470
+ EuiDatePicker,
50471
+ {
50472
+ disabled,
50473
+ selected: value ? utcTimestampToLocalMoment(value) : null,
50474
+ value: value ? utcTimestampToLocalMoment(value).toLocaleString() : void 0,
50475
+ onChange: (event) => {
50476
+ onChange(
50477
+ event ? localMomentToUtcTimestamp(event) : void 0
50478
+ );
50479
+ },
50480
+ showTimeSelect,
50481
+ dateFormat: dateFormat2 ? dateFormat2 : void 0,
50482
+ timeFormat: timeFormat ? timeFormat : void 0,
50483
+ locale: locale ? locale : "en-en",
50484
+ maxDate: max ? moment.unix(max) : void 0,
50485
+ minDate: min ? moment.unix(min) : void 0
50486
+ }
50487
+ )
50488
+ }
50489
+ ) }));
50490
+ }
50491
+ var TimestampField = connectField22(Timestamp, { kind: "leaf" });
50492
+
50493
+ // src/components/WfoForms/formFields/deprecated/VlanField.tsx
50494
+ var import_get3 = __toESM(require_get(), 1);
50495
+ import { useEffect as useEffect13, useState as useState23 } from "react";
50496
+ import { useTranslations as useTranslations34 } from "next-intl";
50497
+ import { connectField as connectField23, filterDOMProps as filterDOMProps23, joinName as joinName7, useForm as useForm7 } from "uniforms";
50498
+ import { EuiFieldText as EuiFieldText4, EuiFormRow as EuiFormRow16, EuiText as EuiText25 } from "@elastic/eui";
50499
+
50500
+ // src/hooks/deprecated/useIsTaggedPort.ts
50501
+ var useIsTaggedPort = (subscriptionId) => {
50502
+ const { data, isFetching } = useGetSubscriptionDetailQuery(
50503
+ { subscriptionId },
50504
+ { skip: !subscriptionId }
50505
+ );
50506
+ const subscriptionDetail = data == null ? void 0 : data.subscription;
50507
+ const portIsTagged = subscriptionDetail ? subscriptionHasTaggedPortModeInstanceValue(subscriptionDetail) || subscriptionHasTaggedProduct(subscriptionDetail) : false;
50508
+ return [!isFetching, portIsTagged];
50509
+ };
50510
+
50511
+ // src/components/WfoForms/formFields/deprecated/VlanField.tsx
50512
+ import { jsx as jsx128 } from "@emotion/react/jsx-runtime";
50513
+ function inValidVlan(vlan) {
50514
+ const value = vlan || "0";
50515
+ const stripped = value.toString().replace(/ /g, "");
50516
+ return !/^\d{1,4}(?:-\d{1,4})?(?:,\d{1,4}(?:-\d{1,4})?)*$/.test(stripped) || stripped.split(",").some(inValidRange);
50517
+ }
50518
+ function inValidRange(range3) {
50519
+ if (range3.indexOf("-") > -1) {
50520
+ const ranges = range3.split("-");
50521
+ return ranges.some(inValidRange) || parseInt(ranges[0], 10) >= parseInt(ranges[1], 10);
50522
+ }
50523
+ return parseInt(range3, 10) < 2 || parseInt(range3, 10) > 4094;
50524
+ }
50525
+ function getAllNumbersForVlanRange(vlanRange) {
50526
+ if (!vlanRange) {
50527
+ return [];
50528
+ }
50529
+ if (vlanRange !== "0" && inValidVlan(vlanRange)) {
50530
+ return [];
50531
+ }
50532
+ return numbersFromGroupedArray(
50533
+ vlanRange.replace(/ /g, "").split(",").map((sl) => sl.split("-").map(Number))
50534
+ );
50535
+ }
50536
+ function numbersFromGroupedArray(list) {
50537
+ return list.reduce((acc, boundaries) => {
50538
+ const max = boundaries[boundaries.length - 1];
50539
+ const min = boundaries[0];
50540
+ return acc.concat(
50541
+ Array.from(new Array(max - min + 1), (x, i) => min + i)
50542
+ );
50543
+ }, []);
50544
+ }
50545
+ function groupedArrayFromNumbers(numbers) {
50546
+ numbers = [...numbers].sort((a, b) => a - b);
50547
+ const groupedNumbers = numbers.reduce((r, n) => {
50548
+ let lastSubArray = r[r.length - 1];
50549
+ if (lastSubArray && lastSubArray[lastSubArray.length - 1] === n) {
50550
+ return r;
50551
+ }
50552
+ if (!lastSubArray || lastSubArray[lastSubArray.length - 1] !== n - 1) {
50553
+ lastSubArray = [];
50554
+ r.push(lastSubArray);
50555
+ }
50556
+ lastSubArray.push(n);
50557
+ return r;
50558
+ }, []);
50559
+ return groupedNumbers.map(
50560
+ (l) => l[0] !== l[l.length - 1] ? [l[0], l[l.length - 1]] : [l[0]]
50561
+ );
50562
+ }
50563
+ function vlanRangeFromNumbers(list) {
50564
+ return groupedArrayFromNumbers(list).map((sl) => sl.join("-")).join(",");
50565
+ }
50566
+ function Vlan(_a) {
50567
+ var _b = _a, {
50568
+ disabled,
50569
+ id,
50570
+ label,
50571
+ description,
50572
+ name,
50573
+ onChange,
50574
+ readOnly,
50575
+ value,
50576
+ error,
50577
+ showInlineError,
50578
+ errorMessage,
50579
+ subscriptionFieldName = "subscription_id",
50580
+ nsiVlansOnly = false
50581
+ } = _b, props = __objRest(_b, [
50582
+ "disabled",
50583
+ "id",
50584
+ "label",
50585
+ "description",
50586
+ "name",
50587
+ "onChange",
50588
+ "readOnly",
50589
+ "value",
50590
+ "error",
50591
+ "showInlineError",
50592
+ "errorMessage",
50593
+ "subscriptionFieldName",
50594
+ "nsiVlansOnly"
50595
+ ]);
50596
+ const t = useTranslations34("pydanticForms");
50597
+ const axiosApiClient = useAxiosApiClient();
50598
+ const { model, schema } = useForm7();
50599
+ const initialValue = schema.getInitialValue(name, {});
50600
+ const nameArray = joinName7(null, name);
50601
+ const selfName = nameArray.slice(-1);
50602
+ const subscriptionIdFieldName = joinName7(
50603
+ nameArray.slice(0, -1),
50604
+ subscriptionFieldName
50605
+ );
50606
+ const completeListFieldName = joinName7(nameArray.slice(0, -2));
50607
+ const subscriptionId = (0, import_get3.default)(model, subscriptionIdFieldName);
50608
+ const [isFetched, portIsTagged] = useIsTaggedPort(subscriptionId);
50609
+ const completeList = (0, import_get3.default)(model, completeListFieldName) || [];
50610
+ const extraUsedVlans = completeList.filter(
50611
+ (_item, index) => index.toString() !== nameArray.slice(-2, -1)[0]
50612
+ ).filter((item) => (0, import_get3.default)(item, subscriptionFieldName) === subscriptionId).map((item) => (0, import_get3.default)(item, selfName)).join(",");
50613
+ useEffect13(() => {
50614
+ if (subscriptionId && isFetched && !portIsTagged && value !== "0") {
50615
+ onChange("0");
50616
+ } else if (!subscriptionId && value !== "" || subscriptionId && portIsTagged && value === "0") {
50617
+ onChange("");
50618
+ }
50619
+ }, [onChange, subscriptionId, value, isFetched, portIsTagged]);
50620
+ const [imsIsLoading, setImsIsLoading] = useState23(false);
50621
+ const [usedVlansInIms, setUsedVlansInIms] = useState23([]);
50622
+ const [missingInIms, setMissingInIms] = useState23(false);
50623
+ useEffect13(() => {
50624
+ if (subscriptionId) {
50625
+ setImsIsLoading(true);
50626
+ axiosApiClient.axiosFetch(
50627
+ `surf/subscriptions/vlans-by-service-port/${subscriptionId}?nsi_vlans_only=${nsiVlansOnly}`
50628
+ ).then((result) => {
50629
+ setUsedVlansInIms(result);
50630
+ setMissingInIms(false);
50631
+ }).catch((error2) => {
50632
+ console.error(error2);
50633
+ setMissingInIms(true);
50634
+ setUsedVlansInIms([]);
50635
+ }).finally(() => setImsIsLoading(false));
50636
+ }
50637
+ }, [axiosApiClient, nsiVlansOnly, subscriptionId]);
50638
+ const currentVlans = getAllNumbersForVlanRange(initialValue);
50639
+ const usedVlans = numbersFromGroupedArray(usedVlansInIms).filter(
50640
+ (n) => !currentVlans.includes(n)
50641
+ );
50642
+ const allUsedVlans = usedVlans.concat(getAllNumbersForVlanRange(extraUsedVlans)).sort();
50643
+ const validFormat = !value || value === "0" || !inValidVlan(value);
50644
+ const vlansInUse = validFormat && !disabled ? getAllNumbersForVlanRange(value).filter(
50645
+ (num) => allUsedVlans.includes(num)
50646
+ ) : [];
50647
+ const placeholder = imsIsLoading ? t("widgets.vlan.loadingIms") : subscriptionId ? t("widgets.vlan.placeholder") : t("widgets.vlan.placeholderNoServicePort");
50648
+ const errorMessageExtra = missingInIms ? t("widgets.vlan.missingInIms") : !validFormat ? t("widgets.vlan.invalidVlan") : vlansInUse.length ? vlansInUse.length >= 1 && vlansInUse[0] === 0 ? t("widgets.vlan.untaggedPortInUse") : t("widgets.vlan.vlansInUseError", {
50649
+ vlans: vlanRangeFromNumbers(vlansInUse)
50650
+ }) : void 0;
50651
+ let message = "";
50652
+ if (!imsIsLoading) {
50653
+ if (missingInIms) {
50654
+ message = t("widgets.vlan.missingInIms");
50655
+ } else if (portIsTagged && nsiVlansOnly) {
50656
+ const initialUsedVlans = schema.getInitialValue("service_ports", {}).map((sp) => sp.vlan);
50657
+ const currentUsedVlans = initialUsedVlans.filter(
50658
+ (vlan) => vlan !== value && vlan !== extraUsedVlans
50659
+ );
50660
+ const allAvailableVlans = [
50661
+ ...usedVlans.filter(
50662
+ (number) => !getAllNumbersForVlanRange(extraUsedVlans).includes(
50663
+ number
50664
+ )
50665
+ ),
50666
+ ...currentUsedVlans
50667
+ ].sort();
50668
+ message = !allAvailableVlans.length ? t("widgets.vlan.nsiNoPortsAvailable") : t("widgets.vlan.nsiVlansAvailable", {
50669
+ vlans: vlanRangeFromNumbers(allAvailableVlans)
50670
+ });
50671
+ } else if (portIsTagged) {
50672
+ message = !allUsedVlans.length ? t("widgets.vlan.allPortsAvailable") : t("widgets.vlan.vlansInUse", {
50673
+ vlans: vlanRangeFromNumbers(allUsedVlans)
50674
+ });
50675
+ } else {
50676
+ message = t("widgets.vlan.taggedOnly");
50677
+ }
50678
+ }
50679
+ return /* @__PURE__ */ jsx128("section", __spreadProps(__spreadValues({}, filterDOMProps23(props)), { children: /* @__PURE__ */ jsx128(
50680
+ EuiFormRow16,
50681
+ {
50682
+ label,
50683
+ labelAppend: /* @__PURE__ */ jsx128(EuiText25, { size: "m", children: description }),
50684
+ error: (error || errorMessageExtra) && showInlineError ? errorMessage || errorMessageExtra : false,
50685
+ isInvalid: error,
50686
+ helpText: message,
50687
+ id,
50688
+ fullWidth: true,
50689
+ children: /* @__PURE__ */ jsx128(
50690
+ EuiFieldText4,
50691
+ {
50692
+ fullWidth: true,
50693
+ disabled: !subscriptionId || disabled || !portIsTagged,
50694
+ name,
50695
+ isInvalid: error,
50696
+ onChange: (event) => onChange(event.target.value),
50697
+ placeholder,
50698
+ readOnly,
50699
+ type: "text",
50700
+ value: value != null ? value : ""
50701
+ }
50702
+ )
50703
+ }
50704
+ ) }));
50705
+ }
50706
+ var VlanField = connectField23(Vlan, { kind: "leaf" });
50707
+
50708
+ // src/components/WfoForms/formFields/NestField.tsx
50709
+ import { connectField as connectField24, filterDOMProps as filterDOMProps24, joinName as joinName8 } from "uniforms";
50710
+ import { AutoField as AutoField3 } from "uniforms-unstyled";
50711
+ import {
50712
+ EuiDescribedFormGroup,
50713
+ EuiFlexGroup as EuiFlexGroup13,
50714
+ EuiFlexItem as EuiFlexItem19,
50715
+ EuiText as EuiText26
50716
+ } from "@elastic/eui";
50717
+ import { Fragment as Fragment24, jsx as jsx129, jsxs as jsxs77 } from "@emotion/react/jsx-runtime";
50718
+ filterDOMProps24.register("properties", "wrap");
50719
+ function Nest(_a) {
50720
+ var _b = _a, {
50721
+ children,
50722
+ fields,
50723
+ itemProps,
50724
+ label,
50725
+ description,
50726
+ name,
50727
+ className = ""
50728
+ } = _b, props = __objRest(_b, [
50729
+ "children",
50730
+ "fields",
50731
+ "itemProps",
50732
+ "label",
50733
+ "description",
50734
+ "name",
50735
+ "className"
50736
+ ]);
50737
+ const nameArray = joinName8(null, name);
50738
+ const lastNamePart = nameArray[nameArray.length - 1];
50739
+ const isInList = !isNaN(parseInt(lastNamePart));
50740
+ const itemIndex = isInList ? parseInt(lastNamePart) : 0;
50741
+ if (isInList) {
50742
+ return /* @__PURE__ */ jsxs77(
50743
+ EuiFlexGroup13,
50744
+ __spreadProps(__spreadValues({}, filterDOMProps24(props)), {
50745
+ className: `${className} nest-field`,
50746
+ children: [
50747
+ label && /* @__PURE__ */ jsxs77(Fragment24, { children: [
50748
+ /* @__PURE__ */ jsx129("label", { className: "euiFormLabel euiFormRow__label", children: label }),
50749
+ /* @__PURE__ */ jsx129(EuiText26, { size: "m", children: description })
50750
+ ] }),
50751
+ children || (fields == null ? void 0 : fields.map((field) => /* @__PURE__ */ jsx129(EuiFlexItem19, { children: /* @__PURE__ */ jsx129(
50752
+ AutoField3,
50753
+ __spreadProps(__spreadValues({
50754
+ name: field
50755
+ }, itemProps), {
50756
+ label: itemIndex === 0 ? void 0 : false
50757
+ })
50758
+ ) }, field)))
50759
+ ]
50760
+ })
50761
+ );
50762
+ } else {
50763
+ return /* @__PURE__ */ jsx129(
50764
+ EuiDescribedFormGroup,
50765
+ __spreadProps(__spreadValues({}, filterDOMProps24(props)), {
50766
+ title: /* @__PURE__ */ jsx129("span", { children: label }),
50767
+ description,
50768
+ className: `${className} nest-field`,
50769
+ children: children || (fields == null ? void 0 : fields.map((field) => /* @__PURE__ */ jsx129(
50770
+ AutoField3,
50771
+ __spreadProps(__spreadValues({
50772
+ name: field
50773
+ }, itemProps), {
50774
+ label: itemIndex === 0 ? void 0 : false
50775
+ }),
50776
+ field
50777
+ )))
50778
+ })
50779
+ );
50780
+ }
50781
+ }
50782
+ var NestField = connectField24(Nest);
50783
+
50784
+ // src/components/WfoForms/formFields/OptGroupField.tsx
50785
+ import { useTranslations as useTranslations35 } from "next-intl";
50786
+ import { connectField as connectField25, filterDOMProps as filterDOMProps25, useField as useField7 } from "uniforms";
50787
+ import { AutoField as AutoField4 } from "uniforms-unstyled";
50788
+ import { EuiDescribedFormGroup as EuiDescribedFormGroup2, EuiFlexItem as EuiFlexItem20, EuiFormRow as EuiFormRow17 } from "@elastic/eui";
50789
+ import { Fragment as Fragment25, jsx as jsx130, jsxs as jsxs78 } from "@emotion/react/jsx-runtime";
50790
+ filterDOMProps25.register("properties");
50791
+ function OptGroup(_a) {
50792
+ var _b = _a, {
50793
+ fields,
50794
+ itemProps,
50795
+ name,
50796
+ readOnly,
50797
+ className = ""
50798
+ } = _b, props = __objRest(_b, [
50799
+ "fields",
50800
+ "itemProps",
50801
+ "name",
50802
+ "readOnly",
50803
+ "className"
50804
+ ]);
50805
+ const t = useTranslations35("pydanticForms.backendTranslations");
50806
+ const enabled = useField7("enabled", {})[0].value;
50807
+ return /* @__PURE__ */ jsx130(
50808
+ EuiDescribedFormGroup2,
50809
+ __spreadProps(__spreadValues({}, filterDOMProps25(props)), {
50810
+ title: /* @__PURE__ */ jsx130("span", { children: t(`${name}.title`) }),
50811
+ description: t(`${name}.description`),
50812
+ className: `${className} optgroup-field`,
50813
+ children: /* @__PURE__ */ jsxs78(Fragment25, { children: [
50814
+ /* @__PURE__ */ jsx130(EuiFlexItem20, { children: /* @__PURE__ */ jsx130(
50815
+ EuiFormRow17,
50876
50816
  {
50877
- id: "test",
50878
- style: { marginTop: "6px" },
50879
- itemId: "id",
50880
- tableCaption: "Prefix table",
50881
- loading,
50882
- items: ipBlocks,
50883
- columns,
50884
- pagination,
50885
- sorting: true
50817
+ error: false,
50818
+ isInvalid: false,
50819
+ id: name,
50820
+ children: /* @__PURE__ */ jsx130(BoolField, { name: "enabled", readOnly })
50886
50821
  }
50887
- )
50822
+ ) }),
50823
+ enabled && (fields == null ? void 0 : fields.filter((field) => field !== "enabled").map((field) => /* @__PURE__ */ jsx130(EuiFlexItem20, { children: /* @__PURE__ */ jsx130(AutoField4, __spreadValues({ name: field }, itemProps)) }, field)))
50888
50824
  ] })
50889
- ] });
50890
- }
50891
- };
50892
- IpPrefixTableField.contextType = ApiClientContext;
50825
+ })
50826
+ );
50827
+ }
50828
+ var OptGroupField = connectField25(OptGroup);
50893
50829
 
50894
- // src/components/WfoForms/formFields/SplitPrefix.tsx
50895
- var import_lodash7 = __toESM(require_lodash(), 1);
50896
- import React32 from "react";
50830
+ // src/components/WfoForms/formFields/SubscriptionField.tsx
50831
+ var import_get4 = __toESM(require_get(), 1);
50897
50832
  import ReactSelect5 from "react-select";
50898
- import { EuiFlexItem as EuiFlexItem21 } from "@elastic/eui";
50899
-
50900
- // src/components/WfoForms/formFields/SplitPrefixStyling.ts
50901
- import { css as css18 } from "@emotion/react";
50902
- var splitPrefixStyling = css18`
50903
- section.split-prefix {
50904
- display: flex;
50905
- flex-direction: column;
50906
- flex-wrap: wrap;
50907
- width: 100%;
50908
- height: 80;
50909
- }
50910
- `;
50833
+ import { useTranslations as useTranslations36 } from "next-intl";
50834
+ import {
50835
+ connectField as connectField26,
50836
+ filterDOMProps as filterDOMProps26,
50837
+ joinName as joinName9,
50838
+ useField as useField8,
50839
+ useForm as useForm8
50840
+ } from "uniforms";
50841
+ import {
50842
+ EuiButtonIcon as EuiButtonIcon3,
50843
+ EuiFlexGroup as EuiFlexGroup14,
50844
+ EuiFlexItem as EuiFlexItem21,
50845
+ EuiFormRow as EuiFormRow18,
50846
+ EuiText as EuiText27
50847
+ } from "@elastic/eui";
50911
50848
 
50912
- // src/components/WfoForms/formFields/SplitPrefix.tsx
50913
- import { jsx as jsx130, jsxs as jsxs78 } from "@emotion/react/jsx-runtime";
50914
- var SplitPrefix = class extends React32.PureComponent {
50915
- constructor() {
50916
- super(...arguments);
50917
- this.state = {
50918
- subnets: [],
50919
- desiredPrefixlen: 0
50920
- };
50921
- this.changePrefixLength = (e) => {
50922
- const { subnet, prefixlen } = __spreadValues({}, this.props);
50923
- const desiredPrefixlen = e == null ? void 0 : e.value;
50924
- if (desiredPrefixlen) {
50925
- this.fetchFreePrefixes(subnet, prefixlen, desiredPrefixlen);
50926
- }
50927
- };
50928
- this.selectSubnet = (e) => {
50929
- var _a;
50930
- this.props.onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
50931
- };
50849
+ // src/hooks/deprecated/useGetSubscriptionDropdownOptions.ts
50850
+ import { isError as isError2 } from "react-query";
50851
+ var useGetSubscriptionDropdownOptions = (tags = [], statuses = ["active"]) => {
50852
+ const tagValue = tags.join("-");
50853
+ const statusValue = statuses.join("-");
50854
+ const filters = [];
50855
+ if (tagValue) {
50856
+ filters.push({
50857
+ field: "tag",
50858
+ value: tagValue
50859
+ });
50932
50860
  }
50933
- fetchFreePrefixes(subnet, prefixlen, desiredPrefixlen) {
50934
- this.context.apiClient.free_subnets(subnet, prefixlen, desiredPrefixlen).then((result) => {
50935
- const subnets = result.filter(
50936
- (x) => parseInt(x.split("/")[1], 10) === desiredPrefixlen
50937
- );
50938
- this.setState({
50939
- subnets,
50940
- desiredPrefixlen,
50941
- loading: false
50942
- });
50861
+ if (statusValue) {
50862
+ filters.push({
50863
+ field: "status",
50864
+ value: statusValue
50943
50865
  });
50944
50866
  }
50945
- componentDidUpdate(prevProps) {
50946
- if (this.props.subnet !== prevProps.subnet || this.props.prefixlen !== prevProps.prefixlen) {
50947
- this.fetchFreePrefixes(
50948
- this.props.subnet,
50949
- this.props.prefixlen,
50950
- this.props.prefixMin
50951
- );
50867
+ const { data, isFetching, refetch } = useGetSubscriptionsDropdownOptionsQuery({ filterBy: filters });
50868
+ const subscriptions = (() => {
50869
+ if (!isFetching && !isError2(data) && data) {
50870
+ return data.subscriptionDropdownOptions;
50952
50871
  }
50953
- }
50954
- componentDidMount() {
50955
- const { subnet, prefixlen, prefixMin } = __spreadValues({}, this.props);
50956
- this.fetchFreePrefixes(subnet, prefixlen, prefixMin);
50957
- }
50958
- render() {
50959
- const { id, name, subnet, prefixlen, prefixMin, selectedSubnet } = this.props;
50960
- const version = subnet.indexOf(":") === -1 ? 4 : 6;
50961
- const minPrefixLength = version === 4 ? 12 : 32;
50962
- const minimalSelectablePrefixLength = minPrefixLength > prefixMin ? minPrefixLength : prefixMin;
50963
- const maximalSelectablePrefixLength = version === 4 ? 32 : minimalSelectablePrefixLength + 12;
50964
- const { desiredPrefixlen } = this.state;
50965
- const prefixlengths = (0, import_lodash7.range)(
50966
- maximalSelectablePrefixLength - minimalSelectablePrefixLength + 1
50967
- ).map((x) => minimalSelectablePrefixLength + x);
50968
- const length_options = prefixlengths.map((pl) => ({
50969
- value: pl,
50970
- label: pl.toString()
50971
- }));
50972
- const length_value = length_options.find(
50973
- (option) => option.value === desiredPrefixlen
50974
- );
50975
- const prefix_options = this.state.subnets.map((sn) => ({
50976
- label: sn,
50977
- value: sn
50978
- }));
50979
- const prefix_value = prefix_options.find(
50980
- (option) => option.value === selectedSubnet
50981
- );
50982
- return /* @__PURE__ */ jsx130(EuiFlexItem21, { css: splitPrefixStyling, children: /* @__PURE__ */ jsxs78("section", { children: [
50983
- /* @__PURE__ */ jsxs78("h3", { children: [
50984
- "Selected prefix: ",
50985
- subnet,
50986
- "/",
50987
- prefixlen
50988
- ] }),
50989
- /* @__PURE__ */ jsx130("div", { children: "Desired netmask of the new subnet:" }),
50990
- /* @__PURE__ */ jsx130(
50991
- ReactSelect5,
50992
- {
50993
- id: `${id}.desired-netmask`,
50994
- inputId: `${id}.desired-netmask.search`,
50995
- name: `${name}.desired-netmask`,
50996
- onChange: this.changePrefixLength,
50997
- options: length_options,
50998
- value: length_value
50999
- }
51000
- ),
51001
- this.state.subnets && /* @__PURE__ */ jsxs78("div", { children: [
51002
- /* @__PURE__ */ jsx130("div", { children: "Desired prefix:" }),
51003
- /* @__PURE__ */ jsx130(
51004
- ReactSelect5,
51005
- {
51006
- id: `${id}.desired-prefix`,
51007
- inputId: `${id}.desired-prefix.search`,
51008
- name: `${name}.desired-prefix`,
51009
- options: prefix_options,
51010
- onChange: this.selectSubnet,
51011
- value: prefix_value
51012
- }
51013
- )
51014
- ] })
51015
- ] }) });
51016
- }
50872
+ return [];
50873
+ })();
50874
+ return { isFetching, refetch, subscriptions };
51017
50875
  };
51018
- SplitPrefix.contextType = ApiClientContext;
51019
50876
 
51020
- // src/components/WfoForms/formFields/IpNetworkField.tsx
50877
+ // src/components/WfoForms/formFields/SubscriptionFieldStyling.ts
50878
+ import { css as css18 } from "@emotion/react";
50879
+ var subscriptionFieldStyling = css18`
50880
+ .subscription-field {
50881
+ > div {
50882
+ display: flex;
50883
+
50884
+ .subscription-field-select {
50885
+ width: 100%;
50886
+ margin-left: 5px;
50887
+ }
50888
+ }
50889
+
50890
+ .euiFormRow > .euiFormRow__fieldWrapper > div {
50891
+ display: flex;
50892
+ }
50893
+ }
50894
+
50895
+ // Setup sensible margins for port selectors
50896
+ .subscription-field-disabled {
50897
+ > div {
50898
+ display: flex;
50899
+ .subscription-field-select {
50900
+ margin-left: 0px;
50901
+ margin-top: 5px;
50902
+ }
50903
+ }
50904
+ }
50905
+
50906
+ .reload-subscriptions-icon-button {
50907
+ margin-left: -7px;
50908
+ }
50909
+ `;
50910
+
50911
+ // src/components/WfoForms/formFields/SubscriptionField.tsx
51021
50912
  import { jsx as jsx131, jsxs as jsxs79 } from "@emotion/react/jsx-runtime";
51022
- function IpNetwork(_a) {
50913
+ filterDOMProps26.register(
50914
+ "productIds",
50915
+ "excludedSubscriptionIds",
50916
+ "customerId",
50917
+ "customerKey",
50918
+ "visiblePortMode",
50919
+ "bandwidth",
50920
+ "bandwidthKey",
50921
+ "tags",
50922
+ "statuses"
50923
+ );
50924
+ function SubscriptionFieldDefinition(_a) {
51023
50925
  var _b = _a, {
50926
+ disabled,
51024
50927
  id,
51025
50928
  label,
51026
50929
  description,
@@ -51031,8 +50934,18 @@ function IpNetwork(_a) {
51031
50934
  error,
51032
50935
  showInlineError,
51033
50936
  errorMessage,
51034
- prefixMin
50937
+ className = "",
50938
+ productIds = [],
50939
+ excludedSubscriptionIds = [],
50940
+ customerId,
50941
+ customerKey,
50942
+ visiblePortMode = "all",
50943
+ bandwidth,
50944
+ bandwidthKey,
50945
+ tags,
50946
+ statuses
51035
50947
  } = _b, props = __objRest(_b, [
50948
+ "disabled",
51036
50949
  "id",
51037
50950
  "label",
51038
50951
  "description",
@@ -51043,82 +50956,189 @@ function IpNetwork(_a) {
51043
50956
  "error",
51044
50957
  "showInlineError",
51045
50958
  "errorMessage",
51046
- "prefixMin"
50959
+ "className",
50960
+ "productIds",
50961
+ "excludedSubscriptionIds",
50962
+ "customerId",
50963
+ "customerKey",
50964
+ "visiblePortMode",
50965
+ "bandwidth",
50966
+ "bandwidthKey",
50967
+ "tags",
50968
+ "statuses"
51047
50969
  ]);
51048
- var _a2, _b2;
51049
50970
  const t = useTranslations36("pydanticForms");
51050
- const [selectedPrefix, setSelectedPrefix] = useState23(
51051
- void 0
51052
- );
51053
- const [manualOverride, setManualOverride] = useState23(false);
51054
- const usePrefix = (_a2 = selectedPrefix == null ? void 0 : selectedPrefix.prefix) != null ? _a2 : value;
51055
- const [subnet, netmask] = (_b2 = usePrefix == null ? void 0 : usePrefix.split("/")) != null ? _b2 : ["", ""];
51056
- const usedPrefixMin = prefixMin != null ? prefixMin : parseInt(netmask, 10) + ((selectedPrefix == null ? void 0 : selectedPrefix.state) === 0 ? 0 : 1);
51057
- return /* @__PURE__ */ jsx131("section", __spreadProps(__spreadValues({}, filterDOMProps26(props)), { children: /* @__PURE__ */ jsx131(
51058
- EuiFormRow18,
51059
- {
51060
- label,
51061
- labelAppend: /* @__PURE__ */ jsx131(EuiText27, { size: "m", children: description }),
51062
- error: showInlineError ? errorMessage : false,
51063
- isInvalid: error,
51064
- id,
51065
- fullWidth: true,
51066
- children: /* @__PURE__ */ jsx131("section", { className: "ipblock-selector", children: /* @__PURE__ */ jsxs79("div", { id, children: [
51067
- !prefixMin && /* @__PURE__ */ jsx131(
51068
- IpPrefixTableField,
51069
- {
51070
- id,
51071
- name,
51072
- onChange: (prefix) => {
51073
- if (!readOnly) {
51074
- if (prefix.state === 0 || prefix.state === 1) {
51075
- setSelectedPrefix(prefix);
51076
- }
51077
- setManualOverride(false);
51078
- onChange(prefix.prefix);
51079
- }
51080
- },
51081
- onManualOverride: (prefixString) => {
51082
- if (!readOnly) {
51083
- setManualOverride(true);
51084
- onChange(prefixString);
51085
- }
51086
- },
51087
- selected_prefix_id: selectedPrefix == null ? void 0 : selectedPrefix.id
50971
+ const { theme } = useOrchestratorTheme();
50972
+ const reactSelectInnerComponentStyles = getReactSelectInnerComponentStyles(theme);
50973
+ const { refetch, subscriptions, isFetching } = useGetSubscriptionDropdownOptions(tags, statuses);
50974
+ const nameArray = joinName9(null, name);
50975
+ let parentName = joinName9(nameArray.slice(0, -1));
50976
+ if (parentName === "") {
50977
+ parentName = name;
50978
+ }
50979
+ const parent = useField8(parentName, {}, { absoluteName: true })[0];
50980
+ const { model, schema } = useForm8();
50981
+ const bandWithFromField = bandwidthKey ? (0, import_get4.default)(model, bandwidthKey) || schema.getInitialValue(bandwidthKey, {}) : void 0;
50982
+ const usedBandwidth = bandwidth || bandWithFromField;
50983
+ const usedCustomerId = customerKey ? (0, import_get4.default)(model, customerKey, "nonExistingOrgToFilterEverything") : customerId;
50984
+ const makeLabel = (subscription) => {
50985
+ var _a2;
50986
+ const description2 = subscription.description || t("widgets.subscription.missingDescription");
50987
+ const subscriptionSubstring = subscription.subscriptionId.substring(
50988
+ 0,
50989
+ 8
50990
+ );
50991
+ if (["Node"].includes(subscription.product.tag)) {
50992
+ const description3 = subscription.description || t("widgets.subscription.missingDescription");
50993
+ return `${subscription.subscriptionId.substring(
50994
+ 0,
50995
+ 8
50996
+ )} ${description3.trim()}`;
50997
+ } else if ([
50998
+ "SP" /* SP */,
50999
+ "SPNL" /* SPNL */,
51000
+ "AGGSP" /* AGGSP */,
51001
+ "AGGSPNL" /* AGGSPNL */,
51002
+ "MSC" /* MSC */,
51003
+ "MSCNL" /* MSCNL */,
51004
+ "IRBSP" /* IRBSP */
51005
+ ].includes(subscription.product.tag)) {
51006
+ const portMode = getPortMode(subscription.productBlockInstances);
51007
+ const subscriptionTitle = subscription.productBlockInstances[0].productBlockInstanceValues.find(
51008
+ (item) => item.field === "title"
51009
+ );
51010
+ if (subscriptionTitle) {
51011
+ return `${subscriptionSubstring} - ${description2.trim()} - ${subscriptionTitle.value}`;
51012
+ }
51013
+ return `${subscriptionSubstring} ${portMode == null ? void 0 : portMode.toUpperCase()} ${description2.trim()} ${(_a2 = subscription.customer) == null ? void 0 : _a2.fullname}`;
51014
+ } else {
51015
+ return description2.trim();
51016
+ }
51017
+ };
51018
+ const getSubscriptionOptions = () => {
51019
+ const filteredSubscriptions = subscriptions == null ? void 0 : subscriptions.filter((subscription) => {
51020
+ var _a2;
51021
+ if (usedBandwidth) {
51022
+ const portSpeedInput = subscription.fixedInputs.find(
51023
+ (fixedInput) => fixedInput.field === "port_speed"
51024
+ );
51025
+ if (portSpeedInput && parseInt(portSpeedInput.value.toString(), 10) < parseInt(usedBandwidth.toString(), 10)) {
51026
+ return false;
51027
+ }
51028
+ }
51029
+ if (!usedBandwidth && productIds && productIds.length > 0 && !productIds.includes(subscription.product.productId)) {
51030
+ return false;
51031
+ }
51032
+ if (!usedBandwidth && !productIds && tags && (tags == null ? void 0 : tags.length) > 0 && !tags.includes(subscription.product.tag)) {
51033
+ return false;
51034
+ }
51035
+ if (excludedSubscriptionIds && excludedSubscriptionIds.length > 0 && excludedSubscriptionIds.includes(subscription.subscriptionId)) {
51036
+ return false;
51037
+ }
51038
+ if (visiblePortMode !== "all") {
51039
+ const portMode = getPortMode(
51040
+ subscription.productBlockInstances
51041
+ );
51042
+ if (visiblePortMode === "normal" && !["tagged" /* TAGGED */, "untagged" /* UNTAGGED */, void 0].includes(
51043
+ portMode
51044
+ )) {
51045
+ return false;
51046
+ } else if (portMode !== visiblePortMode && visiblePortMode !== "normal") {
51047
+ return false;
51048
+ }
51049
+ }
51050
+ if (usedCustomerId && ((_a2 = subscription.customer) == null ? void 0 : _a2.customerId) !== usedCustomerId) {
51051
+ return false;
51052
+ }
51053
+ if (parentName !== name) {
51054
+ if (parent.fieldType === Array && // @ts-expect-error Parent field can have the uniqueItems boolean property but this is not part of JSONSchema6 type
51055
+ // TODO: Figure out why this is so
51056
+ parent.uniqueItems) {
51057
+ const allValues = (0, import_get4.default)(model, parentName, []);
51058
+ const chosenValues = allValues.filter(
51059
+ (_item, index) => index.toString() !== nameArray[nameArray.length - 1]
51060
+ );
51061
+ if (!chosenValues.includes(subscription.subscriptionId)) {
51062
+ return false;
51088
51063
  }
51089
- ),
51090
- usePrefix && !manualOverride && /* @__PURE__ */ jsx131(
51091
- SplitPrefix,
51092
- {
51093
- id,
51094
- name,
51095
- subnet,
51096
- prefixlen: parseInt(netmask, 10),
51097
- prefixMin: usedPrefixMin,
51098
- onChange: (prefix) => {
51099
- if (!readOnly) {
51100
- onChange(prefix);
51064
+ }
51065
+ }
51066
+ return true;
51067
+ });
51068
+ return filteredSubscriptions ? filteredSubscriptions.map((subscription) => ({
51069
+ label: makeLabel(subscription),
51070
+ value: subscription.subscriptionId
51071
+ })) : [];
51072
+ };
51073
+ const options = getSubscriptionOptions();
51074
+ const selectedValue = options.find(
51075
+ (option) => option.value === value
51076
+ );
51077
+ const isDisabled = disabled || readOnly || isFetching;
51078
+ return /* @__PURE__ */ jsx131(EuiFlexItem21, { css: subscriptionFieldStyling, grow: 1, children: /* @__PURE__ */ jsx131(
51079
+ "section",
51080
+ __spreadProps(__spreadValues({}, filterDOMProps26(props)), {
51081
+ className: `${className} subscription-field${disabled ? "-disabled" : ""}`,
51082
+ children: /* @__PURE__ */ jsx131(
51083
+ EuiFormRow18,
51084
+ {
51085
+ label,
51086
+ labelAppend: /* @__PURE__ */ jsx131(EuiText27, { size: "m", children: description }),
51087
+ error: showInlineError ? errorMessage : false,
51088
+ isInvalid: error,
51089
+ id,
51090
+ fullWidth: true,
51091
+ children: /* @__PURE__ */ jsxs79("div", { children: [
51092
+ !disabled && /* @__PURE__ */ jsx131(
51093
+ EuiFlexGroup14,
51094
+ {
51095
+ alignItems: "center",
51096
+ gutterSize: "none",
51097
+ responsive: false,
51098
+ children: /* @__PURE__ */ jsx131(
51099
+ EuiButtonIcon3,
51100
+ {
51101
+ className: "reload-subscriptions-icon-button",
51102
+ id: `refresh-icon-${id}`,
51103
+ "aria-label": `reload-${label}`,
51104
+ iconType: "refresh",
51105
+ iconSize: "l",
51106
+ disabled: isDisabled,
51107
+ onClick: () => {
51108
+ !isDisabled ? refetch() : null;
51109
+ }
51110
+ }
51111
+ )
51101
51112
  }
51102
- },
51103
- selectedSubnet: usePrefix
51104
- }
51105
- ),
51106
- usePrefix && manualOverride && /* @__PURE__ */ jsx131(
51107
- EuiCallOut2,
51108
- {
51109
- title: t(
51110
- "widgets.ipvAnyNetworkField.manuallySelectedPrefix"
51111
51113
  ),
51112
- color: "primary",
51113
- iconType: "check",
51114
- children: /* @__PURE__ */ jsx131("p", { children: value })
51115
- }
51116
- )
51117
- ] }) })
51118
- }
51119
- ) }));
51114
+ /* @__PURE__ */ jsx131(
51115
+ ReactSelect5,
51116
+ {
51117
+ id,
51118
+ inputId: `${id}.search`,
51119
+ name,
51120
+ onChange: (option) => {
51121
+ onChange(option == null ? void 0 : option.value);
51122
+ },
51123
+ options,
51124
+ value: selectedValue,
51125
+ isSearchable: true,
51126
+ isClearable: false,
51127
+ placeholder: isFetching ? t("widgets.subscription.loading") : t("widgets.subscription.placeholder"),
51128
+ isDisabled,
51129
+ styles: reactSelectInnerComponentStyles,
51130
+ className: "subscription-field-select"
51131
+ }
51132
+ )
51133
+ ] })
51134
+ }
51135
+ )
51136
+ })
51137
+ ) });
51120
51138
  }
51121
- var IpNetworkField = connectField26(IpNetwork, { kind: "leaf" });
51139
+ var SubscriptionField = connectField26(SubscriptionFieldDefinition, {
51140
+ kind: "leaf"
51141
+ });
51122
51142
 
51123
51143
  // src/components/WfoForms/formFields/SummaryField.tsx
51124
51144
  import { connectField as connectField27, filterDOMProps as filterDOMProps27 } from "uniforms";
@@ -52014,6 +52034,7 @@ import { EuiButtonGroup, EuiPopover as EuiPopover4 } from "@elastic/eui";
52014
52034
  import { jsx as jsx143 } from "@emotion/react/jsx-runtime";
52015
52035
  var WfoDropdownButton = ({
52016
52036
  label,
52037
+ isDisabled = false,
52017
52038
  children
52018
52039
  }) => {
52019
52040
  const [isHovered, setIsHovered] = useState27(false);
@@ -52057,7 +52078,8 @@ var WfoDropdownButton = ({
52057
52078
  buttonSize: "m",
52058
52079
  legend: "Buttons",
52059
52080
  options: buttonOptions,
52060
- onChange: onButtonClick
52081
+ onChange: onButtonClick,
52082
+ isDisabled
52061
52083
  }
52062
52084
  ),
52063
52085
  isOpen: isPopoverOpen,
@@ -54219,10 +54241,6 @@ var WfoStartProcessPage = ({
54219
54241
  (result) => {
54220
54242
  const process2 = result;
54221
54243
  if (process2.id) {
54222
- console.log(
54223
- "resolver successfullly!: ",
54224
- process2.id
54225
- );
54226
54244
  const basePath = isTask ? PATH_TASKS : PATH_WORKFLOWS;
54227
54245
  router.push(`${basePath}/${process2.id}`);
54228
54246
  }
@@ -57143,6 +57161,7 @@ export {
57143
57161
  ConfirmationDialogContextWrapper,
57144
57162
  ConfirmationDialogProvider,
57145
57163
  ConnectedSelectField,
57164
+ ContactPersonAutocomplete,
57146
57165
  ContactPersonNameField,
57147
57166
  CreateForm,
57148
57167
  CustomerField,
@@ -57192,10 +57211,12 @@ export {
57192
57211
  PolicyContext,
57193
57212
  PolicyContextProvider,
57194
57213
  PolicyResource,
57214
+ PortMode,
57195
57215
  ProcessDoneStatuses,
57196
57216
  ProcessStatus,
57197
57217
  ProductField,
57198
57218
  ProductLifecycleStatus,
57219
+ ProductTag,
57199
57220
  RENDER_ALL,
57200
57221
  RESOURCE_TYPE_FIELD_DESCRIPTION,
57201
57222
  RESOURCE_TYPE_FIELD_ID,
@@ -57377,13 +57398,17 @@ export {
57377
57398
  getSortDirectionFromString,
57378
57399
  getStatusBadgeColor,
57379
57400
  getStepContent,
57401
+ getStyles9 as getStyles,
57380
57402
  getTableConfigFromLocalStorage,
57381
57403
  getTasksListTabTypeFromString,
57382
57404
  getTypedFieldFromObject,
57383
57405
  getWfoBasicTableStyles,
57384
57406
  getWorkflowTargetColor,
57385
57407
  getWorkflowTargetIconContent,
57408
+ imsPortIdFieldStyling,
57386
57409
  initiateCsvFileDownload,
57410
+ ipPrefixTableFieldStyling,
57411
+ ipamStates,
57387
57412
  isToday,
57388
57413
  isUuid4,
57389
57414
  isValidLocalStorageTableConfig,
@@ -57413,6 +57438,7 @@ export {
57413
57438
  setTableConfigToLocalStorage,
57414
57439
  snakeToHuman,
57415
57440
  snakeToKebab,
57441
+ splitPrefixStyling,
57416
57442
  stop,
57417
57443
  subscriptionDetailQuery,
57418
57444
  subscriptionsDropdownOptionsQuery,