@datalayer/core 0.0.24 → 0.0.26

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.
Files changed (70) hide show
  1. package/README.md +11 -11
  2. package/lib/api/index.d.ts +1 -1
  3. package/lib/api/index.js +1 -1
  4. package/lib/api/spacer/agentSpaces.d.ts +193 -0
  5. package/lib/api/spacer/agentSpaces.js +127 -0
  6. package/lib/api/spacer/index.d.ts +2 -1
  7. package/lib/api/spacer/index.js +2 -1
  8. package/lib/api/utils/validation.d.ts +1 -1
  9. package/lib/api/utils/validation.js +1 -1
  10. package/lib/client/auth/AuthenticationManager.d.ts +2 -2
  11. package/lib/client/auth/AuthenticationManager.js +2 -2
  12. package/lib/client/auth/index.d.ts +1 -1
  13. package/lib/client/auth/index.js +1 -1
  14. package/lib/client/auth/types.d.ts +1 -1
  15. package/lib/client/auth/types.js +1 -1
  16. package/lib/client/base.d.ts +9 -9
  17. package/lib/client/base.js +3 -3
  18. package/lib/client/constants.d.ts +2 -2
  19. package/lib/client/constants.js +2 -2
  20. package/lib/client/index.d.ts +2 -2
  21. package/lib/client/mixins/IAMMixin.js +1 -1
  22. package/lib/client/utils/spacerUtils.d.ts +1 -1
  23. package/lib/client/utils/spacerUtils.js +1 -1
  24. package/lib/components/progress/ConsumptionBar.js +19 -1
  25. package/lib/hooks/useCache.d.ts +95 -2
  26. package/lib/hooks/useCache.js +422 -9
  27. package/lib/hooks/useNavigate.d.ts +1 -1
  28. package/lib/hooks/useNavigate.js +11 -1
  29. package/lib/index.d.ts +1 -1
  30. package/lib/models/CreditsDTO.js +1 -1
  31. package/lib/models/Datasource.d.ts +2 -2
  32. package/lib/models/Datasource.js +2 -2
  33. package/lib/models/EnvironmentDTO.d.ts +3 -3
  34. package/lib/models/EnvironmentDTO.js +2 -2
  35. package/lib/models/HealthCheck.d.ts +1 -1
  36. package/lib/models/HealthCheck.js +1 -1
  37. package/lib/models/ItemDTO.d.ts +2 -2
  38. package/lib/models/ItemDTO.js +2 -2
  39. package/lib/models/LexicalDTO.d.ts +2 -2
  40. package/lib/models/LexicalDTO.js +2 -2
  41. package/lib/models/NotebookDTO.d.ts +2 -2
  42. package/lib/models/NotebookDTO.js +1 -1
  43. package/lib/models/RuntimeDTO.d.ts +2 -2
  44. package/lib/models/RuntimeDTO.js +2 -2
  45. package/lib/models/RuntimeSnapshotDTO.d.ts +3 -3
  46. package/lib/models/RuntimeSnapshotDTO.js +1 -1
  47. package/lib/models/Secret.d.ts +3 -3
  48. package/lib/models/Secret.js +2 -2
  49. package/lib/models/SpaceDTO.d.ts +2 -2
  50. package/lib/models/SpaceDTO.js +3 -3
  51. package/lib/models/UserDTO.d.ts +2 -2
  52. package/lib/models/UserDTO.js +1 -1
  53. package/lib/models/index.d.ts +1 -1
  54. package/lib/models/index.js +1 -1
  55. package/lib/state/substates/CoreState.js +1 -1
  56. package/lib/theme/DatalayerTheme.d.ts +17 -2
  57. package/lib/theme/DatalayerTheme.js +195 -29
  58. package/lib/theme/DatalayerThemeProvider.d.ts +22 -2
  59. package/lib/theme/DatalayerThemeProvider.js +48 -5
  60. package/lib/theme/index.d.ts +1 -0
  61. package/lib/theme/index.js +1 -0
  62. package/lib/theme/useSystemColorMode.d.ts +9 -0
  63. package/lib/theme/useSystemColorMode.js +26 -0
  64. package/lib/views/iam-tokens/IAMTokenNew.d.ts +5 -1
  65. package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
  66. package/lib/views/iam-tokens/IAMTokens.d.ts +7 -1
  67. package/lib/views/iam-tokens/IAMTokens.js +6 -4
  68. package/package.json +3 -3
  69. package/lib/hooks/useCache0.d.ts +0 -312
  70. package/lib/hooks/useCache0.js +0 -3189
