@frogbotai/next 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/ChannelCell/index.client.js +6 -3
- package/dist/elements/ChannelCell/index.client.js.map +1 -1
- package/dist/elements/CostUSD/index.client.d.ts +13 -0
- package/dist/elements/CostUSD/index.client.d.ts.map +1 -0
- package/dist/elements/CostUSD/index.client.js +42 -0
- package/dist/elements/CostUSD/index.client.js.map +1 -0
- package/dist/elements/Nav/AccountMenu.js +80 -12
- package/dist/elements/Nav/AccountMenu.js.map +1 -1
- package/dist/elements/Nav/AppSidebar.js +144 -36
- package/dist/elements/Nav/AppSidebar.js.map +1 -1
- package/dist/elements/Nav/CollectionsSection.js +45 -13
- package/dist/elements/Nav/CollectionsSection.js.map +1 -1
- package/dist/elements/Nav/MobileNavToggle.js +11 -3
- package/dist/elements/Nav/MobileNavToggle.js.map +1 -1
- package/dist/elements/Nav/NavItem.d.ts.map +1 -1
- package/dist/elements/Nav/NavItem.js +22 -9
- package/dist/elements/Nav/NavItem.js.map +1 -1
- package/dist/elements/Nav/NavSection.js +47 -7
- package/dist/elements/Nav/NavSection.js.map +1 -1
- package/dist/elements/Nav/RecentsSection.client.js +72 -28
- package/dist/elements/Nav/RecentsSection.client.js.map +1 -1
- package/dist/elements/Nav/RecentsSection.js +19 -9
- package/dist/elements/Nav/RecentsSection.js.map +1 -1
- package/dist/elements/Nav/buildNavModel.js +35 -29
- package/dist/elements/Nav/buildNavModel.js.map +1 -1
- package/dist/elements/Nav/fixtures/consumer/RecentsSection.js +19 -9
- package/dist/elements/Nav/fixtures/consumer/RecentsSection.js.map +1 -1
- package/dist/elements/Nav/fixtures/consumer/config.js +5 -2
- package/dist/elements/Nav/fixtures/consumer/config.js.map +1 -1
- package/dist/elements/Nav/index.client.js +86 -27
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/elements/Nav/index.css +0 -5
- package/dist/elements/Nav/index.js +93 -47
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/elements/Nav/navShellState.js +2 -2
- package/dist/elements/Nav/navShellState.js.map +1 -1
- package/dist/elements/Nav/renderNavIcon.js +11 -4
- package/dist/elements/Nav/renderNavIcon.js.map +1 -1
- package/dist/elements/SettingsNav/index.d.ts.map +1 -1
- package/dist/elements/SettingsNav/index.js +59 -3
- package/dist/elements/SettingsNav/index.js.map +1 -1
- package/dist/elements/SignInButtons/index.client.js +44 -8
- package/dist/elements/SignInButtons/index.client.js.map +1 -1
- package/dist/elements/SignInButtons/index.js +16 -7
- package/dist/elements/SignInButtons/index.js.map +1 -1
- package/dist/elements/StepNavReset/TabTitleSync.js +17 -12
- package/dist/elements/StepNavReset/TabTitleSync.js.map +1 -1
- package/dist/elements/StepNavReset/index.client.js +14 -6
- package/dist/elements/StepNavReset/index.client.js.map +1 -1
- package/dist/elements/ViewSwitcher/index.client.js +19 -10
- package/dist/elements/ViewSwitcher/index.client.js.map +1 -1
- package/dist/exports/ChatView.client.js +219 -101
- package/dist/exports/ChatView.client.js.map +1 -1
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +6 -4
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/config.js +1 -0
- package/dist/exports/config.js.map +1 -1
- package/dist/exports/css.js +1 -0
- package/dist/exports/css.js.map +1 -1
- package/dist/exports/layouts.js +15 -4
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/routes.js +3 -2
- package/dist/exports/routes.js.map +1 -1
- package/dist/exports/rsc.js +1 -0
- package/dist/exports/rsc.js.map +1 -1
- package/dist/exports/templates.js +1 -0
- package/dist/exports/templates.js.map +1 -1
- package/dist/exports/views.d.ts.map +1 -1
- package/dist/exports/views.js +274 -104
- package/dist/exports/views.js.map +1 -1
- package/dist/graphics/FrogBotIcon.js +5 -1
- package/dist/graphics/FrogBotIcon.js.map +1 -1
- package/dist/graphics/FrogBotLogo.js +42 -1
- package/dist/graphics/FrogBotLogo.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/Default/index.js +7 -2
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/brandImportMapErrors.js +4 -6
- package/dist/utilities/brandImportMapErrors.js.map +1 -1
- package/dist/views/Board/BoardPreference.client.js +26 -11
- package/dist/views/Board/BoardPreference.client.js.map +1 -1
- package/dist/views/Board/BoardView.client.js +155 -59
- package/dist/views/Board/BoardView.client.js.map +1 -1
- package/dist/views/Board/data.js +46 -35
- package/dist/views/Board/data.js.map +1 -1
- package/dist/views/Board/index.js +103 -63
- package/dist/views/Board/index.js.map +1 -1
- package/dist/views/Board/resolveActiveView.js +3 -2
- package/dist/views/Board/resolveActiveView.js.map +1 -1
- package/dist/views/Board/resolveColumns.js +40 -33
- package/dist/views/Board/resolveColumns.js.map +1 -1
- package/dist/views/Calendar/CalendarPreference.client.js +26 -11
- package/dist/views/Calendar/CalendarPreference.client.js.map +1 -1
- package/dist/views/Calendar/CalendarView.client.js +194 -72
- package/dist/views/Calendar/CalendarView.client.js.map +1 -1
- package/dist/views/Calendar/data.js +9 -9
- package/dist/views/Calendar/data.js.map +1 -1
- package/dist/views/Calendar/index.js +83 -52
- package/dist/views/Calendar/index.js.map +1 -1
- package/dist/views/CollectionViewShell.client.js +70 -9
- package/dist/views/CollectionViewShell.client.js.map +1 -1
- package/dist/views/CollectionViewShell.js +34 -12
- package/dist/views/CollectionViewShell.js.map +1 -1
- package/dist/views/CollectionViewSwitcher.js +18 -6
- package/dist/views/CollectionViewSwitcher.js.map +1 -1
- package/dist/views/Connections/ConnectionFields.js +141 -9
- package/dist/views/Connections/ConnectionFields.js.map +1 -1
- package/dist/views/Connections/ConnectionsView.client.js +397 -89
- package/dist/views/Connections/ConnectionsView.client.js.map +1 -1
- package/dist/views/Connections/index.js +34 -22
- package/dist/views/Connections/index.js.map +1 -1
- package/dist/views/Connections/schema.js +75 -50
- package/dist/views/Connections/schema.js.map +1 -1
- package/dist/views/Connections/types.js +2 -1
- package/dist/views/Connections/types.js.map +1 -1
- package/dist/views/CustomCollectionView.js +12 -7
- package/dist/views/CustomCollectionView.js.map +1 -1
- package/dist/views/List/DefaultListView.client.js +197 -52
- package/dist/views/List/DefaultListView.client.js.map +1 -1
- package/dist/views/Settings/metadata.d.ts +6 -0
- package/dist/views/Settings/metadata.d.ts.map +1 -0
- package/dist/views/Settings/metadata.js +40 -0
- package/dist/views/Settings/metadata.js.map +1 -0
- package/dist/views/Settings/resolveSection.d.ts +24 -0
- package/dist/views/Settings/resolveSection.d.ts.map +1 -0
- package/dist/views/Settings/resolveSection.js +24 -0
- package/dist/views/Settings/resolveSection.js.map +1 -0
- package/dist/views/cells.js +10 -17
- package/dist/views/cells.js.map +1 -1
- package/dist/views/collectionViews.js +9 -9
- package/dist/views/collectionViews.js.map +1 -1
- package/dist/views/controls/SortBuilder.client.js +140 -37
- package/dist/views/controls/SortBuilder.client.js.map +1 -1
- package/dist/views/controls/ViewControls.client.js +105 -41
- package/dist/views/controls/ViewControls.client.js.map +1 -1
- package/dist/views/controls/groupBy.js +2 -1
- package/dist/views/controls/groupBy.js.map +1 -1
- package/dist/views/preferences.js +17 -9
- package/dist/views/preferences.js.map +1 -1
- package/dist/withFrogBot.js +56 -42
- package/dist/withFrogBot.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Label, RadioGroup, RadioGroupItem, SearchInput
|
|
4
|
-
import { ChevronLeftIcon, DeleteIcon, LinkSquareIcon, LoadingIcon, MoreHorizontalIcon
|
|
3
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Label, RadioGroup, RadioGroupItem, SearchInput } from '@frogbotai/ui';
|
|
4
|
+
import { ChevronLeftIcon, DeleteIcon, LinkSquareIcon, LoadingIcon, MoreHorizontalIcon } from '@frogbotai/ui/icons';
|
|
5
5
|
import { useId, useRef, useState } from 'react';
|
|
6
6
|
import { ConnectionFields } from './ConnectionFields.js';
|
|
7
7
|
import { connectionInput, initialConnectionValue } from './schema.js';
|
|
8
|
-
function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated, onBusyChange
|
|
8
|
+
function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated, onBusyChange }) {
|
|
9
9
|
const id = useId();
|
|
10
10
|
const [method, setMethod] = useState(piece.oauth ? 'oauth' : 'secret');
|
|
11
|
-
const [value, setValue] = useState(()
|
|
11
|
+
const [value, setValue] = useState(()=>piece.secretSchema ? initialConnectionValue(piece.secretSchema) : undefined);
|
|
12
12
|
const [error, setError] = useState('');
|
|
13
13
|
const [busy, setBusy] = useState(false);
|
|
14
14
|
const submitting = useRef(false);
|
|
15
|
-
const submit = async ()
|
|
16
|
-
if (submitting.current)
|
|
17
|
-
return;
|
|
15
|
+
const submit = async ()=>{
|
|
16
|
+
if (submitting.current) return;
|
|
18
17
|
setError('');
|
|
19
18
|
if (method === 'oauth') {
|
|
20
19
|
submitting.current = true;
|
|
21
20
|
setBusy(true);
|
|
22
21
|
onBusyChange(true);
|
|
23
|
-
window.location.assign(`${apiPath}/${encodeURIComponent(piece.slug)}/authorize?${new URLSearchParams({
|
|
22
|
+
window.location.assign(`${apiPath}/${encodeURIComponent(piece.slug)}/authorize?${new URLSearchParams({
|
|
23
|
+
returnTo
|
|
24
|
+
})}`);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
if (!piece.secretSchema) {
|
|
@@ -29,9 +30,11 @@ function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated,
|
|
|
29
30
|
}
|
|
30
31
|
let body;
|
|
31
32
|
try {
|
|
32
|
-
body = JSON.stringify(connectionInput({
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
body = JSON.stringify(connectionInput({
|
|
34
|
+
field: piece.secretSchema,
|
|
35
|
+
value
|
|
36
|
+
}));
|
|
37
|
+
} catch (error) {
|
|
35
38
|
setError(error instanceof Error ? error.message : 'Check your credential values.');
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
@@ -42,81 +45,311 @@ function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated,
|
|
|
42
45
|
const response = await fetch(`${apiPath}/${encodeURIComponent(piece.slug)}`, {
|
|
43
46
|
method: 'POST',
|
|
44
47
|
credentials: 'same-origin',
|
|
45
|
-
headers: {
|
|
46
|
-
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json'
|
|
50
|
+
},
|
|
51
|
+
body
|
|
47
52
|
});
|
|
48
53
|
if (!response.ok) {
|
|
49
|
-
setError(response.status === 401
|
|
50
|
-
? 'Your session has expired. Sign in and try again.'
|
|
51
|
-
: response.status === 400
|
|
52
|
-
? 'These credentials were not accepted. Check the values and try again.'
|
|
53
|
-
: 'Could not create the connection. Please try again.');
|
|
54
|
+
setError(response.status === 401 ? 'Your session has expired. Sign in and try again.' : response.status === 400 ? 'These credentials were not accepted. Check the values and try again.' : 'Could not create the connection. Please try again.');
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
setValue(undefined);
|
|
57
58
|
onCreated();
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
59
|
+
} catch {
|
|
60
60
|
setError('Could not reach the server. Please try again.');
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
61
|
+
} finally{
|
|
63
62
|
submitting.current = false;
|
|
64
63
|
setBusy(false);
|
|
65
64
|
onBusyChange(false);
|
|
66
65
|
}
|
|
67
66
|
};
|
|
68
|
-
return
|
|
67
|
+
return /*#__PURE__*/ _jsxs("form", {
|
|
68
|
+
className: "frogbot-connections__form",
|
|
69
|
+
onSubmit: (event)=>{
|
|
69
70
|
event.preventDefault();
|
|
70
71
|
void submit();
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
},
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsxs(Button, {
|
|
75
|
+
autoFocus: true,
|
|
76
|
+
type: "button",
|
|
77
|
+
variant: "ghost",
|
|
78
|
+
size: "sm",
|
|
79
|
+
className: "frogbot-connections__back",
|
|
80
|
+
disabled: busy,
|
|
81
|
+
onClick: onBack,
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ _jsx(ChevronLeftIcon, {
|
|
84
|
+
size: 16
|
|
85
|
+
}),
|
|
86
|
+
"Back"
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ _jsxs(DialogHeader, {
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ _jsxs(DialogTitle, {
|
|
92
|
+
children: [
|
|
93
|
+
"Connect to ",
|
|
94
|
+
piece.label
|
|
95
|
+
]
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ _jsx(DialogDescription, {
|
|
98
|
+
children: method === 'oauth' ? 'Authorize access with your account.' : 'Enter your credentials to link this integration.'
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ _jsxs("fieldset", {
|
|
103
|
+
disabled: busy,
|
|
104
|
+
className: "frogbot-connections__form-fields",
|
|
105
|
+
children: [
|
|
106
|
+
piece.oauth && piece.secret && /*#__PURE__*/ _jsxs(RadioGroup, {
|
|
107
|
+
"aria-label": "Connection method",
|
|
108
|
+
value: method,
|
|
109
|
+
onValueChange: (next)=>{
|
|
74
110
|
setMethod(next);
|
|
75
111
|
setError('');
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
:
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
},
|
|
113
|
+
className: "frogbot-connections__methods",
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ _jsxs(Label, {
|
|
116
|
+
className: "frogbot-connections__method",
|
|
117
|
+
htmlFor: `${id}-oauth`,
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsx(RadioGroupItem, {
|
|
120
|
+
id: `${id}-oauth`,
|
|
121
|
+
value: "oauth"
|
|
122
|
+
}),
|
|
123
|
+
"OAuth"
|
|
124
|
+
]
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ _jsxs(Label, {
|
|
127
|
+
className: "frogbot-connections__method",
|
|
128
|
+
htmlFor: `${id}-secret`,
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ _jsx(RadioGroupItem, {
|
|
131
|
+
id: `${id}-secret`,
|
|
132
|
+
value: "secret"
|
|
133
|
+
}),
|
|
134
|
+
"Static credentials"
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
method === 'secret' && piece.secretSchema && /*#__PURE__*/ _jsx(ConnectionFields, {
|
|
140
|
+
field: piece.secretSchema,
|
|
141
|
+
label: "Credential",
|
|
142
|
+
value: value,
|
|
143
|
+
onChange: setValue
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}),
|
|
147
|
+
error && /*#__PURE__*/ _jsx("p", {
|
|
148
|
+
role: "alert",
|
|
149
|
+
className: "frogbot-connections__error",
|
|
150
|
+
children: error
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ _jsxs(DialogFooter, {
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
155
|
+
type: "button",
|
|
156
|
+
variant: "outline",
|
|
157
|
+
disabled: busy,
|
|
158
|
+
onClick: onCancel,
|
|
159
|
+
children: "Cancel"
|
|
160
|
+
}),
|
|
161
|
+
/*#__PURE__*/ _jsxs(Button, {
|
|
162
|
+
type: "submit",
|
|
163
|
+
disabled: busy || method === 'secret' && !piece.secretSchema,
|
|
164
|
+
children: [
|
|
165
|
+
busy && /*#__PURE__*/ _jsx(LoadingIcon, {
|
|
166
|
+
className: "frogbot-connections__spinner",
|
|
167
|
+
size: 16
|
|
168
|
+
}),
|
|
169
|
+
busy ? method === 'oauth' ? 'Redirecting…' : 'Connecting…' : method === 'oauth' ? `Continue with ${piece.label}` : 'Connect'
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
83
176
|
}
|
|
84
|
-
function NewConnectionDialog({ pieces, apiPath, returnTo, open, onOpenChange, onCreated
|
|
177
|
+
function NewConnectionDialog({ pieces, apiPath, returnTo, open, onOpenChange, onCreated }) {
|
|
85
178
|
const [selected, setSelected] = useState();
|
|
86
179
|
const [search, setSearch] = useState('');
|
|
87
180
|
const [busy, setBusy] = useState(false);
|
|
88
181
|
const query = search.trim().toLowerCase();
|
|
89
|
-
const filtered = pieces.filter((piece)
|
|
90
|
-
const changeOpen = (next)
|
|
91
|
-
if (busy)
|
|
92
|
-
return;
|
|
182
|
+
const filtered = pieces.filter((piece)=>`${piece.label} ${piece.slug}`.toLowerCase().includes(query));
|
|
183
|
+
const changeOpen = (next)=>{
|
|
184
|
+
if (busy) return;
|
|
93
185
|
if (!next) {
|
|
94
186
|
setSelected(undefined);
|
|
95
187
|
setSearch('');
|
|
96
188
|
}
|
|
97
189
|
onOpenChange(next);
|
|
98
190
|
};
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
191
|
+
return /*#__PURE__*/ _jsx(Dialog, {
|
|
192
|
+
open: open,
|
|
193
|
+
onOpenChange: changeOpen,
|
|
194
|
+
children: /*#__PURE__*/ _jsx(DialogContent, {
|
|
195
|
+
className: `frogbot-connections__dialog${selected ? ' frogbot-connections__dialog--selected' : ''}`,
|
|
196
|
+
onInteractOutside: (event)=>event.preventDefault(),
|
|
197
|
+
onEscapeKeyDown: (event)=>{
|
|
198
|
+
if (busy) event.preventDefault();
|
|
199
|
+
},
|
|
200
|
+
withCloseButton: !busy,
|
|
201
|
+
children: selected ? /*#__PURE__*/ _jsx(ConnectionForm, {
|
|
202
|
+
piece: selected,
|
|
203
|
+
apiPath: apiPath,
|
|
204
|
+
returnTo: returnTo,
|
|
205
|
+
onBack: ()=>setSelected(undefined),
|
|
206
|
+
onCancel: ()=>changeOpen(false),
|
|
207
|
+
onBusyChange: setBusy,
|
|
208
|
+
onCreated: ()=>{
|
|
103
209
|
setSelected(undefined);
|
|
104
210
|
setSearch('');
|
|
105
211
|
onCreated();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
212
|
+
}
|
|
213
|
+
}, selected.slug) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
214
|
+
children: [
|
|
215
|
+
/*#__PURE__*/ _jsxs(DialogHeader, {
|
|
216
|
+
children: [
|
|
217
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
218
|
+
children: "Select integration"
|
|
219
|
+
}),
|
|
220
|
+
/*#__PURE__*/ _jsx(DialogDescription, {
|
|
221
|
+
children: "Choose an integration to connect."
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
}),
|
|
225
|
+
/*#__PURE__*/ _jsx(SearchInput, {
|
|
226
|
+
autoFocus: true,
|
|
227
|
+
"aria-label": "Search integrations",
|
|
228
|
+
placeholder: "Search integrations…",
|
|
229
|
+
value: search,
|
|
230
|
+
onChange: setSearch
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
233
|
+
className: "frogbot-connections__picker",
|
|
234
|
+
children: [
|
|
235
|
+
filtered.length === 0 && /*#__PURE__*/ _jsx("p", {
|
|
236
|
+
className: "frogbot-connections__empty",
|
|
237
|
+
children: "No integrations found"
|
|
238
|
+
}),
|
|
239
|
+
filtered.map((piece)=>/*#__PURE__*/ _jsxs("button", {
|
|
240
|
+
type: "button",
|
|
241
|
+
className: "frogbot-connections__piece",
|
|
242
|
+
onClick: ()=>setSelected(piece),
|
|
243
|
+
children: [
|
|
244
|
+
/*#__PURE__*/ _jsx("span", {
|
|
245
|
+
className: "frogbot-connections__icon",
|
|
246
|
+
children: /*#__PURE__*/ _jsx(LinkSquareIcon, {
|
|
247
|
+
size: 20
|
|
248
|
+
})
|
|
249
|
+
}),
|
|
250
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
251
|
+
children: [
|
|
252
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
253
|
+
children: piece.label
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ _jsx("span", {
|
|
256
|
+
className: "frogbot-connections__muted",
|
|
257
|
+
children: [
|
|
258
|
+
piece.oauth && 'OAuth',
|
|
259
|
+
piece.secret && 'Static credentials'
|
|
260
|
+
].filter(Boolean).join(' · ')
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
]
|
|
265
|
+
}, piece.slug))
|
|
266
|
+
]
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
});
|
|
109
272
|
}
|
|
110
|
-
function ConnectionRow({ connection, label, busy, onDisconnect
|
|
111
|
-
const expired = connection.status === 'active' &&
|
|
112
|
-
connection.expiresAt &&
|
|
113
|
-
Date.parse(connection.expiresAt) <= Date.now();
|
|
273
|
+
function ConnectionRow({ connection, label, busy, onDisconnect }) {
|
|
274
|
+
const expired = connection.status === 'active' && connection.expiresAt && Date.parse(connection.expiresAt) <= Date.now();
|
|
114
275
|
const status = expired ? 'expired' : connection.status;
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
|
|
276
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
277
|
+
className: "frogbot-connections__row",
|
|
278
|
+
children: [
|
|
279
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
280
|
+
className: "frogbot-connections__identity",
|
|
281
|
+
children: [
|
|
282
|
+
/*#__PURE__*/ _jsx("span", {
|
|
283
|
+
className: "frogbot-connections__icon",
|
|
284
|
+
children: /*#__PURE__*/ _jsx(LinkSquareIcon, {
|
|
285
|
+
size: 20
|
|
286
|
+
})
|
|
287
|
+
}),
|
|
288
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
289
|
+
children: [
|
|
290
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
291
|
+
children: connection.account?.label || connection.account?.email || label
|
|
292
|
+
}),
|
|
293
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
294
|
+
className: "frogbot-connections__muted",
|
|
295
|
+
children: [
|
|
296
|
+
label,
|
|
297
|
+
connection.account?.email && connection.account.email !== connection.account.label ? ` · ${connection.account.email}` : ''
|
|
298
|
+
]
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
})
|
|
302
|
+
]
|
|
303
|
+
}),
|
|
304
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
305
|
+
className: "frogbot-connections__row-actions",
|
|
306
|
+
children: [
|
|
307
|
+
/*#__PURE__*/ _jsx("span", {
|
|
308
|
+
className: `frogbot-connections__status frogbot-connections__status--${status}`,
|
|
309
|
+
children: status
|
|
310
|
+
}),
|
|
311
|
+
/*#__PURE__*/ _jsx("span", {
|
|
312
|
+
className: "frogbot-connections__muted",
|
|
313
|
+
children: connection.method === 'oauth' ? 'OAuth' : 'Static credentials'
|
|
314
|
+
}),
|
|
315
|
+
/*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
316
|
+
children: [
|
|
317
|
+
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
318
|
+
asChild: true,
|
|
319
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
320
|
+
variant: "ghost",
|
|
321
|
+
size: "icon",
|
|
322
|
+
disabled: busy,
|
|
323
|
+
"aria-label": `Options for ${label}`,
|
|
324
|
+
children: busy ? /*#__PURE__*/ _jsx(LoadingIcon, {
|
|
325
|
+
className: "frogbot-connections__spinner",
|
|
326
|
+
size: 16
|
|
327
|
+
}) : /*#__PURE__*/ _jsx(MoreHorizontalIcon, {
|
|
328
|
+
size: 16
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
}),
|
|
332
|
+
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
333
|
+
align: "end",
|
|
334
|
+
children: /*#__PURE__*/ _jsxs(DropdownMenuItem, {
|
|
335
|
+
className: "frogbot-connections__disconnect",
|
|
336
|
+
onSelect: onDisconnect,
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ _jsx(DeleteIcon, {
|
|
339
|
+
size: 16
|
|
340
|
+
}),
|
|
341
|
+
"Disconnect"
|
|
342
|
+
]
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
]
|
|
346
|
+
})
|
|
347
|
+
]
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
});
|
|
118
351
|
}
|
|
119
|
-
export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnections, initialError
|
|
352
|
+
export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnections, initialError }) {
|
|
120
353
|
const [connections, setConnections] = useState(initialConnections);
|
|
121
354
|
const [error, setError] = useState(initialError ?? '');
|
|
122
355
|
const [search, setSearch] = useState('');
|
|
@@ -125,72 +358,147 @@ export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnec
|
|
|
125
358
|
const [deleting, setDeleting] = useState();
|
|
126
359
|
const requestID = useRef(0);
|
|
127
360
|
const removing = useRef(false);
|
|
128
|
-
const labels = new Map(pieces.map((piece)
|
|
361
|
+
const labels = new Map(pieces.map((piece)=>[
|
|
362
|
+
piece.slug,
|
|
363
|
+
piece.label
|
|
364
|
+
]));
|
|
129
365
|
const query = search.trim().toLowerCase();
|
|
130
|
-
const filtered = connections.filter((connection)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.toLowerCase()
|
|
138
|
-
.includes(query));
|
|
139
|
-
const refresh = async () => {
|
|
366
|
+
const filtered = connections.filter((connection)=>[
|
|
367
|
+
connection.piece,
|
|
368
|
+
labels.get(connection.piece),
|
|
369
|
+
connection.account?.label,
|
|
370
|
+
connection.account?.email
|
|
371
|
+
].join(' ').toLowerCase().includes(query));
|
|
372
|
+
const refresh = async ()=>{
|
|
140
373
|
const request = ++requestID.current;
|
|
141
374
|
setLoading(true);
|
|
142
375
|
setError('');
|
|
143
376
|
try {
|
|
144
377
|
const response = await fetch(`${apiPath}?limit=0&depth=0`, {
|
|
145
378
|
credentials: 'same-origin',
|
|
146
|
-
cache: 'no-store'
|
|
379
|
+
cache: 'no-store'
|
|
147
380
|
});
|
|
148
|
-
if (!response.ok)
|
|
149
|
-
|
|
150
|
-
const data = (await response.json());
|
|
381
|
+
if (!response.ok) throw new Error('Could not load your linked accounts. Please try again.');
|
|
382
|
+
const data = await response.json();
|
|
151
383
|
if (!Array.isArray(data.docs)) {
|
|
152
384
|
throw new Error('Could not load your linked accounts. Please try again.');
|
|
153
385
|
}
|
|
154
|
-
if (request === requestID.current)
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
386
|
+
if (request === requestID.current) setConnections(data.docs);
|
|
387
|
+
} catch {
|
|
158
388
|
if (request === requestID.current) {
|
|
159
389
|
setError('Could not load your linked accounts. Please try again.');
|
|
160
390
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (request === requestID.current)
|
|
164
|
-
setLoading(false);
|
|
391
|
+
} finally{
|
|
392
|
+
if (request === requestID.current) setLoading(false);
|
|
165
393
|
}
|
|
166
394
|
};
|
|
167
|
-
const disconnect = async (id)
|
|
168
|
-
if (removing.current)
|
|
169
|
-
return;
|
|
395
|
+
const disconnect = async (id)=>{
|
|
396
|
+
if (removing.current) return;
|
|
170
397
|
removing.current = true;
|
|
171
398
|
setDeleting(id);
|
|
172
399
|
setError('');
|
|
173
400
|
try {
|
|
174
401
|
const response = await fetch(`${apiPath}/${encodeURIComponent(String(id))}`, {
|
|
175
402
|
method: 'DELETE',
|
|
176
|
-
credentials: 'same-origin'
|
|
403
|
+
credentials: 'same-origin'
|
|
177
404
|
});
|
|
178
|
-
if (!response.ok)
|
|
179
|
-
|
|
180
|
-
setConnections((current) => current.filter((connection) => connection.id !== id));
|
|
405
|
+
if (!response.ok) throw new Error('Could not disconnect this account. Please try again.');
|
|
406
|
+
setConnections((current)=>current.filter((connection)=>connection.id !== id));
|
|
181
407
|
await refresh();
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
408
|
+
} catch {
|
|
184
409
|
setError('Could not disconnect this account. Please try again.');
|
|
185
|
-
}
|
|
186
|
-
finally {
|
|
410
|
+
} finally{
|
|
187
411
|
removing.current = false;
|
|
188
412
|
setDeleting(undefined);
|
|
189
413
|
}
|
|
190
414
|
};
|
|
191
|
-
return
|
|
415
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
416
|
+
className: "frogbot-connections",
|
|
417
|
+
children: [
|
|
418
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
419
|
+
className: "frogbot-connections__toolbar",
|
|
420
|
+
children: [
|
|
421
|
+
/*#__PURE__*/ _jsx(SearchInput, {
|
|
422
|
+
"aria-label": "Search connections",
|
|
423
|
+
placeholder: "Search connections…",
|
|
424
|
+
value: search,
|
|
425
|
+
onChange: setSearch
|
|
426
|
+
}),
|
|
427
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
428
|
+
size: "sm",
|
|
429
|
+
onClick: ()=>setOpen(true),
|
|
430
|
+
disabled: pieces.length === 0,
|
|
431
|
+
children: "+ New Connection"
|
|
432
|
+
})
|
|
433
|
+
]
|
|
434
|
+
}),
|
|
435
|
+
error && /*#__PURE__*/ _jsxs("div", {
|
|
436
|
+
className: "frogbot-connections__error",
|
|
437
|
+
role: "alert",
|
|
438
|
+
children: [
|
|
439
|
+
/*#__PURE__*/ _jsx("span", {
|
|
440
|
+
children: error
|
|
441
|
+
}),
|
|
442
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
443
|
+
variant: "outline",
|
|
444
|
+
size: "sm",
|
|
445
|
+
disabled: loading,
|
|
446
|
+
onClick: ()=>void refresh(),
|
|
447
|
+
children: "Try again"
|
|
448
|
+
})
|
|
449
|
+
]
|
|
450
|
+
}),
|
|
451
|
+
loading ? /*#__PURE__*/ _jsxs("div", {
|
|
452
|
+
role: "status",
|
|
453
|
+
className: "frogbot-connections__empty",
|
|
454
|
+
children: [
|
|
455
|
+
/*#__PURE__*/ _jsx(LoadingIcon, {
|
|
456
|
+
size: 24,
|
|
457
|
+
className: "frogbot-connections__spinner"
|
|
458
|
+
}),
|
|
459
|
+
/*#__PURE__*/ _jsx("span", {
|
|
460
|
+
children: "Loading connections…"
|
|
461
|
+
})
|
|
462
|
+
]
|
|
463
|
+
}) : filtered.length === 0 ? error ? null : /*#__PURE__*/ _jsxs("div", {
|
|
464
|
+
className: "frogbot-connections__empty frogbot-connections__empty--bordered",
|
|
465
|
+
children: [
|
|
466
|
+
/*#__PURE__*/ _jsx(LinkSquareIcon, {
|
|
467
|
+
size: 32
|
|
468
|
+
}),
|
|
469
|
+
/*#__PURE__*/ _jsx("p", {
|
|
470
|
+
children: query ? 'No connections match your search' : 'No connections yet'
|
|
471
|
+
}),
|
|
472
|
+
!query && /*#__PURE__*/ _jsx(Button, {
|
|
473
|
+
variant: "outline",
|
|
474
|
+
size: "sm",
|
|
475
|
+
disabled: pieces.length === 0,
|
|
476
|
+
onClick: ()=>setOpen(true),
|
|
477
|
+
children: "Add your first connection"
|
|
478
|
+
})
|
|
479
|
+
]
|
|
480
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
481
|
+
className: "frogbot-connections__rows",
|
|
482
|
+
children: filtered.map((connection)=>/*#__PURE__*/ _jsx(ConnectionRow, {
|
|
483
|
+
connection: connection,
|
|
484
|
+
label: labels.get(connection.piece) ?? connection.piece,
|
|
485
|
+
busy: deleting === connection.id,
|
|
486
|
+
onDisconnect: ()=>void disconnect(connection.id)
|
|
487
|
+
}, connection.id))
|
|
488
|
+
}),
|
|
489
|
+
/*#__PURE__*/ _jsx(NewConnectionDialog, {
|
|
490
|
+
pieces: pieces,
|
|
491
|
+
apiPath: apiPath,
|
|
492
|
+
returnTo: returnTo,
|
|
493
|
+
open: open,
|
|
494
|
+
onOpenChange: setOpen,
|
|
495
|
+
onCreated: ()=>{
|
|
192
496
|
setOpen(false);
|
|
193
497
|
void refresh();
|
|
194
|
-
}
|
|
498
|
+
}
|
|
499
|
+
})
|
|
500
|
+
]
|
|
501
|
+
});
|
|
195
502
|
}
|
|
503
|
+
|
|
196
504
|
//# sourceMappingURL=ConnectionsView.client.js.map
|