@datalayer/core 1.0.23 → 1.0.25
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 +30 -7
- package/lib/api/constants.d.ts +3 -0
- package/lib/api/constants.js +3 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/runtimes/checkpoints.d.ts +4 -4
- package/lib/api/runtimes/runtimes.d.ts +3 -3
- package/lib/api/scheduler/index.d.ts +6 -0
- package/lib/api/scheduler/index.js +10 -0
- package/lib/api/scheduler/schedules.d.ts +85 -0
- package/lib/api/scheduler/schedules.js +78 -0
- package/lib/components/checkout/StripeCheckout.js +48 -2
- package/lib/components/display/LiveRelativeTime.d.ts +1 -10
- package/lib/components/display/LiveRelativeTime.js +3 -18
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/components/runtimes/RuntimePickerBase.js +18 -16
- package/lib/components/runtimes/RuntimePickerCell.js +1 -1
- package/lib/components/scheduler/ScheduleMenu.d.ts +54 -0
- package/lib/components/scheduler/ScheduleMenu.js +154 -0
- package/lib/components/scheduler/index.d.ts +1 -0
- package/lib/{views/iam-tokens → components/scheduler}/index.js +1 -3
- package/lib/components/time/LiveRelativeTime.d.ts +14 -0
- package/lib/components/time/LiveRelativeTime.js +39 -0
- package/lib/components/time/index.d.ts +1 -0
- package/lib/components/time/index.js +5 -0
- package/lib/components/timeline/Timeline.d.ts +20 -0
- package/lib/components/timeline/Timeline.js +90 -0
- package/lib/components/timeline/index.d.ts +1 -0
- package/lib/components/timeline/index.js +5 -0
- package/lib/hooks/useCache.d.ts +31 -1
- package/lib/hooks/useCache.js +221 -17
- package/lib/hooks/useProjectStore.d.ts +1 -1
- package/lib/hooks/useProjects.d.ts +2 -2
- package/lib/models/IAMToken.d.ts +1 -1
- package/lib/models/Page.d.ts +3 -0
- package/lib/models/ProjectDTO.d.ts +1 -1
- package/lib/models/ProjectDTO.js +1 -1
- package/lib/state/substates/CoreState.js +2 -2
- package/lib/utils/Date.d.ts +7 -0
- package/lib/utils/Date.js +43 -10
- package/lib/utils/Name.d.ts +1 -0
- package/lib/utils/Name.js +8 -0
- package/lib/utils/Snapshot.js +2 -2
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/views/api-keys/APIKeyEdit.d.ts +8 -0
- package/lib/views/{iam-tokens/IAMTokenEdit.js → api-keys/APIKeyEdit.js} +31 -31
- package/lib/views/api-keys/APIKeyNew.d.ts +8 -0
- package/lib/views/api-keys/APIKeyNew.js +143 -0
- package/lib/views/api-keys/APIKeys.d.ts +12 -0
- package/lib/views/api-keys/APIKeys.js +119 -0
- package/lib/views/api-keys/APIKeysStandalone.d.ts +2 -0
- package/lib/views/api-keys/APIKeysStandalone.js +117 -0
- package/lib/views/api-keys/index.d.ts +3 -0
- package/lib/views/api-keys/index.js +7 -0
- package/package.json +1 -1
- package/lib/views/iam-tokens/IAMTokenEdit.d.ts +0 -6
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +0 -8
- package/lib/views/iam-tokens/IAMTokenNew.js +0 -118
- package/lib/views/iam-tokens/IAMTokens.d.ts +0 -12
- package/lib/views/iam-tokens/IAMTokens.js +0 -87
- package/lib/views/iam-tokens/Tokens.d.ts +0 -2
- package/lib/views/iam-tokens/Tokens.js +0 -85
- package/lib/views/iam-tokens/index.d.ts +0 -3
- /package/lib/utils/{logger.d.ts → Logger.d.ts} +0 -0
- /package/lib/utils/{logger.js → Logger.js} +0 -0
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
7
|
-
import { PageHeader, FormControl, Button, TextInput, Textarea, Select, Text, IconButton, } from '@primer/react';
|
|
8
|
-
import { Box } from '@datalayer/primer-addons';
|
|
9
|
-
import { CopyIcon } from '@primer/octicons-react';
|
|
10
|
-
import { Calendar, defaultCalendarStrings } from '@fluentui/react';
|
|
11
|
-
import { useCache, useNavigate, useToast } from '../../hooks/index.js';
|
|
12
|
-
import { useRunStore } from '../../state/index.js';
|
|
13
|
-
export const IAMTokenNew = ({ tokensListRoute = '/settings/iam/tokens', showTitle = true, } = {}) => {
|
|
14
|
-
const runStore = useRunStore();
|
|
15
|
-
const { useCreateToken } = useCache();
|
|
16
|
-
const createTokenMutation = useCreateToken();
|
|
17
|
-
const navigate = useNavigate();
|
|
18
|
-
const { enqueueToast } = useToast();
|
|
19
|
-
const [today, _] = useState(new Date());
|
|
20
|
-
const [showToken, setShowToken] = useState(false);
|
|
21
|
-
const [token, setToken] = useState();
|
|
22
|
-
const [formValues, setFormValues] = useState({
|
|
23
|
-
variant: 'user_token',
|
|
24
|
-
name: undefined,
|
|
25
|
-
description: undefined,
|
|
26
|
-
expirationDate: undefined,
|
|
27
|
-
});
|
|
28
|
-
const [validationResult, setValidationResult] = useState({
|
|
29
|
-
variant: undefined,
|
|
30
|
-
name: undefined,
|
|
31
|
-
description: undefined,
|
|
32
|
-
expirationDate: undefined,
|
|
33
|
-
});
|
|
34
|
-
const valueVariantChange = (event) => {
|
|
35
|
-
setFormValues(prevFormValues => ({
|
|
36
|
-
...prevFormValues,
|
|
37
|
-
variant: event.target.value,
|
|
38
|
-
}));
|
|
39
|
-
};
|
|
40
|
-
const valueNameChange = (event) => {
|
|
41
|
-
setFormValues(prevFormValues => ({
|
|
42
|
-
...prevFormValues,
|
|
43
|
-
name: event.target.value,
|
|
44
|
-
}));
|
|
45
|
-
};
|
|
46
|
-
const valueDescriptionChange = (event) => {
|
|
47
|
-
setFormValues(prevFormValues => ({
|
|
48
|
-
...prevFormValues,
|
|
49
|
-
description: event.target.value,
|
|
50
|
-
}));
|
|
51
|
-
};
|
|
52
|
-
const expirationDateChange = (expirationDate) => {
|
|
53
|
-
setFormValues(prevFormValues => ({
|
|
54
|
-
...prevFormValues,
|
|
55
|
-
expirationDate,
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
setValidationResult({
|
|
60
|
-
...validationResult,
|
|
61
|
-
name: formValues.name === undefined
|
|
62
|
-
? undefined
|
|
63
|
-
: formValues.name.length > 2
|
|
64
|
-
? true
|
|
65
|
-
: false,
|
|
66
|
-
description: formValues.description === undefined
|
|
67
|
-
? undefined
|
|
68
|
-
: formValues.description.length > 2
|
|
69
|
-
? true
|
|
70
|
-
: false,
|
|
71
|
-
expirationDate: formValues.expirationDate === undefined
|
|
72
|
-
? undefined
|
|
73
|
-
: formValues.expirationDate.getTime() > today.getTime()
|
|
74
|
-
? true
|
|
75
|
-
: false,
|
|
76
|
-
});
|
|
77
|
-
}, [formValues]);
|
|
78
|
-
const valueSubmit = () => {
|
|
79
|
-
runStore.layout().showBackdrop('Creating an token...');
|
|
80
|
-
createTokenMutation.mutate({
|
|
81
|
-
name: formValues.name,
|
|
82
|
-
variant: formValues.variant,
|
|
83
|
-
description: formValues.description,
|
|
84
|
-
expirationDate: formValues.expirationDate,
|
|
85
|
-
}, {
|
|
86
|
-
onSuccess: (resp) => {
|
|
87
|
-
if (resp.success && resp.token) {
|
|
88
|
-
enqueueToast(resp.message, { variant: 'success' });
|
|
89
|
-
setToken(resp.token);
|
|
90
|
-
setShowToken(true);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
onSettled: () => {
|
|
94
|
-
runStore.layout().hideBackdrop();
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
return (_jsx(Box, { children: showToken ? (_jsxs(_Fragment, { children: [_jsx(PageHeader, { children: _jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "Your API Key is created" }) }) }), _jsx(Box, { children: _jsx(Text, { children: "Take note of the API Key value, you will not be able to see it after." }) }), _jsx(Box, { children: _jsxs(Text, { children: ["Name: ", token?.name] }) }), _jsx(Box, { children: _jsxs(Text, { children: ["Description: ", token?.description] }) }), _jsx(Box, { children: _jsxs(Text, { children: ["Expiration date: ", token?.expirationDate.toISOString()] }) }), _jsxs(Box, { children: [_jsx(Text, { mb: 2, children: "Value: " }), _jsxs(Box, { display: "flex", sx: { alignItems: 'center', gap: 2 }, children: [_jsx(Text, { as: "code", sx: {
|
|
99
|
-
color: 'fg.onEmphasis',
|
|
100
|
-
bg: 'neutral.emphasis',
|
|
101
|
-
p: 2,
|
|
102
|
-
overflowWrap: 'anywhere',
|
|
103
|
-
flex: 1,
|
|
104
|
-
}, children: token?.value }), _jsx(IconButton, { "aria-label": "Copy token to clipboard", icon: CopyIcon, size: "small", onClick: () => {
|
|
105
|
-
if (token?.value) {
|
|
106
|
-
navigator.clipboard.writeText(token.value);
|
|
107
|
-
enqueueToast('Token copied to clipboard', {
|
|
108
|
-
variant: 'success',
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
} })] })] }), _jsx(Box, { mt: 3, children: _jsx(Button, { onClick: e => navigate(tokensListRoute, e), children: "List my API Keys" }) })] })) : (_jsxs(_Fragment, { children: [showTitle ? (_jsx(PageHeader, { children: _jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "New API Key" }) }) })) : null, _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
|
-
!validationResult.description ||
|
|
113
|
-
!validationResult.expirationDate, sx: { marginTop: 2 }, onClick: e => {
|
|
114
|
-
e.preventDefault();
|
|
115
|
-
valueSubmit();
|
|
116
|
-
}, children: "Create a token" })] }) }) })] })) }));
|
|
117
|
-
};
|
|
118
|
-
export default IAMTokenNew;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type IAMTokensProps = {
|
|
2
|
-
/** Route to navigate when clicking "New API Key" 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
|
-
/** Whether to display view titles/headings. Defaults to true. */
|
|
7
|
-
showTitle?: boolean;
|
|
8
|
-
/** Whether to render the "New API Key" button in this component header. Defaults to true. */
|
|
9
|
-
showNewButton?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare const IAMTokens: ({ newTokenRoute, tokensListRoute, showTitle, showNewButton, }?: IAMTokensProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export default IAMTokens;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useState, useEffect, useRef } from 'react';
|
|
7
|
-
import { PageLayout, Button, IconButton, Text, Label, RelativeTime, ConfirmationDialog, } from '@primer/react';
|
|
8
|
-
import { Blankslate, PageHeader, Table, DataTable, } from '@primer/react/experimental';
|
|
9
|
-
import { Box } from '@datalayer/primer-addons';
|
|
10
|
-
import { EditIcon } from '@datalayer/icons-react';
|
|
11
|
-
import { TrashIcon } from '@primer/octicons-react';
|
|
12
|
-
import { useCache, useNavigate, useToast } from '../../hooks/index.js';
|
|
13
|
-
const TokensTable = ({ tokensListRoute, showTitle = true, }) => {
|
|
14
|
-
const { useTokens, useDeleteToken } = useCache();
|
|
15
|
-
const { enqueueToast } = useToast();
|
|
16
|
-
const getTokensQuery = useTokens();
|
|
17
|
-
const deleteTokenMutation = useDeleteToken();
|
|
18
|
-
const navigate = useNavigate();
|
|
19
|
-
const [tokens, setTokens] = useState([]);
|
|
20
|
-
const [deletingToken, setDeletingToken] = useState(null);
|
|
21
|
-
const returnFocusRef = useRef(null);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (getTokensQuery.data) {
|
|
24
|
-
setTokens(getTokensQuery.data);
|
|
25
|
-
}
|
|
26
|
-
}, [getTokensQuery.data]);
|
|
27
|
-
const handleDeleteConfirm = () => {
|
|
28
|
-
if (!deletingToken)
|
|
29
|
-
return;
|
|
30
|
-
deleteTokenMutation.mutate(deletingToken.id, {
|
|
31
|
-
onSuccess: (resp) => {
|
|
32
|
-
if (resp.success) {
|
|
33
|
-
enqueueToast(`Token "${deletingToken.name}" deleted.`, {
|
|
34
|
-
variant: 'success',
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
enqueueToast(resp.message || 'Failed to delete token.', {
|
|
39
|
-
variant: 'error',
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
onError: () => {
|
|
44
|
-
enqueueToast('Failed to delete token.', { variant: 'error' });
|
|
45
|
-
},
|
|
46
|
-
onSettled: () => setDeletingToken(null),
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return tokens.length === 0 ? (_jsxs(Blankslate, { border: true, spacious: true, children: [showTitle && _jsx(Blankslate.Heading, { children: "API Keys" }), _jsx(Blankslate.Description, { children: _jsx(Text, { sx: { textAlign: 'center' }, children: "No API Keys found." }) })] })) : (_jsxs(_Fragment, { children: [_jsxs(Table.Container, { children: [showTitle && (_jsxs(_Fragment, { children: [_jsx(Table.Title, { as: "h2", id: "tokens", children: "API Keys" }), _jsx(Table.Subtitle, { as: "p", id: "tokens-subtitle", children: "Your tokens." })] })), _jsx(DataTable, { "aria-labelledby": "teams", "aria-describedby": "teams-subtitle", data: tokens, columns: [
|
|
50
|
-
{
|
|
51
|
-
header: 'Type',
|
|
52
|
-
field: 'variant',
|
|
53
|
-
renderCell: token => _jsx(Label, { children: token.variant }),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
header: 'Name',
|
|
57
|
-
field: 'name',
|
|
58
|
-
rowHeader: true,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
header: 'Description',
|
|
62
|
-
field: 'description',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
header: 'Expiration date',
|
|
66
|
-
field: 'expirationDate',
|
|
67
|
-
renderCell: token => (_jsx(RelativeTime, { date: new Date(token.expirationDate) })),
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
header: '',
|
|
71
|
-
field: 'id',
|
|
72
|
-
renderCell: token => (_jsxs(Box, { display: "flex", sx: { gap: 1 }, children: [_jsx(IconButton, { icon: EditIcon, "aria-label": "Edit", size: "small", variant: "invisible", onClick: e => navigate(tokensListRoute
|
|
73
|
-
? `${tokensListRoute}/${token.id}`
|
|
74
|
-
: `${token.id}`, e) }), _jsx(IconButton, { ref: returnFocusRef, icon: TrashIcon, "aria-label": "Delete", size: "small", variant: "invisible", sx: { color: 'danger.fg' }, onClick: () => setDeletingToken(token) })] })),
|
|
75
|
-
},
|
|
76
|
-
] })] }), deletingToken && (_jsxs(ConfirmationDialog, { title: "Delete token", onClose: gesture => {
|
|
77
|
-
if (gesture === 'confirm')
|
|
78
|
-
handleDeleteConfirm();
|
|
79
|
-
else
|
|
80
|
-
setDeletingToken(null);
|
|
81
|
-
}, confirmButtonContent: "Delete", confirmButtonType: "danger", children: ["Are you sure you want to delete the token", ' ', _jsx("strong", { children: deletingToken.name }), "? This action cannot be undone."] }))] }));
|
|
82
|
-
};
|
|
83
|
-
export const IAMTokens = ({ newTokenRoute = '/new/token', tokensListRoute, showTitle = true, showNewButton = true, } = {}) => {
|
|
84
|
-
const navigate = useNavigate();
|
|
85
|
-
return (_jsxs(PageLayout, { containerWidth: "full", padding: "normal", style: { overflow: 'visible', minHeight: 'calc(100vh - 45px)' }, children: [showTitle || showNewButton ? (_jsx(PageLayout.Header, { children: _jsxs(PageHeader, { children: [showTitle && (_jsx(PageHeader.TitleArea, { variant: "large", children: _jsx(PageHeader.Title, { children: "API Keys" }) })), showNewButton && (_jsx(PageHeader.Actions, { children: _jsx(Button, { size: "small", variant: "primary", onClick: e => navigate(newTokenRoute, e), children: "New API Key" }) }))] }) })) : null, _jsx(PageLayout.Content, { children: _jsx(Box, { children: _jsx(TokensTable, { tokensListRoute: tokensListRoute, showTitle: showTitle }) }) })] }));
|
|
86
|
-
};
|
|
87
|
-
export default IAMTokens;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { useState, useEffect, useRef } from 'react';
|
|
7
|
-
import { PageLayout, Button, IconButton, Text, Label, RelativeTime, ConfirmationDialog, } from '@primer/react';
|
|
8
|
-
import { Blankslate, PageHeader, Table, DataTable, } from '@primer/react/experimental';
|
|
9
|
-
import { Box } from '@datalayer/primer-addons';
|
|
10
|
-
import { EditIcon } from '@datalayer/icons-react';
|
|
11
|
-
import { TrashIcon } from '@primer/octicons-react';
|
|
12
|
-
import { useCache, useNavigate, useToast } from '../../hooks/index.js';
|
|
13
|
-
const TokensTable = () => {
|
|
14
|
-
const { useTokens, useDeleteToken } = useCache();
|
|
15
|
-
const { enqueueToast } = useToast();
|
|
16
|
-
const getTokensQuery = useTokens();
|
|
17
|
-
const deleteTokenMutation = useDeleteToken();
|
|
18
|
-
const navigate = useNavigate();
|
|
19
|
-
const [tokens, setTokens] = useState([]);
|
|
20
|
-
const [deletingToken, setDeletingToken] = useState(null);
|
|
21
|
-
const returnFocusRef = useRef(null);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (getTokensQuery.data) {
|
|
24
|
-
setTokens(getTokensQuery.data);
|
|
25
|
-
}
|
|
26
|
-
}, [getTokensQuery.data]);
|
|
27
|
-
const handleDeleteConfirm = () => {
|
|
28
|
-
if (!deletingToken)
|
|
29
|
-
return;
|
|
30
|
-
deleteTokenMutation.mutate(deletingToken.id, {
|
|
31
|
-
onSuccess: (resp) => {
|
|
32
|
-
if (resp.success) {
|
|
33
|
-
enqueueToast(`Token "${deletingToken.name}" deleted.`, {
|
|
34
|
-
variant: 'success',
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
enqueueToast(resp.message || 'Failed to delete token.', {
|
|
39
|
-
variant: 'error',
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
onError: () => {
|
|
44
|
-
enqueueToast('Failed to delete token.', { variant: 'error' });
|
|
45
|
-
},
|
|
46
|
-
onSettled: () => setDeletingToken(null),
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return tokens.length === 0 ? (_jsxs(Blankslate, { border: true, spacious: true, children: [_jsx(Blankslate.Heading, { children: "Tokens" }), _jsx(Blankslate.Description, { children: _jsx(Text, { sx: { textAlign: 'center' }, children: "No Tokens found." }) })] })) : (_jsxs(_Fragment, { children: [_jsxs(Table.Container, { children: [_jsx(Table.Title, { as: "h2", id: "tokens", children: "Tokens" }), _jsx(Table.Subtitle, { as: "p", id: "tokens-subtitle", children: "Your tokens." }), _jsx(DataTable, { "aria-labelledby": "teams", "aria-describedby": "teams-subtitle", data: tokens, columns: [
|
|
50
|
-
{
|
|
51
|
-
header: 'Type',
|
|
52
|
-
field: 'variant',
|
|
53
|
-
renderCell: token => _jsx(Label, { children: token.variant }),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
header: 'Name',
|
|
57
|
-
field: 'name',
|
|
58
|
-
rowHeader: true,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
header: 'Description',
|
|
62
|
-
field: 'description',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
header: 'Expiration date',
|
|
66
|
-
field: 'expirationDate',
|
|
67
|
-
renderCell: token => (_jsx(RelativeTime, { date: new Date(token.expirationDate) })),
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
header: '',
|
|
71
|
-
field: 'id',
|
|
72
|
-
renderCell: token => (_jsxs(Box, { display: "flex", sx: { gap: 1 }, children: [_jsx(IconButton, { icon: EditIcon, "aria-label": "Edit", size: "small", variant: "invisible", onClick: e => navigate(`${token.id}`, e) }), _jsx(IconButton, { ref: returnFocusRef, icon: TrashIcon, "aria-label": "Delete", size: "small", variant: "invisible", sx: { color: 'danger.fg' }, onClick: () => setDeletingToken(token) })] })),
|
|
73
|
-
},
|
|
74
|
-
] })] }), deletingToken && (_jsxs(ConfirmationDialog, { title: "Delete token", onClose: gesture => {
|
|
75
|
-
if (gesture === 'confirm')
|
|
76
|
-
handleDeleteConfirm();
|
|
77
|
-
else
|
|
78
|
-
setDeletingToken(null);
|
|
79
|
-
}, confirmButtonContent: "Delete", confirmButtonType: "danger", children: ["Are you sure you want to delete the token", ' ', _jsx("strong", { children: deletingToken.name }), "? This action cannot be undone."] }))] }));
|
|
80
|
-
};
|
|
81
|
-
export const Tokens = () => {
|
|
82
|
-
const navigate = useNavigate();
|
|
83
|
-
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: "Tokens" }) }), _jsx(PageHeader.Actions, { children: _jsx(Button, { size: "small", variant: "primary", onClick: e => navigate('/tokens/new', e), children: "New token" }) })] }) }), _jsx(PageLayout.Content, { children: _jsx(Box, { children: _jsx(TokensTable, {}) }) })] }));
|
|
84
|
-
};
|
|
85
|
-
export default Tokens;
|
|
File without changes
|
|
File without changes
|