@@ -5,58 +5,224 @@
5
5
  import { theme as primerTheme } from '@primer/react';
6
6
  import cloneDeep from 'lodash/cloneDeep.js';
7
7
  import merge from 'lodash/merge.js';
8
+ /**
9
+ * Datalayer Accessible Color System
10
+ * Based on Datalayer's brand manual - WCAG AA/AAA compliant
11
+ */
12
+ export const datalayerColors = {
13
+ // Core Neutrals
14
+ black: '#000000', // Primary text - AAA on white
15
+ gray: '#59595C', // Secondary text - AA on white
16
+ white: '#FFFFFF', // Background
17
+ // Greens (Brand & Accessibility)
18
+ greenBrand: '#16A085', // Brand accent, icons, dividers, headings
19
+ greenAccent: '#1ABC9C', // Icons, charts, highlights on dark surfaces
20
+ greenText: '#117A65', // Accessible green for text & buttons (AA+ on white)
21
+ greenTint: '#E9F7F1', // Soft background for success / callouts
22
+ greenBright: '#2ECC71', // Highlights and glow on dark backgrounds
23
+ greenHover: '#0E6655', // Primary button hover
24
+ };
8
25
  /**
9
26
  * Datalayer Theme for Primer React.
27
+ *
28
+ * Uses accessible color palette from Datalayer's brand manual.
10
29
  */
