@datalayer/core 1.1.47 → 1.1.48
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/lib/components/principal/PrincipalSwitcherMenu.js +1 -1
- package/lib/components/progress/SpinnerBar.d.ts +2 -0
- package/lib/components/progress/{ProgressBar.js → SpinnerBar.js} +4 -4
- package/lib/components/progress/index.d.ts +1 -1
- package/lib/components/progress/index.js +1 -1
- package/lib/components/subnav/SubNav.d.ts +1 -1
- package/lib/config/Configuration.js +1 -1
- package/lib/hooks/useCache.d.ts +2 -2
- package/lib/otel/client/OtelClient.js +5 -1
- package/lib/utils/Date.js +4 -1
- package/lib/views/iam/SignInSimple.js +30 -4
- package/package.json +1 -1
- package/lib/components/progress/ProgressBar.d.ts +0 -2
|
@@ -277,7 +277,7 @@ export function PrincipalSwitcherMenu({ maxLabelChars = 48, fullWidth = true, sh
|
|
|
277
277
|
}, children: _jsx(Text, { sx: {
|
|
278
278
|
color: 'accent.fg',
|
|
279
279
|
fontWeight: 'semibold',
|
|
280
|
-
}, children: selectedPrincipalLabelClosed }) }), isPlatformAdmin && isCurrentUserPrincipal ? (_jsx(Label, { variant: "secondary", size: "small", sx: adminBadgeSx, children: "admin" })) : null] }) })) }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsxs(ActionList, { children: [_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "Personal" }), _jsxs(ActionList.Item, { disabled: isCurrentUserPrincipal, selected: isCurrentUserPrincipal, sx: isCurrentUserPrincipal ? selectedItemSx : undefined, onSelect: () => {
|
|
280
|
+
}, children: selectedPrincipalLabelClosed }) }), isPlatformAdmin && isCurrentUserPrincipal ? (_jsx(Label, { variant: "secondary", size: "small", sx: adminBadgeSx, children: "admin" })) : null] }) })) }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsxs(ActionList, { selectionVariant: "single", children: [_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "Personal" }), _jsxs(ActionList.Item, { disabled: isCurrentUserPrincipal, selected: isCurrentUserPrincipal, sx: isCurrentUserPrincipal ? selectedItemSx : undefined, onSelect: () => {
|
|
281
281
|
if (isCurrentUserPrincipal) {
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
@@ -5,8 +5,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import { useInterval } from 'usehooks-ts';
|
|
8
|
-
import { ProgressBar
|
|
9
|
-
export const
|
|
8
|
+
import { ProgressBar } from '@primer/react';
|
|
9
|
+
export const SpinnerBar = () => {
|
|
10
10
|
const [progress, setProgress] = useState(0);
|
|
11
11
|
useInterval(() => {
|
|
12
12
|
if (progress >= 100) {
|
|
@@ -16,6 +16,6 @@ export const ProgressBar = () => {
|
|
|
16
16
|
setProgress(progress + 1);
|
|
17
17
|
}
|
|
18
18
|
}, 100);
|
|
19
|
-
return _jsx(
|
|
19
|
+
return _jsx(ProgressBar, { progress: progress, "aria-label": "" });
|
|
20
20
|
};
|
|
21
|
-
export default
|
|
21
|
+
export default SpinnerBar;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
export * from './ConsumptionBar.js';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './SpinnerBar.js';
|
|
7
7
|
export * from './ProgressRing.js';
|
|
8
8
|
export * from './Timer.js';
|
|
9
9
|
export * from './consumption.js';
|
|
@@ -68,7 +68,7 @@ export declare const SubNav: React.NamedExoticComponent<{
|
|
|
68
68
|
readonly type: ({ id, children, className, "data-testid": testId, fullWidth, hasShadow, }: SubNavProps) => import("react/jsx-runtime").JSX.Element;
|
|
69
69
|
} & {
|
|
70
70
|
Heading: ({ href, children, className, "data-testid": testID, ...props }: SubNavHeadingProps) => import("react/jsx-runtime").JSX.Element;
|
|
71
|
-
Link: React.ForwardRefExoticComponent<Omit<SubNavLinkProps, "ref"> & React.RefAttributes<
|
|
71
|
+
Link: React.ForwardRefExoticComponent<Omit<SubNavLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement | HTMLDivElement>>;
|
|
72
72
|
Action: typeof _SubNavAction;
|
|
73
73
|
SubMenu: typeof SubMenu;
|
|
74
74
|
testIds: {
|
|
@@ -26,7 +26,7 @@ export class DatalayerConfiguration {
|
|
|
26
26
|
* Default configuration values for Datalayer
|
|
27
27
|
*/
|
|
28
28
|
export const DEFAULT_DATALAYER_CONFIG = {
|
|
29
|
-
datalayerUrl: 'https://
|
|
29
|
+
datalayerUrl: 'https://prod1.datalayer.run',
|
|
30
30
|
credits: 100,
|
|
31
31
|
cpuEnvironment: 'ai-agents-env',
|
|
32
32
|
gpuEnvironment: 'ai-env',
|
package/lib/hooks/useCache.d.ts
CHANGED
|
@@ -744,7 +744,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
744
744
|
selectedPrincipalKind?: "personal" | "organization" | "team";
|
|
745
745
|
}) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
746
746
|
useCreatePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<any, "id">, unknown>;
|
|
747
|
-
useUpdatePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, Pick<any, "name" | "
|
|
747
|
+
useUpdatePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, Pick<any, "name" | "id" | "tags" | "description">, unknown>;
|
|
748
748
|
useDeletePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
749
749
|
useDatasource: (datasourceId: string, options?: {
|
|
750
750
|
principalUid?: string;
|
|
@@ -788,7 +788,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
788
788
|
}) => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
789
789
|
useToken: (tokenId: string) => import("@tanstack/react-query").UseQueryResult<NoInfer<IIAMToken | null | undefined>, Error>;
|
|
790
790
|
useTokens: () => import("@tanstack/react-query").UseQueryResult<NoInfer<(IIAMToken | undefined)[]>, Error>;
|
|
791
|
-
useCreateToken: () => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<IIAMToken, "
|
|
791
|
+
useCreateToken: () => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<IIAMToken, "value" | "id">, unknown>;
|
|
792
792
|
useUpdateToken: () => import("@tanstack/react-query").UseMutationResult<any, Error, IIAMToken, unknown>;
|
|
793
793
|
useDeleteToken: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
794
794
|
useInvite: (token: string) => import("@tanstack/react-query").UseQueryResult<NoInfer<import("..").IInvite | undefined>, Error>;
|
|
@@ -190,7 +190,11 @@ export class OtelClient {
|
|
|
190
190
|
if (filteredTotal > 0 || !serviceName || !fallbackWithoutService) {
|
|
191
191
|
return filteredTotal;
|
|
192
192
|
}
|
|
193
|
-
const unfiltered = await this.fetchMetrics({
|
|
193
|
+
const unfiltered = await this.fetchMetrics({
|
|
194
|
+
metricName,
|
|
195
|
+
limit,
|
|
196
|
+
accountUid,
|
|
197
|
+
});
|
|
194
198
|
return unfiltered.data.reduce((sum, row) => sum + Number(row.value || 0), 0);
|
|
195
199
|
}
|
|
196
200
|
// ── Services ──────────────────────────────────────────────────────────────
|
package/lib/utils/Date.js
CHANGED
|
@@ -99,7 +99,10 @@ export const formatRelativeTime = (value, now = new Date()) => {
|
|
|
99
99
|
if (weeks < 52)
|
|
100
100
|
return withDirection(weeks, 'w');
|
|
101
101
|
const years = Math.floor(days / 365);
|
|
102
|
-
|
|
102
|
+
if (years >= 1)
|
|
103
|
+
return withDirection(years, 'y');
|
|
104
|
+
// Around the year boundary (e.g. 364 days), prefer weeks over "0y".
|
|
105
|
+
return withDirection(weeks, 'w');
|
|
103
106
|
};
|
|
104
107
|
/**
|
|
105
108
|
* Build a detailed datetime string suitable for tooltips.
|
|
@@ -17,6 +17,7 @@ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
|
17
17
|
import { Box, Button, FormControl, Heading, Text, Textarea, TextInput, } from '@primer/react';
|
|
18
18
|
import { EyeIcon, EyeClosedIcon, KeyIcon, LinkExternalIcon, TelescopeIcon, } from '@primer/octicons-react';
|
|
19
19
|
import { GithubMarkIcon, LinkedInGreyIcon } from '@datalayer/icons-react';
|
|
20
|
+
import { useToast } from '../../hooks/index.js';
|
|
20
21
|
import { isInsideJupyterLab } from '../../utils/Jupyter.js';
|
|
21
22
|
const GoogleIcon = () => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid", viewBox: "0 0 256 262", height: "16px", fill: "currentColor", "aria-hidden": "true", children: [_jsx("path", { fill: "currentColor", d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027" }), _jsx("path", { fill: "currentColor", d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1" }), _jsx("path", { fill: "currentColor", d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782" }), _jsx("path", { fill: "currentColor", d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251" })] }));
|
|
22
23
|
const OAUTH2_PROVIDERS = {
|
|
@@ -52,6 +53,21 @@ const getIAMUrlFromDocumentConfig = () => {
|
|
|
52
53
|
return '';
|
|
53
54
|
}
|
|
54
55
|
};
|
|
56
|
+
const getErrorMessage = (error, fallback = 'Unable to start social sign-in.') => {
|
|
57
|
+
if (error instanceof Error && error.message) {
|
|
58
|
+
return error.message;
|
|
59
|
+
}
|
|
60
|
+
if (typeof error === 'string' && error.trim()) {
|
|
61
|
+
return error;
|
|
62
|
+
}
|
|
63
|
+
if (error && typeof error === 'object' && 'message' in error) {
|
|
64
|
+
const message = error.message;
|
|
65
|
+
if (typeof message === 'string' && message.trim()) {
|
|
66
|
+
return message;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return fallback;
|
|
70
|
+
};
|
|
55
71
|
// ── Component ────────────────────────────────────────────────────────
|
|
56
72
|
export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp, name, title = 'Datalayer OTEL', description = 'Sign in to access the observability dashboard.', icon, leadingIcon = _jsx(TelescopeIcon, { size: 24 }), github = false, google = false, linkedin = false, apiKey = false, signUp = true, socialSignInNavigationTarget, }) => {
|
|
57
73
|
const headingText = name ?? title;
|
|
@@ -68,6 +84,7 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
|
|
|
68
84
|
const [loading, setLoading] = useState(false);
|
|
69
85
|
const [socialLoading, setSocialLoading] = useState(false);
|
|
70
86
|
const [error, setError] = useState(null);
|
|
87
|
+
const { enqueueToast } = useToast();
|
|
71
88
|
// API Key dialog state
|
|
72
89
|
const [showApiKeyDialog, setShowApiKeyDialog] = useState(false);
|
|
73
90
|
const [apiKeyValue, setApiKeyValue] = useState('');
|
|
@@ -86,6 +103,9 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
|
|
|
86
103
|
return route.startsWith('/') ? route : '/';
|
|
87
104
|
}, []);
|
|
88
105
|
const startOAuthSignIn = useCallback(async (providerSpec) => {
|
|
106
|
+
if (socialLoading) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
89
109
|
setError(null);
|
|
90
110
|
setSocialLoading(true);
|
|
91
111
|
try {
|
|
@@ -120,12 +140,18 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
|
|
|
120
140
|
window.location.assign(authorizationURL);
|
|
121
141
|
}
|
|
122
142
|
catch (err) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
143
|
+
const message = getErrorMessage(err);
|
|
144
|
+
setError(message);
|
|
145
|
+
enqueueToast(message, { variant: 'error' });
|
|
126
146
|
setSocialLoading(false);
|
|
127
147
|
}
|
|
128
|
-
}, [
|
|
148
|
+
}, [
|
|
149
|
+
buildCallbackURI,
|
|
150
|
+
currentRelativeRoute,
|
|
151
|
+
enqueueToast,
|
|
152
|
+
socialLoading,
|
|
153
|
+
socialSignInNavigationTarget,
|
|
154
|
+
]);
|
|
129
155
|
useEffect(() => {
|
|
130
156
|
if (showApiKeyDialog) {
|
|
131
157
|
apiKeyRef.current?.focus();
|
package/package.json
CHANGED