@odigos/ui-kit 0.0.251 → 0.0.253
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 +19 -0
- package/docs/api-context.md +44 -38
- package/lib/chunks/connections-scope-h3bbPbRd.js +1 -0
- package/lib/chunks/{flow-CQi_KYfs.js → flow-BnkrFBJL.js} +1 -1
- package/lib/chunks/{helpers-K1tnyqhm.js → helpers-BEkhis3j.js} +1 -1
- package/lib/chunks/{index-Dv0RvKAp.js → index-DIVbcB6F.js} +8 -8
- package/lib/chunks/source-instrument-form-context-6ViZM1Z_.js +1 -0
- package/lib/chunks/{ui-components-BKrLf2tx.js → ui-components-TeG65JGy.js} +36 -35
- package/lib/chunks/use-odigos-api-li2VrVHH.js +5 -0
- package/lib/components/_v2/drawer/index.d.ts +1 -0
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants.js +1 -1
- package/lib/containers/v2.js +138 -138
- package/lib/containers.js +7 -7
- package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +16 -8
- package/lib/contexts/odigos-api/hooks/use-collectors-api.d.ts +12 -1
- package/lib/contexts/odigos-api/hooks/use-config-api.d.ts +10 -1
- package/lib/contexts/odigos-api/hooks/use-data-streams-api.d.ts +19 -13
- package/lib/contexts/odigos-api/hooks/use-destinations-api.d.ts +30 -21
- package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +16 -8
- package/lib/contexts/odigos-api/hooks/use-metrics-api.d.ts +9 -3
- package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +14 -4
- package/lib/contexts/odigos-api/hooks/use-profiling-api.d.ts +5 -0
- package/lib/contexts/odigos-api/hooks/use-sampling-api.d.ts +18 -1
- package/lib/contexts/odigos-api/hooks/use-service-map-api.d.ts +8 -1
- package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +24 -0
- package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +24 -6
- package/lib/contexts/odigos-api/hooks/use-tokens-api.d.ts +11 -4
- package/lib/contexts/odigos-api/index.d.ts +3 -3
- package/lib/contexts/odigos-api/types.d.ts +26 -27
- package/lib/contexts/odigos-api/use-odigos-api.d.ts +21 -36
- package/lib/contexts/odigos-api.js +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/snippets/v2.js +1 -1
- package/lib/snippets.js +1 -1
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/connections-scope-CneIqjeg.js +0 -1
- package/lib/chunks/source-instrument-form-context-C79I_5cH.js +0 -1
- package/lib/chunks/use-odigos-api-CDHW7ekQ.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.253](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.252...ui-kit-v0.0.253) (2026-06-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **api:** streamline operation execution by introducing custom executor support and removing legacy types ([#1006](https://github.com/odigos-io/ui-kit/issues/1006)) ([c425b82](https://github.com/odigos-io/ui-kit/commit/c425b82568dfa61bf96b4fefc068085c1548d79b))
|
|
9
|
+
|
|
10
|
+
## [0.0.252](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.251...ui-kit-v0.0.252) (2026-06-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **drawer:** add minWidth prop to Drawer component, and apply minWidth in EditSourceDrawer ([#1001](https://github.com/odigos-io/ui-kit/issues/1001)) ([15642f6](https://github.com/odigos-io/ui-kit/commit/15642f6083ee2bc12f20c8bf1377f9a34c7efa03))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **api:** add missing toasts ([#1005](https://github.com/odigos-io/ui-kit/issues/1005)) ([ffb2954](https://github.com/odigos-io/ui-kit/commit/ffb29545bc20982b2bc0d501d23ec6e2d7aea61c))
|
|
21
|
+
|
|
3
22
|
## [0.0.251](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.250...ui-kit-v0.0.251) (2026-06-16)
|
|
4
23
|
|
|
5
24
|
|
package/docs/api-context.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- **Containers fetch their own data.** Every `_v2` container that previously took a forest of API-function props now consumes `useOdigosApi()` / `useApiQuery(key)` from the kit's API context. Pages collapse to one-liners.
|
|
10
10
|
- **Hosts ship a thin adapter** (~250 lines) mapping GraphQL documents to typed `Operation` slots. No more 16 CRUD hooks per host (`useSourceCRUD`, `useDestinationCRUD`, …).
|
|
11
11
|
- **Apollo cache is the entity store.** The kit's `useEntityStore` Zustand store is gone — sources/destinations/actions/rules/namespaces all flow through Apollo's normalized cache via `useApiQuery('GET_X', …, { fetchPolicy: 'cache-first' })`. Mutations call `runMutation` then `await fetchAll()`; cache writes broadcast to every active subscriber.
|
|
12
|
-
- **Uniform API surface.** `useOdigosApi()` returns `{ sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi, …, capabilities, resetCache }` — every
|
|
12
|
+
- **Uniform API surface.** `useOdigosApi()` returns `{ sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi, …, capabilities, resetCache }` — every namespace exposes its reactive reads as `use…()` sub-hooks (`sourcesApi.useSources()` → `{ items, loading, refetch }`) plus imperative methods (`fetchAll`, `create`, …) as top-level keys. No aliasing on destructure, no stuttery `sourcesApi.sources`.
|
|
13
13
|
- **Strict types end-to-end.** ~80 named `OdigosApiOperations` slots, each typed as `Operation<TData, TVars>`. Zero `any`, zero envelope/bare unions, zero `unknown` data fields at the public hook surface.
|
|
14
14
|
- **Storybook is production-unaware.** The kit's runtime has no mock context, no interceptor hooks. The Storybook mock provider uses a custom Apollo `ApolloLink` that intercepts stub queries with predefined data.
|
|
15
15
|
- **Mock data lives in `.storybook/`.** `src/mock-data/` was relocated; production builds never touch it.
|
|
@@ -89,7 +89,7 @@ graph TB
|
|
|
89
89
|
ADAPTER --> PROVIDER[OdigosApiProvider]
|
|
90
90
|
PROVIDER --> APOLLO["ApolloClient<br/>(normalized cache)"]
|
|
91
91
|
PROVIDER --> CTX[OdigosApiContext]
|
|
92
|
-
CTX --> HOOK1["useOdigosApi()<br/>sourcesApi.
|
|
92
|
+
CTX --> HOOK1["useOdigosApi()<br/>sourcesApi.useSources(), fetchAll, …"]
|
|
93
93
|
CTX --> HOOK2["useApiQuery('GET_X')"]
|
|
94
94
|
CTX --> HOOK3["useApiMutation('CREATE_X')"]
|
|
95
95
|
HOOK1 -.reads / writes.-> APOLLO
|
|
@@ -353,16 +353,17 @@ const [updateToken, { loading: saving }] = useApiMutation('UPDATE_TOKEN', {
|
|
|
353
353
|
|
|
354
354
|
`useApiQuery` consults the operations map, applies `transformVariables` / `transformResult` automatically, and returns `{ data: SlotData<K>, loading, error, refetch, unsupported }`. The `unsupported` flag is `true` when the host adapter omitted the slot — containers either render an "operation not supported" UI or hide the affordance via `capabilities.canX`.
|
|
355
355
|
|
|
356
|
-
### Imperative — `useOdigosApi()` + per-domain APIs
|
|
356
|
+
### Imperative + reactive — `useOdigosApi()` + per-domain APIs
|
|
357
357
|
|
|
358
358
|
For places that need both a cached list and dispatchable methods (event handlers, side-effect chains, drawers):
|
|
359
359
|
|
|
360
360
|
```typescript
|
|
361
|
-
|
|
362
|
-
const { sourcesApi } = useOdigosApi({ subscribe: ['sources'] });
|
|
361
|
+
const { sourcesApi } = useOdigosApi();
|
|
363
362
|
|
|
364
|
-
// Cached list — read
|
|
365
|
-
|
|
363
|
+
// Cached list — read it via the domain's reactive `use…()` sub-hook. The
|
|
364
|
+
// sub-hook owns `useApiQuery('GET_WORKLOADS')`, so calling it IS the
|
|
365
|
+
// subscription. Kept fresh by Apollo's cache + SSE-driven refetch.
|
|
366
|
+
const { items: sources, loading } = sourcesApi.useSources();
|
|
366
367
|
|
|
367
368
|
const onClick = async () => {
|
|
368
369
|
await sourcesApi.update(sourceId, formData);
|
|
@@ -371,50 +372,55 @@ const onClick = async () => {
|
|
|
371
372
|
};
|
|
372
373
|
```
|
|
373
374
|
|
|
374
|
-
Every
|
|
375
|
+
Every domain API splits its surface into two consistent halves:
|
|
375
376
|
|
|
376
|
-
|
|
377
|
+
- **Reactive reads** are exposed as `use…()` sub-hooks (`sourcesApi.useSources()`, `actionsApi.useActions()`, `destinationsApi.useDestinations()`, `collectorsApi.useGatewayInfo()`, `configApi.useEffectiveConfig()`, …). Each owns a `useApiQuery('GET_…')` and returns the reactive `{ items, loading, refetch }` (list hooks) or `{ data, loading, … }` (single/parameterized hooks).
|
|
378
|
+
- **Imperative methods** (`fetchAll`, `create`, `update`, `remove`, `persist`, `testConnection`, …) stay as plain top-level keys.
|
|
377
379
|
|
|
378
|
-
The
|
|
380
|
+
The `*Api` suffix on the top-level keys means destructuring stays rename-free even when the consumer has a local `sources` / `destinations` variable.
|
|
379
381
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
#### Reactive reads via `use…()` sub-hooks
|
|
383
|
+
|
|
384
|
+
Calling a `use…()` sub-hook is the opt-in: the underlying `useApiQuery('GET_…')` only mounts (and the network request only fires) for the queries a container actually reads. `useOdigosApi()` itself fires nothing — calling it from a page that only needs `configApi` (e.g. `/settings`) does NOT trigger any list query. Because the sub-hooks are React hooks, call them unconditionally at the top level of a container, exactly like any other hook:
|
|
383
385
|
|
|
386
|
+
```typescript
|
|
384
387
|
export const Columns: FC = () => {
|
|
385
|
-
const { sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi } = useOdigosApi(
|
|
386
|
-
|
|
387
|
-
});
|
|
388
|
-
const { items:
|
|
388
|
+
const { sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi } = useOdigosApi();
|
|
389
|
+
const { items: sources, loading: sourcesLoading } = sourcesApi.useSources();
|
|
390
|
+
const { items: destinations } = destinationsApi.useDestinations();
|
|
391
|
+
const { items: actions } = actionsApi.useActions();
|
|
392
|
+
const { items: rules } = instrumentationRulesApi.useRules();
|
|
389
393
|
// …
|
|
390
394
|
};
|
|
391
395
|
```
|
|
392
396
|
|
|
393
|
-
Symptoms of forgetting the
|
|
394
|
-
|
|
395
|
-
| Container |
|
|
396
|
-
| --------------------------------------- |
|
|
397
|
-
| `_v2/overview/columns` | `
|
|
398
|
-
| `_v2/overview/drawers` | `
|
|
399
|
-
| `_v2/overview/filters` | `
|
|
400
|
-
| `_v2/overview/search` | `
|
|
401
|
-
| `_v2/overview/data-stream-select` | `
|
|
402
|
-
| `_v2/sampling-rules` | `
|
|
403
|
-
| `service-map` | `
|
|
404
|
-
| `_v2/_drawers/edit-source-drawer/peers` | `
|
|
405
|
-
| `_v2/_drawers/system-drawer/diagnose` | `
|
|
406
|
-
| `
|
|
397
|
+
Symptoms of forgetting to call the sub-hook: empty lists in the UI, `loading` permanently `false`, no auto-refresh on SSE. The fix is always to call the missing `use…()` sub-hook. Containers that only call imperative methods (create / update / delete / fetchAll) never call the sub-hook — the domain still exposes those methods, just without any auto-fetch.
|
|
398
|
+
|
|
399
|
+
| Container | Reactive sub-hooks called |
|
|
400
|
+
| --------------------------------------- | ------------------------------------------------------------------------------- |
|
|
401
|
+
| `_v2/overview/columns` | `useSources()`, `useDestinations()`, `useActions()`, `useRules()` |
|
|
402
|
+
| `_v2/overview/drawers` | `useSources()` |
|
|
403
|
+
| `_v2/overview/filters` | `useSources()`, `useNamespaces()` |
|
|
404
|
+
| `_v2/overview/search` | `useSources()`, `useDestinations()`, `useActions()`, `useRules()` |
|
|
405
|
+
| `_v2/overview/data-stream-select` | `useDataStreams()` |
|
|
406
|
+
| `_v2/sampling-rules` | `useSources()`, `useSamplingRules()` |
|
|
407
|
+
| `service-map` | `useSources()` |
|
|
408
|
+
| `_v2/_drawers/edit-source-drawer/peers` | `useSources()` |
|
|
409
|
+
| `_v2/_drawers/system-drawer/diagnose` | `useNamespaces()` |
|
|
410
|
+
| `_v2/_drawers/add-source-drawer` | `useSnapshots()`, `useNamespaces()` |
|
|
411
|
+
| `_v2/_drawers/add-destination-drawer` | `useDestinations()`, `useDestinationCategories()`, `usePotentialDestinations()` |
|
|
412
|
+
| `contexts/destination-form-context` | `useDestinations()` |
|
|
407
413
|
|
|
408
414
|
The full surface returned by `useOdigosApi()`:
|
|
409
415
|
|
|
410
416
|
```typescript
|
|
411
417
|
const {
|
|
412
|
-
sourcesApi, // {
|
|
413
|
-
destinationsApi, // {
|
|
414
|
-
actionsApi, // {
|
|
415
|
-
instrumentationRulesApi, // {
|
|
416
|
-
namespacesApi, // {
|
|
417
|
-
dataStreamsApi, // {
|
|
418
|
+
sourcesApi, // { useSources, fetchAll, fetchByTargets, fetchById, persist, update, usePeerSources, … }
|
|
419
|
+
destinationsApi, // { useDestinations, useDestinationCategories, usePotentialDestinations, fetchAll, create, update, remove, testConnection }
|
|
420
|
+
actionsApi, // { useActions, fetchAll, create, update, remove }
|
|
421
|
+
instrumentationRulesApi, // { useRules, fetchAll, create, update, remove }
|
|
422
|
+
namespacesApi, // { useNamespaces, fetchAll, persist }
|
|
423
|
+
dataStreamsApi, // { useDataStreams, fetchAll, create, update, remove }
|
|
418
424
|
k8sManifestApi,
|
|
419
425
|
configApi,
|
|
420
426
|
describeApi,
|
|
@@ -463,7 +469,7 @@ graph LR
|
|
|
463
469
|
|
|
464
470
|
**Reads.** Every consumer of `useOdigosApi().sourcesApi` registers an Apollo observer of `GET_WORKLOADS` via `useApiQuery`. The first observer fetches over the network, every subsequent one hits the shared cache (`fetchPolicy: 'cache-first'`). Cache writes broadcast — when _any_ refetch lands, every observer re-renders with the new list.
|
|
465
471
|
|
|
466
|
-
**Writes.** Mutations call `runMutation` and `await fetchAll()` immediately after success. The runner's `client.query({ fetchPolicy: 'network-only' })` writes the response into the cache, which broadcasts. Every container that reads `sourcesApi.items` updates within one render — no Zustand selector hop, no manual `setEntities`. Apollo's request dedup keeps the cost of "fan-out from one mutation" at a single network round-trip.
|
|
472
|
+
**Writes.** Mutations call `runMutation` and `await fetchAll()` immediately after success. The runner's `client.query({ fetchPolicy: 'network-only' })` writes the response into the cache, which broadcasts. Every container that reads `sourcesApi.useSources().items` updates within one render — no Zustand selector hop, no manual `setEntities`. Apollo's request dedup keeps the cost of "fan-out from one mutation" at a single network round-trip.
|
|
467
473
|
|
|
468
474
|
**SSE.** Both host SSE handlers (`useSSE.ts`) drop their old `useEntityStore` imports and refresh through the same `sourcesApi.fetchAll()` / `destinationsApi.fetchAll()` entry points. The deleted-target eviction primitive is gone — for an envelope-aware kit (central-ui's `REMOTE_FETCH` makes generic `cache.modify` impractical), refetching the canonical list is simpler and the result is identical.
|
|
469
475
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{useMemo as n}from"react";import{b as t,_ as r}from"./use-odigos-api-li2VrVHH.js";const e=({connectionIds:e,children:i})=>{const s=t(),a=n(()=>({operations:s.operations,context:{...s.context,connectionIds:e},apolloConfig:s.apolloConfig}),[s.operations,s.context,s.apolloConfig,e.join(",")]);return o(r.Provider,{value:a,children:i})};export{e as O};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{memo as i,useRef as r,useEffect as n}from"react";import"@xyflow/react/dist/style.css";import d,{useTheme as s}from"styled-components";import{N as a,F as l,I as c,T as p,S as h,g as m,u,a as g,b}from"./ui-components-
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{memo as i,useRef as r,useEffect as n}from"react";import"@xyflow/react/dist/style.css";import d,{useTheme as s}from"styled-components";import{N as a,F as l,I as c,T as p,S as h,g as m,u,a as g,b}from"./ui-components-TeG65JGy.js";import{Handle as x,Position as f,ReactFlowProvider as y,ReactFlow as w,Controls as v,ControlButton as N,useReactFlow as k}from"@xyflow/react";import{RefreshIcon as $}from"../icons.js";const C=d(l)`
|
|
2
2
|
max-width: 300px;
|
|
3
3
|
padding: 12px;
|
|
4
4
|
border-radius: 12px;
|
|
@@ -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,c as u,P as l,d as c,e as p,f as d,h 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,c as u,P as l,d as c,e as p,f as d,h as f}from"./ui-components-TeG65JGy.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(){return{sources:[],namespaces:[],languages:[]}}function k(e){return!e||!e.sources?.length&&!e.namespaces?.length&&!e.languages?.length}function S(e){return e?{sources:e.sources?[...e.sources]:[],namespaces:e.namespaces?[...e.namespaces]:[],languages:e.languages?[...e.languages]:[]}:{sources:[],namespaces:[],languages:[]}}function A(e){return null==e||0===e}function T(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 R(e){return k(e.sourceScopes)?null:e.sourceScopes}function P(e){return R(e)}function b(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 M(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function D(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function $(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function C(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),percentageAtMost:b(e),operation:I(e)}}function E(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),error:e.keepErrors,durationAtLeastMs:"Duration"===e.ruleType?M(e):null,percentageAtLeast:b(e),operation:$(e)}}function w(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),percentageAtMost:b(e)??0,operation:$(e)}}function L(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:I(e),percentageAtMost:b(e),notes:e.notes||null}}function O(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),error:"Error"===e.ruleType,durationAtLeastMs:"Duration"===e.ruleType?M(e):null,operation:$(e),percentageAtLeast:b(e),notes:e.notes||null}}function N(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:$(e),percentageAtMost:b(e)??0,notes:e.notes||null}}const H=["5000","1000","500","100","50"],K=["50","25","10","1","0.5","0.1","0"];function j(e){if(null==e)return{percentageMode:"all",percentagePreset:"0",customPercentage:""};const t=K.find(t=>Number(t)===e);return t?{percentageMode:"sample",percentagePreset:t,customPercentage:""}:{percentageMode:"sample",percentagePreset:"custom",customPercentage:String(e)}}function z(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 F(e){const t=T(),r=S(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=A(u=e.rule.percentageAtMost)?{percentageMode:"all",percentagePreset:"0",customPercentage:""}:j(u);break;case"highlyRelevant":o=z(e.rule.operation),a=j(e.rule.percentageAtLeast),s=function(e){if(null==e)return{durationPreset:"500",customDurationMs:""};const t=H.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=z(e.rule.operation),a=j(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 X;!function(e){e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"}(X||(X={}));const J=[X.Action,X.Endpoint,X.Scope,X.Duration],V=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,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aA as e,ag as a,L as t,a9 as l,aa as r,dT as n,a5 as i,aN as s,ar as o,a7 as d,J as c,ab as u,an as p,dU as h,ae as g,af as m,dV as v,dW as f,V as b,Q as y,U as x,R as C,O as S,aw as $,au as k,b4 as T,c as w,n as A,F as P,a4 as M,ah as L,aJ as I,dX as O,dY as D,aU as z,dZ as N,f as X,d_ as R,ad as H,h as E,d$ as B,e0 as V,e1 as q,e2 as j,e3 as G,e4 as J,e5 as U,ak as K,e6 as F,e7 as W,e8 as Y,e9 as Q,ea as Z,bV as _,eb as ee,ec as ae,ed as te,ee as le,ef as re,eg as ne,eh as ie,ei as se,ej as oe,ek as de,el as ce,aK as ue,em as pe,en as he,eo as ge,ep as me,eq as ve,bI as fe,er as be,es as ye,et as xe,eu as Ce,ev as Se,ew as $e,ex as ke,ey as Te,ez as we,a_ as Ae,q as Pe,eA as Me,S as Le,eB as Ie,b5 as Oe,eC as De,eD as ze,eE as Ne,eF as Xe,by as Re,az as He,eG as Ee,eH as Be,eI as Ve,di as qe,eJ as je,eK as Ge,eL as Je,s as Ue,dg as Ke,a6 as Fe,eM as We,bk as Ye,aM as Qe,N as Ze,l as _e,aQ as ea,du as aa,bj as ta,bq as la,bi as ra,bY as na,eN as ia}from"./ui-components-TeG65JGy.js";import{jsx as sa,jsxs as oa,Fragment as da}from"react/jsx-runtime";import{D as ca,C as ua,E as pa,u as ha,F as ga,h as ma,f as va,e as fa,G as ba,H as ya,I as xa,i as Ca,m as Sa}from"./helpers-BEkhis3j.js";import{EditIcon as $a,OdigosLogoTextCentral as ka,OdigosLogoTextEnterprise as Ta,OdigosLogoTextCommunity as wa,OdigosLogoTextColoredCentral as Aa,OdigosLogoTextColoredEnterprise as Pa,OdigosLogoTextColoredCommunity as Ma,ArrowLeftIcon as La,ArrowRightIcon as Ia,VSquareIcon as Oa,VIcon as Da,CopyIcon as za,YamlIcon as Na}from"../icons.js";import Xa,{useMemo as Ra,useCallback as Ha,useState as Ea,useRef as Ba,useEffect as Va,forwardRef as qa,useImperativeHandle as ja}from"react";import Ga,{useTheme as Ja}from"styled-components";const Ua=({isOpen:t,onClose:l,onDeny:r,onApprove:n})=>sa(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:()=>{n?.(),l()}}}),Ka=({isOpen:t,onClose:l,onDeny:r,onApprove:n,action:i="delete",target:s,description:o,overrideApproveButtonLabel:d,overrideDenyButtonLabel:c})=>{const u=i.charAt(0).toUpperCase()+i.substring(1),p=s?.endsWith("s")?"these":"this";return sa(e,{title:`${u}${s?` ${s}`:""}?`,description:o??`Are you sure you want to ${i}${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:()=>{n?.(),l()}}})},Fa=({componentType:e,inputType:a,name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C,setValue:S,errorMessage:$,warnMessage:k,helpMessage:T,dropdownOptions:w,dropdownNoSearch:A,dropdownNoCheckbox:P,timeUnits:M,timeDefaultUnit:L})=>{switch(e){case t.Input:return sa(p,{name:g,type:a,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C??"",onChange:e=>{const t=e.target.value;S(a===h.Number?""===t?null:Number(t):t)},errorMessage:$,warnMessage:k,helpMessage:T},g);case t.MultiInput:return sa(u,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,values:Array.isArray(C)?C:c(C,[]),setValues:e=>S(e),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.KeyValuePair:return sa(d,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,limitFieldsPerRow:2,columns:[{keyName:"key",label:"Key",placeholder:"Key"},{keyName:"value",label:"Value",placeholder:"Value"}],values:Array.isArray(C)?C:c(C,[]),setValues:e=>S(e),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.TextArea:return sa(o,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,placeholder:b,value:C??"",onChange:e=>S(e.target.value),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Dropdown:return sa(s,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,withSearch:!A,options:w?.map(e=>({id:e.id||"",label:e.label||"",withCheckbox:!P}))||[],values:C?[String(C)]:[],setValues:e=>S(e[0]),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Checkbox:return sa(i,{name:g,label:m,tooltip:v,badge:f,value:!0===C||"true"===C,onChange:e=>S(e),disabled:x,errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Time:return sa(n,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C??"",setValue:e=>S(e),units:M,defaultUnit:L,errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Toggle:return sa(l,{name:g,labelAlign:r.Right,label:m,tooltip:v,badge:f,value:!0===C||"true"===C,onChange:e=>S(e),disabled:x,errorMessage:$,warnMessage:k,helpMessage:T},g);default:return null}},Wa=Ga.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 24px;
|
|
@@ -10,7 +10,7 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
10
10
|
min-width: 0;
|
|
11
11
|
white-space: pre;
|
|
12
12
|
overflow-x: auto;
|
|
13
|
-
`,
|
|
13
|
+
`,Qa=({title:e,summary:t,onEdit:l,renderAction:r})=>{const n=Ra(()=>{const a=[];return e&&(a.push({text:e,variant:ca.Default}),a.push({text:" - ",variant:ca.Default})),a.push(...t),a},[e,t]);return oa(Wa,{children:[sa(Ya,{children:sa(ua,{parts:n})}),r&&r(),l&&sa(g,{"data-id":"sampling-btn-edit-auto-rule",label:v,rightIcon:$a,variant:a.Text,size:m.S,onClick:l})]})},Za={[$.HttpRequest]:"HTTP request",[$.HttpResponse]:"HTTP response",[$.DbQuery]:"DB query",[$.Messaging]:"messaging"};function _a(e,a,t){return 1===e?a:t??`${a}s`}function et(e,a){const t=[],l=e.slice(0,3),r=e.slice(3);return l.forEach((e,l)=>{l>0&&t.push({text:", ",variant:ca.Default}),t.push({text:e,variant:a})}),r.length>0&&t.push({text:` + ${r.length} more`,variant:ca.Default,tooltipItems:r}),t}function at(e,a){switch(e){case b.CodeAttributes:return function(e){const a=Object.values(k).filter(a=>!!e.codeAttributes?.[a]).map(e=>T(e).toLowerCase());return a.length?[{text:"Collect",variant:ca.Action},{text:" ",variant:ca.Default},...et(a,ca.Endpoint)]:null}(a);case b.PayloadCollection:return function(e){const a=Object.values($).filter(a=>null!=e.payloadCollection?.[a]).map(e=>Za[e]);return a.length?[{text:"Collect",variant:ca.Action},{text:" ",variant:ca.Default},...et(a,ca.Endpoint)]:null}(a);case b.HeadersCollection:return function(e){const a=(e.headersCollection?.[S.HeaderKeys]??[]).map(e=>e.trim()).filter(e=>e.length>0);if(!a.length)return null;const t=_a(a.length,"HTTP header");return[{text:`Collect ${a.length} ${t}`,variant:ca.Action},{text:"",variant:ca.Default,tooltipItems:a}]}(a);case b.CustomInstrumentation:return function(e){const a=(e.customInstrumentations?.[y.Java]??[]).map(e=>new x(e.className,e.methodName)).filter(e=>e.Verify()),t=(e.customInstrumentations?.[y.Golang]??[]).map(e=>new C(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>e.Verify());if(!(a.length+t.length))return null;const l=[];a.length&&l.push(`${a.length} Java ${_a(a.length,"probe")}`),t.length&&l.push(`${t.length} Go ${_a(t.length,"probe")}`);const r=[...a.map(e=>`Java: ${e.toString()}`),...t.map(e=>`Go: ${e.toString()}`)];return[{text:`Apply ${l.join(" + ")}`,variant:ca.Action},{text:"",variant:ca.Default,tooltipItems:r}]}(a);default:return null}}const tt=({option:e,formState:a,renderAction:t})=>{const l=Ra(()=>{const t=at(e?.type,a);return t?[...t,...pa(a.sourceScopes)]:[]},[e?.type,a]),r=0===l.length;return sa(Qa,{title:r?f:"Instrumentation Rule Preview",summary:l,renderAction:t})},lt=({size:e=200,central:a=!1,useInline:t=!1})=>{const{tier:l}=ha();if(t){if(a)return sa(ka,{size:e});switch(l){case w.Community:return sa(wa,{size:e});case w.Onprem:return sa(Ta,{size:e});default:return null}}if(a)return sa(Aa,{size:e});switch(l){case w.Community:return sa(Ma,{size:e});case w.Onprem:return sa(Pa,{size:e});default:return null}},rt=[{value:"50",label:"50%"},{value:"25",label:"25%"},{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"custom",label:"Custom"}],nt=[{value:"10",label:"10%"},{value:"1",label:"1%"},{value:"0.5",label:"0.5%"},{value:"0.1",label:"0.1%"},{value:"custom",label:"Custom"}],it=[{value:"5000",label:"5s"},{value:"1000",label:"1s"},{value:"500",label:"500ms"},{value:"100",label:"100ms"},{value:"50",label:"50ms"},{value:"custom",label:"Custom"}],st=({description:e,options:a,selected:t,onSelect:l,customName:r,customLabel:n,customPlaceholder:i,customValue:s,onCustomChange:o,customInputType:d=h.Number,customMin:c,customMax:u})=>oa(A,{$gap:16,$alignItems:"flex-end",children:[oa(P,{$gap:6,children:[sa(M,{label:e}),sa(L,{options:a,selected:t,setSelected:l})]}),"custom"===t&&sa(p,{name:r,label:n,placeholder:i,type:d,value:s,onChange:o,width:160,min:c,max:u})]}),ot=()=>{},dt=e=>e.readOnly?sa(ct,{rule:e.rule}):sa(ut,{ruleType:e.ruleType,formState:e.formState,onChange:e.onChange}),ct=({rule:e})=>{const a=null!=e.durationAtLeastMs;return e.error?sa(I,{richTitle:{title:O},children:sa(l,{name:"sampling-view-toggle-keep-errors",onChange:ot,value:!0,size:z.S,label:D,labelAlign:r.Right})}):a?sa(I,{richTitle:{title:N},children:oa("div",{children:[sa(X,{size:E.XXXS,color:H.Secondary,children:R}),sa(X,{size:E.XS,children:`${e.durationAtLeastMs}ms`})]})}):null},ut=({ruleType:e,formState:a,onChange:t})=>{const n=Ha(e=>t({durationPreset:e}),[t]),i=Ha(e=>t({customDurationMs:e.target.value}),[t]);return"Error"===e?sa(I,{richTitle:{title:O,subTitle:B},children:sa(l,{name:"sampling-toggle-keep-errors",value:!0,onChange:ot,size:z.S,label:D,labelAlign:r.Right})}):"Duration"===e?sa(I,{richTitle:{title:N,subTitle:V},children:sa(st,{description:R,options:it,selected:a.durationPreset,onSelect:n,customName:"sampling-input-custom-duration",customLabel:q,customPlaceholder:"200ms",customValue:a.customDurationMs,onCustomChange:i})}):null},pt=Ga.div`
|
|
14
14
|
display: flex;
|
|
15
15
|
gap: 32px;
|
|
16
16
|
`,ht=Ga.div`
|
|
@@ -43,7 +43,7 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
43
43
|
align-items: flex-end;
|
|
44
44
|
gap: 16px;
|
|
45
45
|
margin-bottom: 12px;
|
|
46
|
-
`,yt="Any",xt="Kafka topic",Ct=()=>sa("div",{style:{marginBottom:"8px"},children:sa(X,{size:E.XS,weight:500,children:"And"})}),St=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"httpClient",label:"HTTP Client"}],$t=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"kafkaConsumer",label:"Kafka Consumer"},{value:"kafkaProducer",label:"Kafka Producer"}],kt=[{id:"",label:yt},{id:"GET",label:"GET"},{id:"POST",label:"POST"},{id:"PUT",label:"PUT"},{id:"DELETE",label:"DELETE"},{id:"PATCH",label:"PATCH"}];const Tt=e=>e.readOnly?sa(wt,{data:e.data}):sa(At,{category:e.category,formState:e.formState,onChange:e.onChange}),wt=({data:e})=>{const a=Ra(()=>function(e){if("noisy"===e.category){const a=e.rule.operation;if(a?.httpServer)return[{id:"type",title:le,value:te},{id:"route",title:Y,value:a.httpServer.route||a.httpServer.routePrefix||re},{id:"method",title:ee,value:a.httpServer.method||yt}];if(a?.httpClient){const e=[{id:"type",title:le,value:ne}];return a.httpClient.serverAddress&&e.push({id:"serverAddress",title:"Server address",value:a.httpClient.serverAddress}),e.push({id:"route",title:Y,value:a.httpClient.templatedPath||a.httpClient.templatedPathPrefix||re}),e.push({id:"method",title:ee,value:a.httpClient.method||yt}),e}return[{id:"type",title:le,value:ie}]}const a=e.rule.operation;return a?.httpServer?[{id:"type",title:le,value:te},{id:"route",title:Y,value:a.httpServer.route||a.httpServer.routePrefix||re},{id:"method",title:ee,value:a.httpServer.method||yt}]:a?.kafkaConsumer?[{id:"type",title:le,value:se},{id:"topic",title:xt,value:a.kafkaConsumer.kafkaTopic||re}]:a?.kafkaProducer?[{id:"type",title:le,value:oe},{id:"topic",title:xt,value:a.kafkaProducer.kafkaTopic||re}]:[{id:"type",title:le,value:ie}]}(e),[e]);return sa(I,{richTitle:{title:j},children:sa(pt,{children:a.map(({id:e,title:a,value:t})=>oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,nowrap:!0,children:a}),sa(X,{size:E.XS,nowrap:!0,children:t})]},e))})})},At=({category:e,formState:t,onChange:l})=>{const r=Ra(()=>"noisy"===e?St:$t,[e]),n=Ha(e=>l({operationType:e,route:"",serverAddress:"",method:"",kafkaTopic:""}),[l]),i=Ha(e=>a=>{a&&l({routeType:e,route:""})},[l]),s=Ha(e=>l({route:e.target.value}),[l]),o=Ha(e=>l({serverAddress:e.target.value}),[l]),d=Ha(e=>l({method:e[0]||""}),[l]),c=Ha(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?W:Y,v="httpClient"===t.operationType?Z
|
|
46
|
+
`,yt="Any",xt="Kafka topic",Ct=()=>sa("div",{style:{marginBottom:"8px"},children:sa(X,{size:E.XS,weight:500,children:"And"})}),St=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"httpClient",label:"HTTP Client"}],$t=[{value:"all",label:"All Operations"},{value:"httpServer",label:"HTTP Server"},{value:"kafkaConsumer",label:"Kafka Consumer"},{value:"kafkaProducer",label:"Kafka Producer"}],kt=[{id:"",label:yt},{id:"GET",label:"GET"},{id:"POST",label:"POST"},{id:"PUT",label:"PUT"},{id:"DELETE",label:"DELETE"},{id:"PATCH",label:"PATCH"}];const Tt=e=>e.readOnly?sa(wt,{data:e.data}):sa(At,{category:e.category,formState:e.formState,onChange:e.onChange}),wt=({data:e})=>{const a=Ra(()=>function(e){if("noisy"===e.category){const a=e.rule.operation;if(a?.httpServer)return[{id:"type",title:le,value:te},{id:"route",title:Y,value:a.httpServer.route||a.httpServer.routePrefix||re},{id:"method",title:ee,value:a.httpServer.method||yt}];if(a?.httpClient){const e=[{id:"type",title:le,value:ne}];return a.httpClient.serverAddress&&e.push({id:"serverAddress",title:"Server address",value:a.httpClient.serverAddress}),e.push({id:"route",title:Y,value:a.httpClient.templatedPath||a.httpClient.templatedPathPrefix||re}),e.push({id:"method",title:ee,value:a.httpClient.method||yt}),e}return[{id:"type",title:le,value:ie}]}const a=e.rule.operation;return a?.httpServer?[{id:"type",title:le,value:te},{id:"route",title:Y,value:a.httpServer.route||a.httpServer.routePrefix||re},{id:"method",title:ee,value:a.httpServer.method||yt}]:a?.kafkaConsumer?[{id:"type",title:le,value:se},{id:"topic",title:xt,value:a.kafkaConsumer.kafkaTopic||re}]:a?.kafkaProducer?[{id:"type",title:le,value:oe},{id:"topic",title:xt,value:a.kafkaProducer.kafkaTopic||re}]:[{id:"type",title:le,value:ie}]}(e),[e]);return sa(I,{richTitle:{title:j},children:sa(pt,{children:a.map(({id:e,title:a,value:t})=>oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,nowrap:!0,children:a}),sa(X,{size:E.XS,nowrap:!0,children:t})]},e))})})},At=({category:e,formState:t,onChange:l})=>{const r=Ra(()=>"noisy"===e?St:$t,[e]),n=Ha(e=>l({operationType:e,route:"",serverAddress:"",method:"",kafkaTopic:""}),[l]),i=Ha(e=>a=>{a&&l({routeType:e,route:""})},[l]),s=Ha(e=>l({route:e.target.value}),[l]),o=Ha(e=>l({serverAddress:e.target.value}),[l]),d=Ha(e=>l({method:e[0]||""}),[l]),c=Ha(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?W:Y,v="httpClient"===t.operationType?Q:Z;return oa(I,{richTitle:{title:`2. ${j}`,subTitle:G},children:[sa(P,{$alignItems:"flex-start",children:sa(L,{options:r,selected:t.operationType,setSelected:n})}),u&&oa(gt,{children:["httpClient"===t.operationType&&oa(bt,{children:[sa(p,{name:"sampling-input-server-address",label:U,placeholder:J,value:t.serverAddress,onChange:o}),sa(Ct,{})]}),oa(mt,{children:[oa(vt,{children:[sa(ft,{children:sa(K,{"data-id":"sampling-radio-route",value:"route"===t.routeType,onChange:i("route")})}),sa(p,{name:"sampling-input-route",label:g,placeholder:F,value:"route"===t.routeType?t.route:"",onChange:s,disabled:"route"!==t.routeType})]}),oa(vt,{children:[sa(ft,{children:sa(K,{"data-id":"sampling-radio-route-prefix",value:"routePrefix"===t.routeType,onChange:i("routePrefix")})}),sa(p,{name:"sampling-input-route-prefix",label:v,placeholder:F,value:"routePrefix"===t.routeType?t.route:"",onChange:s,disabled:"routePrefix"!==t.routeType})]})]}),oa(bt,{children:[sa(Ct,{}),sa(_,{label:ee,items:kt,selectedIds:[t.method||""],setSelectedIds:e=>d(e),buttonProps:{"data-id":"sampling-btn-method",label:kt.find(e=>e.id===t.method)?.label||yt,size:m.S,variant:a.Secondary}})]})]}),h&&sa(p,{name:"sampling-input-kafka-topic",label:ae,placeholder:"Type kafka topic",value:t.kafkaTopic,onChange:c,width:"320px"})]})},Pt=[{value:"all",label:"Drop All"},{value:"sample",label:"Sample"}],Mt=[{value:"all",label:"Keep All"},{value:"sample",label:"Sample"}];const Lt=e=>e.readOnly?sa(It,{data:e.data}):sa(Ot,{category:e.category,formState:e.formState,onChange:e.onChange}),It=({data:e})=>{const a=Ra(()=>function(e){switch(e.category){case"highlyRelevant":return null!=e.rule.percentageAtLeast?{title:ce,method:ge,description:pe,value:`${e.rule.percentageAtLeast}%`}:{title:ce,method:ve,description:null,value:null};case"noisy":return ga(e.rule.percentageAtMost)?{title:ce,method:me,description:null,value:null}:{title:ce,method:ge,description:he,value:`${e.rule.percentageAtMost}%`};case"costReduction":return{title:ce,method:ge,description:he,value:`${e.rule.percentageAtMost}%`}}}(e),[e]),t=[{id:"method",title:ee,value:a.method},...null!=a.description?[{id:"value",title:a.description,value:a.value}]:[]];return sa(I,{richTitle:{title:a.title},children:sa(pt,{children:t.map(({id:e,title:a,value:t})=>oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,nowrap:!0,children:a}),sa(X,{size:E.XS,nowrap:!0,children:t})]},e))})})},Ot=({category:e,formState:a,onChange:t})=>{const l="highlyRelevant"===e,r=l?Mt:Pt,n=`${l?4:3}. ${ce}`,i=de[e],s=l?pe:he,o="noisy"===e?nt:rt,d=Ha(e=>t({percentageMode:e}),[t]),c=Ha(e=>t({percentagePreset:e}),[t]),u=Ha(e=>t({customPercentage:e.target.value}),[t]);return oa(I,{richTitle:{title:n,subTitle:i},children:["costReduction"!==e&&sa(P,{$alignItems:"flex-start",children:sa(L,{options:r,selected:a.percentageMode,setSelected:d})}),("costReduction"===e||"sample"===a.percentageMode)&&sa(st,{description:s,options:o,selected:a.percentagePreset,onSelect:c,customName:"sampling-input-custom-percentage",customLabel:ue,customPlaceholder:"5%",customValue:a.customPercentage,onCustomChange:u,customInputType:h.Decimal,customMin:0,customMax:100})]})},Dt=Ga.div`
|
|
47
47
|
display: flex;
|
|
48
48
|
align-items: flex-end;
|
|
49
49
|
gap: 16px;
|
|
@@ -53,7 +53,7 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
53
53
|
`,Nt=Ga.div`
|
|
54
54
|
flex: 1;
|
|
55
55
|
min-width: 0;
|
|
56
|
-
`;function Xt(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":ke[e.category]}const Rt=e=>e.readOnly?sa(Ht,{data:e.data}):sa(Et,{formState:e.formState,onChange:e.onChange}),Ht=({data:e})=>{const a=Ra(()=>[{id:"name",title:be,value:e.rule.name||fe},{id:"type",title:ye,value:Xt(e)}],[e]),t=e.rule.notes||re;return oa(I,{children:[sa(pt,{children:a.map(({id:e,title:a,value:t})=>oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,nowrap:!0,children:a}),sa(X,{size:E.XS,nowrap:!0,children:t})]},e))}),oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,children:xe}),sa(X,{size:E.XS,children:t})]})]})},Et=({formState:e,onChange:a})=>{const t=Ha(e=>a({name:e.target.value}),[a]),l=Ha(e=>a({notes:e.target.value}),[a]);return sa(I,{children:oa(Dt,{children:[sa(zt,{children:sa(p,{name:"sampling-input-rule-name",label:be,tooltip:"Optional. Give this rule a name for easier identification.",placeholder:Ce,value:e.name,onChange:t})}),sa(Nt,{children:sa(p,{name:"sampling-input-note",label:xe,tooltip:$e,placeholder:Se,value:e.notes,onChange:l})})]})})},Bt=[{value:"Relevance",label:"Relevance"},{value:"Error",label:"Error"},{value:"Duration",label:"Duration"}],Vt=({formState:e,onChange:a})=>{const t=Ha(e=>a({ruleType:e,keepErrors:"Error"===e}),[a]);return sa(I,{richTitle:{title:`3. ${ye}`,subTitle:Te},children:sa(P,{$alignItems:"flex-start",children:sa(L,{options:Bt,selected:e.ruleType,setSelected:t})})})},qt=e=>{const a=Ra(()=>{if(e.readOnly)return e.summary;switch(e.category){case"noisy":return fa(xa(e.formState));case"highlyRelevant":return va(ya(e.formState));case"costReduction":return ma(ba(e.formState))}},[e]);if(e.readOnly)return sa(
|
|
56
|
+
`;function Xt(e){return"highlyRelevant"===e.category?e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance":ke[e.category]}const Rt=e=>e.readOnly?sa(Ht,{data:e.data}):sa(Et,{formState:e.formState,onChange:e.onChange}),Ht=({data:e})=>{const a=Ra(()=>[{id:"name",title:be,value:e.rule.name||fe},{id:"type",title:ye,value:Xt(e)}],[e]),t=e.rule.notes||re;return oa(I,{children:[sa(pt,{children:a.map(({id:e,title:a,value:t})=>oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,nowrap:!0,children:a}),sa(X,{size:E.XS,nowrap:!0,children:t})]},e))}),oa(ht,{children:[sa(X,{size:E.XXXS,color:H.Secondary,children:xe}),sa(X,{size:E.XS,children:t})]})]})},Et=({formState:e,onChange:a})=>{const t=Ha(e=>a({name:e.target.value}),[a]),l=Ha(e=>a({notes:e.target.value}),[a]);return sa(I,{children:oa(Dt,{children:[sa(zt,{children:sa(p,{name:"sampling-input-rule-name",label:be,tooltip:"Optional. Give this rule a name for easier identification.",placeholder:Ce,value:e.name,onChange:t})}),sa(Nt,{children:sa(p,{name:"sampling-input-note",label:xe,tooltip:$e,placeholder:Se,value:e.notes,onChange:l})})]})})},Bt=[{value:"Relevance",label:"Relevance"},{value:"Error",label:"Error"},{value:"Duration",label:"Duration"}],Vt=({formState:e,onChange:a})=>{const t=Ha(e=>a({ruleType:e,keepErrors:"Error"===e}),[a]);return sa(I,{richTitle:{title:`3. ${ye}`,subTitle:Te},children:sa(P,{$alignItems:"flex-start",children:sa(L,{options:Bt,selected:e.ruleType,setSelected:t})})})},qt=e=>{const a=Ra(()=>{if(e.readOnly)return e.summary;switch(e.category){case"noisy":return fa(xa(e.formState));case"highlyRelevant":return va(ya(e.formState));case"costReduction":return ma(ba(e.formState))}},[e]);if(e.readOnly)return sa(Qa,{title:we,summary:a,renderAction:e.renderAction});const t=1===a.length&&"default"===a[0].variant;return sa(Qa,{title:t?f:we,summary:t?[]:a,renderAction:e.renderAction})},jt=Ga.div`
|
|
57
57
|
display: flex;
|
|
58
58
|
flex-wrap: wrap;
|
|
59
59
|
gap: 8px;
|
|
@@ -101,7 +101,7 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
101
101
|
border-radius: 999px;
|
|
102
102
|
background-color: ${({theme:e})=>e.v2.colors.silver[700]};
|
|
103
103
|
border: 1px solid ${({theme:e})=>e.v2.colors.silver[600]};
|
|
104
|
-
`,Yt={[Re.JavaScript]:"Node.js",[Re.DotNet]:".NET",[Re.Php]:"PHP",[Re.Java]:"Java",[Re.Go]:"Go",[Re.Python]:"Python",[Re.Ruby]:"Ruby",[Re.Rust]:"Rust"},
|
|
104
|
+
`,Yt={[Re.JavaScript]:"Node.js",[Re.DotNet]:".NET",[Re.Php]:"PHP",[Re.Java]:"Java",[Re.Go]:"Go",[Re.Python]:"Python",[Re.Ruby]:"Ruby",[Re.Rust]:"Rust"},Qt=[Re.Python,Re.Java,Re.JavaScript,Re.DotNet,Re.Php,Re.Ruby,Re.Go],Zt=[{value:"all",label:"Entire Cluster"},{value:"source",label:"Specific Source"},{value:"namespace",label:"Specific Namespace"},{value:"language",label:"Specific Programming Language"}];function _t(e){const a=Yt[e];return a||e.charAt(0).toUpperCase()+e.slice(1)}function el(e){return null!=e?`${e}. ${Je}`:Je}const al=({readOnly:e,...a})=>sa(e?rl:nl,{...a}),tl=({title:e,count:a,children:t})=>oa(P,{$gap:6,children:[oa(A,{$gap:8,$alignItems:"center",children:[sa(X,{size:E.XS,color:H.Primary,nowrap:!0,children:e}),a>1&&oa(X,{size:E.XXS,color:H.Secondary,nowrap:!0,children:["(",je,")"]})]}),sa(Kt,{children:t})]}),ll=()=>{const e=Ja();return sa(Ft,{children:sa(Wt,{children:sa(X,{size:E.XXS,color:e.v2.colors.white[500],nowrap:!0,children:Ge})})})},rl=({scopes:e,titleNumber:a})=>{const t=el(a);if(Ca(e))return sa(Ae,{bgTint:"900",richTitle:{title:t},withCollapse:!0,collapseIsDefaultOpen:!0,children:sa(Pe,{status:Le.Default,message:Me,fullWidth:!0})});const l=e.sources??[],r=e.namespaces??[],n=e.languages??[],i=[];return l.length&&i.push({kind:"sources",node:sa(tl,{title:Ie,count:l.length,children:l.map((e,a)=>{const t=[e.namespace,e.kind,e.name].filter(Boolean),l=t.length?t.join(" / "):De;return sa(Oe,{label:l},`src-${a}-${l}`)})})}),r.length&&i.push({kind:"namespaces",node:sa(tl,{title:ze,count:r.length,children:r.map((e,a)=>sa(Oe,{label:e},`ns-${a}-${e}`))})}),n.length&&i.push({kind:"languages",node:sa(tl,{title:Ne,count:n.length,children:n.map((e,a)=>{const t=He(e);return sa(Oe,{label:_t(e),leftIcon:t},`lang-${a}-${e}`)})})}),sa(Ae,{bgTint:"900",richTitle:{title:t,subTitle:i.length>1?Xe:void 0},withCollapse:!0,collapseIsDefaultOpen:!0,children:sa(Ae,{bgTint:"800",children:sa(Ut,{children:i.map((e,a)=>oa(Xa.Fragment,{children:[a>0&&sa(ll,{}),e.node]},e.kind))})})})},nl=({scopes:e,onChange:a,sourceOptions:t=[],namespaceOptions:l=[],supportedLanguages:r,titleNumber:n,dataIdPrefix:s="source-scope",slim:o})=>{const d=e??Sa(),[c,u]=Ea(()=>(e=>e.sources.length>0?"source":e.namespaces.length>0?"namespace":e.languages.length>0?"language":"all")(d)),{sources:p,namespaces:h,languages:g}=d,m=p.length>0||h.length>0||g.length>0,v=Ra(()=>Zt.map(e=>"language"===e.value&&0===r?.length?null:{...e,disabled:"all"===e.value&&m}).filter(Boolean),[m]),f=Ra(()=>p.map(e=>{return a=e.namespace,t=e.kind,l=e.name,`${a}/${t}/${l}`;var a,t,l}),[p]),b=Ra(()=>[...h],[h]),y=Ra(()=>new Set(g),[g]),x=Ha(e=>{u(e)},[]),C=Ha(e=>{const t=e.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({...d,sources:t})},[d,a]),S=Ha(e=>{a({...d,namespaces:e})},[d,a]),$=Ha(e=>{const t=d.languages,l=t.includes(e)?t.filter(a=>a!==e):[...t,e];a({...d,languages:l})},[d,a]),k=!m&&"all"===c,T=(r||Qt).map(e=>({id:e,label:Yt[e]??e.charAt(0).toUpperCase()+e.slice(1),Icon:He(e)}));return oa(I,{richTitle:o?{title:el(n),titleSize:E.XS,titleColor:H.Secondary,tooltip:Ee}:{title:el(n),subTitle:Ee,subTitleWrap:!0},backgroundColor:o?"transparent":void 0,padding:o?0:void 0,children:[sa(Pe,k?{status:Le.Default,message:Me,fullWidth:!0,smallIcon:!0}:{status:Le.Info,message:Xe,fullWidth:!0,smallIcon:!0}),sa(P,{$alignItems:"flex-start",children:sa(L,{options:v,selected:c,setSelected:x})}),"source"===c&&sa(Be,{multiple:!0,"data-id":`${s}-autocomplete-source`,options:t,value:f,onSelect:C,placeholder:Ve}),"namespace"===c&&sa(Be,{multiple:!0,"data-id":`${s}-autocomplete-namespace`,options:l,value:b,onSelect:S,placeholder:"Search namespace"}),"language"===c&&T.length>0&&sa(jt,{children:T.map(({id:e,label:a,Icon:t})=>{const l=y.has(e);return oa(Gt,{$selected:l,onClick:()=>$(e),children:[sa(i,{name:`${s}-lang-${e}`,size:qe.S,value:l,onChange:()=>$(e)}),sa(Jt,{children:sa(t,{size:20})}),sa(X,{size:E.XS,nowrap:!0,children:a})]},e)})})]})},il=(e,a)=>!a?.length||!!a?.find(a=>a===e),sl=({title:e="Signals",required:a,errorMessage:t,allowedSignals:l,selectedSignals:r,setSelectedSignals:n,disabled:s})=>{const[o,d]=Ea(1===r.length),c=Ba(JSON.stringify(r));Va(()=>{let e=Ue(r).filter(e=>il(e,l));e.length||(e=Ke.filter(({id:e})=>il(e,l)).map(({id:e})=>e));const a=JSON.stringify(e);c.current!==a&&(c.current=a,n(e),d(1===e.length))},[l,r]);return oa(P,{$gap:12,children:[sa(M,{label:e,required:a}),sa(A,{$gap:12,children:Ke.map(e=>{const a=il(e.id,l),t=((e,a)=>!!a?.find(a=>a===e))(e.id,r);return a?sa(i,{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);n(l),d(1===l.length)})(e.id,a)},e.id):null})}),sa(Fe,{errorMessage:t})]})},ol=({minSupportedVersion:a,currentVersion:t})=>sa(e,{isOpen:!0,onClose:()=>{},relativeToParent:!0,visual:()=>sa(We,{scale:2.4,icon:()=>sa("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"21",viewBox:"0 0 22 21",fill:"none",children:sa("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}.`}),dl=Ga.div`
|
|
105
105
|
display: flex;
|
|
106
106
|
flex-direction: column;
|
|
107
107
|
justify-content: flex-end;
|
|
@@ -125,7 +125,7 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
125
125
|
background-color: ${({theme:e})=>e.v2.colors.silver[900]};
|
|
126
126
|
overflow-y: auto;
|
|
127
127
|
overflow-x: hidden;
|
|
128
|
-
`,pl=({isLeft:e,isRight:a,heightOffset:t=0,width:l,header:r,list:n})=>oa(dl,{$width:l,$columnHasHeader:!!r,children:[r&&sa(cl,{children:r}),sa(ul,{$gap:8,$isLeft:e,$isRight:a,$heightOffset:t,$columnHasHeader:!!r,children:n.length?n.length>1?sa(Ye,{gap:8,elements:n}):sa(da,{children:n[0]}):sa(
|
|
128
|
+
`,pl=({isLeft:e,isRight:a,heightOffset:t=0,width:l,header:r,list:n})=>oa(dl,{$width:l,$columnHasHeader:!!r,children:[r&&sa(cl,{children:r}),sa(ul,{$gap:8,$isLeft:e,$isRight:a,$heightOffset:t,$columnHasHeader:!!r,children:n.length?n.length>1?sa(Ye,{gap:8,elements:n}):sa(da,{children:n[0]}):sa(Qe,{$height:"100%",children:sa(Ze,{})})})]}),hl="75vw",gl=Ga.div`
|
|
129
129
|
display: flex;
|
|
130
130
|
flex-direction: column;
|
|
131
131
|
border-radius: 16px;
|
|
@@ -148,8 +148,8 @@ import{az as e,af as a,L as t,a8 as l,a9 as r,dT as n,a4 as i,aM as s,aq as o,a6
|
|
|
148
148
|
padding: 5vh 10vw;
|
|
149
149
|
border-radius: 12px;
|
|
150
150
|
background-color: ${({theme:e})=>e.v2.colors.silver[800]};
|
|
151
|
-
`,yl=qa(({isOpen:t,withOverlay:l,disableAnimation:r,onClose:n,onBack:i,onNext:s,nextIsSkip:o,onSave:d,disableSave:c,connectionIds:u,header:p,subHeader:h,leftColumn:g,rightColumn:m,search:v,filters:f,errorMessage:b,isFormDirty:y,hideDirtyNote:x,isFetching:C,progress:S},$)=>{const[k,T]=Ea(!1),[w,A]=Ea(!1),[P,M]=Ea(void 0);ja($,()=>({clearErrors:()=>M(void 0)}));const L=w,I=Ha(()=>{y&&!k?T(!0):(T(!1),n?.())},[y,k,n]),O=c||w||"boolean"==typeof y&&!y,D=Ha(async()=>{A(!0);const e=await d();A(!1),!1!==e&&(e?.error?M(e.error):(u?.setValue([]),n?.()))},[d,u,n]),z=!!v||!!u||!!f,N=!!h,X=(z?48:0)+(N?50:0),R=Ra(()=>C?{status:Le.Info,message:"Fetching Data..."}:w&&!S?{status:Le.Info,message:"Saving Changes..."}:P||b?{status:Le.Error,message:P||b}:"boolean"==typeof y&&y&&!x?{status:Le.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:Le.Success,message:"The values reflect the current configuration of the selected cluster."},[C,w,S,P,b,y,x]),H=Ra(()=>i?{label:"Back",leftIcon:La,variant:a.Secondary,onClick:i}:{label:"Cancel",variant:a.Secondary,onClick:I,disabled:L},[i,I,L]),[B,V]=Ea(!1),q=Ra(()=>s?o?{"data-id":"wide-drawer-skip",label:"Skip",rightIcon:Ia,variant:a.Secondary,onClick:()=>V(!0)}:{"data-id":"wide-drawer-next",label:"Next",rightIcon:Ia,variant:a.Primary,onClick:s}:{"data-id":"wide-drawer-save",label:"Save",variant:a.Primary,onClick:D,disabled:O},[s,o,D,O]);return oa(_e,{width:hl,isOpen:t,disableAnimation:r,hideOverlay:!w&&!l,header:{...p,onClose:n?I:void 0,onCloseDisabled:L},footer:{note:R,actions:[H,q]},children:[w?sa(
|
|
151
|
+
`,yl=qa(({isOpen:t,withOverlay:l,disableAnimation:r,onClose:n,onBack:i,onNext:s,nextIsSkip:o,onSave:d,disableSave:c,connectionIds:u,header:p,subHeader:h,leftColumn:g,rightColumn:m,search:v,filters:f,errorMessage:b,isFormDirty:y,hideDirtyNote:x,isFetching:C,progress:S},$)=>{const[k,T]=Ea(!1),[w,A]=Ea(!1),[P,M]=Ea(void 0);ja($,()=>({clearErrors:()=>M(void 0)}));const L=w,I=Ha(()=>{y&&!k?T(!0):(T(!1),n?.())},[y,k,n]),O=c||w||"boolean"==typeof y&&!y,D=Ha(async()=>{A(!0);const e=await d();A(!1),!1!==e&&(e?.error?M(e.error):(u?.setValue([]),n?.()))},[d,u,n]),z=!!v||!!u||!!f,N=!!h,X=(z?48:0)+(N?50:0),R=Ra(()=>C?{status:Le.Info,message:"Fetching Data..."}:w&&!S?{status:Le.Info,message:"Saving Changes..."}:P||b?{status:Le.Error,message:P||b}:"boolean"==typeof y&&y&&!x?{status:Le.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:Le.Success,message:"The values reflect the current configuration of the selected cluster."},[C,w,S,P,b,y,x]),H=Ra(()=>i?{label:"Back",leftIcon:La,variant:a.Secondary,onClick:i}:{label:"Cancel",variant:a.Secondary,onClick:I,disabled:L},[i,I,L]),[B,V]=Ea(!1),q=Ra(()=>s?o?{"data-id":"wide-drawer-skip",label:"Skip",rightIcon:Ia,variant:a.Secondary,onClick:()=>V(!0)}:{"data-id":"wide-drawer-next",label:"Next",rightIcon:Ia,variant:a.Primary,onClick:s}:{"data-id":"wide-drawer-save",label:"Save",variant:a.Primary,onClick:D,disabled:O},[s,o,D,O]);return oa(_e,{width:hl,isOpen:t,disableAnimation:r,hideOverlay:!w&&!l,header:{...p,onClose:n?I:void 0,onCloseDisabled:L},footer:{note:R,actions:[H,q]},children:[w?sa(Qe,{$height:"calc(100vh - 136px)",children:sa(bl,{children:sa(ea,{titleSize:E.S,subTitleSize:E.XXXS,withGradient:!0,withSpinner:!0,...S})})}):oa(gl,{children:[z&&oa(ml,{children:[u&&sa(aa,{icon:Oa,title:"Selected Clusters",badge:{label:u.value.length}}),v&&sa(ta,{width:"100%",...v}),f]}),N&&sa(vl,{children:sa(aa,{icon:h.icon,title:h.title,subTitle:h.description,badge:h.badge})}),oa(fl,{children:[sa(pl,{isLeft:!0,heightOffset:X,...g}),sa(pl,{isRight:!0,heightOffset:X,...m})]})]}),sa(Ua,{isOpen:k,onClose:()=>T(!1),onApprove:I}),sa(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:B,onClose:()=>V(!1),denyButton:{label:"Go Back",variant:a.Secondary,onClick:()=>V(!1)},approveButton:{label:"Skip",variant:a.Primary,onClick:()=>{s?.(),V(!1)}}})]})});yl.displayName=yl.name;const xl=Ga.div`
|
|
152
152
|
padding: 0 24px;
|
|
153
153
|
border-radius: 12px;
|
|
154
154
|
background-color: ${({$codeBgColor:e})=>e||"transparent"};
|
|
155
|
-
`,Cl=({title:e="YAML",yaml:t,defaultOpen:l,fullHeight:r,bgTint:n="1000",codeBgColor:i})=>{const{clickCopy:s,isCopied:o}=la(),d=Ra(()=>t?[{id:na(),type:ra.Button,buttonProps:{variant:a.Text,size:m.S,leftIcon:o?Da:za,onClick:()=>s(t||""),disabled:o}}]:[],[t,o]);return sa(Ae,{bgTint:n,richTitle:{icon:Na,title:e},actions:d,withCollapse:!0,collapseIsDefaultOpen:l,fullHeight:r,children:sa(xl,{$codeBgColor:i,children:t?sa(ia,{code:t,language:"yaml",theme:"duotoneDark"}):sa(
|
|
155
|
+
`,Cl=({title:e="YAML",yaml:t,defaultOpen:l,fullHeight:r,bgTint:n="1000",codeBgColor:i})=>{const{clickCopy:s,isCopied:o}=la(),d=Ra(()=>t?[{id:na(),type:ra.Button,buttonProps:{variant:a.Text,size:m.S,leftIcon:o?Da:za,onClick:()=>s(t||""),disabled:o}}]:[],[t,o]);return sa(Ae,{bgTint:n,richTitle:{icon:Na,title:e},actions:d,withCollapse:!0,collapseIsDefaultOpen:l,fullHeight:r,children:sa(xl,{$codeBgColor:i,children:t?sa(ia,{code:t,language:"yaml",theme:"duotoneDark"}):sa(Qe,{children:sa(Ze,{title:"YAML not found",subTitle:"The YAML for this resource is not available"})})})})};export{Qa as A,Ua as C,Fa as D,tt as I,nt as N,Tt as O,st as P,Rt as R,sl as S,ol as U,yl as W,Cl as Y,al as a,rt as b,qt as c,Vt as d,dt as e,Lt as f,Ka as g,lt as h,hl as i,it as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as r,useContext as n,createContext as s,useRef as o,useEffect as i}from"react";import{r as l,s as d,A as c,v as u,w as m,x as p,y as h,z as f,B as g,C as v,G as b,H as y,J as D,K as E,L as S,M as k,O as C,Q as A,R as F,U as I,V as w,W as N,c as x,E as R}from"./ui-components-TeG65JGy.js";import{u as P}from"./use-odigos-api-li2VrVHH.js";import{n as O,m as T,i as L,b as M,a as U,d as j,v as K,g as V,u as G}from"./helpers-BEkhis3j.js";const _={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},q=s(null),H="All row fields are required",z="At least one row is required",J=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!("string"==typeof(r=a)?!r.trim():p(r));var r}),Q=({children:n})=>{const[s,o]=t(null),i=l(_),f=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),g=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:r,signals:n,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!r,signals:n??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??null))},[]),v=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(_)};const e=(e=>{const t=d(e),a=t.fields||{},r=a[u.UrlTemplatizationRulesGroups];r?.length&&(a[u.UrlTemplatizationRulesGroups]=r.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const n=a[u.AttributeNamesToDelete];n?.length&&(a[u.AttributeNamesToDelete]=n.filter(e=>!!e?.trim()));const s=a[u.Renames];s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim())));const o=a[u.ExtractAttribute];return o?.extractions?.length&&(a[u.ExtractAttribute]={extractions:o.extractions.map(e=>({targetAttributeName:e.targetAttributeName?.trim()||"",lookupKey:e.lookupKey?.trim()||"",dataFormat:e.dataFormat||"",regex:e.regex?.trim()||""})).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),t.fields=a,t})(i.formData),t={};p(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const r={},n=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(n[u.CollectContainerAttributes]||n[u.CollectReplicaSetAttributes]||n[u.CollectWorkloadId]||n[u.CollectClusterId]),t=!n[u.LabelsAttributes]?.length,a=!n[u.AnnotationsAttributes]?.length;e&&t&&a&&(r[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=n[u.LabelsAttributes];s?.some(e=>!J(e,["labelKey","attributeKey","fromSources"]))&&(r[u.LabelsAttributes]=H);const o=n[u.AnnotationsAttributes];o?.some(e=>!J(e,["annotationKey","attributeKey","fromSources"]))&&(r[u.AnnotationsAttributes]=H);break}case m.AddClusterInfo:{const e=n[u.ClusterAttributes];e?.length?e.some(e=>!J(e,["attributeName","attributeStringValue"]))&&(r[u.ClusterAttributes]=H):r[u.ClusterAttributes]=z;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=n[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(r[u.AttributeNamesToDelete]=H):r[u.AttributeNamesToDelete]=e.length?H:z;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(n[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(r[u.Renames]=H):r[u.Renames]=e.length?H:z;break}case m.PiiMasking:{const e=n[u.PiiCategories];e?.length||(r[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=n[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(r[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case m.ExtractAttribute:{const e=n[u.ExtractAttribute]?.extractions||[],t=s[u.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),a=!!e.lookupKey?.trim();return a!==!!e.dataFormat||t===a}))r[u.ExtractAttribute]="Each row needs a target attribute name and either a regex or both lookup key and data format";else{const t=new Set;e.some(e=>{const a=e.targetAttributeName?.trim()||"";return!!t.has(a)||(t.add(a),!1)})&&(r[u.ExtractAttribute]="Each new span attribute name must be unique")}else r[u.ExtractAttribute]=t.length?H:z;break}}return r})(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]),b=r(()=>({selectedOption:s,onSelectOption:f,loadAction:g,genericForm:i,validateFormData:v}),[s,f,g,i,v]);return e(q.Provider,{value:b,children:n})},W=()=>{const e=n(q);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:n,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[v,b]=t(void 0),[y,D]=t(null),E=o(null),S=l($),k=a(e=>{S.resetFormData({name:e}),S.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),b(e),D(null),E.current=null},[]),C=a(()=>{const e=d(S.formData),t=(e=>{const t={};return e.name?g(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);S.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return u(a),{errorMessage:a,preparedFormData:e}},[S]),A=a(async e=>{const{errorMessage:t,preparedFormData:a}=C();if(t)return;const r=i.find(e=>e.name===a.name&&e.name!==m);if(r)return E.current=e,void D({preparedFormData:a,existingName:r.name,editingName:v});await e(a)},[C,i,m,v]),F=a(async()=>{const e=E.current,t=y?.preparedFormData;E.current=null,D(null),e&&t&&await e(t)},[y]),I=a(()=>{E.current=null,D(null)},[]),w=r(()=>({genericForm:S,loadDataStream:k,editingName:v,validateFormData:C,requestSubmit:A,pendingMerge:y,confirmMerge:F,cancelMerge:I,errorMessage:c,excludeName:m,setExcludeName:p}),[S,k,v,C,A,y,F,I,c,m]);return e(B.Provider,{value:w,children:n})},Y=()=>{const e=n(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:r,displayName:n,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=D(r,{});return{componentType:a,renderCondition:o,name:t,title:n,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}}),re=({children:n})=>{const{selectedStreamName:s}=f(),{items:o}=P().destinationsApi.useDestinations(),[c,u]=t(null),[m,g]=t(ee.unsavedDestinations),S=r(()=>"number"==typeof c?.unsavedIdx?m[c.unsavedIdx]:void 0,[c,m]),k=a((e,t)=>{c&&(g(t=>[...t,{...e,option:c.option}]),u(t?e=>e?{...e,listType:v.UNSAVED,unsavedIdx:m.length}:null:null))},[c,m.length]),C=a((e,t,a)=>{c&&(g(a=>a.map((a,r)=>r===e?{...a,...t,option:c.option}:a)),u(a?e=>e?{...e,listType:v.UNSAVED}:null:null))},[c]),A=a(e=>{g(t=>t.filter((t,a)=>a!==e)),u(null)},[]),F=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(S)return void F.resetFormData({...S.formData});if(c.listType===v.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void F.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=b(c.option.supportedSignals);F.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(y.Logs),metrics:e.includes(y.Metrics),traces:e.includes(y.Traces),profiles:e.includes(y.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,S]);const I=a(e=>{F.resetFormData(),F.handleErrorChange(void 0,void 0,{}),u(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const r of t){const t=r.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const r=D(e.fields,{}),n={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:r[e.name]??e.initialValue})):[]},s=ae(n.fields);u({listType:v.EXISTS,option:n,dynamicFields:s})},[]),N=a(()=>{const e=d(F.formData),t={};c?.dynamicFields.forEach(({name:a,required:r})=>{if(r){const r=e.fields.find(e=>e.key===a)?.value;p(r)&&(t[a]=h.FIELD_IS_REQUIRED)}});return E(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),F.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[F,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:I,loadDestination:w,genericForm:F,validateFormData:N,unsavedDestinations:m,thisUnsavedDestination:S,setUnsavedDestinations:g,addUnsavedDestination:k,updateUnsavedDestination:C,deleteUnsavedDestination:A},children:n})},ne=()=>n(te),se={disabled:!1,ruleName:"",notes:"",sourceScopes:T(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:n,sourceOptions:s=[],namespaceOptions:o=[]})=>{const[i,c]=t(null),u=l(se),m=a(e=>{u.resetFormData(),u.handleErrorChange(void 0,void 0,{}),c(e)},[]),p=a(e=>{var t;u.resetFormData((({ruleName:e,notes:t,disabled:a,sourceScopes:r,instrumentationLibraries:n,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,sourceScopes:O(r),workloads:null,instrumentationLibraries:n??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),u.handleErrorChange(void 0,void 0,{}),c((t=e.type,k.find(e=>e.type===t)??null))},[]),h=a(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e),a={...t,sourceScopes:L(t.sourceScopes)?null:t.sourceScopes,workloads:null};return a.headersCollection?.[C.HeaderKeys]?.length&&(a.headersCollection[C.HeaderKeys]=a.headersCollection[C.HeaderKeys].map(e=>e.trim()).filter(e=>e)),a.customInstrumentations?.[A.Golang]?.length&&(a.customInstrumentations[A.Golang]=a.customInstrumentations[A.Golang].map(e=>new F(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})),a.customInstrumentations?.[A.Java]?.length&&(a.customInstrumentations[A.Java]=a.customInstrumentations[A.Java].map(e=>new I(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),a})(u.formData),t=((e,t)=>{const a={};switch(e){case w.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case w.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case w.HeadersCollection:t.headersCollection?.[C.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case w.CustomInstrumentation:{const e=t.customInstrumentations?.[A.Golang]||[],r=t.customInstrumentations?.[A.Java]||[];if(!e.length&&!r.length){a.customInstrumentations="Custom instrumentation are required";break}const n=e.findIndex(e=>!new F(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==n){a.customInstrumentations=`Golang probe #${n+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=r.findIndex(e=>!new I(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})(i.type,e);return u.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[u,i]),f=r(()=>({selectedOption:i,onSelectOption:m,loadRule:p,genericForm:u,validateFormData:h,sourceOptions:s,namespaceOptions:o}),[i,m,p,u,h,s,o]);return e(oe.Provider,{value:f,children:n})},le=()=>{const e=n(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),ue=["50","25","10","1"];function me(e){const t=String(e);return ue.includes(t)?t:"custom"}const pe=({category:n,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(V(n)),[p,h]=t(null);i(()=>{m(V(n)),h(null)},[n]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),g=a(()=>{m(V(n)),h(null)},[n,m]),v=r(()=>({formType:de.Create,category:n,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[n,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:n,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:u})=>{const[m,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{n!==v.current&&(v.current=n,n&&s?(g(K(n)),y(null),p(!0)):(p(!1),y(null)))},[n,s]);const D=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),E=a(()=>{n&&(g(K(n)),y(null),p(!0))},[n,g]),S=a(()=>{p(!1),y(null)},[]),k=r(()=>({formType:de.View,data:n,isEditing:m,formData:h,handleChange:D,handleEdit:E,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[n,m,h,D,E,S,b,d,c]);return e(ce.Provider,{value:k,children:u})};function fe(e){const[a,n]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>me(e)),[l,d]=t(()=>"custom"===me(e)?String(e):"");i(()=>{n(0===e?"all":"sample");const t=me(e);o(t),d("custom"===t?String(e):"")},[e]);const c=r(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:n,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=r(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},ve=({enabled:a,dropPercentage:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=r(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},be=({enabled:a,children:n})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=r(()=>M(s?{disabled:!1}:null),[s]),d=r(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:n})},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 De(e){const t=n(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 Ee={otelServiceName:"",currentStreamName:""},Se=s(null),ke=({children:n})=>{const[s,o]=t(void 0),i=l(Ee),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),u=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),m=r(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(Se.Provider,{value:m,children:n})},Ce=()=>{const e=n(Se);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ae=new Set([N.StaticPod]),Fe=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}},Ie=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:r}=Fe(e);return t||a||r}return!0},we=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),Ne=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),xe=({children:n,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=G(),c=l===x.Onprem,{selectedStreamName:u}=f(),[m,p]=t(!1),[h,g]=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),r=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(r);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=>{Ae.has(e.kind)&&!c||(e.selected=!0)})}),a}return r})})},[h,s,o]);const{formDiff:y,isFormDirty:D}=r(()=>{const e=((e,t,a)=>{const r={};return e.forEach(e=>{e.namespaces.forEach(n=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===n.name),o=n.selected||!1;if(o!==s?.selected)r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push({namespace:n.name,selected:o,currentStreamName:a}),o?r[e.clusterId]=r[e.clusterId].filter(e=>e.namespace!==n.name||e.namespace===n.name&&(!e.name||!e.kind)):n.workloads.forEach(t=>{t.selected&&r[e.clusterId].push({namespace:n.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const r=[];return t.workloads.forEach(n=>{const s=e?.workloads.find(e=>e.name===n.name&&e.kind===n.kind);n.selected!==s?.selected&&r.push({namespace:t.name,name:n.name,kind:n.kind,selected:n.selected||!1,currentStreamName:a})}),r})(s,n,a);t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t))}})}),r})(v,h?.clusters||[],u);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[v,h,u]),E=a(e=>!c&&Ae.has(e),[c]),S=a(({clusterId:e,workloadId:t,selected:a,auto:r})=>{b(n=>{const s=d(n),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 r="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=r,r){s[o].namespaces[i].workloads.filter(e=>!E(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof r?r:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{E(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[E]),k=a(({clusterId:e,namespaceName:t,boolean:a,searchText:r="",searchBy:n="",filters:s})=>{b(o=>{const i=d(o),l=n===R.Namespace?r:"",c=n===R.Source?r:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((r,n)=>{e&&r.clusterId!==e||r.namespaces.forEach(({name:e,workloads:r},o)=>{if(!t||e===t)if(u)if(t){r.forEach((e,t)=>{a&&E(e.kind)||we(e,c,s||{showOnlySelected:!1})&&(i[n].namespaces[o].workloads[t].selected=a)});const e=i[n].namespaces[o].workloads.filter(e=>!E(e.kind)).every(e=>e.selected);i[n].namespaces[o].selected=e}else{if(!Ie(i[n].namespaces[o],l,s||{showOnlySelected:!1}))return;i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&E(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})}else i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&E(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})})}),i})},[E]);return e(Ne.Provider,{value:{snapshots:h,setSnapshots:g,isFetching:m,setIsFetching:p,formData:v,handleSourceChange:S,handleSelectAll:k,formDiff:y,isFormDirty:D},children:n})},Re=()=>n(Ne);export{Q as A,X as D,Ae as E,ie as R,de as S,re as a,ye as b,ke as c,xe as d,Y as e,ne as f,le as g,De as h,Ce as i,Re as j,we as k,Ie as l,Fe as m,W as u};
|