@odigos/ui-kit 0.0.31 → 0.0.32
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 +8 -0
- package/lib/components.js +9 -12
- package/lib/constants.js +3 -6
- package/lib/containers/instrumentation-rule-form/custom-fields/headers-collection.d.ts +5 -0
- package/lib/containers.js +34 -19
- package/lib/functions.js +6 -8
- package/lib/hooks/useInstrumentationRuleFormData.d.ts +1 -1
- package/lib/hooks.js +4 -7
- package/lib/icons/instrumentation-rules/headers-collection-icon/headers-collection-icon.stories.d.ts +8 -0
- package/lib/icons/instrumentation-rules/headers-collection-icon/index.d.ts +2 -0
- package/lib/icons/instrumentation-rules/index.d.ts +1 -0
- package/lib/icons.js +7 -8
- package/lib/{index-CWbxXTof.js → index-B3j_QWzh.js} +1 -1
- package/lib/index-B9cvsYnj.js +100 -0
- package/lib/{index-nltUpkWT.js → index-BxckQJom.js} +6 -8
- package/lib/{index-CJs4RDHU.js → index-C7YDojNh.js} +2 -3
- package/lib/{index-BJxaoI0G.js → index-DAbcw-wM.js} +1 -1
- package/lib/{index-CamnKrev.js → index-DR5ryS5d.js} +1 -1
- package/lib/{index-B46Mcu9H.js → index-DeD-SIlN.js} +5 -6
- package/lib/{index-IKusBlIE.js → index-DuSmjoDs.js} +1 -1
- package/lib/{index-BbbCCewR.js → index-PfG5pvFK.js} +1 -1
- package/lib/{index-DYNMhZMX.js → index-cG2lNgzz.js} +6 -6
- package/lib/index-ivnS3eWW.js +1178 -0
- package/lib/{index-BGK1nMOD.js → index-rbphz5kH.js} +2 -2
- package/lib/snippets.js +9 -12
- package/lib/store.js +2 -2
- package/lib/theme.js +3 -233
- package/lib/types/instrumentation-rules/index.d.ts +26 -18
- package/lib/types.js +15 -9
- package/lib/{useSourceSelectionFormData-BWz8fTJr.js → useSourceSelectionFormData-A5_zhn1C.js} +3 -3
- package/lib/{useTransition-B65KBqdK.js → useTransition-9tDdAS9s.js} +1 -2
- package/package.json +1 -1
- package/lib/index-CFnxjzaW.js +0 -37
- package/lib/index-DGel4E-Z.js +0 -67
- package/lib/index-DGuOxbBR.js +0 -227
- package/lib/index-DMXaEyAB.js +0 -720
package/lib/index-DMXaEyAB.js
DELETED
|
@@ -1,720 +0,0 @@
|
|
|
1
|
-
import { EntityTypes } from './types.js';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { keyframes } from 'styled-components';
|
|
4
|
-
|
|
5
|
-
const createStoreImpl = (createState) => {
|
|
6
|
-
let state;
|
|
7
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
8
|
-
const setState = (partial, replace) => {
|
|
9
|
-
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
10
|
-
if (!Object.is(nextState, state)) {
|
|
11
|
-
const previousState = state;
|
|
12
|
-
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
13
|
-
listeners.forEach((listener) => listener(state, previousState));
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const getState = () => state;
|
|
17
|
-
const getInitialState = () => initialState;
|
|
18
|
-
const subscribe = (listener) => {
|
|
19
|
-
listeners.add(listener);
|
|
20
|
-
return () => listeners.delete(listener);
|
|
21
|
-
};
|
|
22
|
-
const api = { setState, getState, getInitialState, subscribe };
|
|
23
|
-
const initialState = state = createState(setState, getState, api);
|
|
24
|
-
return api;
|
|
25
|
-
};
|
|
26
|
-
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
27
|
-
|
|
28
|
-
const identity = (arg) => arg;
|
|
29
|
-
function useStore(api, selector = identity) {
|
|
30
|
-
const slice = React.useSyncExternalStore(
|
|
31
|
-
api.subscribe,
|
|
32
|
-
() => selector(api.getState()),
|
|
33
|
-
() => selector(api.getInitialState())
|
|
34
|
-
);
|
|
35
|
-
React.useDebugValue(slice);
|
|
36
|
-
return slice;
|
|
37
|
-
}
|
|
38
|
-
const createImpl = (createState) => {
|
|
39
|
-
const api = createStore(createState);
|
|
40
|
-
const useBoundStore = (selector) => useStore(api, selector);
|
|
41
|
-
Object.assign(useBoundStore, api);
|
|
42
|
-
return useBoundStore;
|
|
43
|
-
};
|
|
44
|
-
const create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
45
|
-
|
|
46
|
-
function createJSONStorage(getStorage, options) {
|
|
47
|
-
let storage;
|
|
48
|
-
try {
|
|
49
|
-
storage = getStorage();
|
|
50
|
-
} catch (e) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const persistStorage = {
|
|
54
|
-
getItem: (name) => {
|
|
55
|
-
var _a;
|
|
56
|
-
const parse = (str2) => {
|
|
57
|
-
if (str2 === null) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
return JSON.parse(str2, void 0 );
|
|
61
|
-
};
|
|
62
|
-
const str = (_a = storage.getItem(name)) != null ? _a : null;
|
|
63
|
-
if (str instanceof Promise) {
|
|
64
|
-
return str.then(parse);
|
|
65
|
-
}
|
|
66
|
-
return parse(str);
|
|
67
|
-
},
|
|
68
|
-
setItem: (name, newValue) => storage.setItem(
|
|
69
|
-
name,
|
|
70
|
-
JSON.stringify(newValue, void 0 )
|
|
71
|
-
),
|
|
72
|
-
removeItem: (name) => storage.removeItem(name)
|
|
73
|
-
};
|
|
74
|
-
return persistStorage;
|
|
75
|
-
}
|
|
76
|
-
const toThenable = (fn) => (input) => {
|
|
77
|
-
try {
|
|
78
|
-
const result = fn(input);
|
|
79
|
-
if (result instanceof Promise) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
then(onFulfilled) {
|
|
84
|
-
return toThenable(onFulfilled)(result);
|
|
85
|
-
},
|
|
86
|
-
catch(_onRejected) {
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
} catch (e) {
|
|
91
|
-
return {
|
|
92
|
-
then(_onFulfilled) {
|
|
93
|
-
return this;
|
|
94
|
-
},
|
|
95
|
-
catch(onRejected) {
|
|
96
|
-
return toThenable(onRejected)(e);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const persistImpl = (config, baseOptions) => (set, get, api) => {
|
|
102
|
-
let options = {
|
|
103
|
-
storage: createJSONStorage(() => localStorage),
|
|
104
|
-
partialize: (state) => state,
|
|
105
|
-
version: 0,
|
|
106
|
-
merge: (persistedState, currentState) => ({
|
|
107
|
-
...currentState,
|
|
108
|
-
...persistedState
|
|
109
|
-
}),
|
|
110
|
-
...baseOptions
|
|
111
|
-
};
|
|
112
|
-
let hasHydrated = false;
|
|
113
|
-
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
114
|
-
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
115
|
-
let storage = options.storage;
|
|
116
|
-
if (!storage) {
|
|
117
|
-
return config(
|
|
118
|
-
(...args) => {
|
|
119
|
-
console.warn(
|
|
120
|
-
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
121
|
-
);
|
|
122
|
-
set(...args);
|
|
123
|
-
},
|
|
124
|
-
get,
|
|
125
|
-
api
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
const setItem = () => {
|
|
129
|
-
const state = options.partialize({ ...get() });
|
|
130
|
-
return storage.setItem(options.name, {
|
|
131
|
-
state,
|
|
132
|
-
version: options.version
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
const savedSetState = api.setState;
|
|
136
|
-
api.setState = (state, replace) => {
|
|
137
|
-
savedSetState(state, replace);
|
|
138
|
-
void setItem();
|
|
139
|
-
};
|
|
140
|
-
const configResult = config(
|
|
141
|
-
(...args) => {
|
|
142
|
-
set(...args);
|
|
143
|
-
void setItem();
|
|
144
|
-
},
|
|
145
|
-
get,
|
|
146
|
-
api
|
|
147
|
-
);
|
|
148
|
-
api.getInitialState = () => configResult;
|
|
149
|
-
let stateFromStorage;
|
|
150
|
-
const hydrate = () => {
|
|
151
|
-
var _a, _b;
|
|
152
|
-
if (!storage) return;
|
|
153
|
-
hasHydrated = false;
|
|
154
|
-
hydrationListeners.forEach((cb) => {
|
|
155
|
-
var _a2;
|
|
156
|
-
return cb((_a2 = get()) != null ? _a2 : configResult);
|
|
157
|
-
});
|
|
158
|
-
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
|
|
159
|
-
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
160
|
-
if (deserializedStorageValue) {
|
|
161
|
-
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
162
|
-
if (options.migrate) {
|
|
163
|
-
const migration = options.migrate(
|
|
164
|
-
deserializedStorageValue.state,
|
|
165
|
-
deserializedStorageValue.version
|
|
166
|
-
);
|
|
167
|
-
if (migration instanceof Promise) {
|
|
168
|
-
return migration.then((result) => [true, result]);
|
|
169
|
-
}
|
|
170
|
-
return [true, migration];
|
|
171
|
-
}
|
|
172
|
-
console.error(
|
|
173
|
-
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
174
|
-
);
|
|
175
|
-
} else {
|
|
176
|
-
return [false, deserializedStorageValue.state];
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return [false, void 0];
|
|
180
|
-
}).then((migrationResult) => {
|
|
181
|
-
var _a2;
|
|
182
|
-
const [migrated, migratedState] = migrationResult;
|
|
183
|
-
stateFromStorage = options.merge(
|
|
184
|
-
migratedState,
|
|
185
|
-
(_a2 = get()) != null ? _a2 : configResult
|
|
186
|
-
);
|
|
187
|
-
set(stateFromStorage, true);
|
|
188
|
-
if (migrated) {
|
|
189
|
-
return setItem();
|
|
190
|
-
}
|
|
191
|
-
}).then(() => {
|
|
192
|
-
postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);
|
|
193
|
-
stateFromStorage = get();
|
|
194
|
-
hasHydrated = true;
|
|
195
|
-
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
196
|
-
}).catch((e) => {
|
|
197
|
-
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
api.persist = {
|
|
201
|
-
setOptions: (newOptions) => {
|
|
202
|
-
options = {
|
|
203
|
-
...options,
|
|
204
|
-
...newOptions
|
|
205
|
-
};
|
|
206
|
-
if (newOptions.storage) {
|
|
207
|
-
storage = newOptions.storage;
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
clearStorage: () => {
|
|
211
|
-
storage == null ? void 0 : storage.removeItem(options.name);
|
|
212
|
-
},
|
|
213
|
-
getOptions: () => options,
|
|
214
|
-
rehydrate: () => hydrate(),
|
|
215
|
-
hasHydrated: () => hasHydrated,
|
|
216
|
-
onHydrate: (cb) => {
|
|
217
|
-
hydrationListeners.add(cb);
|
|
218
|
-
return () => {
|
|
219
|
-
hydrationListeners.delete(cb);
|
|
220
|
-
};
|
|
221
|
-
},
|
|
222
|
-
onFinishHydration: (cb) => {
|
|
223
|
-
finishHydrationListeners.add(cb);
|
|
224
|
-
return () => {
|
|
225
|
-
finishHydrationListeners.delete(cb);
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
if (!options.skipHydration) {
|
|
230
|
-
hydrate();
|
|
231
|
-
}
|
|
232
|
-
return stateFromStorage || configResult;
|
|
233
|
-
};
|
|
234
|
-
const persist = persistImpl;
|
|
235
|
-
|
|
236
|
-
const useDarkMode = create()(persist((set) => ({
|
|
237
|
-
darkMode: true,
|
|
238
|
-
setDarkMode: (bool) => set({ darkMode: bool }),
|
|
239
|
-
}), {
|
|
240
|
-
name: 'odigos-dark-mode',
|
|
241
|
-
storage: typeof window !== 'undefined' ? createJSONStorage(() => localStorage) : undefined,
|
|
242
|
-
}));
|
|
243
|
-
|
|
244
|
-
const initialState$1 = {
|
|
245
|
-
dataStreamsLoading: false,
|
|
246
|
-
dataStreams: [],
|
|
247
|
-
selectedStreamName: '',
|
|
248
|
-
};
|
|
249
|
-
const useDataStreamStore = create((set) => ({
|
|
250
|
-
...initialState$1,
|
|
251
|
-
setDataStreamsLoading: (bool) => set({ dataStreamsLoading: bool }),
|
|
252
|
-
setDataStreams: (dataStreams) => set({ dataStreams }),
|
|
253
|
-
addDataStreams: (newStreams) => set((state) => {
|
|
254
|
-
const merged = [...state.dataStreams, ...newStreams];
|
|
255
|
-
const mapped = merged.map((ds) => [ds.name, ds]);
|
|
256
|
-
const uniqueByName = Array.from(new Map(mapped).values());
|
|
257
|
-
return { dataStreams: uniqueByName };
|
|
258
|
-
}),
|
|
259
|
-
removeDataStreams: (dataStreams) => set((state) => {
|
|
260
|
-
const filtered = state.dataStreams.filter((ds) => !dataStreams.find((toRemove) => toRemove.name === ds.name));
|
|
261
|
-
return { dataStreams: filtered };
|
|
262
|
-
}),
|
|
263
|
-
setSelectedStreamName: (streamName) => set({ selectedStreamName: streamName }),
|
|
264
|
-
resetDataStreamStore: () => set(initialState$1),
|
|
265
|
-
}));
|
|
266
|
-
|
|
267
|
-
const useDrawerStore = create((set) => ({
|
|
268
|
-
drawerType: null,
|
|
269
|
-
drawerEntityId: null,
|
|
270
|
-
setDrawerType: (value) => set({ drawerType: value }),
|
|
271
|
-
setDrawerEntityId: (value) => set({ drawerEntityId: value }),
|
|
272
|
-
}));
|
|
273
|
-
|
|
274
|
-
const getEntityId = (item) => {
|
|
275
|
-
if ('ruleId' in item && !!item.ruleId) {
|
|
276
|
-
// Instrumentation Rule
|
|
277
|
-
return item.ruleId;
|
|
278
|
-
}
|
|
279
|
-
else if ('id' in item && !!item.id) {
|
|
280
|
-
// Destination or Action
|
|
281
|
-
return item.id;
|
|
282
|
-
}
|
|
283
|
-
else if ('namespace' in item && !!item.namespace && 'kind' in item && !!item.kind && 'name' in item && !!item.name) {
|
|
284
|
-
// Source
|
|
285
|
-
return {
|
|
286
|
-
namespace: item.namespace,
|
|
287
|
-
name: item.name,
|
|
288
|
-
kind: item.kind,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
else if ('name' in item && !!item.name) {
|
|
292
|
-
// Namespace
|
|
293
|
-
return item.name;
|
|
294
|
-
}
|
|
295
|
-
console.warn('getEntityId() - cannot get ID of entity:', item);
|
|
296
|
-
return undefined;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
const useEntityStore = create((set) => ({
|
|
300
|
-
namespacesLoading: false,
|
|
301
|
-
namespaces: [],
|
|
302
|
-
sourcesLoading: false,
|
|
303
|
-
sources: [],
|
|
304
|
-
destinationsLoading: false,
|
|
305
|
-
destinations: [],
|
|
306
|
-
actionsLoading: false,
|
|
307
|
-
actions: [],
|
|
308
|
-
instrumentationRulesLoading: false,
|
|
309
|
-
instrumentationRules: [],
|
|
310
|
-
setEntitiesLoading: (entityType, bool) => {
|
|
311
|
-
const KEY = entityType === EntityTypes.Namespace
|
|
312
|
-
? 'namespacesLoading'
|
|
313
|
-
: entityType === EntityTypes.Source
|
|
314
|
-
? 'sourcesLoading'
|
|
315
|
-
: entityType === EntityTypes.Destination
|
|
316
|
-
? 'destinationsLoading'
|
|
317
|
-
: entityType === EntityTypes.Action
|
|
318
|
-
? 'actionsLoading'
|
|
319
|
-
: entityType === EntityTypes.InstrumentationRule
|
|
320
|
-
? 'instrumentationRulesLoading'
|
|
321
|
-
: 'NONE';
|
|
322
|
-
if (KEY === 'NONE')
|
|
323
|
-
return;
|
|
324
|
-
set({ [KEY]: bool });
|
|
325
|
-
},
|
|
326
|
-
setEntities: (entityType, payload) => {
|
|
327
|
-
const KEY = entityType === EntityTypes.Namespace
|
|
328
|
-
? 'namespaces'
|
|
329
|
-
: entityType === EntityTypes.Source
|
|
330
|
-
? 'sources'
|
|
331
|
-
: entityType === EntityTypes.Destination
|
|
332
|
-
? 'destinations'
|
|
333
|
-
: entityType === EntityTypes.Action
|
|
334
|
-
? 'actions'
|
|
335
|
-
: entityType === EntityTypes.InstrumentationRule
|
|
336
|
-
? 'instrumentationRules'
|
|
337
|
-
: 'NONE';
|
|
338
|
-
if (KEY === 'NONE')
|
|
339
|
-
return;
|
|
340
|
-
set({ [KEY]: payload });
|
|
341
|
-
},
|
|
342
|
-
addEntities: (entityType, entities) => {
|
|
343
|
-
const KEY = entityType === EntityTypes.Namespace
|
|
344
|
-
? 'namespaces'
|
|
345
|
-
: entityType === EntityTypes.Source
|
|
346
|
-
? 'sources'
|
|
347
|
-
: entityType === EntityTypes.Destination
|
|
348
|
-
? 'destinations'
|
|
349
|
-
: entityType === EntityTypes.Action
|
|
350
|
-
? 'actions'
|
|
351
|
-
: entityType === EntityTypes.InstrumentationRule
|
|
352
|
-
? 'instrumentationRules'
|
|
353
|
-
: 'NONE';
|
|
354
|
-
if (KEY === 'NONE')
|
|
355
|
-
return;
|
|
356
|
-
set((state) => {
|
|
357
|
-
const prev = [...state[KEY]];
|
|
358
|
-
entities.forEach((newItem) => {
|
|
359
|
-
const foundIdx = prev.findIndex((oldItem) => JSON.stringify(getEntityId(oldItem)) === JSON.stringify(getEntityId(newItem)));
|
|
360
|
-
if (foundIdx !== -1) {
|
|
361
|
-
prev[foundIdx] = { ...prev[foundIdx], ...newItem };
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
prev.push(newItem);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
return { [KEY]: prev };
|
|
368
|
-
});
|
|
369
|
-
},
|
|
370
|
-
removeEntities: (entityType, entityIds) => {
|
|
371
|
-
const KEY = entityType === EntityTypes.Namespace
|
|
372
|
-
? 'namespaces'
|
|
373
|
-
: entityType === EntityTypes.Source
|
|
374
|
-
? 'sources'
|
|
375
|
-
: entityType === EntityTypes.Destination
|
|
376
|
-
? 'destinations'
|
|
377
|
-
: entityType === EntityTypes.Action
|
|
378
|
-
? 'actions'
|
|
379
|
-
: entityType === EntityTypes.InstrumentationRule
|
|
380
|
-
? 'instrumentationRules'
|
|
381
|
-
: 'NONE';
|
|
382
|
-
if (KEY === 'NONE')
|
|
383
|
-
return;
|
|
384
|
-
set((state) => {
|
|
385
|
-
const prev = [...state[KEY]];
|
|
386
|
-
entityIds.forEach((id) => {
|
|
387
|
-
const foundIdx = prev.findIndex((entity) => entityType === EntityTypes.Source ? JSON.stringify(getEntityId(entity)) === JSON.stringify(getEntityId(id)) : getEntityId(entity) === id);
|
|
388
|
-
if (foundIdx !== -1) {
|
|
389
|
-
prev.splice(foundIdx, 1);
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
return { [KEY]: prev };
|
|
393
|
-
});
|
|
394
|
-
},
|
|
395
|
-
resetEntityStore: () => {
|
|
396
|
-
set({
|
|
397
|
-
namespacesLoading: false,
|
|
398
|
-
namespaces: [],
|
|
399
|
-
sourcesLoading: false,
|
|
400
|
-
sources: [],
|
|
401
|
-
destinationsLoading: false,
|
|
402
|
-
destinations: [],
|
|
403
|
-
actionsLoading: false,
|
|
404
|
-
actions: [],
|
|
405
|
-
instrumentationRulesLoading: false,
|
|
406
|
-
instrumentationRules: [],
|
|
407
|
-
});
|
|
408
|
-
},
|
|
409
|
-
}));
|
|
410
|
-
|
|
411
|
-
const getEmptyState = () => ({
|
|
412
|
-
searchText: '',
|
|
413
|
-
statuses: [],
|
|
414
|
-
platformTypes: [],
|
|
415
|
-
namespaces: [],
|
|
416
|
-
kinds: [],
|
|
417
|
-
monitors: [],
|
|
418
|
-
languages: [],
|
|
419
|
-
errors: [],
|
|
420
|
-
onlyErrors: false,
|
|
421
|
-
});
|
|
422
|
-
const useFilterStore = create((set) => ({
|
|
423
|
-
searchText: '',
|
|
424
|
-
setSearchText: (searchText) => set({ searchText }),
|
|
425
|
-
statuses: [],
|
|
426
|
-
setStatuses: (statuses) => set({ statuses }),
|
|
427
|
-
platformTypes: [],
|
|
428
|
-
setPlatformTypes: (platformTypes) => set({ platformTypes }),
|
|
429
|
-
namespaces: [],
|
|
430
|
-
setNamespaces: (namespaces) => set({ namespaces }),
|
|
431
|
-
kinds: [],
|
|
432
|
-
setKinds: (kinds) => set({ kinds }),
|
|
433
|
-
monitors: [],
|
|
434
|
-
setMonitors: (monitors) => set({ monitors }),
|
|
435
|
-
languages: [],
|
|
436
|
-
setLanguages: (languages) => set({ languages }),
|
|
437
|
-
errors: [],
|
|
438
|
-
setErrors: (errors) => set({ errors }),
|
|
439
|
-
onlyErrors: false,
|
|
440
|
-
setOnlyErrors: (onlyErrors) => set({ onlyErrors }),
|
|
441
|
-
setAll: (params) => set(params),
|
|
442
|
-
clearAll: () => set(getEmptyState()),
|
|
443
|
-
getEmptyState,
|
|
444
|
-
}));
|
|
445
|
-
|
|
446
|
-
const useInstrumentStore = create((set) => ({
|
|
447
|
-
isAwaitingInstrumentation: false,
|
|
448
|
-
sourcesToCreate: 0,
|
|
449
|
-
sourcesCreated: 0,
|
|
450
|
-
sourcesToDelete: 0,
|
|
451
|
-
sourcesDeleted: 0,
|
|
452
|
-
setInstrumentAwait: (v) => set({ isAwaitingInstrumentation: v }),
|
|
453
|
-
setInstrumentCount: (k, v) => set({ [k]: v }),
|
|
454
|
-
}));
|
|
455
|
-
|
|
456
|
-
const useModalStore = create((set) => ({
|
|
457
|
-
currentModal: '',
|
|
458
|
-
setCurrentModal: (str) => set({ currentModal: str }),
|
|
459
|
-
}));
|
|
460
|
-
|
|
461
|
-
const useNotificationStore = create((set, get) => ({
|
|
462
|
-
notifications: [],
|
|
463
|
-
addNotification: (notif) => {
|
|
464
|
-
const date = new Date();
|
|
465
|
-
const id = `${date.getTime().toString()}${!!notif.target ? `#${notif.target}` : ''}`;
|
|
466
|
-
// This is to prevent duplicate notifications.
|
|
467
|
-
// This is useful for notifications that are triggered multiple times in a short period, like failed API queries...
|
|
468
|
-
const { notifications } = get();
|
|
469
|
-
const isSameNotification = (n) => n.type === notif.type && n.title === notif.title && n.message === notif.message && !n.dismissed;
|
|
470
|
-
const hasThisToast = notifications.some(isSameNotification);
|
|
471
|
-
if (!hasThisToast) {
|
|
472
|
-
set((state) => ({
|
|
473
|
-
notifications: [
|
|
474
|
-
{
|
|
475
|
-
...notif,
|
|
476
|
-
id,
|
|
477
|
-
time: date.toISOString(),
|
|
478
|
-
dismissed: false,
|
|
479
|
-
seen: false,
|
|
480
|
-
},
|
|
481
|
-
...state.notifications,
|
|
482
|
-
],
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
markAsDismissed: (id) => {
|
|
487
|
-
set((state) => {
|
|
488
|
-
const foundIdx = state.notifications.findIndex((notif) => notif.id === id);
|
|
489
|
-
if (foundIdx !== -1) {
|
|
490
|
-
state.notifications[foundIdx].dismissed = true;
|
|
491
|
-
}
|
|
492
|
-
return {
|
|
493
|
-
notifications: state.notifications,
|
|
494
|
-
};
|
|
495
|
-
});
|
|
496
|
-
},
|
|
497
|
-
markAsSeen: (id) => {
|
|
498
|
-
set((state) => {
|
|
499
|
-
const foundIdx = state.notifications.findIndex((notif) => notif.id === id);
|
|
500
|
-
if (foundIdx !== -1) {
|
|
501
|
-
state.notifications[foundIdx].seen = true;
|
|
502
|
-
}
|
|
503
|
-
return {
|
|
504
|
-
notifications: state.notifications,
|
|
505
|
-
};
|
|
506
|
-
});
|
|
507
|
-
},
|
|
508
|
-
removeNotification: (id) => {
|
|
509
|
-
set((state) => {
|
|
510
|
-
const foundIdx = state.notifications.findIndex((notif) => notif.id === id);
|
|
511
|
-
if (foundIdx !== -1) {
|
|
512
|
-
state.notifications.splice(foundIdx, 1);
|
|
513
|
-
}
|
|
514
|
-
return {
|
|
515
|
-
notifications: state.notifications,
|
|
516
|
-
};
|
|
517
|
-
});
|
|
518
|
-
},
|
|
519
|
-
removeNotifications: (target) => {
|
|
520
|
-
if (!target)
|
|
521
|
-
return;
|
|
522
|
-
set((state) => {
|
|
523
|
-
const filtered = state.notifications.filter((notif) => notif.id.split('#')[1] !== target);
|
|
524
|
-
return {
|
|
525
|
-
notifications: filtered,
|
|
526
|
-
};
|
|
527
|
-
});
|
|
528
|
-
},
|
|
529
|
-
}));
|
|
530
|
-
|
|
531
|
-
const itemsAreEqual = (item1, item2) => {
|
|
532
|
-
const entityTypesEqual = item1.entityType === item2.entityType;
|
|
533
|
-
const idsEqual = typeof item1.entityId === 'string' && typeof item2.entityId === 'string'
|
|
534
|
-
? item1.entityId === item2.entityId
|
|
535
|
-
: typeof item1.entityId === 'object' && typeof item2.entityId === 'object'
|
|
536
|
-
? item1.entityId.namespace === item2.entityId.namespace && item1.entityId.name === item2.entityId.name && item1.entityId.kind === item2.entityId.kind
|
|
537
|
-
: !item1.entityId && !item2.entityId;
|
|
538
|
-
return entityTypesEqual && idsEqual;
|
|
539
|
-
};
|
|
540
|
-
const usePendingStore = create((set, get) => ({
|
|
541
|
-
pendingItems: [],
|
|
542
|
-
setPendingItems: (arr) => set({ pendingItems: arr }),
|
|
543
|
-
addPendingItems: (arr) => set((state) => ({
|
|
544
|
-
pendingItems: state.pendingItems.concat(arr.filter((addItem) => !state.pendingItems.some((existingItem) => itemsAreEqual(existingItem, addItem)))),
|
|
545
|
-
})),
|
|
546
|
-
removePendingItems: (arr) => set((state) => ({
|
|
547
|
-
pendingItems: state.pendingItems.filter((existingItem) => !arr.find((removeItem) => itemsAreEqual(existingItem, removeItem))),
|
|
548
|
-
})),
|
|
549
|
-
// Pass an item to check if it's in the pending items array.
|
|
550
|
-
// This is used to show loading spinners, toasts etc.
|
|
551
|
-
isThisPending: (item) => {
|
|
552
|
-
const { pendingItems } = get();
|
|
553
|
-
let bool = false;
|
|
554
|
-
for (let i = 0; i < pendingItems.length; i++) {
|
|
555
|
-
const pendingItem = pendingItems[i];
|
|
556
|
-
if (pendingItem.entityType === item.entityType &&
|
|
557
|
-
(!item.entityId ||
|
|
558
|
-
(pendingItem.entityType === EntityTypes.Source
|
|
559
|
-
? !!pendingItem.entityId &&
|
|
560
|
-
!!item.entityId &&
|
|
561
|
-
pendingItem.entityId.namespace === item.entityId.namespace &&
|
|
562
|
-
pendingItem.entityId.name === item.entityId.name &&
|
|
563
|
-
pendingItem.entityId.kind === item.entityId.kind
|
|
564
|
-
: pendingItem.entityId === item.entityId))) {
|
|
565
|
-
bool = true;
|
|
566
|
-
break;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return bool;
|
|
570
|
-
},
|
|
571
|
-
}));
|
|
572
|
-
|
|
573
|
-
const useSelectedStore = create((set) => ({
|
|
574
|
-
selectedSources: {},
|
|
575
|
-
setSelectedSources: (payload) => set({ selectedSources: payload }),
|
|
576
|
-
resetSelectedState: () => set(() => ({ selectedSources: {} })),
|
|
577
|
-
}));
|
|
578
|
-
|
|
579
|
-
const initialState = {
|
|
580
|
-
availableSources: {},
|
|
581
|
-
configuredSources: {},
|
|
582
|
-
configuredFutureApps: {},
|
|
583
|
-
configuredDestinations: [],
|
|
584
|
-
configuredDestinationsUpdateOnly: [],
|
|
585
|
-
};
|
|
586
|
-
const filterByType = (existingDest, compareDest) => existingDest.destinationType.type !== compareDest.destinationType.type;
|
|
587
|
-
const useSetupStore = create((set) => ({
|
|
588
|
-
...initialState,
|
|
589
|
-
setAvailableSources: (payload) => set({ availableSources: payload }),
|
|
590
|
-
setConfiguredSources: (payload) => set({ configuredSources: payload }),
|
|
591
|
-
setConfiguredFutureApps: (payload) => set({ configuredFutureApps: payload }),
|
|
592
|
-
setConfiguredDestinations: (payload) => set({ configuredDestinations: payload }),
|
|
593
|
-
addConfiguredDestination: (payload) => set((state) => ({ configuredDestinations: [...state.configuredDestinations, payload] })),
|
|
594
|
-
removeConfiguredDestination: (payload) => set((state) => ({ configuredDestinations: state.configuredDestinations.filter((dest) => filterByType(dest, payload)) })),
|
|
595
|
-
setConfiguredDestinationsUpdateOnly: (payload) => set({ configuredDestinationsUpdateOnly: payload }),
|
|
596
|
-
addConfiguredDestinationUpdateOnly: (payload) => set((state) => {
|
|
597
|
-
// For update-only cases, we have to prevent duplicates using the dest ID
|
|
598
|
-
const merged = [...state.configuredDestinationsUpdateOnly, payload];
|
|
599
|
-
const mapped = merged.map((d) => [d.id, d]);
|
|
600
|
-
const uniqueById = Array.from(new Map(mapped).values());
|
|
601
|
-
return { configuredDestinationsUpdateOnly: uniqueById };
|
|
602
|
-
}),
|
|
603
|
-
removeConfiguredDestinationUpdateOnly: (payload) => set((state) => ({ configuredDestinationsUpdateOnly: state.configuredDestinationsUpdateOnly.filter((dest) => filterByType(dest, payload)) })),
|
|
604
|
-
resetState: () => set(() => ({ ...initialState })),
|
|
605
|
-
}));
|
|
606
|
-
|
|
607
|
-
function styleInject(css, ref) {
|
|
608
|
-
if ( ref === void 0 ) ref = {};
|
|
609
|
-
var insertAt = ref.insertAt;
|
|
610
|
-
|
|
611
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
612
|
-
|
|
613
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
614
|
-
var style = document.createElement('style');
|
|
615
|
-
style.type = 'text/css';
|
|
616
|
-
|
|
617
|
-
if (insertAt === 'top') {
|
|
618
|
-
if (head.firstChild) {
|
|
619
|
-
head.insertBefore(style, head.firstChild);
|
|
620
|
-
} else {
|
|
621
|
-
head.appendChild(style);
|
|
622
|
-
}
|
|
623
|
-
} else {
|
|
624
|
-
head.appendChild(style);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
if (style.styleSheet) {
|
|
628
|
-
style.styleSheet.cssText = css;
|
|
629
|
-
} else {
|
|
630
|
-
style.appendChild(document.createTextNode(css));
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
var css_248z = "/* Preload key fonts in your global CSS */\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');\n@import url('https://fonts.googleapis.com/css2?family=Kode+Mono:wght@100;200;300;400;500;600;700&display=swap');\n@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;700&display=swap');\n@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');\n\n* {\n -ms-overflow-style: none; /* IE, Edge */\n scrollbar-width: none; /* Firefox */\n}\n*::-webkit-scrollbar {\n display: none; /* Chrome, Safari, Opera */\n}\n\nsvg {\n transition: all 0.3s;\n}\n\n/*\n The input styles below are to override the browser \":-webkit-autofill\" default style declarations.\n The issue is when someone autocompletes an input field, the browser will apply its own styles (and the browser applies \"!important\" preventing direct overrides).\n With the following, we're able to delay the browser styles to be applied for 50000s (13.8 hours), so the user will not see the browser styles applied.\n*/\n\ninput {\n all: unset;\n}\n\ninput:-webkit-autofill,\ninput:-webkit-autofill:hover,\ninput:-webkit-autofill:focus,\ninput:-webkit-autofill:active {\n -webkit-transition: all 50000s ease-in-out 0s;\n transition: all 50000s ease-in-out 0s;\n}\n";
|
|
635
|
-
styleInject(css_248z);
|
|
636
|
-
|
|
637
|
-
const slide = {
|
|
638
|
-
in: {
|
|
639
|
-
left: keyframes `
|
|
640
|
-
from { transform: translateX(-100%); }
|
|
641
|
-
to { transform: translateX(0); }
|
|
642
|
-
`,
|
|
643
|
-
right: keyframes `
|
|
644
|
-
from { transform: translateX(100%); }
|
|
645
|
-
to { transform: translateX(0); }
|
|
646
|
-
`,
|
|
647
|
-
top: keyframes `
|
|
648
|
-
from { transform: translateY(-100%); }
|
|
649
|
-
to { transform: translateY(0); }
|
|
650
|
-
`,
|
|
651
|
-
bottom: keyframes `
|
|
652
|
-
from { transform: translateY(100%); }
|
|
653
|
-
to { transform: translateY(0); }
|
|
654
|
-
`,
|
|
655
|
-
center: keyframes `
|
|
656
|
-
from { transform: translate(-50%, 100%); }
|
|
657
|
-
to { transform: translate(-50%, -50%); }
|
|
658
|
-
`,
|
|
659
|
-
},
|
|
660
|
-
out: {
|
|
661
|
-
left: keyframes `
|
|
662
|
-
from { transform: translateX(0); }
|
|
663
|
-
to { transform: translateX(-100%); }
|
|
664
|
-
`,
|
|
665
|
-
right: keyframes `
|
|
666
|
-
from { transform: translateX(0); }
|
|
667
|
-
to { transform: translateX(100%); }
|
|
668
|
-
`,
|
|
669
|
-
top: keyframes `
|
|
670
|
-
from { transform: translateY(0); }
|
|
671
|
-
to { transform: translateY(-100%); }
|
|
672
|
-
`,
|
|
673
|
-
bottom: keyframes `
|
|
674
|
-
from { transform: translateY(0); }
|
|
675
|
-
to { transform: translateY(100%); }
|
|
676
|
-
`,
|
|
677
|
-
center: keyframes `
|
|
678
|
-
from { transform: translate(-50%, -50%); }
|
|
679
|
-
to { transform: translate(-50%, 100%); }
|
|
680
|
-
`,
|
|
681
|
-
},
|
|
682
|
-
};
|
|
683
|
-
const progress = {
|
|
684
|
-
in: keyframes `
|
|
685
|
-
from { width: 0%; }
|
|
686
|
-
to { width: 100%; }
|
|
687
|
-
`,
|
|
688
|
-
out: keyframes `
|
|
689
|
-
from { width: 100%; }
|
|
690
|
-
to { width: 0%; }
|
|
691
|
-
`,
|
|
692
|
-
};
|
|
693
|
-
const ping = keyframes `
|
|
694
|
-
0% {
|
|
695
|
-
transform: scale(1);
|
|
696
|
-
opacity: 1;
|
|
697
|
-
}
|
|
698
|
-
75%, 100% {
|
|
699
|
-
transform: scale(2);
|
|
700
|
-
opacity: 0;
|
|
701
|
-
}
|
|
702
|
-
`;
|
|
703
|
-
const shimmer = keyframes `
|
|
704
|
-
0% {
|
|
705
|
-
background-position: -500px 0;
|
|
706
|
-
}
|
|
707
|
-
100% {
|
|
708
|
-
background-position: 500px 0;
|
|
709
|
-
}
|
|
710
|
-
`;
|
|
711
|
-
|
|
712
|
-
var animations = /*#__PURE__*/Object.freeze({
|
|
713
|
-
__proto__: null,
|
|
714
|
-
ping: ping,
|
|
715
|
-
progress: progress,
|
|
716
|
-
shimmer: shimmer,
|
|
717
|
-
slide: slide
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
export { useDataStreamStore as a, useDrawerStore as b, useEntityStore as c, useFilterStore as d, useInstrumentStore as e, useModalStore as f, useNotificationStore as g, usePendingStore as h, useSelectedStore as i, useSetupStore as j, getEntityId as k, animations as l, styleInject as s, useDarkMode as u };
|