11
30
  const datalayerThemeDefs = {
12
31
  colorSchemes: {
13
32
  light: {
14
33
  colors: {
34
+ // Canvas colors
35
+ canvas: {
36
+ default: datalayerColors.white,
37
+ // subtle: datalayerColors.greenTint,
38
+ },
39
+ // Foreground colors
40
+ fg: {
41
+ default: datalayerColors.black,
42
+ muted: datalayerColors.gray,
43
+ onEmphasis: datalayerColors.white,
44
+ },
45
+ // Accent colors (brand green)
46
+ accent: {
47
+ fg: datalayerColors.greenText,
48
+ emphasis: datalayerColors.greenBrand,
49
+ muted: datalayerColors.greenAccent,
50
+ // subtle: datalayerColors.greenTint,
51
+ },
52
+ // Success colors (green)
53
+ success: {
54
+ fg: datalayerColors.greenText,
55
+ emphasis: datalayerColors.greenBrand,
56
+ muted: datalayerColors.greenAccent,
57
+ // subtle: datalayerColors.greenTint,
58
+ },
59
+ // Button colors
15
60
  btn: {
16
- // text: 'var(--jp-ui-font-color1, rgba(0, 0, 0, 0.87))',
17
- // bg: 'var(--jp-layout-color1, white)',
18
- // border: 'var(--jp-border-color1, #bdbdbd)',
19
- // hoverBg: 'var(--jp-layout-color2, #eee)',
20
- // hoverBorder: 'var(--jp-border-color1, #bdbdbd)',
21
- // activeBg: 'var(--jp-layout-color3, #bdbdbd)',
22
- // activeBorder: 'var(--jp-border-color1, #bdbdbd)',
23
- // selectedBg: 'var(--jp-layout-color0, white)',
24
- // counterBg: 'var(--jp-layout-color4, #757575)',
61
+ text: datalayerColors.black,
62
+ bg: datalayerColors.white,
63
+ border: datalayerColors.gray,
64
+ hoverBg: datalayerColors.greenTint,
65
+ hoverBorder: datalayerColors.gray,
66
+ activeBg: datalayerColors.greenTint,
67
+ activeBorder: datalayerColors.gray,
68
+ selectedBg: datalayerColors.white,
69
+ counterBg: datalayerColors.gray,
25
70
  primary: {
26
- // text: 'var(--jp-ui-inverse-font-color1, rgba(255, 255, 255, 1))',
27
- bg: 'var(--dla-color-green-dark)',
28
- // border: 'var(--dla-color-green-light)',
29
- hoverBg: 'var(--dla-color-grey)',
30
- // hoverBorder: 'var(--dla-color-green-light)',
31
- selectedBg: 'var(--dla-color-black)',
32
- // disabledText: 'var(--jp-ui-inverse-font-color2, rgba(255, 255, 255, 0.7))',
33
- // disabledBg: 'var(--jp-brand-color3, #c8e6c9)',
34
- // disabledBorder: 'var(--jp-border-color1, #bdbdbd)',
35
- // icon: 'var(--jp-ui-inverse-font-color2, rgba(255, 255, 255, 0.7))',
36
- // counterBg: 'var(--jp-inverse-layout-color3, #616161)',
71
+ text: datalayerColors.white,
72
+ bg: datalayerColors.greenText,
73
+ border: datalayerColors.greenText,
74
+ hoverBg: datalayerColors.greenHover,
75
+ hoverBorder: datalayerColors.greenHover,
76
+ selectedBg: datalayerColors.greenHover,
77
+ disabledText: 'rgba(255, 255, 255, 0.7)',
78
+ disabledBg: datalayerColors.gray,
79
+ disabledBorder: datalayerColors.gray,
80
+ icon: datalayerColors.white,
81
+ counterBg: 'rgba(0, 0, 0, 0.2)',
82
+ },
83
+ outline: {
84
+ text: datalayerColors.greenText,
85
+ hoverText: datalayerColors.white,
86
+ hoverBg: datalayerColors.greenText,
87
+ hoverBorder: datalayerColors.greenText,
88
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
89
+ selectedText: datalayerColors.white,
90
+ selectedBg: datalayerColors.greenHover,
91
+ selectedBorder: datalayerColors.greenHover,
92
+ disabledText: datalayerColors.gray,
93
+ disabledBg: datalayerColors.greenTint,
94
+ disabledCounterBg: 'rgba(0, 0, 0, 0.05)',
95
+ counterBg: 'rgba(0, 0, 0, 0.05)',
96
+ counterFg: datalayerColors.greenText,
97
+ hoverCounterFg: datalayerColors.white,
98
+ disabledCounterFg: datalayerColors.gray,
99
+ },
100
+ danger: {
101
+ text: '#d32f2f',
102
+ hoverText: datalayerColors.white,
103
+ hoverBg: '#d32f2f',
104
+ hoverBorder: '#d32f2f',
105
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
106
+ selectedText: datalayerColors.white,
107
+ selectedBg: '#b71c1c',
108
+ selectedBorder: '#b71c1c',
109
+ disabledText: 'rgba(211, 47, 47, 0.5)',
110
+ disabledBg: datalayerColors.greenTint,
111
+ disabledCounterBg: 'rgba(211, 47, 47, 0.05)',
112
+ counterBg: 'rgba(211, 47, 47, 0.1)',
113
+ counterFg: '#d32f2f',
114
+ hoverCounterFg: datalayerColors.white,
115
+ disabledCounterFg: 'rgba(211, 47, 47, 0.5)',
116
+ icon: '#d32f2f',
37
117
  },
38
118
  },
39
119
  },
40
120
  shadows: {},
41
121
  },
42
122
  dark: {
43
- colors: {},
123
+ colors: {
124
+ // Canvas colors
125
+ canvas: {
126
+ default: datalayerColors.black,
127
+ subtle: '#0d1117',
128
+ },
129
+ // Foreground colors
130
+ fg: {
131
+ default: datalayerColors.white,
132
+ muted: '#8b949e',
133
+ onEmphasis: datalayerColors.white,
134
+ },
135
+ // Accent colors (bright greens for dark mode)
136
+ accent: {
137
+ fg: datalayerColors.greenAccent,
138
+ emphasis: datalayerColors.greenBright,
139
+ muted: datalayerColors.greenBrand,
140
+ subtle: '#1f352d',
141
+ },
142
+ // Success colors
143
+ success: {
144
+ fg: datalayerColors.greenAccent,
145
+ emphasis: datalayerColors.greenBright,
146
+ muted: datalayerColors.greenBrand,
147
+ subtle: '#1f352d',
148
+ },
149
+ // Button colors for dark mode
150
+ btn: {
151
+ text: '#c9d1d9',
152
+ bg: '#21262d',
153
+ border: 'rgba(240, 246, 252, 0.1)',
154
+ hoverBg: '#30363d',
155
+ hoverBorder: '#8b949e',
156
+ activeBg: 'hsla(212, 12%, 18%, 1)',
157
+ activeBorder: '#6e7681',
158
+ selectedBg: '#161b22',
159
+ counterBg: '#30363d',
160
+ primary: {
161
+ text: datalayerColors.white,
162
+ bg: datalayerColors.greenAccent,
163
+ border: 'rgba(240, 246, 252, 0.1)',
164
+ hoverBg: datalayerColors.greenBright,
165
+ hoverBorder: 'rgba(240, 246, 252, 0.1)',
166
+ selectedBg: datalayerColors.greenBright,
167
+ disabledText: 'rgba(255, 255, 255, 0.5)',
168
+ disabledBg: 'rgba(22, 160, 133, 0.6)',
169
+ disabledBorder: 'rgba(240, 246, 252, 0.1)',
170
+ icon: datalayerColors.white,
171
+ counterBg: 'rgba(0, 0, 0, 0.2)',
172
+ },
173
+ outline: {
174
+ text: datalayerColors.greenAccent,
175
+ hoverText: datalayerColors.white,
176
+ hoverBg: datalayerColors.greenAccent,
177
+ hoverBorder: datalayerColors.greenAccent,
178
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
179
+ selectedText: datalayerColors.white,
180
+ selectedBg: datalayerColors.greenBright,
181
+ selectedBorder: datalayerColors.greenBright,
182
+ disabledText: 'rgba(26, 188, 156, 0.5)',
183
+ disabledBg: 'rgba(26, 188, 156, 0.1)',
184
+ disabledCounterBg: 'rgba(26, 188, 156, 0.05)',
185
+ counterBg: 'rgba(26, 188, 156, 0.1)',
186
+ counterFg: datalayerColors.greenAccent,
187
+ hoverCounterFg: datalayerColors.white,
188
+ disabledCounterFg: 'rgba(26, 188, 156, 0.5)',
189
+ },
190
+ danger: {
191
+ text: '#f85149',
192
+ hoverText: datalayerColors.white,
193
+ hoverBg: '#da3633',
194
+ hoverBorder: '#f85149',
195
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
196
+ selectedText: datalayerColors.white,
197
+ selectedBg: '#b62324',
198
+ selectedBorder: '#ff7b72',
199
+ disabledText: 'rgba(248, 81, 73, 0.5)',
200
+ disabledBg: 'rgba(248, 81, 73, 0.1)',
201
+ disabledCounterBg: 'rgba(248, 81, 73, 0.05)',
202
+ counterBg: 'rgba(248, 81, 73, 0.1)',
203
+ counterFg: '#f85149',
204
+ hoverCounterFg: datalayerColors.white,
205
+ disabledCounterFg: 'rgba(248, 81, 73, 0.5)',
206
+ icon: '#f85149',
207
+ },
208
+ },
209
+ },
44
210
  shadows: {},
45
211
  },
46
212
  },
47
213
  };
