@iblai/iblai-js 2.62.1 → 2.62.3
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/data-layer/playwright/index.d.ts +1 -1
- package/dist/data-layer/playwright/spend-limits-helpers.d.ts +80 -2
- package/dist/playwright/index.cjs +210 -2
- package/dist/playwright/index.cjs.map +1 -1
- package/dist/playwright/index.d.ts +81 -3
- package/dist/playwright/index.esm.js +197 -3
- package/dist/playwright/index.esm.js.map +1 -1
- package/dist/playwright/playwright/index.d.ts +1 -1
- package/dist/playwright/playwright/spend-limits-helpers.d.ts +80 -2
- package/dist/security/playwright/index.d.ts +1 -1
- package/dist/security/playwright/spend-limits-helpers.d.ts +80 -2
- package/dist/web-containers/playwright/index.d.ts +1 -1
- package/dist/web-containers/playwright/spend-limits-helpers.d.ts +80 -2
- package/dist/web-containers/source/_virtual/index2.js +2 -2
- package/dist/web-containers/source/_virtual/index3.js +2 -2
- package/dist/web-containers/source/add-resource-modal.js +3 -2
- package/dist/web-containers/source/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/agent-limits-section.js +3 -5
- package/dist/web-containers/source/agent-limits-section.js.map +1 -1
- package/dist/web-containers/source/billing.js +9 -3
- package/dist/web-containers/source/billing.js.map +1 -1
- package/dist/web-containers/source/chat/index.js +39 -11
- package/dist/web-containers/source/chat/index.js.map +1 -1
- package/dist/web-containers/source/chat-input-form.js +2 -2
- package/dist/web-containers/source/chat-input-form.js.map +1 -1
- package/dist/web-containers/source/components/chat/index.js +39 -11
- package/dist/web-containers/source/components/chat/index.js.map +1 -1
- package/dist/web-containers/source/components/chat-input-form.js +2 -2
- package/dist/web-containers/source/components/chat-input-form.js.map +1 -1
- package/dist/web-containers/source/components/hooks/use-google-drive-picker.js +158 -54
- package/dist/web-containers/source/components/hooks/use-google-drive-picker.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js +3 -2
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/billing.js +9 -3
- package/dist/web-containers/source/components/profile/billing.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/agent-limits-section.js +3 -5
- package/dist/web-containers/source/components/spend-caps/agent-limits-section.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/labels.js +74 -0
- package/dist/web-containers/source/components/spend-caps/labels.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/new-user-default-section.js +78 -0
- package/dist/web-containers/source/components/spend-caps/new-user-default-section.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/row-icon-action.js +16 -0
- package/dist/web-containers/source/components/spend-caps/row-icon-action.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/spend-cap-fields.js +23 -0
- package/dist/web-containers/source/components/spend-caps/spend-cap-fields.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/spend-cap-form.js +21 -23
- package/dist/web-containers/source/components/spend-caps/spend-cap-form.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/spend-cap-usage.js +1 -0
- package/dist/web-containers/source/components/spend-caps/spend-cap-usage.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/use-platform-user-options.js +39 -0
- package/dist/web-containers/source/components/spend-caps/use-platform-user-options.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/use-spend-cap-status.js +23 -0
- package/dist/web-containers/source/components/spend-caps/use-spend-cap-status.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/use-spend-caps.js +1 -11
- package/dist/web-containers/source/components/spend-caps/use-spend-caps.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/user-cap-modal.js +8 -32
- package/dist/web-containers/source/components/spend-caps/user-cap-modal.js.map +1 -1
- package/dist/web-containers/source/components/spend-caps/user-limits-section.js +117 -0
- package/dist/web-containers/source/components/spend-caps/user-limits-section.js.map +1 -0
- package/dist/web-containers/source/components/spend-caps/utils.js +14 -1
- package/dist/web-containers/source/components/spend-caps/utils.js.map +1 -1
- package/dist/web-containers/source/datasets-tab/add-resource-modal.js +3 -2
- package/dist/web-containers/source/datasets-tab/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js +3 -2
- package/dist/web-containers/source/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/en.json.js +45 -5
- package/dist/web-containers/source/en.json.js.map +1 -1
- package/dist/web-containers/source/es.json.js +45 -5
- package/dist/web-containers/source/es.json.js.map +1 -1
- package/dist/web-containers/source/fr.json.js +45 -5
- package/dist/web-containers/source/fr.json.js.map +1 -1
- package/dist/web-containers/source/hooks/use-google-drive-picker.js +158 -54
- package/dist/web-containers/source/hooks/use-google-drive-picker.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/en.json.js +45 -5
- package/dist/web-containers/source/i18n/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/es.json.js +45 -5
- package/dist/web-containers/source/i18n/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/fr.json.js +45 -5
- package/dist/web-containers/source/i18n/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/zh.json.js +45 -5
- package/dist/web-containers/source/i18n/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/index2.js +2 -2
- package/dist/web-containers/source/index3.js +2 -2
- package/dist/web-containers/source/messages/en.json.js +45 -5
- package/dist/web-containers/source/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/messages/es.json.js +45 -5
- package/dist/web-containers/source/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/messages/fr.json.js +45 -5
- package/dist/web-containers/source/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/messages/zh.json.js +45 -5
- package/dist/web-containers/source/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js +3 -2
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/datasets-tab/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/new-user-default-section.js +78 -0
- package/dist/web-containers/source/new-user-default-section.js.map +1 -0
- package/dist/web-containers/source/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
- package/dist/web-containers/source/profile/billing.js +9 -3
- package/dist/web-containers/source/profile/billing.js.map +1 -1
- package/dist/web-containers/source/row-icon-action.js +16 -0
- package/dist/web-containers/source/row-icon-action.js.map +1 -0
- package/dist/web-containers/source/spend-cap-fields.js +23 -0
- package/dist/web-containers/source/spend-cap-fields.js.map +1 -0
- package/dist/web-containers/source/spend-cap-form.js +21 -23
- package/dist/web-containers/source/spend-cap-form.js.map +1 -1
- package/dist/web-containers/source/spend-cap-usage.js +1 -0
- package/dist/web-containers/source/spend-cap-usage.js.map +1 -1
- package/dist/web-containers/source/spend-caps/agent-limits-section.js +3 -5
- package/dist/web-containers/source/spend-caps/agent-limits-section.js.map +1 -1
- package/dist/web-containers/source/spend-caps/labels.js +74 -0
- package/dist/web-containers/source/spend-caps/labels.js.map +1 -1
- package/dist/web-containers/source/spend-caps/new-user-default-section.js +78 -0
- package/dist/web-containers/source/spend-caps/new-user-default-section.js.map +1 -0
- package/dist/web-containers/source/spend-caps/row-icon-action.js +16 -0
- package/dist/web-containers/source/spend-caps/row-icon-action.js.map +1 -0
- package/dist/web-containers/source/spend-caps/spend-cap-fields.js +23 -0
- package/dist/web-containers/source/spend-caps/spend-cap-fields.js.map +1 -0
- package/dist/web-containers/source/spend-caps/spend-cap-form.js +21 -23
- package/dist/web-containers/source/spend-caps/spend-cap-form.js.map +1 -1
- package/dist/web-containers/source/spend-caps/spend-cap-usage.js +1 -0
- package/dist/web-containers/source/spend-caps/spend-cap-usage.js.map +1 -1
- package/dist/web-containers/source/spend-caps/use-platform-user-options.js +39 -0
- package/dist/web-containers/source/spend-caps/use-platform-user-options.js.map +1 -0
- package/dist/web-containers/source/spend-caps/use-spend-cap-status.js +23 -0
- package/dist/web-containers/source/spend-caps/use-spend-cap-status.js.map +1 -0
- package/dist/web-containers/source/spend-caps/use-spend-caps.js +1 -11
- package/dist/web-containers/source/spend-caps/use-spend-caps.js.map +1 -1
- package/dist/web-containers/source/spend-caps/user-cap-modal.js +8 -32
- package/dist/web-containers/source/spend-caps/user-cap-modal.js.map +1 -1
- package/dist/web-containers/source/spend-caps/user-limits-section.js +117 -0
- package/dist/web-containers/source/spend-caps/user-limits-section.js.map +1 -0
- package/dist/web-containers/source/spend-caps/utils.js +14 -1
- package/dist/web-containers/source/spend-caps/utils.js.map +1 -1
- package/dist/web-containers/source/tabs/datasets-tab/add-resource-modal.js +3 -2
- package/dist/web-containers/source/tabs/datasets-tab/add-resource-modal.js.map +1 -1
- package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/use-google-drive-picker.js +158 -54
- package/dist/web-containers/source/use-google-drive-picker.js.map +1 -1
- package/dist/web-containers/source/use-platform-user-options.js +39 -0
- package/dist/web-containers/source/use-platform-user-options.js.map +1 -0
- package/dist/web-containers/source/use-spend-cap-status.js +23 -0
- package/dist/web-containers/source/use-spend-cap-status.js.map +1 -0
- package/dist/web-containers/source/use-spend-caps.js +1 -11
- package/dist/web-containers/source/use-spend-caps.js.map +1 -1
- package/dist/web-containers/source/user-cap-modal.js +8 -32
- package/dist/web-containers/source/user-cap-modal.js.map +1 -1
- package/dist/web-containers/source/user-limits-section.js +117 -0
- package/dist/web-containers/source/user-limits-section.js.map +1 -0
- package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/zh.json.js +45 -5
- package/dist/web-containers/source/zh.json.js.map +1 -1
- package/dist/web-utils/playwright/index.d.ts +1 -1
- package/dist/web-utils/playwright/spend-limits-helpers.d.ts +80 -2
- package/package.json +5 -5
|
@@ -7,6 +7,40 @@ import { extractErrorMessage } from '../modals/edit-mentor-modal/tabs/datasets-t
|
|
|
7
7
|
|
|
8
8
|
/** Least-privilege scope: only files the user picks/creates via the picker. */
|
|
9
9
|
const GOOGLE_DRIVE_SCOPES = ['https://www.googleapis.com/auth/drive.file'];
|
|
10
|
+
/**
|
|
11
|
+
* How long the picker may take to report `loaded` after sign-in. When the browser
|
|
12
|
+
* blocks Google's cookies in our page (Brave's default), docs.google.com/picker
|
|
13
|
+
* answers 401 with a sign-in page that never sends `loaded`.
|
|
14
|
+
*/
|
|
15
|
+
const PICKER_LOAD_TIMEOUT_MS = 10000;
|
|
16
|
+
const PICKER_BLOCKED_MESSAGE = 'Your browser blocked Google Drive. Try again and click Allow cookies in the Google window.';
|
|
17
|
+
const PICKER_OPEN_FAILED_MESSAGE = "Google Drive couldn't open. Try again in a moment.";
|
|
18
|
+
const PICKER_SELECTION_FAILED_MESSAGE = 'Something went wrong with Google Drive. Try again.';
|
|
19
|
+
/** How long to keep making newly added picker elements clickable after sign-in. */
|
|
20
|
+
const PICKER_CLICKABLE_WATCH_MS = 60000;
|
|
21
|
+
const PICKER_ELEMENTS_SELECTOR = [
|
|
22
|
+
'.picker-dialog',
|
|
23
|
+
'.picker-dialog-bg',
|
|
24
|
+
'div[role="dialog"][aria-label*="picker"]',
|
|
25
|
+
].join(',');
|
|
26
|
+
const PICKER_BOX_SELECTOR = '.picker-dialog, div[role="dialog"][aria-label*="picker"]';
|
|
27
|
+
/**
|
|
28
|
+
* The Add Resource dialog is modal and turns off pointer events outside itself, so
|
|
29
|
+
* Google's picker (and its "Allow cookies" screen, which never reports `loaded`)
|
|
30
|
+
* must opt back in.
|
|
31
|
+
*/
|
|
32
|
+
const makePickerClickable = () => {
|
|
33
|
+
document.querySelectorAll('iframe[src*="docs.google.com/picker"]').forEach((iframe) => {
|
|
34
|
+
if (iframe.parentElement) {
|
|
35
|
+
iframe.parentElement.style.pointerEvents = 'auto';
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
document.querySelectorAll(PICKER_ELEMENTS_SELECTOR).forEach((element) => {
|
|
39
|
+
element.style.pointerEvents = 'auto';
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
/** Google's picker wants the Cloud project number, the numeric prefix of the OAuth client id. */
|
|
43
|
+
const getGoogleAppId = (clientId) => { var _a; return (_a = /^(\d+)-[^.]+\.apps\.googleusercontent\.com$/.exec(clientId)) === null || _a === void 0 ? void 0 : _a[1]; };
|
|
10
44
|
const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
11
45
|
const [authToken, setAuthToken] = React__default.useState(null);
|
|
12
46
|
const [driveFiles, setDriveFiles] = React__default.useState([]);
|
|
@@ -22,6 +56,41 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
22
56
|
client_secret: '',
|
|
23
57
|
});
|
|
24
58
|
const [pickerError, setPickerError] = React__default.useState(null);
|
|
59
|
+
const pickerLoadTimerRef = React__default.useRef(null);
|
|
60
|
+
// True from opening the picker until it reports back; the lib only shows the
|
|
61
|
+
// picker after the sign-in popup returns a token, so the timer starts then.
|
|
62
|
+
const awaitingPickerRef = React__default.useRef(false);
|
|
63
|
+
const pickerObserverRef = React__default.useRef(null);
|
|
64
|
+
const pickerObserverCapRef = React__default.useRef(null);
|
|
65
|
+
const stopWatchingPicker = React__default.useCallback(() => {
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = pickerObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
68
|
+
pickerObserverRef.current = null;
|
|
69
|
+
if (pickerObserverCapRef.current) {
|
|
70
|
+
clearTimeout(pickerObserverCapRef.current);
|
|
71
|
+
pickerObserverCapRef.current = null;
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
const stopWaitingForPicker = React__default.useCallback(() => {
|
|
75
|
+
awaitingPickerRef.current = false;
|
|
76
|
+
if (pickerLoadTimerRef.current) {
|
|
77
|
+
clearTimeout(pickerLoadTimerRef.current);
|
|
78
|
+
pickerLoadTimerRef.current = null;
|
|
79
|
+
}
|
|
80
|
+
stopWatchingPicker();
|
|
81
|
+
}, [stopWatchingPicker]);
|
|
82
|
+
// Set once the picker reports `loaded`; an outside close before that means it was blocked.
|
|
83
|
+
const pickerLoadedRef = React__default.useRef(false);
|
|
84
|
+
const removePickerGuardRef = React__default.useRef(null);
|
|
85
|
+
const stopGuardingPicker = React__default.useCallback(() => {
|
|
86
|
+
var _a;
|
|
87
|
+
(_a = removePickerGuardRef.current) === null || _a === void 0 ? void 0 : _a.call(removePickerGuardRef);
|
|
88
|
+
removePickerGuardRef.current = null;
|
|
89
|
+
}, []);
|
|
90
|
+
React__default.useEffect(() => () => {
|
|
91
|
+
stopWaitingForPicker();
|
|
92
|
+
stopGuardingPicker();
|
|
93
|
+
}, [stopWaitingForPicker, stopGuardingPicker]);
|
|
25
94
|
// Fetch credentials on mount
|
|
26
95
|
React__default.useEffect(() => {
|
|
27
96
|
const fetchCredentials = async () => {
|
|
@@ -112,37 +181,6 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
112
181
|
handlePickerFileSelection();
|
|
113
182
|
}
|
|
114
183
|
}, [authToken, driveFiles, credentials, addTrainingDocument, tenantKey, username]);
|
|
115
|
-
// Force close picker modal
|
|
116
|
-
const forceClosePickerModal = React__default.useCallback(() => {
|
|
117
|
-
try {
|
|
118
|
-
// Try to close any open Google picker modals
|
|
119
|
-
const pickerIframes = document.querySelectorAll('iframe[src*="docs.google.com/picker"]');
|
|
120
|
-
pickerIframes.forEach((iframe) => {
|
|
121
|
-
const parent = iframe.parentElement;
|
|
122
|
-
if (parent) {
|
|
123
|
-
parent.style.display = 'none';
|
|
124
|
-
// Try to remove the entire picker container
|
|
125
|
-
setTimeout(() => {
|
|
126
|
-
if (parent.parentElement) {
|
|
127
|
-
parent.parentElement.removeChild(parent);
|
|
128
|
-
}
|
|
129
|
-
}, 100);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
// Also try to close picker overlay divs
|
|
133
|
-
const pickerOverlays = document.querySelectorAll('div[role="dialog"][aria-label*="picker"]');
|
|
134
|
-
pickerOverlays.forEach((overlay) => {
|
|
135
|
-
overlay.style.display = 'none';
|
|
136
|
-
});
|
|
137
|
-
setPickerError(null);
|
|
138
|
-
toast.success('Google Drive picker closed');
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
console.error('Error closing picker modal:', error);
|
|
142
|
-
toast.error('Unable to close picker modal. Please refresh the page.');
|
|
143
|
-
console.error(JSON.stringify({ tenant: tenantKey, error }));
|
|
144
|
-
}
|
|
145
|
-
}, []);
|
|
146
184
|
// Reset and clean up before opening picker
|
|
147
185
|
const resetPickerState = React__default.useCallback(() => {
|
|
148
186
|
// Clear any existing picker modals/iframes
|
|
@@ -154,7 +192,7 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
154
192
|
}
|
|
155
193
|
});
|
|
156
194
|
// Clear picker overlay divs
|
|
157
|
-
const pickerOverlays = document.querySelectorAll(
|
|
195
|
+
const pickerOverlays = document.querySelectorAll(PICKER_ELEMENTS_SELECTOR);
|
|
158
196
|
pickerOverlays.forEach((overlay) => {
|
|
159
197
|
if (overlay.parentElement) {
|
|
160
198
|
overlay.parentElement.removeChild(overlay);
|
|
@@ -172,7 +210,13 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
172
210
|
const openPickerInternal = () => {
|
|
173
211
|
try {
|
|
174
212
|
setPickerError(null);
|
|
213
|
+
stopWaitingForPicker();
|
|
214
|
+
stopGuardingPicker();
|
|
215
|
+
awaitingPickerRef.current = true;
|
|
216
|
+
pickerLoadedRef.current = false;
|
|
217
|
+
const appId = getGoogleAppId(credentials.client_id);
|
|
175
218
|
openPicker({
|
|
219
|
+
...(appId ? { appId } : {}),
|
|
176
220
|
clientId: credentials.client_id,
|
|
177
221
|
developerKey: credentials.developer_key,
|
|
178
222
|
customScopes: GOOGLE_DRIVE_SCOPES,
|
|
@@ -186,6 +230,15 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
186
230
|
multiselect: false,
|
|
187
231
|
callbackFunction: async (data) => {
|
|
188
232
|
try {
|
|
233
|
+
if (['picked', 'cancel', 'loaded'].includes(data.action)) {
|
|
234
|
+
stopWaitingForPicker();
|
|
235
|
+
}
|
|
236
|
+
if (data.action === 'loaded') {
|
|
237
|
+
pickerLoadedRef.current = true;
|
|
238
|
+
}
|
|
239
|
+
else if (['picked', 'cancel'].includes(data.action)) {
|
|
240
|
+
stopGuardingPicker();
|
|
241
|
+
}
|
|
189
242
|
if (data.action === 'picked' && data.docs) {
|
|
190
243
|
handlePickerFileSelected(data.docs);
|
|
191
244
|
}
|
|
@@ -198,35 +251,22 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
198
251
|
// Picker loaded successfully
|
|
199
252
|
console.log('Google Drive picker loaded');
|
|
200
253
|
setPickerError(null);
|
|
201
|
-
|
|
202
|
-
setTimeout(() => {
|
|
203
|
-
const pickerIframes = document.querySelectorAll('iframe[src*="docs.google.com/picker"]');
|
|
204
|
-
pickerIframes.forEach((iframe) => {
|
|
205
|
-
const parent = iframe.parentElement;
|
|
206
|
-
if (parent) {
|
|
207
|
-
parent.style.pointerEvents = 'auto';
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
const pickerOverlays = document.querySelectorAll('div[role="dialog"][aria-label*="picker"]');
|
|
211
|
-
pickerOverlays.forEach((overlay) => {
|
|
212
|
-
overlay.style.pointerEvents = 'auto';
|
|
213
|
-
});
|
|
214
|
-
}, 100);
|
|
254
|
+
setTimeout(makePickerClickable, 100);
|
|
215
255
|
}
|
|
216
256
|
}
|
|
217
257
|
catch (error) {
|
|
218
258
|
console.error('Error in picker callback:', error);
|
|
219
|
-
setPickerError(
|
|
220
|
-
toast.error('Error with Google Drive picker. Try refreshing the page if it gets stuck.');
|
|
259
|
+
setPickerError(PICKER_SELECTION_FAILED_MESSAGE);
|
|
221
260
|
console.error(JSON.stringify({ tenant: tenantKey, error }));
|
|
222
261
|
}
|
|
223
262
|
},
|
|
224
263
|
});
|
|
225
264
|
}
|
|
226
265
|
catch (error) {
|
|
266
|
+
stopWaitingForPicker();
|
|
267
|
+
stopGuardingPicker();
|
|
227
268
|
console.error('Error opening picker:', error);
|
|
228
|
-
setPickerError(
|
|
229
|
-
toast.error('Failed to open Google Drive picker. This might be due to permission issues (403 error).');
|
|
269
|
+
setPickerError(PICKER_OPEN_FAILED_MESSAGE);
|
|
230
270
|
console.error(JSON.stringify({ tenant: tenantKey, error }));
|
|
231
271
|
}
|
|
232
272
|
};
|
|
@@ -238,14 +278,79 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
238
278
|
openPickerInternal();
|
|
239
279
|
}
|
|
240
280
|
else {
|
|
241
|
-
toast.error('Google
|
|
281
|
+
toast.error('Google Drive is still loading. Try again in a moment.');
|
|
242
282
|
}
|
|
243
|
-
}, [
|
|
283
|
+
}, [
|
|
284
|
+
credentials,
|
|
285
|
+
handlePickerFileSelected,
|
|
286
|
+
openPicker,
|
|
287
|
+
isPickerLoaded,
|
|
288
|
+
resetPickerState,
|
|
289
|
+
stopWaitingForPicker,
|
|
290
|
+
stopGuardingPicker,
|
|
291
|
+
]);
|
|
292
|
+
/**
|
|
293
|
+
* Google's picker sits on top of our modal dialogs, which close on any outside
|
|
294
|
+
* pointerdown or Escape (Radix listens on document). While the picker is shown,
|
|
295
|
+
* window capture listeners run first: a click on Google's dimmed background or
|
|
296
|
+
* Escape closes only the picker, and no picker event reaches our dialogs.
|
|
297
|
+
*/
|
|
298
|
+
const guardPicker = React__default.useCallback(() => {
|
|
299
|
+
const closePicker = () => {
|
|
300
|
+
const loaded = pickerLoadedRef.current;
|
|
301
|
+
stopWaitingForPicker();
|
|
302
|
+
stopGuardingPicker();
|
|
303
|
+
resetPickerState();
|
|
304
|
+
if (!loaded) {
|
|
305
|
+
setPickerError(PICKER_BLOCKED_MESSAGE);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const onPointer = (event) => {
|
|
309
|
+
const target = event.target;
|
|
310
|
+
if (!(target instanceof Element) || !target.closest(PICKER_ELEMENTS_SELECTOR))
|
|
311
|
+
return;
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
if (event.type === 'pointerdown' && !target.closest(PICKER_BOX_SELECTOR)) {
|
|
314
|
+
closePicker();
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const onKeyDown = (event) => {
|
|
318
|
+
if (event.key !== 'Escape')
|
|
319
|
+
return;
|
|
320
|
+
event.stopPropagation();
|
|
321
|
+
closePicker();
|
|
322
|
+
};
|
|
323
|
+
const pointerEvents = ['pointerdown', 'mousedown', 'click'];
|
|
324
|
+
pointerEvents.forEach((type) => window.addEventListener(type, onPointer, true));
|
|
325
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
326
|
+
removePickerGuardRef.current = () => {
|
|
327
|
+
pointerEvents.forEach((type) => window.removeEventListener(type, onPointer, true));
|
|
328
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
329
|
+
};
|
|
330
|
+
}, [resetPickerState, stopWaitingForPicker, stopGuardingPicker]);
|
|
244
331
|
// Handle auth response
|
|
245
332
|
React__default.useEffect(() => {
|
|
246
333
|
if (authRes) {
|
|
247
334
|
setAuthToken(authRes);
|
|
248
335
|
}
|
|
336
|
+
if ((authRes === null || authRes === void 0 ? void 0 : authRes.access_token) && awaitingPickerRef.current && !pickerLoadTimerRef.current) {
|
|
337
|
+
makePickerClickable();
|
|
338
|
+
guardPicker();
|
|
339
|
+
const observer = new MutationObserver(makePickerClickable);
|
|
340
|
+
observer.observe(document.body, {
|
|
341
|
+
childList: true,
|
|
342
|
+
subtree: true,
|
|
343
|
+
attributes: true,
|
|
344
|
+
attributeFilter: ['src', 'class'],
|
|
345
|
+
});
|
|
346
|
+
pickerObserverRef.current = observer;
|
|
347
|
+
pickerObserverCapRef.current = setTimeout(stopWatchingPicker, PICKER_CLICKABLE_WATCH_MS);
|
|
348
|
+
pickerLoadTimerRef.current = setTimeout(() => {
|
|
349
|
+
pickerLoadTimerRef.current = null;
|
|
350
|
+
awaitingPickerRef.current = false;
|
|
351
|
+
setPickerError(PICKER_BLOCKED_MESSAGE);
|
|
352
|
+
}, PICKER_LOAD_TIMEOUT_MS);
|
|
353
|
+
}
|
|
249
354
|
}, [authRes]);
|
|
250
355
|
const loadGoogleApiScript = React__default.useCallback(() => {
|
|
251
356
|
// This function can be called when the Next.js Script component loads
|
|
@@ -260,7 +365,6 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
260
365
|
credentials,
|
|
261
366
|
loadGoogleApiScript,
|
|
262
367
|
isPickerLoaded,
|
|
263
|
-
forceClosePickerModal,
|
|
264
368
|
pickerError,
|
|
265
369
|
resetPickerState,
|
|
266
370
|
credentialsLoaded: credentialLoaded,
|
|
@@ -268,5 +372,5 @@ const useGoogleDrivePicker = ({ tenantKey, mentorId }) => {
|
|
|
268
372
|
};
|
|
269
373
|
};
|
|
270
374
|
|
|
271
|
-
export { GOOGLE_DRIVE_SCOPES, useGoogleDrivePicker as default };
|
|
375
|
+
export { GOOGLE_DRIVE_SCOPES, PICKER_BLOCKED_MESSAGE, PICKER_CLICKABLE_WATCH_MS, PICKER_LOAD_TIMEOUT_MS, PICKER_OPEN_FAILED_MESSAGE, PICKER_SELECTION_FAILED_MESSAGE, useGoogleDrivePicker as default, getGoogleAppId, makePickerClickable };
|
|
272
376
|
//# sourceMappingURL=use-google-drive-picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-google-drive-picker.js","sources":["../../../../../../../src/components/hooks/use-google-drive-picker.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;AAaA;AACO,MAAM,mBAAmB,GAAG,CAAC,4CAA4C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AC,aAAa,EAAE;AACxD,YAAA,KAAK,CAAC,KAAK,CAAC,6CAA6C,CAAC;YAC1D;QACF;QAEA,IAAI,cAAc,EAAE;AAClB,YAAA,kBAAkB,EAAE;QACtB;aAAO;AACL,YAAA,KAAK,CAAC,KAAK,CAAC,oDAAoD,CAAC;QACnE;AACF,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,wBAAwB,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;;AAGzF,IAAAA,cAAK,CAAC,SAAS,CAAC,MAAK;QACnB,IAAI,OAAO,EAAE;YACX,YAAY,CAAC,OAAO,CAAC;QACvB;AACF,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,MAAM,mBAAmB,GAAGA,cAAK,CAAC,WAAW,CAAC,MAAK;;AAEjD,QAAA,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAK;gBACpC,iBAAiB,CAAC,IAAI,CAAC;AACzB,YAAA,CAAC,CAAC;QACJ;AACF,IAAA,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;IAEpB,OAAO;QACL,gBAAgB;QAChB,WAAW;QACX,mBAAmB;QACnB,cAAc;QACd,qBAAqB;QACrB,WAAW;QACX,gBAAgB;AAChB,QAAA,iBAAiB,EAAE,gBAAgB;AACnC,QAAA,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC;KAC7C;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"use-google-drive-picker.js","sources":["../../../../../../../src/components/hooks/use-google-drive-picker.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;AAaA;AACO,MAAM,mBAAmB,GAAG,CAAC,4CAA4C;AAEhF;;;;AAIG;AACI,MAAM,sBAAsB,GAAG;AAE/B,MAAM,sBAAsB,GACjC;AAEK,MAAM,0BAA0B,GAAG;AAEnC,MAAM,+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,IAAI;AACb,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;AAClC,aAAA,CAAC;AACF,YAAA,iBAAiB,CAAC,OAAO,GAAG,QAAQ;YACpC,oBAAoB,CAAC,OAAO,GAAG,UAAU,CAAC,kBAAkB,EAAE,yBAAyB,CAAC;AAExF,YAAA,kBAAkB,CAAC,OAAO,GAAG,UAAU,CAAC,MAAK;AAC3C,gBAAA,kBAAkB,CAAC,OAAO,GAAG,IAAI;AACjC,gBAAA,iBAAiB,CAAC,OAAO,GAAG,KAAK;gBACjC,cAAc,CAAC,sBAAsB,CAAC;YACxC,CAAC,EAAE,sBAAsB,CAAC;QAC5B;AACF,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,MAAM,mBAAmB,GAAGA,cAAK,CAAC,WAAW,CAAC,MAAK;;AAEjD,QAAA,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAK;gBACpC,iBAAiB,CAAC,IAAI,CAAC;AACzB,YAAA,CAAC,CAAC;QACJ;AACF,IAAA,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;IAEpB,OAAO;QACL,gBAAgB;QAChB,WAAW;QACX,mBAAmB;QACnB,cAAc;QACd,WAAW;QACX,gBAAgB;AAChB,QAAA,iBAAiB,EAAE,gBAAgB;AACnC,QAAA,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC;KAC7C;AACH;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useDebounce as a } from '../../node_modules/.pnpm/use-debounce@10.0.4_react@19.1.0/node_modules/use-debounce/dist/index.module.js';
|
|
2
|
+
import { usePlatformUsersQuery } from '@iblai/data-layer';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for a platform-user picker, searched tenant-wide once the
|
|
6
|
+
* debounced term reaches two characters. Deliberately email-only in the UI
|
|
7
|
+
* (no name/username noise); the cap API is still keyed by username, which
|
|
8
|
+
* rides along as the option value.
|
|
9
|
+
*/
|
|
10
|
+
function usePlatformUserOptions(tenantKey, searchTerm, { enabled = true } = {}) {
|
|
11
|
+
var _a;
|
|
12
|
+
const [debouncedSearch] = a(searchTerm, 300);
|
|
13
|
+
const query = debouncedSearch.trim();
|
|
14
|
+
const shouldSearch = Boolean(enabled && tenantKey && query.length >= 2);
|
|
15
|
+
const { data, isFetching } = usePlatformUsersQuery({
|
|
16
|
+
page: 1,
|
|
17
|
+
page_size: 20,
|
|
18
|
+
platform_key: tenantKey,
|
|
19
|
+
platform_org: tenantKey,
|
|
20
|
+
query,
|
|
21
|
+
return_policies: 'false',
|
|
22
|
+
}, { skip: !shouldSearch });
|
|
23
|
+
// The platform users endpoint returns either `results` or `results.data`
|
|
24
|
+
// depending on whether policies were requested.
|
|
25
|
+
const rawResults = data === null || data === void 0 ? void 0 : data.results;
|
|
26
|
+
const foundUsers = Array.isArray(rawResults)
|
|
27
|
+
? rawResults
|
|
28
|
+
: ((_a = rawResults === null || rawResults === void 0 ? void 0 : rawResults.data) !== null && _a !== void 0 ? _a : []);
|
|
29
|
+
const options = foundUsers
|
|
30
|
+
.filter((user) => Boolean(user.username) && Boolean(user.email))
|
|
31
|
+
.map((user) => ({
|
|
32
|
+
value: user.username,
|
|
33
|
+
label: user.email,
|
|
34
|
+
}));
|
|
35
|
+
return { options, isSearching: isFetching };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { usePlatformUserOptions };
|
|
39
|
+
//# sourceMappingURL=use-platform-user-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-platform-user-options.js","sources":["../../../../../../../src/components/spend-caps/use-platform-user-options.ts"],"sourcesContent":[null],"names":["useDebounce"],"mappings":";;;AAcA;;;;;AAKG;AACG,SAAU,sBAAsB,CACpC,SAAiB,EACjB,UAA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AAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE;AAC7C;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useGetSpendCapStatusQuery } from '@iblai/data-layer';
|
|
3
|
+
|
|
4
|
+
/** How often the chat re-reads the status so a warning appears mid-conversation. */
|
|
5
|
+
const SPEND_CAP_STATUS_POLL_MS = 60000;
|
|
6
|
+
/**
|
|
7
|
+
* Learner-safe spend-cap status for the chat (zones and percentages only,
|
|
8
|
+
* never dollars), polled while the chat is open. `SpendCapUsage` reads the
|
|
9
|
+
* same cache entry, so rendering it beside this hook costs no extra request.
|
|
10
|
+
*/
|
|
11
|
+
function useSpendCapStatus({ tenantKey, userId, mentorId, enabled = true, }) {
|
|
12
|
+
const skip = !enabled || !tenantKey || !userId;
|
|
13
|
+
const { data, refetch } = useGetSpendCapStatusQuery({ org: tenantKey, userId, mentor: mentorId }, { skip, pollingInterval: skip ? 0 : SPEND_CAP_STATUS_POLL_MS, refetchOnMountOrArgChange: true });
|
|
14
|
+
// RTK throws on refetching a query that never started (the skipped case).
|
|
15
|
+
const safeRefetch = React__default.useCallback(() => {
|
|
16
|
+
if (!skip)
|
|
17
|
+
void refetch();
|
|
18
|
+
}, [skip, refetch]);
|
|
19
|
+
return { summary: data, blocked: Boolean(data === null || data === void 0 ? void 0 : data.blocked), refetch: safeRefetch };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { SPEND_CAP_STATUS_POLL_MS, useSpendCapStatus };
|
|
23
|
+
//# sourceMappingURL=use-spend-cap-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-spend-cap-status.js","sources":["../../../../../../../src/components/spend-caps/use-spend-cap-status.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;AAKA;AACO,MAAM,wBAAwB,GAAG;AAoBxC;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,IAAI,GACW,EAAA;IACzB,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM;AAC9C,IAAA,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,yBAAyB,CACjD,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAC5C,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,GAAG,CAAC,GAAG,wBAAwB,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAChG;;AAGD,IAAA,MAAM,WAAW,GAAGA,cAAK,CAAC,WAAW,CAAC,MAAK;AACzC,QAAA,IAAI,CAAC,IAAI;YAAE,KAAK,OAAO,EAAE;AAC3B,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE;AACjF;;;;"}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { toast } from 'sonner';
|
|
2
2
|
import { useGetAgentSpendCapQuery, useGetTenantSpendCapQuery, useListAgentUserSpendCapsQuery, useUpsertAgentSpendCapMutation, useDeleteAgentSpendCapMutation, useUpsertTenantSpendCapMutation, useDeleteTenantSpendCapMutation, useUpsertUserSpendCapMutation, useDeleteUserSpendCapMutation } from '@iblai/data-layer';
|
|
3
|
+
import { errorStatus, errorDetail } from './utils.js';
|
|
3
4
|
|
|
4
|
-
function errorStatus(error) {
|
|
5
|
-
return error === null || error === void 0 ? void 0 : error.status;
|
|
6
|
-
}
|
|
7
|
-
function errorDetail(error) {
|
|
8
|
-
const data = error === null || error === void 0 ? void 0 : error.data;
|
|
9
|
-
if (typeof (data === null || data === void 0 ? void 0 : data.detail) === 'string')
|
|
10
|
-
return data.detail;
|
|
11
|
-
if (typeof (data === null || data === void 0 ? void 0 : data.error) === 'string')
|
|
12
|
-
return data.error;
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
5
|
function useSpendCaps({ tenantKey, mentorId, labels }) {
|
|
16
6
|
const identityReady = Boolean(tenantKey && mentorId);
|
|
17
7
|
// 404 is the documented "no cap configured yet" state for the singleton
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-spend-caps.js","sources":["../../../../../../../src/components/spend-caps/use-spend-caps.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-spend-caps.js","sources":["../../../../../../../src/components/spend-caps/use-spend-caps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAyBM,SAAU,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAuB,EAAA;IAC/E,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC;;;;AAKpD,IAAA,MAAM,EACJ,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,eAAe,GACzB,GAAG,wBAAwB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,aAAa,EAAE,CAAC;AAEpF,IAAA,MAAM,EACJ,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,gBAAgB,GAC1B,GAAG,yBAAyB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC;;;;;;;;;;IAWvE,MAAM,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY;IACzD,MAAM,SAAS,GAAG,cAAc,GAAG,SAAS,GAAG,aAAa;AAE5D,IAAA,MAAM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EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC;AAEjF,IAAA,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,QAA+B,KACpE,OAAO,CACL,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EAC9E,eAAe,CAChB;AACH,IAAA,MAAM,aAAa,GAAG,CAAC,QAAgB,KACrC,SAAS,CACP,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EACpE,eAAe,CAChB;IAEH,OAAO;QACL,QAAQ;QACR,iBAAiB;QACjB,gBAAgB;QAChB,YAAY;QACZ,cAAc;QACd,gBAAgB;QAChB,kBAAkB;QAElB,SAAS;QACT,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,eAAe;QACf,iBAAiB;QACjB,mBAAmB;QAEnB,QAAQ;QACR,iBAAiB;QACjB,gBAAgB;QAChB,WAAW;QACX,aAAa;QACb,eAAe;QACf,iBAAiB;KAClB;AACH;;;;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { useDebounce as a } from '../../node_modules/.pnpm/use-debounce@10.0.4_react@19.1.0/node_modules/use-debounce/dist/index.module.js';
|
|
4
|
-
import { usePlatformUsersQuery } from '@iblai/data-layer';
|
|
5
3
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog.js';
|
|
6
4
|
import { cn } from '../../lib/utils.js';
|
|
7
5
|
import { SearchSelect } from './search-select.js';
|
|
8
6
|
import { SpendCapForm } from './spend-cap-form.js';
|
|
7
|
+
import { usePlatformUserOptions } from './use-platform-user-options.js';
|
|
9
8
|
import { UserProfileLink } from '../profile/user-profile-link.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -14,8 +13,8 @@ import { UserProfileLink } from '../profile/user-profile-link.js';
|
|
|
14
13
|
* (no free-text usernames), edit mode goes straight to the form for the
|
|
15
14
|
* cap's user. The form's Cancel/Save footer acts as the dialog footer.
|
|
16
15
|
*/
|
|
17
|
-
function UserCapModal({ isOpen, onClose, cap, labels, tenantKey, isSaving, onSave }) {
|
|
18
|
-
var _a, _b, _c, _d
|
|
16
|
+
function UserCapModal({ isOpen, onClose, cap, labels, tenantKey, initialUser = null, isSaving, onSave, }) {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
19
18
|
const isEditing = Boolean(cap);
|
|
20
19
|
const [pickedUser, setPickedUser] = React__default.useState(null);
|
|
21
20
|
const [userSearch, setUserSearch] = React__default.useState('');
|
|
@@ -23,34 +22,11 @@ function UserCapModal({ isOpen, onClose, cap, labels, tenantKey, isSaving, onSav
|
|
|
23
22
|
React__default.useEffect(() => {
|
|
24
23
|
if (!isOpen)
|
|
25
24
|
return;
|
|
26
|
-
setPickedUser(
|
|
25
|
+
setPickedUser(initialUser);
|
|
27
26
|
setUserSearch('');
|
|
28
|
-
}, [isOpen, cap]);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const { data: usersData, isFetching: isSearchingUsers } = usePlatformUsersQuery({
|
|
32
|
-
page: 1,
|
|
33
|
-
page_size: 20,
|
|
34
|
-
platform_key: tenantKey,
|
|
35
|
-
platform_org: tenantKey,
|
|
36
|
-
query: debouncedUserSearch.trim(),
|
|
37
|
-
return_policies: 'false',
|
|
38
|
-
}, { skip: !shouldSearchUsers });
|
|
39
|
-
// The platform users endpoint returns either `results` or `results.data`
|
|
40
|
-
// depending on whether policies were requested.
|
|
41
|
-
const rawResults = usersData === null || usersData === void 0 ? void 0 : usersData.results;
|
|
42
|
-
const foundUsers = Array.isArray(rawResults)
|
|
43
|
-
? rawResults
|
|
44
|
-
: ((_a = rawResults === null || rawResults === void 0 ? void 0 : rawResults.data) !== null && _a !== void 0 ? _a : []);
|
|
45
|
-
// Deliberately email-only in the UI (no name/username noise); the cap API
|
|
46
|
-
// is still keyed by username, which rides along as the option value.
|
|
47
|
-
const userOptions = foundUsers
|
|
48
|
-
.filter((user) => Boolean(user.username) && Boolean(user.email))
|
|
49
|
-
.map((user) => ({
|
|
50
|
-
value: user.username,
|
|
51
|
-
label: user.email,
|
|
52
|
-
}));
|
|
53
|
-
const username = isEditing ? ((_b = cap === null || cap === void 0 ? void 0 : cap.username) !== null && _b !== void 0 ? _b : '') : ((_c = pickedUser === null || pickedUser === void 0 ? void 0 : pickedUser.value) !== null && _c !== void 0 ? _c : '');
|
|
27
|
+
}, [isOpen, cap, initialUser]);
|
|
28
|
+
const { options: userOptions, isSearching: isSearchingUsers } = usePlatformUserOptions(tenantKey, userSearch, { enabled: isOpen && !isEditing });
|
|
29
|
+
const username = isEditing ? ((_a = cap === null || cap === void 0 ? void 0 : cap.username) !== null && _a !== void 0 ? _a : '') : ((_b = pickedUser === null || pickedUser === void 0 ? void 0 : pickedUser.value) !== null && _b !== void 0 ? _b : '');
|
|
54
30
|
const handleSave = async (formData) => {
|
|
55
31
|
if (!username)
|
|
56
32
|
return;
|
|
@@ -61,7 +37,7 @@ function UserCapModal({ isOpen, onClose, cap, labels, tenantKey, isSaving, onSav
|
|
|
61
37
|
return (jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: jsxs(DialogContent, { "aria-describedby": "user-cap-modal-description", "data-testid": "user-cap-modal", className: "flex max-h-[85vh] flex-col sm:max-w-xl", children: [jsx(DialogHeader, { className: "flex-shrink-0", children: jsx(DialogTitle, { className: "ibl-dialog-title", children: isEditing ? labels.users.editTitle : labels.users.addTitle }) }), jsxs("div", { className: cn('min-h-0 flex-1 space-y-4 overflow-y-auto',
|
|
62
38
|
// Reserve room for the search results dropdown while no user is
|
|
63
39
|
// picked yet — otherwise the scroll container clips it.
|
|
64
|
-
!isEditing && !pickedUser && 'min-h-[340px]'), id: "user-cap-modal-description", children: [isEditing ? (jsx("p", { className: "text-sm text-[#646464]", "data-testid": "user-cap-modal-username", children: jsx(UserProfileLink, { tenantKey: tenantKey, username: (
|
|
40
|
+
!isEditing && !pickedUser && 'min-h-[340px]'), id: "user-cap-modal-description", children: [isEditing ? (jsx("p", { className: "text-sm text-[#646464]", "data-testid": "user-cap-modal-username", children: jsx(UserProfileLink, { tenantKey: tenantKey, username: (_c = cap === null || cap === void 0 ? void 0 : cap.username) !== null && _c !== void 0 ? _c : '', display: (cap === null || cap === void 0 ? void 0 : cap.email) || ((_d = cap === null || cap === void 0 ? void 0 : cap.username) !== null && _d !== void 0 ? _d : ''), className: "inline", testId: "user-cap-modal-profile-link" }) })) : (jsx(SearchSelect, { labels: labels.users.picker, selected: pickedUser, onSelect: setPickedUser, onClear: () => setPickedUser(null), searchTerm: userSearch, onSearchTermChange: setUserSearch, options: userOptions, isLoading: isSearchingUsers, testId: "user-cap-modal-user-picker" })), Boolean(username) && (jsx(SpendCapForm, { labels: labels, cap: cap !== null && cap !== void 0 ? cap : undefined, isSaving: isSaving, isDeleting: false, onSave: handleSave, onCancel: onClose, testId: "user-cap-modal" }))] })] }) }));
|
|
65
41
|
}
|
|
66
42
|
|
|
67
43
|
export { UserCapModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-cap-modal.js","sources":["../../../../../../../src/components/spend-caps/user-cap-modal.tsx"],"sourcesContent":[null],"names":["React","
|
|
1
|
+
{"version":3,"file":"user-cap-modal.js","sources":["../../../../../../../src/components/spend-caps/user-cap-modal.tsx"],"sourcesContent":[null],"names":["React","_jsx","_jsxs"],"mappings":";;;;;;;;;AAqCA;;;;;AAKG;AACG,SAAU,YAAY,CAAC,EAC3B,MAAM,EACN,OAAO,EACP,GAAG,EACH,MAAM,EACN,SAAS,EACT,WAAW,GAAG,IAAI,EAClB,QAAQ,EACR,MAAM,GACA,EAAA;;AACN,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;AAC9B,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