@elevasis/ui 1.26.1 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/index.js +2 -2
- package/dist/{chunk-MHW43EOH.js → chunk-2IFYDILW.js} +2 -1
- package/dist/{chunk-AWT255UH.js → chunk-2IJCM3VQ.js} +37 -37
- package/dist/{chunk-4INR75ZS.js → chunk-37NT4BNV.js} +589 -65
- package/dist/chunk-5COLSYBE.js +199 -0
- package/dist/{chunk-YNGQ7U5H.js → chunk-7CJ5QBN2.js} +2 -2
- package/dist/{chunk-L3GVDMCA.js → chunk-C27LLJM6.js} +3 -195
- package/dist/chunk-C4WOXS2C.js +6646 -0
- package/dist/{chunk-RMPXGBNI.js → chunk-D25AE46Q.js} +2 -2
- package/dist/{chunk-ZVJKIJFG.js → chunk-EBCIUZVV.js} +13 -42
- package/dist/{chunk-O4UB5DQQ.js → chunk-F2J7675J.js} +1 -1
- package/dist/chunk-KLG4H5NM.js +247 -0
- package/dist/{chunk-BS4J2LAW.js → chunk-QTD5HPKD.js} +1 -1
- package/dist/chunk-S4S6K4MV.js +635 -0
- package/dist/{chunk-FEZZ3IDU.js → chunk-TXPUIHX2.js} +10 -10
- package/dist/{chunk-L4XXM55J.js → chunk-W4VYXIN7.js} +142 -3
- package/dist/{chunk-4WKWLFBZ.js → chunk-ZUJ7WMGV.js} +1 -1
- package/dist/chunk-ZXBD5SBV.js +2115 -0
- package/dist/components/index.d.ts +339 -73
- package/dist/components/index.js +840 -688
- package/dist/features/auth/index.d.ts +125 -0
- package/dist/features/auth/index.js +2 -2
- package/dist/features/dashboard/index.d.ts +28 -2
- package/dist/features/dashboard/index.js +21 -635
- package/dist/features/monitoring/index.d.ts +28 -1
- package/dist/features/monitoring/index.js +19 -529
- package/dist/features/operations/index.d.ts +57 -8
- package/dist/features/operations/index.js +25 -3760
- package/dist/features/settings/index.d.ts +153 -1
- package/dist/features/settings/index.js +19 -1438
- package/dist/hooks/index.d.ts +262 -25
- package/dist/hooks/index.js +12 -8
- package/dist/hooks/published.d.ts +137 -25
- package/dist/hooks/published.js +11 -7
- package/dist/index.d.ts +388 -99
- package/dist/index.js +12 -11
- package/dist/initialization/index.d.ts +125 -0
- package/dist/layout/index.d.ts +2 -0
- package/dist/layout/index.js +6 -5
- package/dist/organization/index.js +1 -2
- package/dist/profile/index.d.ts +125 -0
- package/dist/provider/index.d.ts +130 -3
- package/dist/provider/index.js +10 -4
- package/dist/provider/published.d.ts +130 -3
- package/dist/provider/published.js +8 -2
- package/dist/router/context.d.ts +1 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/index.js +1 -1
- package/dist/supabase/index.d.ts +242 -0
- package/dist/theme/index.js +2 -2
- package/dist/types/index.d.ts +126 -1
- package/package.json +1 -1
- package/dist/chunk-LR4WVA7W.js +0 -682
- package/dist/chunk-R7WLWGPO.js +0 -126
- package/dist/chunk-TCKIAHDC.js +0 -2626
- package/dist/chunk-V7XHGJQZ.js +0 -145
- package/dist/{chunk-WWEMNIHW.js → chunk-YYBM5LNJ.js} +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElevasisLoader } from './chunk-SZHARWKU.js';
|
|
2
|
-
import { PRESETS, getPreset, generateShades, mantineThemeOverride, createCssVariablesResolver, PresetsProvider } from './chunk-
|
|
2
|
+
import { PRESETS, getPreset, generateShades, mantineThemeOverride, createCssVariablesResolver, PresetsProvider } from './chunk-TXPUIHX2.js';
|
|
3
3
|
import { AppBackground } from './chunk-CYXZHBP4.js';
|
|
4
|
-
import { ElevasisCoreProvider } from './chunk-
|
|
4
|
+
import { ElevasisCoreProvider } from './chunk-KLG4H5NM.js';
|
|
5
5
|
import { AppearanceProvider } from './chunk-QJ2KCHKX.js';
|
|
6
6
|
import { getErrorInfo, formatErrorMessage, getErrorTitle } from './chunk-IOKL7BKE.js';
|
|
7
7
|
import { useMemo, useEffect } from 'react';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTimeRangeDates, observabilityKeys } from './chunk-LXHZYSMQ.js';
|
|
2
2
|
import { GRAPH_CONSTANTS } from './chunk-F6RBK7NJ.js';
|
|
3
|
-
import { useNotificationAdapter } from './chunk-
|
|
3
|
+
import { useNotificationAdapter } from './chunk-KLG4H5NM.js';
|
|
4
4
|
import { HTTP_HEADERS } from './chunk-NVOCKXUQ.js';
|
|
5
5
|
import { STALE_TIME_MONITORING, REFETCH_INTERVAL_DASHBOARD, REFETCH_INTERVAL_RUNNING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, getErrorInfo, formatErrorMessage, getErrorTitle, STALE_TIME_DEFAULT, STALE_TIME_ADMIN, APIClientError } from './chunk-IOKL7BKE.js';
|
|
6
6
|
import { useStableAccessToken } from './chunk-ALA56RGZ.js';
|
|
@@ -1997,42 +1997,6 @@ function useSortedData(data, defaultColumn, accessors, defaultDirection = "desc"
|
|
|
1997
1997
|
const sorted = useMemo(() => sortData(data, sort, accessors), [data, sort, accessors]);
|
|
1998
1998
|
return { sorted, sort, toggleSort };
|
|
1999
1999
|
}
|
|
2000
|
-
function createUseFeatureAccess({
|
|
2001
|
-
useInitialization,
|
|
2002
|
-
useOrganization: useOrganization2
|
|
2003
|
-
}) {
|
|
2004
|
-
return function useFeatureAccess() {
|
|
2005
|
-
const { profile, organizationReady } = useInitialization();
|
|
2006
|
-
const { currentMembership } = useOrganization2();
|
|
2007
|
-
const { orgConfig, membershipConfig } = useMemo(() => {
|
|
2008
|
-
const organizationConfig = currentMembership?.organization?.config;
|
|
2009
|
-
const memberConfig = currentMembership?.config;
|
|
2010
|
-
return { orgConfig: organizationConfig, membershipConfig: memberConfig };
|
|
2011
|
-
}, [currentMembership]);
|
|
2012
|
-
const userConfig = profile?.config;
|
|
2013
|
-
const checkFeature = useCallback(
|
|
2014
|
-
(featureKey) => {
|
|
2015
|
-
const key = featureKey;
|
|
2016
|
-
if (profile?.is_platform_admin) {
|
|
2017
|
-
return { allowed: true, restrictedBy: null };
|
|
2018
|
-
}
|
|
2019
|
-
const membershipValue = membershipConfig?.features?.[key];
|
|
2020
|
-
if (membershipValue === false) return { allowed: false, restrictedBy: "membership" };
|
|
2021
|
-
return { allowed: true, restrictedBy: null };
|
|
2022
|
-
},
|
|
2023
|
-
[profile?.is_platform_admin, membershipConfig]
|
|
2024
|
-
);
|
|
2025
|
-
const hasFeature = useCallback((featureKey) => checkFeature(featureKey).allowed, [checkFeature]);
|
|
2026
|
-
return {
|
|
2027
|
-
orgConfig,
|
|
2028
|
-
membershipConfig,
|
|
2029
|
-
userConfig,
|
|
2030
|
-
hasFeature,
|
|
2031
|
-
checkFeature,
|
|
2032
|
-
isReady: organizationReady
|
|
2033
|
-
};
|
|
2034
|
-
};
|
|
2035
|
-
}
|
|
2036
2000
|
function useSSEConnection({
|
|
2037
2001
|
manager,
|
|
2038
2002
|
connectionKey,
|
|
@@ -2260,7 +2224,9 @@ function useExecutionPanelState({
|
|
|
2260
2224
|
manager,
|
|
2261
2225
|
apiUrl,
|
|
2262
2226
|
limit,
|
|
2263
|
-
onConnectionStatus
|
|
2227
|
+
onConnectionStatus,
|
|
2228
|
+
selectedId: controlledSelectedId,
|
|
2229
|
+
onSelectedIdChange
|
|
2264
2230
|
}) {
|
|
2265
2231
|
const queryClient = useQueryClient();
|
|
2266
2232
|
const navigate = useNavigate();
|
|
@@ -2268,17 +2234,22 @@ function useExecutionPanelState({
|
|
|
2268
2234
|
const [resourceStatusFilter, setResourceStatusFilter] = useState("all");
|
|
2269
2235
|
const { data: executionsData, isLoading, isFetched } = useExecutions(resourceId, resourceStatusFilter, limit);
|
|
2270
2236
|
const { liveExecutions, connected, runningCount, streamingLogs } = useExecutionLogSSE(resourceId, manager, apiUrl);
|
|
2237
|
+
const isControlled = controlledSelectedId !== void 0;
|
|
2271
2238
|
const search = useSearch({ strict: false });
|
|
2272
|
-
const selectedId = search.exec;
|
|
2239
|
+
const selectedId = isControlled ? controlledSelectedId ?? void 0 : search.exec;
|
|
2273
2240
|
const setSelectedId = useCallback(
|
|
2274
2241
|
(id) => {
|
|
2242
|
+
if (isControlled) {
|
|
2243
|
+
onSelectedIdChange?.(id ?? null);
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2275
2246
|
void navigate({
|
|
2276
2247
|
to: ".",
|
|
2277
2248
|
search: { exec: id },
|
|
2278
2249
|
replace: true
|
|
2279
2250
|
});
|
|
2280
2251
|
},
|
|
2281
|
-
[navigate]
|
|
2252
|
+
[isControlled, navigate, onSelectedIdChange]
|
|
2282
2253
|
);
|
|
2283
2254
|
const executions = executionsData?.executions || [];
|
|
2284
2255
|
const prevExecutionCountRef = useRef(0);
|
|
@@ -3161,7 +3132,7 @@ function useBatchTelemetry() {
|
|
|
3161
3132
|
const { apiRequest, isReady, organizationId } = useElevasisServices();
|
|
3162
3133
|
return useQuery({
|
|
3163
3134
|
queryKey: ["acq-batch-telemetry", organizationId],
|
|
3164
|
-
queryFn: () => apiRequest("/acquisition/
|
|
3135
|
+
queryFn: () => apiRequest("/acquisition/lists/telemetry"),
|
|
3165
3136
|
enabled: isReady
|
|
3166
3137
|
});
|
|
3167
3138
|
}
|
|
@@ -3205,4 +3176,4 @@ function useDeleteDeal() {
|
|
|
3205
3176
|
});
|
|
3206
3177
|
}
|
|
3207
3178
|
|
|
3208
|
-
export { CredentialNameSchema, OperationsService, UuidSchema, calibrationKeys,
|
|
3179
|
+
export { CredentialNameSchema, OperationsService, UuidSchema, calibrationKeys, dealKeys, dealNoteKeys, dealTaskKeys, executionsKeys, isSessionCapable, operationsKeys, scheduleKeys, sessionsKeys, showApiErrorNotification, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, sortData, useActivities, useActivityTrend, useAllCalibrationProjects, useArchiveSession, useArchivedLogs, useBatchDelete, useBatchTelemetry, useBatchedResourcesHealth, useBulkDeleteExecutions, useBusinessImpact, useCalibrationProject, useCalibrationProjects, useCalibrationRun, useCalibrationRunFull, useCalibrationRuns, useCalibrationSSE, useCancelExecution, useCancelSchedule, useCheckpointTasks, useCommandQueue, useCommandQueueTotals, useCommandViewData, useCommandViewLayout, useCommandViewStats, useCommandViewStore, useCompleteDealTask, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateDealNote, useCreateDealTask, useCreateProject, useCreateRun, useCreateSchedule, useCreateSession, useDashboardMetrics, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDeleteDeal, useDeleteExecution, useDeleteProject, useDeleteRun, useDeleteSchedule, useDeleteSession, useDeleteTask, useDeploymentDocs, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorNotification, useExecuteAsync, useExecuteRun, useExecuteWorkflow, useExecution, useExecutionHealth, useExecutionLogSSE, useExecutionLogs, useExecutionPanelState, useExecutions, useGetExecutionHistory, useGetSchedule, useGradeRun, useGraphStats, useListSchedules, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications, usePaginationState, usePatchTask, usePauseSchedule, useRecentExecutionsByResource, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResourceErrors, useResourceExecutions, useResources, useResourcesHealth, useResumeSchedule, useRetryExecution, useSSEConnection, useScheduledTasks, useSession, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket, useSessions, useSortedData, useSubmitAction, useSuccessNotification, useSyncDealStage, useTableSelection, useTableSort, useTestNotification, useTopFailingResources, useUnresolveError, useUnresolvedErrors, useUpdateAnchor, useUpdateProject, useUpdateSchedule, useWarningNotification };
|
|
@@ -2,7 +2,7 @@ import { useCyberColors } from './chunk-JHVKGZ2P.js';
|
|
|
2
2
|
import { GlowDot } from './chunk-MCA6LOGM.js';
|
|
3
3
|
import { Graph_module_css_default, useDirectedChainHighlighting, useNodeSelection, useFitViewTrigger } from './chunk-F6RBK7NJ.js';
|
|
4
4
|
import { STATUS_COLORS, getStatusIcon, formatDuration, getStatusColors, AGENT_CONSTANTS, shouldAnimateEdge, TIMELINE_CONSTANTS, calculateBarPosition, CONTAINER_CONSTANTS, useExecutionPath, useUnifiedWorkflowLayout, WORKFLOW_CONSTANTS, useReactFlowAgent } from './chunk-XA34RETF.js';
|
|
5
|
-
import { glassBase } from './chunk-
|
|
5
|
+
import { glassBase } from './chunk-TXPUIHX2.js';
|
|
6
6
|
import { memo, useMemo, useEffect, useState, useCallback, Fragment } from 'react';
|
|
7
7
|
import { Paper, Stack, Text, Group, Badge, Box, useComputedColorScheme, Card, ActionIcon, Loader, SegmentedControl } from '@mantine/core';
|
|
8
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { SubshellContainer, SubshellSidebar, SubshellRightSideContainer } from './chunk-5COLSYBE.js';
|
|
2
|
+
import { ApiClientProvider, useApiClient } from './chunk-NVOCKXUQ.js';
|
|
3
|
+
import { OrganizationProvider } from './chunk-W4VYXIN7.js';
|
|
4
|
+
import { getErrorInfo, getErrorTitle, formatErrorMessage } from './chunk-IOKL7BKE.js';
|
|
5
|
+
import { useInitialization, InitializationProvider } from './chunk-TUXTSEAF.js';
|
|
6
|
+
import { useOrganization } from './chunk-DD3CCMCZ.js';
|
|
7
|
+
import { ProfileProvider, ElevasisServiceProvider } from './chunk-QEPXAWE2.js';
|
|
8
|
+
import { useAuthContext } from './chunk-BRJ3QZ4E.js';
|
|
9
|
+
import { useRouterContext } from './chunk-Q7DJKLEN.js';
|
|
10
|
+
import { createContext, lazy, useContext, useMemo, useCallback, Suspense, useRef } from 'react';
|
|
11
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
12
|
+
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
|
13
|
+
|
|
14
|
+
var consoleAdapter = {
|
|
15
|
+
success(title, message) {
|
|
16
|
+
console.log(`[Notification][Success] ${title}: ${message}`);
|
|
17
|
+
},
|
|
18
|
+
error(title, message) {
|
|
19
|
+
console.warn(`[Notification][Error] ${title}: ${message}`);
|
|
20
|
+
},
|
|
21
|
+
info(title, message) {
|
|
22
|
+
console.log(`[Notification][Info] ${title}: ${message}`);
|
|
23
|
+
},
|
|
24
|
+
warning(title, message) {
|
|
25
|
+
console.warn(`[Notification][Warning] ${title}: ${message}`);
|
|
26
|
+
},
|
|
27
|
+
apiError(error) {
|
|
28
|
+
const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
|
|
29
|
+
const title = getErrorTitle(code);
|
|
30
|
+
const formatted = formatErrorMessage(message, requestId, fields, retryAfter);
|
|
31
|
+
console.warn(`[Notification][API Error] ${title}: ${formatted}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var NotificationContext = createContext(consoleAdapter);
|
|
35
|
+
function NotificationProvider({ adapter, children }) {
|
|
36
|
+
return /* @__PURE__ */ jsx(NotificationContext.Provider, { value: adapter, children });
|
|
37
|
+
}
|
|
38
|
+
function useNotificationAdapter() {
|
|
39
|
+
return useContext(NotificationContext);
|
|
40
|
+
}
|
|
41
|
+
var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-I32JCNE7.js').then((m) => ({ default: m.CoreAuthKitInner })));
|
|
42
|
+
var defaultQueryClient = null;
|
|
43
|
+
function getDefaultQueryClient() {
|
|
44
|
+
if (!defaultQueryClient) {
|
|
45
|
+
defaultQueryClient = new QueryClient({
|
|
46
|
+
defaultOptions: { queries: { retry: 1 } }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return defaultQueryClient;
|
|
50
|
+
}
|
|
51
|
+
var consoleNotificationAdapter = {
|
|
52
|
+
success(title, message) {
|
|
53
|
+
console.log(`[Notification][Success] ${title}: ${message}`);
|
|
54
|
+
},
|
|
55
|
+
error(title, message) {
|
|
56
|
+
console.warn(`[Notification][Error] ${title}: ${message}`);
|
|
57
|
+
},
|
|
58
|
+
info(title, message) {
|
|
59
|
+
console.log(`[Notification][Info] ${title}: ${message}`);
|
|
60
|
+
},
|
|
61
|
+
warning(title, message) {
|
|
62
|
+
console.warn(`[Notification][Warning] ${title}: ${message}`);
|
|
63
|
+
},
|
|
64
|
+
apiError(error) {
|
|
65
|
+
console.warn(`[Notification][API Error]`, error);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function ElevasisCoreProvider({
|
|
69
|
+
auth,
|
|
70
|
+
queryClient,
|
|
71
|
+
apiUrl,
|
|
72
|
+
onError,
|
|
73
|
+
notifications,
|
|
74
|
+
children
|
|
75
|
+
}) {
|
|
76
|
+
if (auth.mode === "apiKey") {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' mode is supported.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
|
|
82
|
+
const content = apiUrl ? /* @__PURE__ */ jsx(ServiceStack, { apiUrl, onError, notifications, children }) : children;
|
|
83
|
+
const AuthInner = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) });
|
|
84
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: AuthInner });
|
|
85
|
+
}
|
|
86
|
+
function ServiceStack({
|
|
87
|
+
apiUrl,
|
|
88
|
+
onError,
|
|
89
|
+
notifications,
|
|
90
|
+
children
|
|
91
|
+
}) {
|
|
92
|
+
const { getAccessToken } = useAuthContext();
|
|
93
|
+
const orgIdRef = useRef(null);
|
|
94
|
+
const getOrganizationId = useRef(() => orgIdRef.current).current;
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
ApiClientProvider,
|
|
97
|
+
{
|
|
98
|
+
getAccessToken,
|
|
99
|
+
getOrganizationId,
|
|
100
|
+
isOrganizationReady: false,
|
|
101
|
+
onError,
|
|
102
|
+
children: /* @__PURE__ */ jsx(ServiceStackInner, { apiUrl, orgIdRef, notifications, children })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function ServiceStackInner({
|
|
107
|
+
apiUrl,
|
|
108
|
+
orgIdRef,
|
|
109
|
+
notifications,
|
|
110
|
+
children
|
|
111
|
+
}) {
|
|
112
|
+
const { apiRequest } = useApiClient(apiUrl);
|
|
113
|
+
const resolvedNotifications = notifications ?? consoleNotificationAdapter;
|
|
114
|
+
return /* @__PURE__ */ jsx(ProfileProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrganizationProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrgServiceBridge, { orgIdRef, apiRequest, notifications: resolvedNotifications, children }) }) });
|
|
115
|
+
}
|
|
116
|
+
function OrgServiceBridge({
|
|
117
|
+
orgIdRef,
|
|
118
|
+
apiRequest,
|
|
119
|
+
notifications,
|
|
120
|
+
children
|
|
121
|
+
}) {
|
|
122
|
+
const { currentWorkOSOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
|
|
123
|
+
orgIdRef.current = currentWorkOSOrganizationId;
|
|
124
|
+
const isReady = !!currentWorkOSOrganizationId && !isInitializing && !isOrgRefreshing;
|
|
125
|
+
return /* @__PURE__ */ jsx(ElevasisServiceProvider, { apiRequest, organizationId: currentWorkOSOrganizationId, isReady, children: /* @__PURE__ */ jsx(NotificationProvider, { adapter: notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) }) });
|
|
126
|
+
}
|
|
127
|
+
function createUseFeatureAccess({
|
|
128
|
+
useInitialization: useInitialization2,
|
|
129
|
+
useOrganization: useOrganization2
|
|
130
|
+
}) {
|
|
131
|
+
return function useFeatureAccess2() {
|
|
132
|
+
const { profile, organizationReady } = useInitialization2();
|
|
133
|
+
const { currentMembership } = useOrganization2();
|
|
134
|
+
const { orgConfig, membershipConfig } = useMemo(() => {
|
|
135
|
+
const organizationConfig = currentMembership?.organization?.config;
|
|
136
|
+
const memberConfig = currentMembership?.config;
|
|
137
|
+
return { orgConfig: organizationConfig, membershipConfig: memberConfig };
|
|
138
|
+
}, [currentMembership]);
|
|
139
|
+
const userConfig = profile?.config;
|
|
140
|
+
const checkFeature = useCallback(
|
|
141
|
+
(featureKey) => {
|
|
142
|
+
const key = featureKey;
|
|
143
|
+
if (profile?.is_platform_admin) {
|
|
144
|
+
return { allowed: true, restrictedBy: null };
|
|
145
|
+
}
|
|
146
|
+
const membershipValue = membershipConfig?.features?.[key];
|
|
147
|
+
if (membershipValue === false) return { allowed: false, restrictedBy: "membership" };
|
|
148
|
+
return { allowed: true, restrictedBy: null };
|
|
149
|
+
},
|
|
150
|
+
[profile?.is_platform_admin, membershipConfig]
|
|
151
|
+
);
|
|
152
|
+
const hasFeature = useCallback((featureKey) => checkFeature(featureKey).allowed, [checkFeature]);
|
|
153
|
+
return {
|
|
154
|
+
orgConfig,
|
|
155
|
+
membershipConfig,
|
|
156
|
+
userConfig,
|
|
157
|
+
hasFeature,
|
|
158
|
+
checkFeature,
|
|
159
|
+
isReady: organizationReady
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var useFeatureAccess = createUseFeatureAccess({
|
|
164
|
+
useInitialization,
|
|
165
|
+
useOrganization
|
|
166
|
+
});
|
|
167
|
+
var ElevasisFeaturesContext = createContext(null);
|
|
168
|
+
function useElevasisFeatures() {
|
|
169
|
+
const context = useContext(ElevasisFeaturesContext);
|
|
170
|
+
if (!context) {
|
|
171
|
+
throw new Error(
|
|
172
|
+
"useElevasisFeatures must be used within an ElevasisFeaturesProvider. Wrap your app (or the relevant subtree) with <ElevasisFeaturesProvider>."
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return context;
|
|
176
|
+
}
|
|
177
|
+
function getEnabledFeatures(features, hasFeature) {
|
|
178
|
+
return features.filter((feature) => hasFeature(feature.key));
|
|
179
|
+
}
|
|
180
|
+
function getNavItems(features) {
|
|
181
|
+
return features.flatMap((feature) => feature.navEntry ? [feature.navEntry] : []);
|
|
182
|
+
}
|
|
183
|
+
function ElevasisFeaturesProvider({
|
|
184
|
+
features,
|
|
185
|
+
timeRange,
|
|
186
|
+
operationsApiUrl,
|
|
187
|
+
operationsSSEManager,
|
|
188
|
+
children
|
|
189
|
+
}) {
|
|
190
|
+
const { hasFeature } = useFeatureAccess();
|
|
191
|
+
const enabledFeatures = useMemo(() => getEnabledFeatures(features, hasFeature), [features, hasFeature]);
|
|
192
|
+
const navItems = useMemo(() => getNavItems(enabledFeatures), [enabledFeatures]);
|
|
193
|
+
const getFeature = useCallback(
|
|
194
|
+
(key) => features.find((feature) => feature.key === key),
|
|
195
|
+
[features]
|
|
196
|
+
);
|
|
197
|
+
const isFeatureEnabled = useCallback(
|
|
198
|
+
(key) => enabledFeatures.some((feature) => feature.key === key),
|
|
199
|
+
[enabledFeatures]
|
|
200
|
+
);
|
|
201
|
+
const value = useMemo(
|
|
202
|
+
() => ({
|
|
203
|
+
navItems,
|
|
204
|
+
enabledFeatures,
|
|
205
|
+
allFeatures: features,
|
|
206
|
+
timeRange,
|
|
207
|
+
operationsApiUrl,
|
|
208
|
+
operationsSSEManager,
|
|
209
|
+
isFeatureEnabled,
|
|
210
|
+
getFeature
|
|
211
|
+
}),
|
|
212
|
+
[navItems, enabledFeatures, features, timeRange, operationsApiUrl, operationsSSEManager, isFeatureEnabled, getFeature]
|
|
213
|
+
);
|
|
214
|
+
return /* @__PURE__ */ jsx(ElevasisFeaturesContext.Provider, { value, children });
|
|
215
|
+
}
|
|
216
|
+
function isRouteMatch(currentPath, route) {
|
|
217
|
+
return currentPath.startsWith(route);
|
|
218
|
+
}
|
|
219
|
+
function resolveFeatureShellFeature(features, currentPath) {
|
|
220
|
+
for (const feature of features) {
|
|
221
|
+
if (!feature.sidebar || !feature.subshellRoutes?.length) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (feature.subshellRoutes.some((route) => isRouteMatch(currentPath, route))) {
|
|
225
|
+
return feature;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
function FeatureShell({ children }) {
|
|
231
|
+
const { enabledFeatures } = useElevasisFeatures();
|
|
232
|
+
const { currentPath } = useRouterContext();
|
|
233
|
+
const matchedFeature = useMemo(
|
|
234
|
+
() => resolveFeatureShellFeature(enabledFeatures, currentPath),
|
|
235
|
+
[enabledFeatures, currentPath]
|
|
236
|
+
);
|
|
237
|
+
if (!matchedFeature?.sidebar) {
|
|
238
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
239
|
+
}
|
|
240
|
+
const SidebarComponent = matchedFeature.sidebar;
|
|
241
|
+
return /* @__PURE__ */ jsxs(SubshellContainer, { children: [
|
|
242
|
+
/* @__PURE__ */ jsx(SubshellSidebar, { width: 250, children: /* @__PURE__ */ jsx(SidebarComponent, {}) }),
|
|
243
|
+
/* @__PURE__ */ jsx(SubshellRightSideContainer, { children })
|
|
244
|
+
] });
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { ElevasisCoreProvider, ElevasisFeaturesProvider, FeatureShell, NotificationProvider, createUseFeatureAccess, useElevasisFeatures, useNotificationAdapter };
|