48
214
  const { colorSchemes: primerSchemes, ...primerOthers } = cloneDeep(primerTheme);
49
- const { colorSchemes: jupyterSchemes, ...datalayerOthers } = datalayerThemeDefs;
50
- // Merge with the light theme to ensure all variables are defined (although the style may be ugly).
51
- const datalayerTheme = merge(primerOthers, datalayerOthers, {
215
+ const { colorSchemes: datalayerSchemes, ...datalayerOthers } = datalayerThemeDefs;
216
+ // Merge with the light theme to ensure all variables are defined.
217
+ export const datalayerTheme = merge(primerOthers, datalayerOthers, {
52
218
  colorSchemes: { light: {}, dark: {} },
53
219
  });
54
220
  datalayerTheme.colorSchemes.light = {
55
- colors: merge(primerSchemes.light.colors, jupyterSchemes.light.colors),
56
- shadows: merge(primerSchemes.light.shadows, jupyterSchemes.light.shadows),
221
+ colors: merge(primerSchemes.light.colors, datalayerSchemes.light.colors),
222
+ shadows: merge(primerSchemes.light.shadows, datalayerSchemes.light.shadows),
57
223
  };
58
224
  datalayerTheme.colorSchemes.dark = {
59
- colors: merge(primerSchemes.dark.colors, jupyterSchemes.dark.colors),
60
- shadows: merge(primerSchemes.dark.shadows, jupyterSchemes.dark.shadows),
225
+ colors: merge(primerSchemes.dark.colors, datalayerSchemes.dark.colors),
226
+ shadows: merge(primerSchemes.dark.shadows, datalayerSchemes.dark.shadows),
61
227
  };
62
- export { datalayerTheme };
228
+ export default datalayerTheme;
@@ -1,9 +1,29 @@
1
1
  import { type CSSProperties } from 'react';
2
2
  import { ThemeProviderProps } from '@primer/react';
3
- export interface IDatalayerThemeProviderProps extends ThemeProviderProps {
3
+ export interface IDatalayerThemeProviderProps extends Omit<ThemeProviderProps, 'theme' | 'colorMode'> {
4
4
  /**
5
- * Base styles.
5
+ * Color mode to use.
6
+ * - `'light'` / `'dark'` — explicit override
7
+ * - `'auto'` — follow the operating system preference (prefers-color-scheme)
8
+ * - Primer's `'day'` / `'night'` are still accepted.
9
+ */
10
+ colorMode?: 'light' | 'dark' | 'auto' | 'day' | 'night';
11
+ /**
12
+ * Additional base styles merged on top of theme defaults.
6
13
  */
7
14
  baseStyles?: CSSProperties;
15
+ /**
16
+ * Optional Primer theme object. Defaults to the built-in datalayerTheme.
17
+ */
18
+ theme?: Record<string, any>;
19
+ /**
20
+ * Optional per-mode style overrides (base + button CSS vars).
21
+ * When provided, these replace the built-in datalayer styles entirely.
22
+ * The `baseStyles` prop is still merged on top.
23
+ */
24
+ themeStyles?: {
25
+ light: CSSProperties;
26
+ dark: CSSProperties;
27
+ };
8
28
  }
9
29
  export declare function DatalayerThemeProvider(props: React.PropsWithChildren<IDatalayerThemeProviderProps>): JSX.Element;
@@ -1,11 +1,54 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { BaseStyles, ThemeProvider } from '@primer/react';
3
+ import { datalayerTheme, datalayerColors } from './DatalayerTheme';
4
+ import { useSystemColorMode } from './useSystemColorMode';
5
+ const baseStyleLight = {
6
+ backgroundColor: datalayerColors.white,
7
+ color: datalayerColors.black,
8
+ fontSize: 'var(--text-body-size-medium)',
9
+ };
10
+ const baseStyleDark = {
11
+ backgroundColor: datalayerColors.black,
12
+ color: datalayerColors.white,
13
+ fontSize: 'var(--text-body-size-medium)',
14
+ };
15
+ const primaryButtonVarsLight = {
16
+ '--button-primary-bgColor-rest': datalayerColors.greenText,
17
+ '--button-primary-bgColor-hover': datalayerColors.greenHover,
18
+ '--button-primary-bgColor-active': datalayerColors.greenHover,
19
+ '--button-primary-fgColor-rest': datalayerColors.white,
20
+ '--button-primary-borderColor-rest': datalayerColors.greenText,
21
+ '--button-primary-borderColor-hover': datalayerColors.greenHover,
22
+ '--color-btn-primary-bg': datalayerColors.greenText,
23
+ '--color-btn-primary-hover-bg': datalayerColors.greenHover,
24
+ };
25
+ const primaryButtonVarsDark = {
26
+ '--button-primary-bgColor-rest': datalayerColors.greenAccent,
27
+ '--button-primary-bgColor-hover': datalayerColors.greenBright,
28
+ '--button-primary-bgColor-active': datalayerColors.greenBright,
29
+ '--button-primary-fgColor-rest': datalayerColors.white,
30
+ '--button-primary-borderColor-rest': datalayerColors.greenAccent,
31
+ '--button-primary-borderColor-hover': datalayerColors.greenBright,
32
+ '--color-btn-primary-bg': datalayerColors.greenAccent,
33
+ '--color-btn-primary-hover-bg': datalayerColors.greenBright,
34
+ };
3
35
  export function DatalayerThemeProvider(props) {
4
- const { children, colorMode, baseStyles, ...rest } = props;
5
- return (_jsx(ThemeProvider, { colorMode: colorMode, ...rest, children: _jsx(BaseStyles, { style: {
6
- backgroundColor: 'var(--bgColor-default)',
7
- color: 'var(--fgColor-default)',
8
- fontSize: 'var(--text-body-size-medium)',
36
+ const { children, colorMode, baseStyles, theme, themeStyles, ...rest } = props;
37
+ // Resolve 'auto' actual system preference ('light' or 'dark').
38
+ const systemMode = useSystemColorMode();
39
+ const resolvedColorMode = colorMode === 'auto' ? systemMode : (colorMode ?? 'light');
40
+ const isDark = resolvedColorMode === 'dark' || resolvedColorMode === 'night';
41
+ const resolvedTheme = theme ?? datalayerTheme;
42
+ const defaultStyles = isDark
43
+ ? { ...baseStyleDark, ...primaryButtonVarsDark }
44
+ : { ...baseStyleLight, ...primaryButtonVarsLight };
45
+ const resolvedStyles = themeStyles
46
+ ? isDark
47
+ ? themeStyles.dark
48
+ : themeStyles.light
49
+ : defaultStyles;
50
+ return (_jsx(ThemeProvider, { colorMode: resolvedColorMode, theme: resolvedTheme, ...rest, children: _jsx(BaseStyles, { style: {
51
+ ...resolvedStyles,
9
52
  ...baseStyles,
10
53
  }, children: children }) }));
11
54
  }
@@ -1,3 +1,4 @@
1
1
  export * from './DatalayerTheme';
2
2
  export * from './DatalayerThemeProvider';
3
3
  export * from './Palette';
4
+ export * from './useSystemColorMode';
@@ -5,3 +5,4 @@
5
5
  export * from './DatalayerTheme';
6
6
  export * from './DatalayerThemeProvider';
7
7
  export * from './Palette';
8
+ export * from './useSystemColorMode';
@@ -0,0 +1,9 @@
1
+ type ResolvedColorMode = 'light' | 'dark';
2
+ /**
3
+ * React hook that tracks the operating system's preferred color scheme.
4
+ *
5
+ * Listens to `prefers-color-scheme` media query changes and returns
6
+ * either `'light'` or `'dark'`.
7
+ */
8
+ export declare function useSystemColorMode(): ResolvedColorMode;
9
+ export default useSystemColorMode;
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { useEffect, useState } from 'react';
6
+ /**
7
+ * React hook that tracks the operating system's preferred color scheme.
8
+ *
9
+ * Listens to `prefers-color-scheme` media query changes and returns
10
+ * either `'light'` or `'dark'`.
11
+ */
12
+ export function useSystemColorMode() {
13
+ const getMode = () => typeof window !== 'undefined' &&
14
+ window.matchMedia('(prefers-color-scheme: dark)').matches
15
+ ? 'dark'
16
+ : 'light';
17
+ const [mode, setMode] = useState(getMode);
18
+ useEffect(() => {
19
+ const media = window.matchMedia('(prefers-color-scheme: dark)');
20
+ const listener = (e) => setMode(e.matches ? 'dark' : 'light');
21
+ media.addEventListener('change', listener);
22
+ return () => media.removeEventListener('change', listener);
23
+ }, []);
24
+ return mode;
25
+ }
26
+ export default useSystemColorMode;
@@ -1,2 +1,6 @@
1
- export declare const IAMTokenNew: () => import("react/jsx-runtime").JSX.Element;
1
+ export type IAMTokenNewProps = {
2
+ /** Route to navigate when clicking "List my Tokens". Defaults to '/settings/iam/tokens'. */
3
+ tokensListRoute?: string;
4
+ };
5
+ export declare const IAMTokenNew: ({ tokensListRoute, }?: IAMTokenNewProps) => import("react/jsx-runtime").JSX.Element;
2
6
  export default IAMTokenNew;
@@ -10,7 +10,7 @@ import { CopyIcon } from '@primer/octicons-react';
10
10
  import { Calendar, defaultCalendarStrings } from '@fluentui/react';
11
11
  import { useCache, useNavigate, useToast } from '../../hooks';
12
12
  import { useRunStore } from '../../state';
13
- export const IAMTokenNew = () => {
13
+ export const IAMTokenNew = ({ tokensListRoute = '/settings/iam/tokens', } = {}) => {
14
14
  const runStore = useRunStore();
15
15
  const { useCreateToken } = useCache();
16
16
  const createTokenMutation = useCreateToken();
@@ -108,7 +108,7 @@ export const IAMTokenNew = () => {
108
108
  variant: 'success',
109
109
  });
110
110
  }
111
- } })] })] }), _jsx(Box, { mt: 3, children: _jsx(Button, { onClick: e => navigate('/settings/iam/tokens', e), children: "List my Tokens" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(PageHeader, { children: _jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "New IAM Token" }) }) }), _jsx(Box, { display: "grid", gridTemplateColumns: "1fr 1fr", sx: { gap: 3 }, children: _jsx(Box, { children: _jsxs(Box, { sx: { label: { marginTop: 2 } }, children: [_jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Token type" }), _jsx(Select, { name: "type", value: formValues.variant, onChange: valueVariantChange, children: _jsx(Select.Option, { value: "user_token", children: "User Token" }) }), _jsx(FormControl.Caption, { children: "Pick the most appropriate token type." })] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Name" }), _jsx(TextInput, { block: true, value: formValues.name, onChange: valueNameChange, autoFocus: true }), _jsx(FormControl.Caption, { children: "Hint: The token name is a short name that identifies in a unique way your token." }), validationResult.name === false && (_jsx(FormControl.Validation, { variant: "error", children: "Name length must be between 2 and 32 characters." }))] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Expiration day" }), _jsx(Calendar, { showGoToToday: true, onSelectDate: expirationDateChange, value: formValues.expirationDate, strings: defaultCalendarStrings }), validationResult.expirationDate !== true ? (_jsx(FormControl.Validation, { variant: "error", children: "Pick an expiration date in the future." })) : (_jsxs(FormControl.Validation, { variant: "success", children: ["Expiration date:", ' ', formValues.expirationDate?.toLocaleDateString(), "."] }))] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Description" }), _jsx(Textarea, { block: true, value: formValues.description, onChange: valueDescriptionChange }), validationResult.description === false && (_jsx(FormControl.Validation, { variant: "error", children: "Description must have more than 2 characters." }))] }), _jsx(Button, { variant: "primary", disabled: !validationResult.name ||
111
+ } })] })] }), _jsx(Box, { mt: 3, children: _jsx(Button, { onClick: e => navigate(tokensListRoute, e), children: "List my Tokens" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(PageHeader, { children: _jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "New IAM Token" }) }) }), _jsx(Box, { display: "grid", gridTemplateColumns: "1fr 1fr", sx: { gap: 3 }, children: _jsx(Box, { children: _jsxs(Box, { sx: { label: { marginTop: 2 } }, children: [_jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Token type" }), _jsx(Select, { name: "type", value: formValues.variant, onChange: valueVariantChange, children: _jsx(Select.Option, { value: "user_token", children: "User Token" }) }), _jsx(FormControl.Caption, { children: "Pick the most appropriate token type." })] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Name" }), _jsx(TextInput, { block: true, value: formValues.name, onChange: valueNameChange, autoFocus: true }), _jsx(FormControl.Caption, { children: "Hint: The token name is a short name that identifies in a unique way your token." }), validationResult.name === false && (_jsx(FormControl.Validation, { variant: "error", children: "Name length must be between 2 and 32 characters." }))] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Expiration day" }), _jsx(Calendar, { showGoToToday: true, onSelectDate: expirationDateChange, value: formValues.expirationDate, strings: defaultCalendarStrings }), validationResult.expirationDate !== true ? (_jsx(FormControl.Validation, { variant: "error", children: "Pick an expiration date in the future." })) : (_jsxs(FormControl.Validation, { variant: "success", children: ["Expiration date:", ' ', formValues.expirationDate?.toLocaleDateString(), "."] }))] }), _jsxs(FormControl, { required: true, children: [_jsx(FormControl.Label, { children: "Description" }), _jsx(Textarea, { block: true, value: formValues.description, onChange: valueDescriptionChange }), validationResult.description === false && (_jsx(FormControl.Validation, { variant: "error", children: "Description must have more than 2 characters." }))] }), _jsx(Button, { variant: "primary", disabled: !validationResult.name ||
112
112
  !validationResult.description ||
113
113
  !validationResult.expirationDate, sx: { marginTop: 2 }, onClick: e => {
114
114
  e.preventDefault();
@@ -1,2 +1,8 @@
1
- export declare const IAMTokens: () => import("react/jsx-runtime").JSX.Element;
1
+ export type IAMTokensProps = {
2
+ /** Route to navigate when clicking "New IAM token" button. Defaults to '/new/token'. */
3
+ newTokenRoute?: string;
4
+ /** Base route for the tokens list (used for edit navigation). Defaults to current relative path. */
5
+ tokensListRoute?: string;
6
+ };
7
+ export declare const IAMTokens: ({ newTokenRoute, tokensListRoute, }?: IAMTokensProps) => import("react/jsx-runtime").JSX.Element;
2
8
  export default IAMTokens;
@@ -9,7 +9,7 @@ import { Blankslate, PageHeader, Table, DataTable, } from '@primer/react/experim
9
9
  import { Box } from '@datalayer/primer-addons';
10
10
  import { EditIcon } from '@datalayer/icons-react';
11
11
  import { useCache, useNavigate } from '../../hooks';
12
- const TokensTable = () => {
12
+ const TokensTable = ({ tokensListRoute }) => {
13
13
  const { useTokens } = useCache();
14
14
  const getTokensQuery = useTokens();
15
15
  const navigate = useNavigate();
@@ -42,12 +42,14 @@ const TokensTable = () => {
42
42
  {
43
43
  header: '',
44
44
  field: 'id',
45
- renderCell: token => (_jsx(IconButton, { icon: EditIcon, "aria-label": "Edit", size: "small", variant: "invisible", onClick: e => navigate(`${token.id}`, e) })),
45
+ renderCell: token => (_jsx(IconButton, { icon: EditIcon, "aria-label": "Edit", size: "small", variant: "invisible", onClick: e => navigate(tokensListRoute
46
+ ? `${tokensListRoute}/${token.id}`
47
+ : `${token.id}`, e) })),
46
48
  },
47
49
  ] })] }));
48
50
  };
