@datalayer/core 0.0.25 → 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.
- package/README.md +11 -11
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/spacer/agentSpaces.d.ts +193 -0
- package/lib/api/spacer/agentSpaces.js +127 -0
- package/lib/api/spacer/index.d.ts +2 -1
- package/lib/api/spacer/index.js +2 -1
- package/lib/api/utils/validation.d.ts +1 -1
- package/lib/api/utils/validation.js +1 -1
- package/lib/client/auth/AuthenticationManager.d.ts +2 -2
- package/lib/client/auth/AuthenticationManager.js +2 -2
- package/lib/client/auth/index.d.ts +1 -1
- package/lib/client/auth/index.js +1 -1
- package/lib/client/auth/types.d.ts +1 -1
- package/lib/client/auth/types.js +1 -1
- package/lib/client/base.d.ts +9 -9
- package/lib/client/base.js +3 -3
- package/lib/client/constants.d.ts +2 -2
- package/lib/client/constants.js +2 -2
- package/lib/client/index.d.ts +2 -2
- package/lib/client/mixins/IAMMixin.js +1 -1
- package/lib/client/utils/spacerUtils.d.ts +1 -1
- package/lib/client/utils/spacerUtils.js +1 -1
- package/lib/components/progress/ConsumptionBar.js +19 -1
- package/lib/hooks/useCache.d.ts +88 -0
- package/lib/hooks/useCache.js +413 -0
- package/lib/index.d.ts +1 -1
- package/lib/models/CreditsDTO.js +1 -1
- package/lib/models/Datasource.d.ts +2 -2
- package/lib/models/Datasource.js +2 -2
- package/lib/models/EnvironmentDTO.d.ts +3 -3
- package/lib/models/EnvironmentDTO.js +2 -2
- package/lib/models/HealthCheck.d.ts +1 -1
- package/lib/models/HealthCheck.js +1 -1
- package/lib/models/ItemDTO.d.ts +2 -2
- package/lib/models/ItemDTO.js +2 -2
- package/lib/models/LexicalDTO.d.ts +2 -2
- package/lib/models/LexicalDTO.js +2 -2
- package/lib/models/NotebookDTO.d.ts +2 -2
- package/lib/models/NotebookDTO.js +1 -1
- package/lib/models/RuntimeDTO.d.ts +2 -2
- package/lib/models/RuntimeDTO.js +2 -2
- package/lib/models/RuntimeSnapshotDTO.d.ts +3 -3
- package/lib/models/RuntimeSnapshotDTO.js +1 -1
- package/lib/models/Secret.d.ts +3 -3
- package/lib/models/Secret.js +2 -2
- package/lib/models/SpaceDTO.d.ts +2 -2
- package/lib/models/SpaceDTO.js +3 -3
- package/lib/models/UserDTO.d.ts +2 -2
- package/lib/models/UserDTO.js +1 -1
- package/lib/models/index.d.ts +1 -1
- package/lib/models/index.js +1 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/theme/DatalayerThemeProvider.d.ts +22 -2
- package/lib/theme/DatalayerThemeProvider.js +17 -9
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +1 -0
- package/lib/theme/useSystemColorMode.d.ts +9 -0
- package/lib/theme/useSystemColorMode.js +26 -0
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +5 -1
- package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
- package/lib/views/iam-tokens/IAMTokens.d.ts +7 -1
- package/lib/views/iam-tokens/IAMTokens.js +6 -4
- package/package.json +1 -1
- package/lib/hooks/useCache0.d.ts +0 -312
- package/lib/hooks/useCache0.js +0 -3189
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Environment domain model for the Datalayer
|
|
2
|
+
* Environment domain model for the Datalayer Client.
|
|
3
3
|
*
|
|
4
4
|
* @module models/EnvironmentDTO
|
|
5
5
|
*/
|
|
@@ -47,7 +47,7 @@ export interface EnvironmentData {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Stable public interface for Environment data.
|
|
50
|
-
* This is the contract that
|
|
50
|
+
* This is the contract that Client consumers can rely on.
|
|
51
51
|
* The raw API may change, but this interface remains stable.
|
|
52
52
|
*/
|
|
53
53
|
export interface EnvironmentJSON {
|
|
@@ -92,7 +92,7 @@ export declare class EnvironmentDTO {
|
|
|
92
92
|
* Create an Environment instance.
|
|
93
93
|
*
|
|
94
94
|
* @param data - Environment data from API
|
|
95
|
-
* @param _sdk -
|
|
95
|
+
* @param _sdk - Client instance (not currently used but kept for consistency)
|
|
96
96
|
*/
|
|
97
97
|
constructor(data: EnvironmentData, _sdk: DatalayerClient);
|
|
98
98
|
/** Human-readable title for the environment (e.g., 'AI Environment', 'Python CPU Environment'). */
|
|
@@ -21,11 +21,11 @@ export class EnvironmentDTO {
|
|
|
21
21
|
* Create an Environment instance.
|
|
22
22
|
*
|
|
23
23
|
* @param data - Environment data from API
|
|
24
|
-
* @param _sdk -
|
|
24
|
+
* @param _sdk - Client instance (not currently used but kept for consistency)
|
|
25
25
|
*/
|
|
26
26
|
constructor(data, _sdk) {
|
|
27
27
|
this._data = data;
|
|
28
|
-
//
|
|
28
|
+
// Client instance not currently used but kept for future extensibility
|
|
29
29
|
}
|
|
30
30
|
// ========================================================================
|
|
31
31
|
// Properties
|
|
@@ -11,7 +11,7 @@ export declare class HealthCheck {
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a HealthCheck instance.
|
|
13
13
|
* @param data - The health check data
|
|
14
|
-
* @param sdk - Reference to the
|
|
14
|
+
* @param sdk - Reference to the Client instance (unused but kept for consistency)
|
|
15
15
|
*/
|
|
16
16
|
constructor(data: any, sdk: any);
|
|
17
17
|
/**
|
|
@@ -17,7 +17,7 @@ export class HealthCheck {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create a HealthCheck instance.
|
|
19
19
|
* @param data - The health check data
|
|
20
|
-
* @param sdk - Reference to the
|
|
20
|
+
* @param sdk - Reference to the Client instance (unused but kept for consistency)
|
|
21
21
|
*/
|
|
22
22
|
constructor(data, sdk) {
|
|
23
23
|
// Initialize properties
|
package/lib/models/ItemDTO.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare abstract class ItemDTO<TData> {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create an Item instance.
|
|
20
20
|
* @param data - Item data from API
|
|
21
|
-
* @param sdk -
|
|
21
|
+
* @param sdk - Client instance
|
|
22
22
|
*/
|
|
23
23
|
constructor(data: TData, sdk: DatalayerClient);
|
|
24
24
|
/** Check if this item has been deleted. */
|
|
@@ -65,7 +65,7 @@ export declare abstract class ItemDTO<TData> {
|
|
|
65
65
|
abstract toJSON(): any;
|
|
66
66
|
/** String representation of the item. */
|
|
67
67
|
toString(): string;
|
|
68
|
-
/** Get
|
|
68
|
+
/** Get Client token for API calls. */
|
|
69
69
|
protected _getToken(): string;
|
|
70
70
|
/** Get spacer API URL for API calls. */
|
|
71
71
|
protected _getSpacerRunUrl(): string;
|
package/lib/models/ItemDTO.js
CHANGED
|
@@ -17,7 +17,7 @@ export class ItemDTO {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create an Item instance.
|
|
19
19
|
* @param data - Item data from API
|
|
20
|
-
* @param sdk -
|
|
20
|
+
* @param sdk - Client instance
|
|
21
21
|
*/
|
|
22
22
|
constructor(data, sdk) {
|
|
23
23
|
this._data = data;
|
|
@@ -171,7 +171,7 @@ export class ItemDTO {
|
|
|
171
171
|
// ========================================================================
|
|
172
172
|
// Protected Helper Methods
|
|
173
173
|
// ========================================================================
|
|
174
|
-
/** Get
|
|
174
|
+
/** Get Client token for API calls. */
|
|
175
175
|
_getToken() {
|
|
176
176
|
return this._sdk.getToken();
|
|
177
177
|
}
|
|
@@ -80,7 +80,7 @@ export interface UpdateLexicalResponse {
|
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Stable public interface for Lexical data.
|
|
83
|
-
* This is the contract that
|
|
83
|
+
* This is the contract that Client consumers can rely on.
|
|
84
84
|
* The raw API may change, but this interface remains stable.
|
|
85
85
|
*/
|
|
86
86
|
export interface LexicalJSON {
|
|
@@ -118,7 +118,7 @@ export declare class LexicalDTO extends ItemDTO<LexicalData> {
|
|
|
118
118
|
* Create a Lexical instance.
|
|
119
119
|
*
|
|
120
120
|
* @param data - Lexical data from API
|
|
121
|
-
* @param sdk -
|
|
121
|
+
* @param sdk - Client instance
|
|
122
122
|
*/
|
|
123
123
|
constructor(data: LexicalData, sdk: DatalayerClient);
|
|
124
124
|
/** Document type identifier. */
|
package/lib/models/LexicalDTO.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Lexical domain model for the Datalayer
|
|
6
|
+
* Lexical domain model for the Datalayer Client.
|
|
7
7
|
*
|
|
8
8
|
* @module models/LexicalDTO
|
|
9
9
|
*/
|
|
@@ -26,7 +26,7 @@ export class LexicalDTO extends ItemDTO {
|
|
|
26
26
|
* Create a Lexical instance.
|
|
27
27
|
*
|
|
28
28
|
* @param data - Lexical data from API
|
|
29
|
-
* @param sdk -
|
|
29
|
+
* @param sdk - Client instance
|
|
30
30
|
*/
|
|
31
31
|
constructor(data, sdk) {
|
|
32
32
|
super(data, sdk);
|
|
@@ -17,7 +17,7 @@ export interface NotebookData {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Stable public interface for Notebook data.
|
|
20
|
-
* This is the contract that
|
|
20
|
+
* This is the contract that Client consumers can rely on.
|
|
21
21
|
* The raw API may change, but this interface remains stable.
|
|
22
22
|
*/
|
|
23
23
|
export interface NotebookJSON {
|
|
@@ -51,7 +51,7 @@ export declare class NotebookDTO extends ItemDTO<NotebookData> {
|
|
|
51
51
|
* Create a Notebook instance.
|
|
52
52
|
*
|
|
53
53
|
* @param data - Notebook data from API
|
|
54
|
-
* @param sdk -
|
|
54
|
+
* @param sdk - Client instance
|
|
55
55
|
*/
|
|
56
56
|
constructor(data: NotebookData, sdk: DatalayerClient);
|
|
57
57
|
/** Document type identifier. */
|
|
@@ -30,7 +30,7 @@ export interface RuntimeData {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Stable public interface for Runtime data.
|
|
33
|
-
* This is the contract that
|
|
33
|
+
* This is the contract that Client consumers can rely on.
|
|
34
34
|
* The raw API may change, but this interface remains stable.
|
|
35
35
|
*/
|
|
36
36
|
export interface RuntimeJSON {
|
|
@@ -118,7 +118,7 @@ export declare class RuntimeDTO {
|
|
|
118
118
|
* Create a Runtime instance.
|
|
119
119
|
*
|
|
120
120
|
* @param data - Runtime data from API
|
|
121
|
-
* @param sdk -
|
|
121
|
+
* @param sdk - Client instance
|
|
122
122
|
*/
|
|
123
123
|
constructor(data: RuntimeData, sdk: DatalayerClient);
|
|
124
124
|
/**
|
package/lib/models/RuntimeDTO.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Runtime domain model for the Datalayer
|
|
6
|
+
* Runtime domain model for the Datalayer Client.
|
|
7
7
|
*
|
|
8
8
|
* @module models/RuntimeDTO
|
|
9
9
|
*/
|
|
@@ -28,7 +28,7 @@ export class RuntimeDTO {
|
|
|
28
28
|
* Create a Runtime instance.
|
|
29
29
|
*
|
|
30
30
|
* @param data - Runtime data from API
|
|
31
|
-
* @param sdk -
|
|
31
|
+
* @param sdk - Client instance
|
|
32
32
|
*/
|
|
33
33
|
constructor(data, sdk) {
|
|
34
34
|
this._data = data;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Snapshot domain model for the Datalayer
|
|
2
|
+
* Snapshot domain model for the Datalayer Client.
|
|
3
3
|
*
|
|
4
4
|
* @module models/RuntimeSnapshotDTO
|
|
5
5
|
*/
|
|
@@ -39,7 +39,7 @@ export interface RuntimeSnapshotData {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Stable public interface for Snapshot data.
|
|
42
|
-
* This is the contract that
|
|
42
|
+
* This is the contract that Client consumers can rely on.
|
|
43
43
|
* The raw API may change, but this interface remains stable.
|
|
44
44
|
*/
|
|
45
45
|
export interface RuntimeSnapshotJSON {
|
|
@@ -122,7 +122,7 @@ export declare class RuntimeSnapshotDTO {
|
|
|
122
122
|
* Create a Runtime Snapshot instance.
|
|
123
123
|
*
|
|
124
124
|
* @param data - Snapshot data from API
|
|
125
|
-
* @param sdk -
|
|
125
|
+
* @param sdk - Client instance
|
|
126
126
|
*/
|
|
127
127
|
constructor(data: RuntimeSnapshotData, sdk: DatalayerClient);
|
|
128
128
|
/**
|
package/lib/models/Secret.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface CreateSecretRequest {
|
|
|
50
50
|
name: string;
|
|
51
51
|
/** Human-readable description */
|
|
52
52
|
description?: string;
|
|
53
|
-
/** Plain text value (will be Base64 encoded by
|
|
53
|
+
/** Plain text value (will be Base64 encoded by Client) */
|
|
54
54
|
value: string;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -111,7 +111,7 @@ export interface DeleteSecretResponse {
|
|
|
111
111
|
message: string;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* Secret domain model for the Datalayer
|
|
114
|
+
* Secret domain model for the Datalayer Client.
|
|
115
115
|
* Provides state management and operations for user secrets.
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
@@ -136,7 +136,7 @@ export declare class SecretDTO {
|
|
|
136
136
|
/**
|
|
137
137
|
* Create a Secret instance.
|
|
138
138
|
* @param data - Secret data from API
|
|
139
|
-
* @param sdk -
|
|
139
|
+
* @param sdk - Client instance
|
|
140
140
|
*/
|
|
141
141
|
constructor(data: SecretData, sdk: DatalayerClient);
|
|
142
142
|
private _checkDeleted;
|
package/lib/models/Secret.js
CHANGED
|
@@ -16,7 +16,7 @@ export const asSecret = (s) => {
|
|
|
16
16
|
// ============================================================================
|
|
17
17
|
import { validateJSON } from '../api/utils/validation';
|
|
18
18
|
/**
|
|
19
|
-
* Secret domain model for the Datalayer
|
|
19
|
+
* Secret domain model for the Datalayer Client.
|
|
20
20
|
* Provides state management and operations for user secrets.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
@@ -41,7 +41,7 @@ export class SecretDTO {
|
|
|
41
41
|
/**
|
|
42
42
|
* Create a Secret instance.
|
|
43
43
|
* @param data - Secret data from API
|
|
44
|
-
* @param sdk -
|
|
44
|
+
* @param sdk - Client instance
|
|
45
45
|
*/
|
|
46
46
|
constructor(data, sdk) {
|
|
47
47
|
this._data = data;
|
package/lib/models/SpaceDTO.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface SpaceData {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Stable public interface for Space data.
|
|
21
|
-
* This is the contract that
|
|
21
|
+
* This is the contract that Client consumers can rely on.
|
|
22
22
|
* The raw API may change, but this interface remains stable.
|
|
23
23
|
*/
|
|
24
24
|
export interface SpaceJSON {
|
|
@@ -55,7 +55,7 @@ export declare class SpaceDTO {
|
|
|
55
55
|
* Create a Space instance.
|
|
56
56
|
*
|
|
57
57
|
* @param data - Space data from API
|
|
58
|
-
* @param sdk -
|
|
58
|
+
* @param sdk - Client instance
|
|
59
59
|
*/
|
|
60
60
|
constructor(data: SpaceData, sdk: DatalayerClient);
|
|
61
61
|
/**
|
package/lib/models/SpaceDTO.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Space domain model for the Datalayer
|
|
6
|
+
* Space domain model for the Datalayer Client.
|
|
7
7
|
*
|
|
8
8
|
* @module models/SpaceDTO
|
|
9
9
|
*/
|
|
@@ -36,7 +36,7 @@ export class SpaceDTO {
|
|
|
36
36
|
* Create a Space instance.
|
|
37
37
|
*
|
|
38
38
|
* @param data - Space data from API
|
|
39
|
-
* @param sdk -
|
|
39
|
+
* @param sdk - Client instance
|
|
40
40
|
*/
|
|
41
41
|
constructor(data, sdk) {
|
|
42
42
|
this._data = data;
|
|
@@ -109,7 +109,7 @@ export class SpaceDTO {
|
|
|
109
109
|
*/
|
|
110
110
|
async _createItem(data) {
|
|
111
111
|
this._checkDeleted();
|
|
112
|
-
// Get necessary configuration from
|
|
112
|
+
// Get necessary configuration from Client
|
|
113
113
|
const token = this._sdk.getToken();
|
|
114
114
|
const spacerRunUrl = this._sdk.getSpacerRunUrl();
|
|
115
115
|
if (data.type === ItemTypes.NOTEBOOK) {
|
package/lib/models/UserDTO.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* User model for the Datalayer
|
|
2
|
+
* User model for the Datalayer Client with rich functionality.
|
|
3
3
|
*
|
|
4
4
|
* @module models/UserDTO
|
|
5
5
|
*/
|
|
@@ -54,7 +54,7 @@ export declare class UserDTO {
|
|
|
54
54
|
* Create a User instance.
|
|
55
55
|
*
|
|
56
56
|
* @param data - User data from API
|
|
57
|
-
* @param sdk -
|
|
57
|
+
* @param sdk - Client instance (currently unused but kept for compatibility)
|
|
58
58
|
*/
|
|
59
59
|
constructor(data: UserData, sdk?: DatalayerClient);
|
|
60
60
|
get id(): string;
|
package/lib/models/UserDTO.js
CHANGED
|
@@ -13,7 +13,7 @@ export class UserDTO {
|
|
|
13
13
|
* Create a User instance.
|
|
14
14
|
*
|
|
15
15
|
* @param data - User data from API
|
|
16
|
-
* @param sdk -
|
|
16
|
+
* @param sdk - Client instance (currently unused but kept for compatibility)
|
|
17
17
|
*/
|
|
18
18
|
constructor(data, sdk) {
|
|
19
19
|
this._data = data;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Models definitions for all Datalayer API services.
|
|
3
3
|
*
|
|
4
|
-
* This module consolidates all type definitions used by the
|
|
4
|
+
* This module consolidates all type definitions used by the Client, providing
|
|
5
5
|
* comprehensive TypeScript support for requests, responses, and data models
|
|
6
6
|
* across all Datalayer services.
|
|
7
7
|
*
|
package/lib/models/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Models definitions for all Datalayer API services.
|
|
7
7
|
*
|
|
8
|
-
* This module consolidates all type definitions used by the
|
|
8
|
+
* This module consolidates all type definitions used by the Client, providing
|
|
9
9
|
* comprehensive TypeScript support for requests, responses, and data models
|
|
10
10
|
* across all Datalayer services.
|
|
11
11
|
*
|
|
@@ -61,7 +61,7 @@ try {
|
|
|
61
61
|
...htmlOverridingConfiguration,
|
|
62
62
|
};
|
|
63
63
|
configLogger.info('Datalayer configuration loaded from HTML page', initialConfiguration);
|
|
64
|
-
window.document.title = `${initialConfiguration.brand.name}
|
|
64
|
+
window.document.title = `${initialConfiguration.brand.name} ☰ ${initialConfiguration.brand.about}`;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { type CSSProperties } from 'react';
|
|
2
2
|
import { ThemeProviderProps } from '@primer/react';
|
|
3
|
-
export interface IDatalayerThemeProviderProps extends Omit<ThemeProviderProps, 'theme'> {
|
|
3
|
+
export interface IDatalayerThemeProviderProps extends Omit<ThemeProviderProps, 'theme' | 'colorMode'> {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { BaseStyles, ThemeProvider } from '@primer/react';
|
|
3
3
|
import { datalayerTheme, datalayerColors } from './DatalayerTheme';
|
|
4
|
+
import { useSystemColorMode } from './useSystemColorMode';
|
|
4
5
|
const baseStyleLight = {
|
|
5
6
|
backgroundColor: datalayerColors.white,
|
|
6
7
|
color: datalayerColors.black,
|
|
@@ -32,15 +33,22 @@ const primaryButtonVarsDark = {
|
|
|
32
33
|
'--color-btn-primary-hover-bg': datalayerColors.greenBright,
|
|
33
34
|
};
|
|
34
35
|
export function DatalayerThemeProvider(props) {
|
|
35
|
-
const { children, colorMode, baseStyles, ...rest } = props;
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,
|
|
44
52
|
...baseStyles,
|
|
45
53
|
}, children: children }) }));
|
|
46
54
|
}
|
package/lib/theme/index.d.ts
CHANGED
package/lib/theme/index.js
CHANGED
|
@@ -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
|
|
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(
|
|
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
|
|
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(
|
|
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(
|
|
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;
|