@odigos/ui-kit 0.0.240 → 0.0.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/lib/chunks/{helpers-D-6cJlOn.js → helpers-L572q0MU.js} +1 -1
- package/lib/chunks/{index-RUJS9Blu.js → index-DHcHiz_q.js} +18 -16
- package/lib/chunks/{source-instrument-form-context-CEgbaSRi.js → source-instrument-form-context-vq8DFX7f.js} +1 -1
- package/lib/chunks/ui-components-DeKNGyn7.js +1570 -0
- package/lib/components/_v2/cards/data-card/index.d.ts +1 -0
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/strings/index.d.ts +13 -3
- package/lib/constants.js +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/common/pods-header.d.ts +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/containers-card/popup-form.d.ts +4 -0
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/containers-card/runtime-override.d.ts +1 -0
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/index.d.ts +1 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/pods-card/pods-list/container-row.d.ts +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/pods-card/pods-list/helpers.d.ts +1 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/pods-card/pods-list/pod-row.d.ts +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/pods-card/pods-list/row-header.d.ts +3 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/pods-card/pods-list/types.d.ts +1 -8
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/statuses-card.d.ts +0 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/pods/pod-debug-commands.d.ts +7 -0
- package/lib/containers/_v2/_drawers/edit-source-drawer/yaml-files/index.d.ts +6 -0
- package/lib/containers/v2.js +122 -115
- package/lib/containers.js +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions/build-badge-for-desired-status/index.d.ts +6 -0
- package/lib/functions/get-health-badge-label/index.d.ts +2 -0
- package/lib/functions/index.d.ts +2 -1
- package/lib/functions/map-desired-status-to-condition-status/index.d.ts +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/icons/common/inbound-icon/index.d.ts +2 -0
- package/lib/icons/common/index.d.ts +2 -0
- package/lib/icons/common/outbound-icon/index.d.ts +2 -0
- package/lib/icons/destinations/open-telemetry-logo/index.d.ts +1 -0
- package/lib/icons.js +1 -1
- package/lib/mock-data/sources/yamls.d.ts +22 -0
- package/lib/snippets/_v2/yaml-section-card/index.d.ts +2 -1
- package/lib/snippets/v2.js +1 -1
- package/lib/snippets.js +4 -4
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types/workload/index.d.ts +12 -4
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/ui-components-B0BVzW_z.js +0 -1570
- package/lib/containers/_v2/_drawers/edit-source-drawer/pods/debug-commands.d.ts +0 -6
- package/lib/functions/is-pod-injected-with-agent/index.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.241](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.240...ui-kit-v0.0.241) (2026-06-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add support for new health objects (odigos & k8s) ([#953](https://github.com/odigos-io/ui-kit/issues/953)) ([f7cf65d](https://github.com/odigos-io/ui-kit/commit/f7cf65daf6ea12564e53d7c9d1b5255db11315a4))
|
|
9
|
+
* add YAML files display in edit-source-drawer ([#956](https://github.com/odigos-io/ui-kit/issues/956)) ([5dbee69](https://github.com/odigos-io/ui-kit/commit/5dbee690e5a8266f80f632fdcb883ad1a9175480))
|
|
10
|
+
* **debug-commands:** update pod command options ([#962](https://github.com/odigos-io/ui-kit/issues/962)) ([52ec744](https://github.com/odigos-io/ui-kit/commit/52ec7442b11e7c6b1dcc0c6893623e16afadf1d8))
|
|
11
|
+
* **peers:** add inbound and outbound icons, update descriptions, and update user icon ([#950](https://github.com/odigos-io/ui-kit/issues/950)) ([fce60d0](https://github.com/odigos-io/ui-kit/commit/fce60d032222f7818c09693f918d50c219d7e750))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* agent injection logic ([#960](https://github.com/odigos-io/ui-kit/issues/960)) ([7318c47](https://github.com/odigos-io/ui-kit/commit/7318c474f583e9ba19a7edbb85d15467bb3e17a5))
|
|
17
|
+
* **badge:** improve icons for loading state ([#955](https://github.com/odigos-io/ui-kit/issues/955)) ([3ce24fd](https://github.com/odigos-io/ui-kit/commit/3ce24fd05a3fb985c770b9cb58bda92987cce205))
|
|
18
|
+
* conditionally render health badges ([#959](https://github.com/odigos-io/ui-kit/issues/959)) ([e0b5d09](https://github.com/odigos-io/ui-kit/commit/e0b5d09892b1be1ce65ec9bf72873ee65bb508ce))
|
|
19
|
+
* **containers-card:** remove redundant tooltip for instrumented status ([#952](https://github.com/odigos-io/ui-kit/issues/952)) ([11a58e3](https://github.com/odigos-io/ui-kit/commit/11a58e3c9666fb36aee2fffceb8bc23be525fb12))
|
|
20
|
+
* do not render when `ConditionStatus` is `Irrelevant` ([#963](https://github.com/odigos-io/ui-kit/issues/963)) ([58b5fd3](https://github.com/odigos-io/ui-kit/commit/58b5fd3a282a6ed5a9a6803639e09452c500a9ca))
|
|
21
|
+
* prioritize reasonEnum in agent status tag/label ([#954](https://github.com/odigos-io/ui-kit/issues/954)) ([a979e6c](https://github.com/odigos-io/ui-kit/commit/a979e6c8fba4896c73f1661394c69dac50a413b5))
|
|
22
|
+
* process attributes & styling ([#949](https://github.com/odigos-io/ui-kit/issues/949)) ([1f9e262](https://github.com/odigos-io/ui-kit/commit/1f9e262816145445b6cb6df4c367b839e84e1ea2))
|
|
23
|
+
* **source-overrides:** refactor based on product review ([#958](https://github.com/odigos-io/ui-kit/issues/958)) ([b9ab924](https://github.com/odigos-io/ui-kit/commit/b9ab92477128ec5b77e1cfd2aff7d0e31aac668f))
|
|
24
|
+
* **sources-distro-override:** add OBI option for unknown programming language ([#957](https://github.com/odigos-io/ui-kit/issues/957)) ([4136276](https://github.com/odigos-io/ui-kit/commit/4136276e9aeecdbb49e242564a8b6a5662a9c3c0))
|
|
25
|
+
* **statuses-card:** simplify rollout & rollback condition handling ([#961](https://github.com/odigos-io/ui-kit/issues/961)) ([e21fc71](https://github.com/odigos-io/ui-kit/commit/e21fc719d4779ff3ef4227975353c8d47a4e0c12))
|
|
26
|
+
|
|
3
27
|
## [0.0.240](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.239...ui-kit-v0.0.240) (2026-05-28)
|
|
4
28
|
|
|
5
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{useMemo as n,useContext as o,createContext as a,Fragment as s}from"react";import{t as i,T as u,P as l,u as c,a as p,b as d,c as f}from"./ui-components-
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{useMemo as n,useContext as o,createContext as a,Fragment as s}from"react";import{t as i,T as u,P as l,u as c,a as p,b as d,c as f}from"./ui-components-DeKNGyn7.js";import h from"styled-components";const m=a({platformType:l.K8s,tier:u.Community,version:"v0.0.0"}),v=({children:t,platformType:r,tier:o,version:a})=>{const s=n(()=>({platformType:r,tier:o,version:a}),[r,o,a]);return e(m.Provider,{value:s,children:t})},g=(e,t)=>!t||i(e)>=i(t),y=e=>{const t=o(m),r=g(t.version,e),n=t.platformType===l.Vm;return{...t,isVersionSupported:r,isVm:n,isEnterprise:t.tier===u.Onprem}};function x(e){return!e||!e.sources?.length&&!e.namespaces?.length&&!e.languages?.length}function k(e){return e?{sources:e.sources?[...e.sources]:[],namespaces:e.namespaces?[...e.namespaces]:[],languages:e.languages?[...e.languages]:[]}:{sources:[],namespaces:[],languages:[]}}function S(e){return null==e||0===e}function A(e){return{name:"",notes:"",disabled:!1,ruleType:"Relevance",sourceScopes:{sources:[],namespaces:[],languages:[]},operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:"",durationPreset:"500",customDurationMs:"",keepErrors:!1,percentageMode:"costReduction"===e?"sample":"all",percentagePreset:"0",customPercentage:""}}function T(e){return x(e.sourceScopes)?null:e.sourceScopes}function P(e){return T(e)}function R(e){if("all"===e.percentageMode)return null;if("custom"===e.percentagePreset){const t=parseFloat(e.customPercentage);return isNaN(t)?null:t}return parseFloat(e.percentagePreset)}function b(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function M(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function D(e){return"all"===e.operationType?null:"httpServer"===e.operationType?M(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?M(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function $(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),percentageAtMost:R(e),operation:D(e)}}function C(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),error:e.keepErrors,durationAtLeastMs:"Duration"===e.ruleType?b(e):null,percentageAtLeast:R(e),operation:I(e)}}function E(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),percentageAtMost:R(e)??0,operation:I(e)}}function w(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:D(e),percentageAtMost:R(e),notes:e.notes||null}}function L(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),error:"Error"===e.ruleType,durationAtLeastMs:"Duration"===e.ruleType?b(e):null,operation:I(e),percentageAtLeast:R(e),notes:e.notes||null}}function O(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:I(e),percentageAtMost:R(e)??0,notes:e.notes||null}}const N=["5000","1000","500","100","50"],H=["50","25","10","1","0.5","0.1","0"];function K(e){if(null==e)return{percentageMode:"all",percentagePreset:"0",customPercentage:""};const t=H.find(t=>Number(t)===e);return t?{percentageMode:"sample",percentagePreset:t,customPercentage:""}:{percentageMode:"sample",percentagePreset:"custom",customPercentage:String(e)}}function j(e){if(!e)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};const t=e;if(t.httpServer){return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""}}return t.kafkaConsumer?{operationType:"kafkaConsumer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaConsumer.kafkaTopic||""}:t.kafkaProducer?{operationType:"kafkaProducer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaProducer.kafkaTopic||""}:{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}function z(e){const t=A(),r=k(e.rule.sourceScopes);const n=function(e){return"highlyRelevant"!==e.category?"Relevance":e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance"}(e);let o,a,s={durationPreset:"500",customDurationMs:""},i=!1;switch(e.category){case"noisy":o=function(e){const t=e.rule.operation;if(!t)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};if(t.httpServer)return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""};if(t.httpClient)return{operationType:"httpClient",routeType:t.httpClient.templatedPathPrefix?"routePrefix":"route",route:t.httpClient.templatedPath||t.httpClient.templatedPathPrefix||"",serverAddress:t.httpClient.serverAddress||"",method:t.httpClient.method||"",kafkaTopic:""};return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}(e),a=S(u=e.rule.percentageAtMost)?{percentageMode:"all",percentagePreset:"0",customPercentage:""}:K(u);break;case"highlyRelevant":o=j(e.rule.operation),a=K(e.rule.percentageAtLeast),s=function(e){if(null==e)return{durationPreset:"500",customDurationMs:""};const t=N.find(t=>Number(t)===e);return t?{durationPreset:t,customDurationMs:""}:{durationPreset:"custom",customDurationMs:String(e)}}(e.rule.durationAtLeastMs),i=e.rule.error;break;case"costReduction":o=j(e.rule.operation),a=K(e.rule.percentageAtMost)}var u;return{...t,name:e.rule.name||"",notes:e.rule.notes||"",disabled:e.rule.disabled,ruleType:n,sourceScopes:r,...o,...s,keepErrors:i,...a}}var F;!function(e){e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"}(F||(F={}));const X=[F.Action,F.Endpoint,F.Scope,F.Duration],J=h.span`
|
|
2
2
|
font-family: ${({theme:e,$isMono:t})=>t?e.font_family.secondary:e.font_family.primary};
|
|
3
3
|
font-size: ${({theme:e})=>e.v2.text.size.xxs}px;
|
|
4
4
|
line-height: 20px;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{ap as e,ab as a,R as t,a6 as l,a7 as r,
|
|
1
|
+
import{ap as e,ab as a,R as t,a6 as l,a7 as r,dP as i,a0 as n,aB as s,ae as o,a4 as d,O as c,a8 as u,a2 as p,a3 as h,T as g,h as m,F as v,$ as b,ad as f,ay as y,dQ as x,dR as S,aI as C,dS as k,b as T,dT as w,ai as $,c as P,dU as A,dV as M,dW as O,dX as L,dY as z,dZ as D,d_ as I,cx as R,d$ as X,e0 as N,e1 as B,e2 as E,e3 as H,bK as V,aa as j,e4 as q,e5 as U,e6 as G,e7 as K,e8 as J,e9 as W,ea as F,eb as Y,ec as Z,ed as Q,ee as _,az as ee,ef as ae,eg as te,eh as le,ei as re,ej as ie,bx as ne,ek as se,el as oe,em as de,en as ce,eo as ue,ep as pe,eq as he,er as ge,a9 as me,es as ve,et as be,eu as fe,ev as ye,ag as xe,ew as Se,S as Ce,ex as ke,ey as Te,ez as we,eA as $e,eB as Pe,dc as Ae,ao as Me,bn as Oe,w as Le,d7 as ze,a1 as De,eC as Ie,b9 as Re,aA as Xe,N as Ne,o as Be,aE as Ee,dp as He,b8 as Ve,be as je,b7 as qe,bN as Ue,aR as Ge,eD as Ke}from"./ui-components-DeKNGyn7.js";import{jsx as Je,jsxs as We,Fragment as Fe}from"react/jsx-runtime";import{u as Ye,w as Ze,x as Qe,C as _e,y as ea,z as aa,A as ta,B as la,D as ra,E as ia,F as na}from"./helpers-L572q0MU.js";import{OdigosLogoTextCentral as sa,OdigosLogoTextEnterprise as oa,OdigosLogoTextCommunity as da,OdigosLogoTextColoredCentral as ca,OdigosLogoTextColoredEnterprise as ua,OdigosLogoTextColoredCommunity as pa,EditIcon as ha,ArrowLeftIcon as ga,ArrowRightIcon as ma,VSquareIcon as va,VIcon as ba,CopyIcon as fa,YamlIcon as ya}from"../icons.js";import{useCallback as xa,useMemo as Sa,useState as Ca,useRef as ka,useEffect as Ta,forwardRef as wa,useImperativeHandle as $a}from"react";import Pa from"styled-components";const Aa=({isOpen:t,onClose:l,onDeny:r,onApprove:i})=>Je(e,{title:"Discard changes?",description:"You have unsaved changes.\nIf you cancel now, your changes won't be saved.",isOpen:t,onClose:l,denyButton:{label:"Keep editing",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:"Discard changes",variant:a.Primary,onClick:()=>{i?.(),l()}}}),Ma=({isOpen:t,onClose:l,onDeny:r,onApprove:i,action:n="delete",target:s,description:o,overrideApproveButtonLabel:d,overrideDenyButtonLabel:c})=>{const u=n.charAt(0).toUpperCase()+n.substring(1),p=s?.endsWith("s")?"these":"this";return Je(e,{title:`${u}${s?` ${s}`:""}?`,description:o??`Are you sure you want to ${n}${s?` ${p} ${s}`:""}?`,isOpen:t,onClose:l,denyButton:{label:c??"Go back",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:d??u,variant:a.Primary,onClick:()=>{i?.(),l()}}})},Oa=({componentType:e,inputType:a,name:g,label:m,tooltip:v,badge:b,placeholder:f,required:y,disabled:x,value:S,setValue:C,errorMessage:k,warnMessage:T,helpMessage:w,dropdownOptions:$,dropdownNoSearch:P,dropdownNoCheckbox:A,timeUnits:M,timeDefaultUnit:O})=>{switch(e){case t.Input:return Je(p,{name:g,type:a,label:m,tooltip:v,badge:b,placeholder:f,required:y,disabled:x,value:S??"",onChange:e=>{const t=e.target.value;C(a===h.Number?""===t?null:Number(t):t)},errorMessage:k,warnMessage:T,helpMessage:w},g);case t.MultiInput:return Je(u,{name:g,label:m,tooltip:v,badge:b,placeholder:f,required:y,disabled:x,values:Array.isArray(S)?S:c(S,[]),setValues:e=>C(e),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.KeyValuePair:return Je(d,{name:g,label:m,tooltip:v,badge:b,required:y,disabled:x,limitFieldsPerRow:2,columns:[{keyName:"key",label:"Key"},{keyName:"value",label:"Value"}],values:Array.isArray(S)?S:c(S,[]),setValues:e=>C(e),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.TextArea:return Je(o,{name:g,label:m,tooltip:v,badge:b,required:y,disabled:x,placeholder:f,value:S??"",onChange:e=>C(e.target.value),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Dropdown:return Je(s,{name:g,label:m,tooltip:v,badge:b,placeholder:f,required:y,disabled:x,withSearch:!P,options:$?.map(e=>({id:e.id||"",label:e.label||"",withCheckbox:!A}))||[],values:S?[String(S)]:[],setValues:e=>C(e[0]),errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Checkbox:return Je(n,{name:g,label:m,tooltip:v,badge:b,value:!0===S||"true"===S,onChange:e=>C(e),disabled:x,errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Time:return Je(i,{name:g,label:m,tooltip:v,badge:b,placeholder:f,required:y,disabled:x,value:S??"",setValue:e=>C(e),units:M,defaultUnit:O,errorMessage:k,warnMessage:T,helpMessage:w},g);case t.Toggle:return Je(l,{name:g,labelAlign:r.Right,label:m,tooltip:v,badge:b,value:!0===S||"true"===S,onChange:e=>C(e),disabled:x,errorMessage:k,warnMessage:T,helpMessage:w},g);default:return null}},La=({size:e=200,central:a=!1,useInline:t=!1})=>{const{tier:l}=Ye();if(t){if(a)return Je(sa,{size:e});switch(l){case g.Community:return Je(da,{size:e});case g.Onprem:return Je(oa,{size:e});default:return null}}if(a)return Je(ca,{size:e});switch(l){case g.Community:return Je(pa,{size:e});case g.Onprem:return Je(ua,{size:e});default:return null}},za=[{value:"50",label:"50%"},{value:"25",label:"25%"},{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"custom",label:"Custom"}],Da=[{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"0.5",label:"0.5%"},{value:"0.1",label:"0.1%"},{value:"custom",label:"Custom"}],Ia=[{value:"5000",label:"5s"},{value:"1000",label:"1s"},{value:"500",label:"500ms"},{value:"100",label:"100ms"},{value:"50",label:"50ms"},{value:"custom",label:"Custom"}],Ra=({description:e,options:a,selected:t,onSelect:l,customName:r,customLabel:i,customPlaceholder:n,customValue:s,onCustomChange:o,customInputType:d=h.Number,customMin:c,customMax:u})=>We(m,{$gap:16,$alignItems:"flex-end",children:[We(v,{$gap:6,children:[Je(b,{label:e}),Je(f,{options:a,selected:t,setSelected:l})]}),"custom"===t&&Je(p,{name:r,label:i,placeholder:n,type:d,value:s,onChange:o,width:160,min:c,max:u})]}),Xa=()=>{},Na=e=>e.readOnly?Je(Ba,{rule:e.rule}):Je(Ea,{ruleType:e.ruleType,formState:e.formState,onChange:e.onChange}),Ba=({rule:e})=>{const a=null!=e.durationAtLeastMs;return e.error?Je(y,{richTitle:{title:x},children:Je(l,{name:"sampling-view-toggle-keep-errors",onChange:Xa,value:!0,size:C.S,label:S,labelAlign:r.Right})}):a?Je(y,{richTitle:{title:k},children:We("div",{children:[Je(T,{size:P.XXXS,color:$.Secondary,children:w}),Je(T,{size:P.XS,children:`${e.durationAtLeastMs}ms`})]})}):null},Ea=({ruleType:e,formState:a,onChange:t})=>{const i=xa(e=>t({durationPreset:e}),[t]),n=xa(e=>t({customDurationMs:e.target.value}),[t]);return"Error"===e?Je(y,{richTitle:{title:x,subTitle:A},children:Je(l,{name:"sampling-toggle-keep-errors",value:!0,onChange:Xa,size:C.S,label:S,labelAlign:r.Right})}):"Duration"===e?Je(y,{richTitle:{title:k,subTitle:M},children:Je(Ra,{description:w,options:Ia,selected:a.durationPreset,onSelect:i,customName:"sampling-input-custom-duration",customLabel:O,customPlaceholder:"200ms",customValue:a.customDurationMs,onCustomChange:n})}):null},Ha=Pa.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
gap: 32px;
|
|
4
4
|
`,Va=Pa.div`
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
gap: 4px;
|
|
8
|
-
`,
|
|
8
|
+
`,ja=Pa.div`
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-wrap: wrap;
|
|
11
11
|
align-items: flex-end;
|
|
12
12
|
gap: 16px;
|
|
13
|
-
`,
|
|
13
|
+
`,qa=Pa.div`
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: flex-end;
|
|
16
16
|
gap: 16px;
|
|
@@ -26,12 +26,12 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
26
26
|
display: flex;
|
|
27
27
|
align-items: center;
|
|
28
28
|
height: 32px;
|
|
29
|
-
`,
|
|
29
|
+
`,Ka=Pa.div`
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: flex-end;
|
|
32
32
|
gap: 16px;
|
|
33
33
|
margin-bottom: 12px;
|
|
34
|
-
`,
|
|
34
|
+
`,Ja="Any",Wa="Kafka topic",Fa=()=>Je("div",{style:{marginBottom:"8px"},children:Je(T,{size:P.XS,weight:500,children:"And"})}),Ya=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"httpClient",label:"HTTP Client"}],Za=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"kafkaConsumer",label:"Kafka Consumer"},{value:"kafkaProducer",label:"Kafka Producer"}],Qa=[{id:"",label:Ja},{id:"GET",label:"GET"},{id:"POST",label:"POST"},{id:"PUT",label:"PUT"},{id:"DELETE",label:"DELETE"},{id:"PATCH",label:"PATCH"}];const _a=e=>e.readOnly?Je(et,{data:e.data}):Je(at,{category:e.category,formState:e.formState,onChange:e.onChange}),et=({data:e})=>{const a=Sa(()=>function(e){if("noisy"===e.category){const a=e.rule.operation;if(a?.httpServer)return[{id:"type",title:K,value:G},{id:"route",title:B,value:a.httpServer.route||a.httpServer.routePrefix||J},{id:"method",title:q,value:a.httpServer.method||Ja}];if(a?.httpClient){const e=[{id:"type",title:K,value:W}];return a.httpClient.serverAddress&&e.push({id:"serverAddress",title:"Server address",value:a.httpClient.serverAddress}),e.push({id:"route",title:B,value:a.httpClient.templatedPath||a.httpClient.templatedPathPrefix||J}),e.push({id:"method",title:q,value:a.httpClient.method||Ja}),e}return[{id:"type",title:K,value:F}]}const a=e.rule.operation;return a?.httpServer?[{id:"type",title:K,value:G},{id:"route",title:B,value:a.httpServer.route||a.httpServer.routePrefix||J},{id:"method",title:q,value:a.httpServer.method||Ja}]:a?.kafkaConsumer?[{id:"type",title:K,value:Y},{id:"topic",title:Wa,value:a.kafkaConsumer.kafkaTopic||J}]:a?.kafkaProducer?[{id:"type",title:K,value:Z},{id:"topic",title:Wa,value:a.kafkaProducer.kafkaTopic||J}]:[{id:"type",title:K,value:F}]}(e),[e]);return Je(y,{richTitle:{title:L},children:Je(Ha,{children:a.map(({id:e,title:a,value:t})=>We(Va,{children:[Je(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Je(T,{size:P.XS,nowrap:!0,children:t})]},e))})})},at=({category:e,formState:t,onChange:l})=>{const r=Sa(()=>"noisy"===e?Ya:Za,[e]),i=xa(e=>l({operationType:e,route:"",serverAddress:"",method:"",kafkaTopic:""}),[l]),n=xa(e=>a=>{a&&l({routeType:e,route:""})},[l]),s=xa(e=>l({route:e.target.value}),[l]),o=xa(e=>l({serverAddress:e.target.value}),[l]),d=xa(e=>l({method:e[0]||""}),[l]),c=xa(e=>l({kafkaTopic:e.target.value}),[l]),u="httpServer"===t.operationType||"httpClient"===t.operationType,h="kafkaConsumer"===t.operationType||"kafkaProducer"===t.operationType,g="httpClient"===t.operationType?N:B,m="httpClient"===t.operationType?E:H;return We(y,{richTitle:{title:`2. ${L}`,subTitle:z},children:[Je(v,{$alignItems:"flex-start",children:Je(f,{options:r,selected:t.operationType,setSelected:i})}),u&&We(ja,{children:["httpClient"===t.operationType&&We(Ka,{children:[Je(p,{name:"sampling-input-server-address",label:I,placeholder:D,value:t.serverAddress,onChange:o}),Je(Fa,{})]}),We(qa,{children:[We(Ua,{children:[Je(Ga,{children:Je(R,{"data-id":"sampling-radio-route",value:"route"===t.routeType,onChange:n("route")})}),Je(p,{name:"sampling-input-route",label:g,placeholder:X,value:"route"===t.routeType?t.route:"",onChange:s,disabled:"route"!==t.routeType})]}),We(Ua,{children:[Je(Ga,{children:Je(R,{"data-id":"sampling-radio-route-prefix",value:"routePrefix"===t.routeType,onChange:n("routePrefix")})}),Je(p,{name:"sampling-input-route-prefix",label:m,placeholder:X,value:"routePrefix"===t.routeType?t.route:"",onChange:s,disabled:"routePrefix"!==t.routeType})]})]}),We(Ka,{children:[Je(Fa,{}),Je(V,{label:q,items:Qa,selectedIds:[t.method||""],setSelectedIds:e=>d(e),buttonProps:{"data-id":"sampling-btn-method",label:Qa.find(e=>e.id===t.method)?.label||Ja,size:j.S,variant:a.Secondary}})]})]}),h&&Je(p,{name:"sampling-input-kafka-topic",label:U,placeholder:"Type kafka topic",value:t.kafkaTopic,onChange:c,width:"320px"})]})},tt=[{value:"all",label:"Drop All"},{value:"sample",label:"Sample"}],lt=[{value:"all",label:"Keep All"},{value:"sample",label:"Sample"}];const rt=e=>e.readOnly?Je(it,{data:e.data}):Je(nt,{category:e.category,formState:e.formState,onChange:e.onChange}),it=({data:e})=>{const a=Sa(()=>function(e){switch(e.category){case"highlyRelevant":return null!=e.rule.percentageAtLeast?{title:_,method:le,description:ae,value:`${e.rule.percentageAtLeast}%`}:{title:_,method:ie,description:null,value:null};case"noisy":return Ze(e.rule.percentageAtMost)?{title:_,method:re,description:null,value:null}:{title:_,method:le,description:te,value:`${e.rule.percentageAtMost}%`};case"costReduction":return{title:_,method:le,description:te,value:`${e.rule.percentageAtMost}%`}}}(e),[e]),t=[{id:"method",title:q,value:a.method},...null!=a.description?[{id:"value",title:a.description,value:a.value}]:[]];return Je(y,{richTitle:{title:a.title},children:Je(Ha,{children:t.map(({id:e,title:a,value:t})=>We(Va,{children:[Je(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Je(T,{size:P.XS,nowrap:!0,children:t})]},e))})})},nt=({category:e,formState:a,onChange:t})=>{const l="highlyRelevant"===e,r=l?lt:tt,i=`${l?4:3}. ${_}`,n=Q[e],s=l?ae:te,o="noisy"===e?Da:za,d=xa(e=>t({percentageMode:e}),[t]),c=xa(e=>t({percentagePreset:e}),[t]),u=xa(e=>t({customPercentage:e.target.value}),[t]);return We(y,{richTitle:{title:i,subTitle:n},children:["costReduction"!==e&&Je(v,{$alignItems:"flex-start",children:Je(f,{options:r,selected:a.percentageMode,setSelected:d})}),("costReduction"===e||"sample"===a.percentageMode)&&Je(Ra,{description:s,options:o,selected:a.percentagePreset,onSelect:c,customName:"sampling-input-custom-percentage",customLabel:ee,customPlaceholder:"5%",customValue:a.customPercentage,onCustomChange:u,customInputType:h.Decimal,customMin:0,customMax:100})]})},st=Pa.div`
|
|
35
35
|
display: flex;
|
|
36
36
|
align-items: flex-end;
|
|
37
37
|
gap: 16px;
|
|
@@ -41,19 +41,19 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
41
41
|
`,dt=Pa.div`
|
|
42
42
|
flex: 1;
|
|
43
43
|
min-width: 0;
|
|
44
|
-
`;function ct(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":he[e.category]}const ut=e=>e.readOnly?
|
|
44
|
+
`;function ct(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":he[e.category]}const ut=e=>e.readOnly?Je(pt,{data:e.data}):Je(ht,{formState:e.formState,onChange:e.onChange}),pt=({data:e})=>{const a=Sa(()=>[{id:"name",title:se,value:e.rule.name||ne},{id:"type",title:oe,value:ct(e)}],[e]),t=e.rule.notes||J;return We(y,{children:[Je(Ha,{children:a.map(({id:e,title:a,value:t})=>We(Va,{children:[Je(T,{size:P.XXXS,color:$.Secondary,nowrap:!0,children:a}),Je(T,{size:P.XS,nowrap:!0,children:t})]},e))}),We(Va,{children:[Je(T,{size:P.XXXS,color:$.Secondary,children:de}),Je(T,{size:P.XS,children:t})]})]})},ht=({formState:e,onChange:a})=>{const t=xa(e=>a({name:e.target.value}),[a]),l=xa(e=>a({notes:e.target.value}),[a]);return Je(y,{children:We(st,{children:[Je(ot,{children:Je(p,{name:"sampling-input-rule-name",label:se,tooltip:"Optional. Give this rule a name for easier identification.",placeholder:ce,value:e.name,onChange:t})}),Je(dt,{children:Je(p,{name:"sampling-input-note",label:de,tooltip:pe,placeholder:ue,value:e.notes,onChange:l})})]})})},gt=[{value:"Relevance",label:"Relevance"},{value:"Error",label:"Error"},{value:"Duration",label:"Duration"}],mt=({formState:e,onChange:a})=>{const t=xa(e=>a({ruleType:e,keepErrors:"Error"===e}),[a]);return Je(y,{richTitle:{title:`3. ${oe}`,subTitle:ge},children:Je(v,{$alignItems:"flex-start",children:Je(f,{options:gt,selected:e.ruleType,setSelected:t})})})},vt=Pa.div`
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
gap: 24px;
|
|
48
48
|
padding: 8px 16px;
|
|
49
49
|
border-radius: 12px;
|
|
50
50
|
background-color: ${({theme:e})=>e.v2.colors.silver[800]};
|
|
51
|
-
`,
|
|
51
|
+
`,bt=Pa.div`
|
|
52
52
|
flex: 1;
|
|
53
53
|
min-width: 0;
|
|
54
54
|
white-space: pre;
|
|
55
55
|
overflow-x: auto;
|
|
56
|
-
`,
|
|
56
|
+
`,ft=({title:e,summary:t,onEdit:l,renderAction:r})=>{const i=Sa(()=>{const a=[];return e&&(a.push({text:e,variant:Qe.Default}),a.push({text:" - ",variant:Qe.Default})),a.push(...t),a},[e,t]);return We(vt,{children:[Je(bt,{children:Je(_e,{parts:i})}),r&&r(),l&&Je(me,{"data-id":"sampling-btn-edit-auto-rule",label:ve,rightIcon:ha,variant:a.Text,size:j.S,onClick:l})]})},yt=e=>{const a=Sa(()=>{if(e.readOnly)return e.summary;switch(e.category){case"noisy":return ta(ia(e.formState));case"highlyRelevant":return aa(ra(e.formState));case"costReduction":return ea(la(e.formState))}},[e]);if(e.readOnly)return Je(ft,{title:be,summary:a,renderAction:e.renderAction});const t=1===a.length&&"default"===a[0].variant;return Je(ft,{title:t?fe:be,summary:t?[]:a,renderAction:e.renderAction})},xt=Pa.div`
|
|
57
57
|
display: flex;
|
|
58
58
|
flex-wrap: wrap;
|
|
59
59
|
gap: 8px;
|
|
@@ -95,7 +95,7 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
95
95
|
justify-content: center;
|
|
96
96
|
align-items: center;
|
|
97
97
|
flex-shrink: 0;
|
|
98
|
-
`,$t={[Oe.JavaScript]:"Node.js",[Oe.DotNet]:".NET",[Oe.Php]:"PHP",[Oe.Java]:"Java",[Oe.Go]:"Go",[Oe.Python]:"Python",[Oe.Ruby]:"Ruby",[Oe.Rust]:"Rust"},Pt=[Oe.Python,Oe.Java,Oe.JavaScript,Oe.DotNet,Oe.Php,Oe.Ruby,Oe.Go].map(e=>({id:e,label:$t[e]??e.charAt(0).toUpperCase()+e.slice(1),Icon:Me(e)})),At=[{value:"all",label:"Entire Cluster"},{value:"source",label:"Specific Source"},{value:"namespace",label:"Specific Namespace"},{value:"language",label:"Specific Programming Language"}];function Mt(e){const a=$t[e];return a||e.charAt(0).toUpperCase()+e.slice(1)}const Ot=e=>e.readOnly?
|
|
98
|
+
`,$t={[Oe.JavaScript]:"Node.js",[Oe.DotNet]:".NET",[Oe.Php]:"PHP",[Oe.Java]:"Java",[Oe.Go]:"Go",[Oe.Python]:"Python",[Oe.Ruby]:"Ruby",[Oe.Rust]:"Rust"},Pt=[Oe.Python,Oe.Java,Oe.JavaScript,Oe.DotNet,Oe.Php,Oe.Ruby,Oe.Go].map(e=>({id:e,label:$t[e]??e.charAt(0).toUpperCase()+e.slice(1),Icon:Me(e)})),At=[{value:"all",label:"Entire Cluster"},{value:"source",label:"Specific Source"},{value:"namespace",label:"Specific Namespace"},{value:"language",label:"Specific Programming Language"}];function Mt(e){const a=$t[e];return a||e.charAt(0).toUpperCase()+e.slice(1)}const Ot=e=>e.readOnly?Je(Lt,{scopes:e.scopes}):Je(zt,{formState:e.formState,onChange:e.onChange,sourceOptions:e.sourceOptions,namespaceOptions:e.namespaceOptions}),Lt=({scopes:e})=>{if(na(e))return Je(y,{richTitle:{title:ye},children:Je(xe,{status:Ce.Default,message:Se,fullWidth:!0})});const a=e.sources??[],t=e.namespaces??[],l=e.languages??[];return Je(y,{richTitle:{title:ye},children:We(kt,{children:[a.map((e,a)=>{const t=[e.namespace,e.kind,e.name].filter(Boolean),l=t.length?t.join(" / "):ke;return Je(Tt,{children:Je(T,{size:P.XS,color:$.Primary,children:l})},`src-${a}`)}),t.map((e,a)=>Je(Tt,{children:Je(T,{size:P.XS,color:$.Primary,children:e})},`ns-${a}`)),l.map((e,a)=>{const t=Me(e);return We(Tt,{children:[t&&Je(wt,{children:Je(t,{size:18})}),Je(T,{size:P.XS,color:$.Primary,children:Mt(e)})]},`lang-${a}`)})]})})},zt=({formState:e,onChange:a,sourceOptions:t=[],namespaceOptions:l=[]})=>{const[r,i]=Ca(()=>{return(a=e.sourceScopes).sources.length>0?"source":a.namespaces.length>0?"namespace":a.languages.length>0?"language":"all";var a}),{sources:s,namespaces:o,languages:d}=e.sourceScopes,c=s.length>0||o.length>0||d.length>0,u=Sa(()=>At.map(e=>({...e,disabled:"all"===e.value&&c})),[c]),p=Sa(()=>s.map(e=>{return a=e.namespace,t=e.kind,l=e.name,`${a}/${t}/${l}`;var a,t,l}),[s]),h=Sa(()=>[...o],[o]),g=Sa(()=>new Set(d),[d]),m=xa(e=>{i(e)},[]),b=xa(t=>{const l=t.map(e=>function(e){const a=e.split("/");return 3!==a.length?null:{namespace:a[0],kind:a[1],name:a[2]}}(e)).filter(e=>null!==e).map(e=>({namespace:e.namespace,kind:e.kind,name:e.name}));a({sourceScopes:{...e.sourceScopes,sources:l}})},[e.sourceScopes,a]),x=xa(t=>{a({sourceScopes:{...e.sourceScopes,namespaces:t}})},[e.sourceScopes,a]),S=xa(t=>{const l=e.sourceScopes.languages,r=l.includes(t)?l.filter(e=>e!==t):[...l,t];a({sourceScopes:{...e.sourceScopes,languages:r}})},[e.sourceScopes,a]);return We(y,{richTitle:{title:`1. ${ye}`,subTitle:Te},children:[Je(xe,!c&&"all"===r?{status:Ce.Default,message:Se,fullWidth:!0,smallIcon:!0}:{status:Ce.Info,message:we,fullWidth:!0,smallIcon:!0}),Je(v,{$alignItems:"flex-start",children:Je(f,{options:u,selected:r,setSelected:m})}),"source"===r&&Je($e,{multiple:!0,"data-id":"sampling-autocomplete-source",options:t,value:p,onSelect:b,placeholder:Pe}),"namespace"===r&&Je($e,{multiple:!0,"data-id":"sampling-autocomplete-namespace",options:l,value:h,onSelect:x,placeholder:"Search namespace"}),"language"===r&&Je(xt,{children:Pt.map(({id:e,label:a,Icon:t})=>{const l=g.has(e);return We(St,{$selected:l,onClick:()=>S(e),children:[Je(n,{name:`sampling-scope-lang-${e}`,size:Ae.S,value:l,onChange:()=>S(e)}),Je(Ct,{children:Je(t,{size:20})}),Je(T,{size:P.XS,nowrap:!0,children:a})]},e)})})]})},Dt=(e,a)=>!a?.length||!!a?.find(a=>a===e),It=({title:e="Signals",required:a,errorMessage:t,allowedSignals:l,selectedSignals:r,setSelectedSignals:i,disabled:s})=>{const[o,d]=Ca(1===r.length),c=ka(JSON.stringify(r));Ta(()=>{let e=Le(r).filter(e=>Dt(e,l));e.length||(e=ze.filter(({id:e})=>Dt(e,l)).map(({id:e})=>e));const a=JSON.stringify(e);c.current!==a&&(c.current=a,i(e),d(1===e.length))},[l,r]);return We(v,{$gap:12,children:[Je(b,{label:e,required:a}),Je(m,{$gap:12,children:ze.map(e=>{const a=Dt(e.id,l),t=((e,a)=>!!a?.find(a=>a===e))(e.id,r);return a?Je(n,{label:e.value,disabled:s||!a||o&&t,value:t,onChange:a=>((e,a)=>{const t=e,l=a?[...r,t]:r.filter(e=>e!==t);i(l),d(1===l.length)})(e.id,a)},e.id):null})}),Je(De,{errorMessage:t})]})},Rt=({minSupportedVersion:a,currentVersion:t})=>Je(e,{isOpen:!0,onClose:()=>{},relativeToParent:!0,visual:()=>Je(Ie,{scale:2.4,icon:()=>Je("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"21",viewBox:"0 0 22 21",fill:"none",children:Je("path",{fill:"#151618",d:"M9.4844 0.730003C9.99694 -0.243259 11.4076 -0.24341 11.92 0.730003L11.9685 0.831353L14.3039 6.22012L20.153 6.77755C21.3553 6.89211 21.841 8.38683 20.9358 9.18621L16.5314 13.0731L17.8091 18.8079C18.0716 19.9868 16.8005 20.9109 15.7605 20.2969L10.7017 17.3093L5.64282 20.2969C4.60289 20.9104 3.33173 19.9866 3.59427 18.8079L4.87192 13.0741L0.468608 9.18621C-0.43662 8.38693 0.0482932 6.8924 1.25029 6.77755L7.09837 6.22012L9.43588 0.831353L9.4844 0.730003ZM8.55284 7.02876C8.35287 7.48992 7.9179 7.80589 7.41751 7.85357L2.03952 8.36571L6.09027 11.941C6.46691 12.2737 6.63296 12.7852 6.5237 13.2758L5.34956 18.5459L10.0008 15.8009L10.1669 15.7179C10.5087 15.574 10.8945 15.5741 11.2364 15.7179L11.4036 15.8009L16.0538 18.5459L14.8807 13.2758C14.7714 12.7851 14.9374 12.2737 15.3141 11.941L19.3627 8.36571L13.9858 7.85357C13.4855 7.80587 13.0505 7.4899 12.8505 7.02876L10.7017 2.07342L8.55284 7.02876Z"})})}),title:"Upgrade Required",description:`To use this feature, please upgrade to Odigos v${a} or later.\nCurrent version: ${t}.`}),Xt=Pa.div`
|
|
99
99
|
display: flex;
|
|
100
100
|
flex-direction: column;
|
|
101
101
|
justify-content: flex-end;
|
|
@@ -108,7 +108,7 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
108
108
|
padding: 12px;
|
|
109
109
|
border-radius: 16px 16px 0 0;
|
|
110
110
|
background-color: ${({theme:e})=>e.v2.colors.silver[800]};
|
|
111
|
-
`,
|
|
111
|
+
`,Bt=Pa.div`
|
|
112
112
|
display: flex;
|
|
113
113
|
flex-direction: column;
|
|
114
114
|
gap: ${({$gap:e})=>e}px;
|
|
@@ -119,20 +119,20 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
119
119
|
background-color: ${({theme:e})=>e.v2.colors.silver[900]};
|
|
120
120
|
overflow-y: auto;
|
|
121
121
|
overflow-x: hidden;
|
|
122
|
-
`,
|
|
122
|
+
`,Et=({isLeft:e,isRight:a,heightOffset:t=0,width:l,header:r,list:i})=>We(Xt,{$width:l,$columnHasHeader:!!r,children:[r&&Je(Nt,{children:r}),Je(Bt,{$gap:8,$isLeft:e,$isRight:a,$heightOffset:t,$columnHasHeader:!!r,children:i.length?i.length>1?Je(Re,{gap:8,elements:i}):Je(Fe,{children:i[0]}):Je(Xe,{$height:"100%",children:Je(Ne,{})})})]}),Ht="75vw",Vt=Pa.div`
|
|
123
123
|
display: flex;
|
|
124
124
|
flex-direction: column;
|
|
125
125
|
border-radius: 16px;
|
|
126
126
|
background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
|
|
127
127
|
overflow: hidden;
|
|
128
|
-
`,
|
|
128
|
+
`,jt=Pa.div`
|
|
129
129
|
display: flex;
|
|
130
130
|
gap: 12px;
|
|
131
131
|
padding: 16px 16px 0 16px;
|
|
132
132
|
background-color: ${({theme:e})=>e.v2.colors.silver[1e3]};
|
|
133
133
|
position: sticky;
|
|
134
134
|
top: 0;
|
|
135
|
-
`,
|
|
135
|
+
`,qt=Pa.div`
|
|
136
136
|
padding: 12px 12px 0 12px;
|
|
137
137
|
`,Ut=Pa.div`
|
|
138
138
|
display: flex;
|
|
@@ -142,6 +142,8 @@ import{ap as e,ab as a,R as t,a6 as l,a7 as r,dQ as i,a0 as n,aB as s,ae as o,a4
|
|
|
142
142
|
padding: 5vh 10vw;
|
|
143
143
|
border-radius: 12px;
|
|
144
144
|
background-color: ${({theme:e})=>e.v2.colors.silver[800]};
|
|
145
|
-
`,
|
|
146
|
-
padding: 0
|
|
147
|
-
|
|
145
|
+
`,Kt=wa(({isOpen:t,withOverlay:l,disableAnimation:r,onClose:i,onBack:n,onNext:s,nextIsSkip:o,onSave:d,disableSave:c,connectionIds:u,header:p,subHeader:h,leftColumn:g,rightColumn:m,search:v,filters:b,errorMessage:f,isFormDirty:y,hideDirtyNote:x,isFetching:S,progress:C},k)=>{const[T,w]=Ca(!1),[$,A]=Ca(!1),[M,O]=Ca(void 0);$a(k,()=>({clearErrors:()=>O(void 0)}));const L=$,z=xa(()=>{y&&!T?w(!0):(w(!1),i?.())},[y,T,i]),D=c||$||"boolean"==typeof y&&!y,I=xa(async()=>{A(!0);const e=await d();A(!1),!1!==e&&(e?.error?O(e.error):(u?.setValue([]),i?.()))},[d,u,i]),R=!!v||!!u||!!b,X=!!h,N=(R?48:0)+(X?50:0),B=Sa(()=>S?{status:Ce.Info,message:"Fetching Data..."}:$&&!C?{status:Ce.Info,message:"Saving Changes..."}:M||f?{status:Ce.Error,message:M||f}:"boolean"==typeof y&&y&&!x?{status:Ce.Info,message:'The values don\'t reflect the current configurations of the selected clusters.\n"Save" will override the current configurations.'}:"boolean"!=typeof y||y||x?void 0:{status:Ce.Success,message:"The values reflect the current configuration of the selected cluster."},[S,$,C,M,f,y,x]),E=Sa(()=>n?{label:"Back",leftIcon:ga,variant:a.Secondary,onClick:n}:{label:"Cancel",variant:a.Secondary,onClick:z,disabled:L},[n,z,L]),[H,V]=Ca(!1),j=Sa(()=>s?o?{"data-id":"wide-drawer-skip",label:"Skip",rightIcon:ma,variant:a.Secondary,onClick:()=>V(!0)}:{"data-id":"wide-drawer-next",label:"Next",rightIcon:ma,variant:a.Primary,onClick:s}:{"data-id":"wide-drawer-save",label:"Save",variant:a.Primary,onClick:I,disabled:D},[s,o,I,D]);return We(Be,{width:Ht,isOpen:t,disableAnimation:r,hideOverlay:!$&&!l,header:{...p,onClose:i?z:void 0,onCloseDisabled:L},footer:{note:B,actions:[E,j]},children:[$?Je(Xe,{$height:"calc(100vh - 136px)",children:Je(Gt,{children:Je(Ee,{titleSize:P.S,subTitleSize:P.XXXS,withGradient:!0,withSpinner:!0,...C})})}):We(Vt,{children:[R&&We(jt,{children:[u&&Je(He,{icon:va,title:"Selected Clusters",badge:{label:u.value.length}}),v&&Je(Ve,{width:"100%",...v}),b]}),X&&Je(qt,{children:Je(He,{icon:h.icon,title:h.title,subTitle:h.description,badge:h.badge})}),We(Ut,{children:[Je(Et,{isLeft:!0,heightOffset:N,...g}),Je(Et,{isRight:!0,heightOffset:N,...m})]})]}),Je(Aa,{isOpen:T,onClose:()=>w(!1),onApprove:z}),Je(e,{title:"Skip setup?",description:"Without completing setup, Odigos won't be able to collect and send your telemetry data. This may interrupt your data flow and limit the platform's ability to provide value.",isOpen:H,onClose:()=>V(!1),denyButton:{label:"Go Back",variant:a.Secondary,onClick:()=>V(!1)},approveButton:{label:"Skip",variant:a.Primary,onClick:()=>{s?.(),V(!1)}}})]})});Kt.displayName=Kt.name;const Jt=Pa.div`
|
|
146
|
+
padding: 0 24px;
|
|
147
|
+
border-radius: 12px;
|
|
148
|
+
background-color: ${({$codeBgColor:e})=>e||"transparent"};
|
|
149
|
+
`,Wt=({title:e="YAML",yaml:t,defaultOpen:l,fullHeight:r,bgTint:i="1000",codeBgColor:n})=>{const{clickCopy:s,isCopied:o}=je(),d=Sa(()=>t?[{id:Ue(),type:qe.Button,buttonProps:{variant:a.Text,size:j.S,leftIcon:o?ba:fa,onClick:()=>s(t||""),disabled:o}}]:[],[t,o]);return Je(Ge,{bgTint:i,richTitle:{icon:ya,title:e},actions:d,withCollapse:!0,collapseIsDefaultOpen:l,fullHeight:r,children:Je(Jt,{$codeBgColor:n,children:t?Je(Ke,{code:t,language:"yaml",theme:"duotoneDark"}):Je(Xe,{children:Je(Ne,{title:"YAML not found",subTitle:"The YAML for this resource is not available"})})})})};export{ft as A,Aa as C,Oa as D,Da as N,_a as O,Ra as P,ut as R,It as S,Rt as U,Kt as W,Wt as Y,za as a,yt as b,Ot as c,mt as d,Na as e,rt as f,Ma as g,La as h,Ht as i,Ia as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as n,useContext as r,createContext as s,useRef as o,useEffect as i}from"react";import{v as l,w as d,A as c,x as m,y as u,z as p,B as h,G as f,H as g,J as v,q as b,K as y,L as S,M as D,O as E,Q as k,R as F,U as C,V as I,W as N,X as A,Y as w,Z as R,_ as P,T,E as x}from"./ui-components-B0BVzW_z.js";import{b as O,a as L,d as U,v as M,g as _,u as j}from"./helpers-D-6cJlOn.js";const V={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},K=s(null),G="All row fields are required",H="At least one row is required",q=h.LATENCY_HTTP_ROUTE,z=e=>"string"==typeof e?!e.trim():f(e),Q=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!z(a)}),W=({children:r})=>{const[s,o]=t(null),i=l(V),g=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),v=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:n,signals:r,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!n,signals:r??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??m.find(e=>e.type===t)??null))},[]),b=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(V)};const e=(e=>{const t=d(e),a=t.fields||{},n=a[u.UrlTemplatizationRulesGroups];n?.length&&(a[u.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const r=a[u.AttributeNamesToDelete];r?.length&&(a[u.AttributeNamesToDelete]=r.filter(e=>!!e?.trim()));const s=a[u.Renames];return s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim()))),t.fields=a,t})(i.formData),t={};f(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const n={},r=t.fields||{},s=a.fields||{};switch(e){case p.K8sAttributes:{const e=!(r[u.CollectContainerAttributes]||r[u.CollectReplicaSetAttributes]||r[u.CollectWorkloadId]||r[u.CollectClusterId]),t=!r[u.LabelsAttributes]?.length,a=!r[u.AnnotationsAttributes]?.length;e&&t&&a&&(n[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=r[u.LabelsAttributes];s?.some(e=>!Q(e,["labelKey","attributeKey","fromSources"]))&&(n[u.LabelsAttributes]=G);const o=r[u.AnnotationsAttributes];o?.some(e=>!Q(e,["annotationKey","attributeKey","fromSources"]))&&(n[u.AnnotationsAttributes]=G);break}case p.AddClusterInfo:{const e=r[u.ClusterAttributes];e?.length?e.some(e=>!Q(e,["attributeName","attributeStringValue"]))&&(n[u.ClusterAttributes]=G):n[u.ClusterAttributes]=H;break}case p.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=r[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(n[u.AttributeNamesToDelete]=G):n[u.AttributeNamesToDelete]=e.length?G:H;break}case p.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(r[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(n[u.Renames]=G):n[u.Renames]=e.length?G:H;break}case p.PiiMasking:{const e=r[u.PiiCategories];e?.length||(n[u.PiiCategories]="Select at least one attribute to mask");break}case p.ErrorSampler:z(r[u.FallbackSamplingRatio])&&(n[u.FallbackSamplingRatio]=h.FIELD_IS_REQUIRED);break;case p.ProbabilisticSampler:z(r[u.SamplingPercentage])&&(n[u.SamplingPercentage]=h.FIELD_IS_REQUIRED);break;case p.LatencySampler:{const e=r[u.EndpointsFilters];e?.length?e.some(e=>!Q(e,["serviceName","httpRoute","minimumLatencyThreshold","fallbackSamplingRatio"]))?n[u.EndpointsFilters]=G:e.some(e=>!!e.httpRoute&&!e.httpRoute.startsWith("/"))&&(n[u.EndpointsFilters]=q):n[u.EndpointsFilters]=H;break}case p.ServiceNameSampler:{const e=r[u.ServicesNameFilters];e?.length?e.some(e=>!Q(e,["serviceName","samplingRatio","fallbackSamplingRatio"]))&&(n[u.ServicesNameFilters]=G):n[u.ServicesNameFilters]=H;break}case p.SpanAttributeSampler:{const e=r[u.AttributeFilters],t=["stringCondition","numberCondition","booleanCondition","jsonCondition"],a=new Set(["exists","is_valid_json","is_invalid_json","jsonpath_exists"]);e?.length?e.some(e=>{if(!Q(e,["serviceName","attributeKey","fallbackSamplingRatio"]))return!0;const n=e.condition||{},r=t.find(e=>!!n[e]);if(!r)return!0;const s=n[r]||{},o=s.operation;return!o||!(a.has(o)||!z(s.expectedValue))})&&(n[u.AttributeFilters]=G):n[u.AttributeFilters]=H;break}case p.URLTemplatization:{const e=r[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(n[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}}return n})(s.type,e,i.formData)),i.handleErrorChange(void 0,void 0,t);return{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),y=n(()=>({selectedOption:s,onSelectOption:g,loadAction:v,genericForm:i,validateFormData:b}),[s,g,v,i,b]);return e(K.Provider,{value:y,children:r})},J=()=>{const e=r(K);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:r,defaultExcludeName:s=""})=>{const{dataStreams:i}=g(),[c,m]=t(void 0),[u,p]=t(s),[f,b]=t(void 0),[y,S]=t(null),D=o(null),E=l($),k=a(e=>{E.resetFormData({name:e}),E.handleErrorChange(void 0,void 0,{}),m(void 0),p(e),b(e),S(null),D.current=null},[]),F=a(()=>{const e=d(E.formData),t=(e=>{const t={};return e.name?v(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);E.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return m(a),{errorMessage:a,preparedFormData:e}},[E]),C=a(async e=>{const{errorMessage:t,preparedFormData:a}=F();if(t)return;const n=i.find(e=>e.name===a.name&&e.name!==u);if(n)return D.current=e,void S({preparedFormData:a,existingName:n.name,editingName:f});await e(a)},[F,i,u,f]),I=a(async()=>{const e=D.current,t=y?.preparedFormData;D.current=null,S(null),e&&t&&await e(t)},[y]),N=a(()=>{D.current=null,S(null)},[]),A=n(()=>({genericForm:E,loadDataStream:k,editingName:f,validateFormData:F,requestSubmit:C,pendingMerge:y,confirmMerge:I,cancelMerge:N,errorMessage:c,excludeName:u,setExcludeName:p}),[E,k,f,F,C,y,I,N,c,u]);return e(B.Provider,{value:A,children:r})},Y=()=>{const e=r(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},ee={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(Z)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},te=s(ee),ae=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:n,displayName:r,initialValue:s,renderCondition:o}=e,i=a===F.Dropdown,l=E(n,{});return{componentType:a,renderCondition:o,name:t,title:r,value:s,placeholder:l.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(l.values)?l.values.map(e=>({id:e,label:e})):void 0,...l}}),ne=({children:r})=>{const{selectedStreamName:s}=g(),o=b(e=>e.destinations),[c,m]=t(null),[u,p]=t(ee.unsavedDestinations),v=n(()=>"number"==typeof c?.unsavedIdx?u[c.unsavedIdx]:void 0,[c,u]),F=a((e,t)=>{c&&(p(t=>[...t,{...e,option:c.option}]),m(t?e=>e?{...e,listType:y.UNSAVED,unsavedIdx:u.length}:null:null))},[c,u.length]),C=a((e,t,a)=>{c&&(p(a=>a.map((a,n)=>n===e?{...a,...t,option:c.option}:a)),m(a?e=>e?{...e,listType:y.UNSAVED}:null:null))},[c]),I=a(e=>{p(t=>t.filter((t,a)=>a!==e)),m(null)},[]),N=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(v)return void N.resetFormData({...v.formData});if(c.listType===y.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void N.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:s,disabled:!!e.disabled,exportedSignals:{logs:!!e.exportedSignals?.logs,metrics:!!e.exportedSignals?.metrics,traces:!!e.exportedSignals?.traces,profiles:!!e.exportedSignals?.profiles},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})}const e=S(c.option.supportedSignals);N.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(D.Logs),metrics:e.includes(D.Metrics),traces:e.includes(D.Traces),profiles:e.includes(D.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,v]);const A=a(e=>{N.resetFormData(),N.handleErrorChange(void 0,void 0,{}),m(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const n of t){const t=n.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const n=E(e.fields,{}),r={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:a?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:a?a.fields.map(e=>({...e,initialValue:n[e.name]??e.initialValue})):[]},s=ae(r.fields);m({listType:y.EXISTS,option:r,dynamicFields:s})},[]),R=a(()=>{const e=d(N.formData),t={};c?.dynamicFields.forEach(({name:a,required:n})=>{if(n){const n=e.fields.find(e=>e.key===a)?.value;f(n)&&(t[a]=h.FIELD_IS_REQUIRED)}});return k(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),N.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[N,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:A,loadDestination:w,genericForm:N,validateFormData:R,unsavedDestinations:u,thisUnsavedDestination:v,setUnsavedDestinations:p,addUnsavedDestination:F,updateUnsavedDestination:C,deleteUnsavedDestination:I},children:r})},re=()=>r(te),se={disabled:!1,ruleName:"",notes:"",workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:r})=>{const[s,o]=t(null),i=l(se),c=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),o(e)},[]),m=a(e=>{var t;i.resetFormData((({ruleName:e,notes:t,disabled:a,workloads:n,instrumentationLibraries:r,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,workloads:n??null,instrumentationLibraries:r??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,C.find(e=>e.type===t)??null))},[]),u=a(()=>{if(!s)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e);return t.headersCollection?.[I.HeaderKeys]?.length&&(t.headersCollection[I.HeaderKeys]=t.headersCollection[I.HeaderKeys].map(e=>e.trim()).filter(e=>e)),t.customInstrumentations?.[N.Golang]?.length&&(t.customInstrumentations[N.Golang]=t.customInstrumentations[N.Golang].map(e=>new A(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>{return t=e,!!(t.packageName?.trim()||t.functionName?.trim()||t.receiverName?.trim()||t.receiverMethodName?.trim());var t})),t.customInstrumentations?.[N.Java]?.length&&(t.customInstrumentations[N.Java]=t.customInstrumentations[N.Java].map(e=>new w(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),t})(i.formData),t=((e,t)=>{const a={};switch(e){case R.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case R.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case R.HeadersCollection:t.headersCollection?.[I.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case R.CustomInstrumentation:{const e=t.customInstrumentations?.[N.Golang]||[],n=t.customInstrumentations?.[N.Java]||[];if(!e.length&&!n.length){a.customInstrumentations="Custom instrumentation are required";break}const r=e.findIndex(e=>!new A(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==r){a.customInstrumentations=`Golang probe #${r+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=n.findIndex(e=>!new w(e.className,e.methodName).Verify());if(-1!==s){a.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}break}}return a})(s.type,e);return i.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),p=n(()=>({selectedOption:s,onSelectOption:c,loadRule:m,genericForm:i,validateFormData:u}),[s,c,m,i,u]);return e(oe.Provider,{value:p,children:r})},le=()=>{const e=r(oe);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var de;!function(e){e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"}(de||(de={}));const ce=s(null),me=["50","25","10","1"];function ue(e){const t=String(e);return me.includes(t)?t:"custom"}const pe=({category:r,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:m,resetFormData:u}=l(_(r)),[p,h]=t(null);i(()=>{u(_(r)),h(null)},[r]);const f=a(e=>{h(null),m(void 0,void 0,{...c,...e})},[c,m]),g=a(()=>{u(_(r)),h(null)},[r,u]),v=n(()=>({formType:de.Create,category:r,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[r,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:r,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:m})=>{const[u,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{r!==v.current&&(v.current=r,r&&s?(g(M(r)),y(null),p(!0)):(p(!1),y(null)))},[r,s]);const S=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),D=a(()=>{r&&(g(M(r)),y(null),p(!0))},[r,g]),E=a(()=>{p(!1),y(null)},[]),k=n(()=>({formType:de.View,data:r,isEditing:u,formData:h,handleChange:S,handleEdit:D,handleCancelEdit:E,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[r,u,h,S,D,E,b,d,c]);return e(ce.Provider,{value:k,children:m})};function fe(e){const[a,r]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>ue(e)),[l,d]=t(()=>"custom"===ue(e)?String(e):"");i(()=>{r(0===e?"all":"sample");const t=ue(e);o(t),d("custom"===t?String(e):"")},[e]);const c=n(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:r,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>U({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),m=n(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:m,children:s})},ve=({enabled:a,dropPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>L(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),m=n(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:m,children:s})},be=({enabled:a,children:r})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=n(()=>O(s?{disabled:!1}:null),[s]),d=n(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:r})},ye=t=>{switch(t.formType){case de.Create:return e(pe,{...t});case de.View:return e(he,{...t});case de.EditAutoNoisy:return e(ge,{...t});case de.EditAutoCostReduction:return e(ve,{...t});case de.EditAutoHighlyRelevant:return e(be,{...t})}};function Se(e){const t=r(ce);if(!t)throw new Error("useSamplingRulesFormContext must be used within a SamplingRulesFormProvider");if(e&&t.formType!==e)throw new Error(`Expected formType "${e}" but found "${t.formType}"`);return t}const De={otelServiceName:"",currentStreamName:""},Ee=s(null),ke=({children:r})=>{const[s,o]=t(void 0),i=l(De),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),m=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),u=n(()=>({loadSource:c,genericForm:i,validateFormData:m,errorMessage:s}),[c,i,m,s]);return e(Ee.Provider,{value:u,children:r})},Fe=()=>{const e=r(Ee);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ce=new Set([P.StaticPod]),Ie=e=>{const t=e.workloads.filter(({selected:e})=>e).length,a=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===a,isSomeSourced:t>0&&t<a,isFutureApps:e.selected||!1}},Ne=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:n}=Ie(e);return t||a||n}return!0},Ae=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),we=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),Re=({children:r,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=j(),c=l===T.Onprem,{selectedStreamName:m}=g(),[u,p]=t(!1),[h,f]=t(null),[v,b]=t([]);i(()=>{h&&b(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(h,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),n=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(n);return e.forEach(e=>{const t=a.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const a=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);a&&(a.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Ce.has(e.kind)&&!c||(e.selected=!0)})}),a}return n})})},[h,s,o]);const{formDiff:y,isFormDirty:S}=n(()=>{const e=((e,t,a)=>{const n={};return e.forEach(e=>{e.namespaces.forEach(r=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===r.name),o=r.selected||!1;if(o!==s?.selected)n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push({namespace:r.name,selected:o,currentStreamName:a}),o?n[e.clusterId]=n[e.clusterId].filter(e=>e.namespace!==r.name||e.namespace===r.name&&(!e.name||!e.kind)):r.workloads.forEach(t=>{t.selected&&n[e.clusterId].push({namespace:r.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const n=[];return t.workloads.forEach(r=>{const s=e?.workloads.find(e=>e.name===r.name&&e.kind===r.kind);r.selected!==s?.selected&&n.push({namespace:t.name,name:r.name,kind:r.kind,selected:r.selected||!1,currentStreamName:a})}),n})(s,r,a);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(v,h?.clusters||[],m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[v,h,m]),D=a(e=>!c&&Ce.has(e),[c]),E=a(({clusterId:e,workloadId:t,selected:a,auto:n})=>{b(r=>{const s=d(r),o=s.findIndex(t=>t.clusterId===e);if(-1===o)return s;const i=s[o].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return s;if(t.kind&&t.name){const e=s[o].namespaces[i].workloads.findIndex(e=>e.name===t.name&&e.kind===t.kind);if(-1===e)return s;const n="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=n,n){s[o].namespaces[i].workloads.filter(e=>!D(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof n?n:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{D(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[D]),k=a(({clusterId:e,namespaceName:t,boolean:a,searchText:n="",searchBy:r="",filters:s})=>{b(o=>{const i=d(o),l=r===x.Namespace?n:"",c=r===x.Source?n:"",m=!!l||!!c||!!s?.showOnlySelected;return i.forEach((n,r)=>{e&&n.clusterId!==e||n.namespaces.forEach(({name:e,workloads:n},o)=>{if(!t||e===t)if(m)if(t){n.forEach((e,t)=>{a&&D(e.kind)||Ae(e,c,s||{showOnlySelected:!1})&&(i[r].namespaces[o].workloads[t].selected=a)});const e=i[r].namespaces[o].workloads.filter(e=>!D(e.kind)).every(e=>e.selected);i[r].namespaces[o].selected=e}else{if(!Ne(i[r].namespaces[o],l,s||{showOnlySelected:!1}))return;i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&D(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})}else i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&D(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})})}),i})},[D]);return e(we.Provider,{value:{snapshots:h,setSnapshots:f,isFetching:u,setIsFetching:p,formData:v,handleSourceChange:E,handleSelectAll:k,formDiff:y,isFormDirty:S},children:r})},Pe=()=>r(we);export{W as A,X as D,Ce as E,ie as R,de as S,ne as a,ye as b,ke as c,Re as d,Y as e,re as f,le as g,Se as h,Fe as i,Pe as j,Ae as k,Ne as l,Ie as m,J as u};
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as n,useContext as r,createContext as s,useRef as o,useEffect as i}from"react";import{v as l,w as d,A as c,x as m,y as u,z as p,B as h,G as f,H as g,J as v,q as b,K as y,L as S,M as D,O as E,Q as k,R as F,U as C,V as I,W as N,X as A,Y as w,Z as R,_ as P,T,E as x}from"./ui-components-DeKNGyn7.js";import{b as O,a as L,d as U,v as M,g as _,u as j}from"./helpers-L572q0MU.js";const V={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},K=s(null),G="All row fields are required",H="At least one row is required",q=h.LATENCY_HTTP_ROUTE,z=e=>"string"==typeof e?!e.trim():f(e),Q=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!z(a)}),W=({children:r})=>{const[s,o]=t(null),i=l(V),g=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),v=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:n,signals:r,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!n,signals:r??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??m.find(e=>e.type===t)??null))},[]),b=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(V)};const e=(e=>{const t=d(e),a=t.fields||{},n=a[u.UrlTemplatizationRulesGroups];n?.length&&(a[u.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const r=a[u.AttributeNamesToDelete];r?.length&&(a[u.AttributeNamesToDelete]=r.filter(e=>!!e?.trim()));const s=a[u.Renames];return s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim()))),t.fields=a,t})(i.formData),t={};f(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const n={},r=t.fields||{},s=a.fields||{};switch(e){case p.K8sAttributes:{const e=!(r[u.CollectContainerAttributes]||r[u.CollectReplicaSetAttributes]||r[u.CollectWorkloadId]||r[u.CollectClusterId]),t=!r[u.LabelsAttributes]?.length,a=!r[u.AnnotationsAttributes]?.length;e&&t&&a&&(n[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=r[u.LabelsAttributes];s?.some(e=>!Q(e,["labelKey","attributeKey","fromSources"]))&&(n[u.LabelsAttributes]=G);const o=r[u.AnnotationsAttributes];o?.some(e=>!Q(e,["annotationKey","attributeKey","fromSources"]))&&(n[u.AnnotationsAttributes]=G);break}case p.AddClusterInfo:{const e=r[u.ClusterAttributes];e?.length?e.some(e=>!Q(e,["attributeName","attributeStringValue"]))&&(n[u.ClusterAttributes]=G):n[u.ClusterAttributes]=H;break}case p.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=r[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(n[u.AttributeNamesToDelete]=G):n[u.AttributeNamesToDelete]=e.length?G:H;break}case p.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(r[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(n[u.Renames]=G):n[u.Renames]=e.length?G:H;break}case p.PiiMasking:{const e=r[u.PiiCategories];e?.length||(n[u.PiiCategories]="Select at least one attribute to mask");break}case p.ErrorSampler:z(r[u.FallbackSamplingRatio])&&(n[u.FallbackSamplingRatio]=h.FIELD_IS_REQUIRED);break;case p.ProbabilisticSampler:z(r[u.SamplingPercentage])&&(n[u.SamplingPercentage]=h.FIELD_IS_REQUIRED);break;case p.LatencySampler:{const e=r[u.EndpointsFilters];e?.length?e.some(e=>!Q(e,["serviceName","httpRoute","minimumLatencyThreshold","fallbackSamplingRatio"]))?n[u.EndpointsFilters]=G:e.some(e=>!!e.httpRoute&&!e.httpRoute.startsWith("/"))&&(n[u.EndpointsFilters]=q):n[u.EndpointsFilters]=H;break}case p.ServiceNameSampler:{const e=r[u.ServicesNameFilters];e?.length?e.some(e=>!Q(e,["serviceName","samplingRatio","fallbackSamplingRatio"]))&&(n[u.ServicesNameFilters]=G):n[u.ServicesNameFilters]=H;break}case p.SpanAttributeSampler:{const e=r[u.AttributeFilters],t=["stringCondition","numberCondition","booleanCondition","jsonCondition"],a=new Set(["exists","is_valid_json","is_invalid_json","jsonpath_exists"]);e?.length?e.some(e=>{if(!Q(e,["serviceName","attributeKey","fallbackSamplingRatio"]))return!0;const n=e.condition||{},r=t.find(e=>!!n[e]);if(!r)return!0;const s=n[r]||{},o=s.operation;return!o||!(a.has(o)||!z(s.expectedValue))})&&(n[u.AttributeFilters]=G):n[u.AttributeFilters]=H;break}case p.URLTemplatization:{const e=r[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(n[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}}return n})(s.type,e,i.formData)),i.handleErrorChange(void 0,void 0,t);return{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),y=n(()=>({selectedOption:s,onSelectOption:g,loadAction:v,genericForm:i,validateFormData:b}),[s,g,v,i,b]);return e(K.Provider,{value:y,children:r})},J=()=>{const e=r(K);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:r,defaultExcludeName:s=""})=>{const{dataStreams:i}=g(),[c,m]=t(void 0),[u,p]=t(s),[f,b]=t(void 0),[y,S]=t(null),D=o(null),E=l($),k=a(e=>{E.resetFormData({name:e}),E.handleErrorChange(void 0,void 0,{}),m(void 0),p(e),b(e),S(null),D.current=null},[]),F=a(()=>{const e=d(E.formData),t=(e=>{const t={};return e.name?v(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);E.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return m(a),{errorMessage:a,preparedFormData:e}},[E]),C=a(async e=>{const{errorMessage:t,preparedFormData:a}=F();if(t)return;const n=i.find(e=>e.name===a.name&&e.name!==u);if(n)return D.current=e,void S({preparedFormData:a,existingName:n.name,editingName:f});await e(a)},[F,i,u,f]),I=a(async()=>{const e=D.current,t=y?.preparedFormData;D.current=null,S(null),e&&t&&await e(t)},[y]),N=a(()=>{D.current=null,S(null)},[]),A=n(()=>({genericForm:E,loadDataStream:k,editingName:f,validateFormData:F,requestSubmit:C,pendingMerge:y,confirmMerge:I,cancelMerge:N,errorMessage:c,excludeName:u,setExcludeName:p}),[E,k,f,F,C,y,I,N,c,u]);return e(B.Provider,{value:A,children:r})},Y=()=>{const e=r(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},ee={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(Z)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},te=s(ee),ae=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:n,displayName:r,initialValue:s,renderCondition:o}=e,i=a===F.Dropdown,l=E(n,{});return{componentType:a,renderCondition:o,name:t,title:r,value:s,placeholder:l.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(l.values)?l.values.map(e=>({id:e,label:e})):void 0,...l}}),ne=({children:r})=>{const{selectedStreamName:s}=g(),o=b(e=>e.destinations),[c,m]=t(null),[u,p]=t(ee.unsavedDestinations),v=n(()=>"number"==typeof c?.unsavedIdx?u[c.unsavedIdx]:void 0,[c,u]),F=a((e,t)=>{c&&(p(t=>[...t,{...e,option:c.option}]),m(t?e=>e?{...e,listType:y.UNSAVED,unsavedIdx:u.length}:null:null))},[c,u.length]),C=a((e,t,a)=>{c&&(p(a=>a.map((a,n)=>n===e?{...a,...t,option:c.option}:a)),m(a?e=>e?{...e,listType:y.UNSAVED}:null:null))},[c]),I=a(e=>{p(t=>t.filter((t,a)=>a!==e)),m(null)},[]),N=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(v)return void N.resetFormData({...v.formData});if(c.listType===y.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void N.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:s,disabled:!!e.disabled,exportedSignals:{logs:!!e.exportedSignals?.logs,metrics:!!e.exportedSignals?.metrics,traces:!!e.exportedSignals?.traces,profiles:!!e.exportedSignals?.profiles},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})}const e=S(c.option.supportedSignals);N.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(D.Logs),metrics:e.includes(D.Metrics),traces:e.includes(D.Traces),profiles:e.includes(D.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,v]);const A=a(e=>{N.resetFormData(),N.handleErrorChange(void 0,void 0,{}),m(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const n of t){const t=n.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const n=E(e.fields,{}),r={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:a?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:a?a.fields.map(e=>({...e,initialValue:n[e.name]??e.initialValue})):[]},s=ae(r.fields);m({listType:y.EXISTS,option:r,dynamicFields:s})},[]),R=a(()=>{const e=d(N.formData),t={};c?.dynamicFields.forEach(({name:a,required:n})=>{if(n){const n=e.fields.find(e=>e.key===a)?.value;f(n)&&(t[a]=h.FIELD_IS_REQUIRED)}});return k(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),N.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[N,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:A,loadDestination:w,genericForm:N,validateFormData:R,unsavedDestinations:u,thisUnsavedDestination:v,setUnsavedDestinations:p,addUnsavedDestination:F,updateUnsavedDestination:C,deleteUnsavedDestination:I},children:r})},re=()=>r(te),se={disabled:!1,ruleName:"",notes:"",workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:r})=>{const[s,o]=t(null),i=l(se),c=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),o(e)},[]),m=a(e=>{var t;i.resetFormData((({ruleName:e,notes:t,disabled:a,workloads:n,instrumentationLibraries:r,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,workloads:n??null,instrumentationLibraries:r??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,C.find(e=>e.type===t)??null))},[]),u=a(()=>{if(!s)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e);return t.headersCollection?.[I.HeaderKeys]?.length&&(t.headersCollection[I.HeaderKeys]=t.headersCollection[I.HeaderKeys].map(e=>e.trim()).filter(e=>e)),t.customInstrumentations?.[N.Golang]?.length&&(t.customInstrumentations[N.Golang]=t.customInstrumentations[N.Golang].map(e=>new A(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>{return t=e,!!(t.packageName?.trim()||t.functionName?.trim()||t.receiverName?.trim()||t.receiverMethodName?.trim());var t})),t.customInstrumentations?.[N.Java]?.length&&(t.customInstrumentations[N.Java]=t.customInstrumentations[N.Java].map(e=>new w(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),t})(i.formData),t=((e,t)=>{const a={};switch(e){case R.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case R.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case R.HeadersCollection:t.headersCollection?.[I.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case R.CustomInstrumentation:{const e=t.customInstrumentations?.[N.Golang]||[],n=t.customInstrumentations?.[N.Java]||[];if(!e.length&&!n.length){a.customInstrumentations="Custom instrumentation are required";break}const r=e.findIndex(e=>!new A(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==r){a.customInstrumentations=`Golang probe #${r+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=n.findIndex(e=>!new w(e.className,e.methodName).Verify());if(-1!==s){a.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}break}}return a})(s.type,e);return i.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),p=n(()=>({selectedOption:s,onSelectOption:c,loadRule:m,genericForm:i,validateFormData:u}),[s,c,m,i,u]);return e(oe.Provider,{value:p,children:r})},le=()=>{const e=r(oe);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var de;!function(e){e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"}(de||(de={}));const ce=s(null),me=["50","25","10","1"];function ue(e){const t=String(e);return me.includes(t)?t:"custom"}const pe=({category:r,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:m,resetFormData:u}=l(_(r)),[p,h]=t(null);i(()=>{u(_(r)),h(null)},[r]);const f=a(e=>{h(null),m(void 0,void 0,{...c,...e})},[c,m]),g=a(()=>{u(_(r)),h(null)},[r,u]),v=n(()=>({formType:de.Create,category:r,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[r,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:r,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:m})=>{const[u,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{r!==v.current&&(v.current=r,r&&s?(g(M(r)),y(null),p(!0)):(p(!1),y(null)))},[r,s]);const S=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),D=a(()=>{r&&(g(M(r)),y(null),p(!0))},[r,g]),E=a(()=>{p(!1),y(null)},[]),k=n(()=>({formType:de.View,data:r,isEditing:u,formData:h,handleChange:S,handleEdit:D,handleCancelEdit:E,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[r,u,h,S,D,E,b,d,c]);return e(ce.Provider,{value:k,children:m})};function fe(e){const[a,r]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>ue(e)),[l,d]=t(()=>"custom"===ue(e)?String(e):"");i(()=>{r(0===e?"all":"sample");const t=ue(e);o(t),d("custom"===t?String(e):"")},[e]);const c=n(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:r,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>U({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),m=n(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:m,children:s})},ve=({enabled:a,dropPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>L(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),m=n(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:m,children:s})},be=({enabled:a,children:r})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=n(()=>O(s?{disabled:!1}:null),[s]),d=n(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:r})},ye=t=>{switch(t.formType){case de.Create:return e(pe,{...t});case de.View:return e(he,{...t});case de.EditAutoNoisy:return e(ge,{...t});case de.EditAutoCostReduction:return e(ve,{...t});case de.EditAutoHighlyRelevant:return e(be,{...t})}};function Se(e){const t=r(ce);if(!t)throw new Error("useSamplingRulesFormContext must be used within a SamplingRulesFormProvider");if(e&&t.formType!==e)throw new Error(`Expected formType "${e}" but found "${t.formType}"`);return t}const De={otelServiceName:"",currentStreamName:""},Ee=s(null),ke=({children:r})=>{const[s,o]=t(void 0),i=l(De),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),m=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),u=n(()=>({loadSource:c,genericForm:i,validateFormData:m,errorMessage:s}),[c,i,m,s]);return e(Ee.Provider,{value:u,children:r})},Fe=()=>{const e=r(Ee);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ce=new Set([P.StaticPod]),Ie=e=>{const t=e.workloads.filter(({selected:e})=>e).length,a=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===a,isSomeSourced:t>0&&t<a,isFutureApps:e.selected||!1}},Ne=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:n}=Ie(e);return t||a||n}return!0},Ae=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),we=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),Re=({children:r,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=j(),c=l===T.Onprem,{selectedStreamName:m}=g(),[u,p]=t(!1),[h,f]=t(null),[v,b]=t([]);i(()=>{h&&b(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(h,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),n=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(n);return e.forEach(e=>{const t=a.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const a=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);a&&(a.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Ce.has(e.kind)&&!c||(e.selected=!0)})}),a}return n})})},[h,s,o]);const{formDiff:y,isFormDirty:S}=n(()=>{const e=((e,t,a)=>{const n={};return e.forEach(e=>{e.namespaces.forEach(r=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===r.name),o=r.selected||!1;if(o!==s?.selected)n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push({namespace:r.name,selected:o,currentStreamName:a}),o?n[e.clusterId]=n[e.clusterId].filter(e=>e.namespace!==r.name||e.namespace===r.name&&(!e.name||!e.kind)):r.workloads.forEach(t=>{t.selected&&n[e.clusterId].push({namespace:r.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const n=[];return t.workloads.forEach(r=>{const s=e?.workloads.find(e=>e.name===r.name&&e.kind===r.kind);r.selected!==s?.selected&&n.push({namespace:t.name,name:r.name,kind:r.kind,selected:r.selected||!1,currentStreamName:a})}),n})(s,r,a);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(v,h?.clusters||[],m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[v,h,m]),D=a(e=>!c&&Ce.has(e),[c]),E=a(({clusterId:e,workloadId:t,selected:a,auto:n})=>{b(r=>{const s=d(r),o=s.findIndex(t=>t.clusterId===e);if(-1===o)return s;const i=s[o].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return s;if(t.kind&&t.name){const e=s[o].namespaces[i].workloads.findIndex(e=>e.name===t.name&&e.kind===t.kind);if(-1===e)return s;const n="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=n,n){s[o].namespaces[i].workloads.filter(e=>!D(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof n?n:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{D(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[D]),k=a(({clusterId:e,namespaceName:t,boolean:a,searchText:n="",searchBy:r="",filters:s})=>{b(o=>{const i=d(o),l=r===x.Namespace?n:"",c=r===x.Source?n:"",m=!!l||!!c||!!s?.showOnlySelected;return i.forEach((n,r)=>{e&&n.clusterId!==e||n.namespaces.forEach(({name:e,workloads:n},o)=>{if(!t||e===t)if(m)if(t){n.forEach((e,t)=>{a&&D(e.kind)||Ae(e,c,s||{showOnlySelected:!1})&&(i[r].namespaces[o].workloads[t].selected=a)});const e=i[r].namespaces[o].workloads.filter(e=>!D(e.kind)).every(e=>e.selected);i[r].namespaces[o].selected=e}else{if(!Ne(i[r].namespaces[o],l,s||{showOnlySelected:!1}))return;i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&D(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})}else i[r].namespaces[o].selected=a,n.forEach((e,t)=>{a&&D(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})})}),i})},[D]);return e(we.Provider,{value:{snapshots:h,setSnapshots:f,isFetching:u,setIsFetching:p,formData:v,handleSourceChange:E,handleSelectAll:k,formDiff:y,isFormDirty:S},children:r})},Pe=()=>r(we);export{W as A,X as D,Ce as E,ie as R,de as S,ne as a,ye as b,ke as c,Re as d,Y as e,re as f,le as g,Se as h,Fe as i,Pe as j,Ae as k,Ne as l,Ie as m,J as u};
|