49
- export const IAMTokens = () => {
51
+ export const IAMTokens = ({ newTokenRoute = '/new/token', tokensListRoute, } = {}) => {
50
52
  const navigate = useNavigate();
51
- return (_jsxs(PageLayout, { containerWidth: "full", padding: "normal", style: { overflow: 'visible', minHeight: 'calc(100vh - 45px)' }, children: [_jsx(PageLayout.Header, { children: _jsxs(PageHeader, { children: [_jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "IAM Tokens" }) }), _jsx(PageHeader.Actions, { children: _jsx(Button, { size: "small", variant: "primary", onClick: e => navigate('/new/token', e), children: "New IAM token" }) })] }) }), _jsx(PageLayout.Content, { children: _jsx(Box, { children: _jsx(TokensTable, {}) }) })] }));
53
+ return (_jsxs(PageLayout, { containerWidth: "full", padding: "normal", style: { overflow: 'visible', minHeight: 'calc(100vh - 45px)' }, children: [_jsx(PageLayout.Header, { children: _jsxs(PageHeader, { children: [_jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "IAM Tokens" }) }), _jsx(PageHeader.Actions, { children: _jsx(Button, { size: "small", variant: "primary", onClick: e => navigate(newTokenRoute, e), children: "New IAM token" }) })] }) }), _jsx(PageLayout.Content, { children: _jsx(Box, { children: _jsx(TokensTable, { tokensListRoute: tokensListRoute }) }) })] }));
52
54
  };
53
55
  export default IAMTokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -103,7 +103,7 @@
103
103
  },
104
104
  "dependencies": {
105
105
  "@datalayer/icons-react": "^1.0.6",
106
- "@datalayer/jupyter-lexical": "^1.0.8",
106
+ "@datalayer/jupyter-lexical": "^1.0.9",
107
107
  "@datalayer/jupyter-react": "^2.0.2",
108
108
  "@datalayer/primer-addons": "^1.0.4",
109
109
  "@datalayer/primer-rjsf": "^1.0.1",
@@ -125,7 +125,7 @@
125
125
  "@lumino/disposable": "^2.1.5",
126
126
  "@lumino/polling": "^2.1.5",
127
127
  "@lumino/signaling": "^2.1.5",
128
- "@lumino/widgets": "^2.7.2",
128
+ "@lumino/widgets": "^2.7.3",
129
129
  "@primer/behaviors": "^1.8.4",
130
130
  "@primer/brand-primitives": "^0.51.0",
131
131
  "@primer/css": "^21.5.1",