@buoy-gg/impersonate 7.0.41 → 7.0.43
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 +12 -80
- package/lib/commonjs/impersonate/components/DataNukeSettings.js +8 -675
- package/lib/commonjs/impersonate/components/ImpersonateBanner.js +1 -221
- package/lib/commonjs/impersonate/components/ImpersonateHistoryList.js +1 -181
- package/lib/commonjs/impersonate/components/ImpersonateModal.js +1 -319
- package/lib/commonjs/impersonate/components/ImpersonateOverlay.js +1 -26
- package/lib/commonjs/impersonate/components/ImpersonateStatusBar.js +1 -130
- package/lib/commonjs/impersonate/components/UserAvatar.js +1 -146
- package/lib/commonjs/impersonate/components/UserCard.js +1 -201
- package/lib/commonjs/impersonate/components/UserSearchView.js +1 -227
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.js +1 -17
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.web.js +1 -11
- package/lib/commonjs/impersonate/hooks/useAutoClearAsyncStorage.js +1 -134
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.js +1 -155
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.web.js +1 -20
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.js +1 -188
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.web.js +1 -27
- package/lib/commonjs/impersonate/hooks/useImpersonate.js +1 -215
- package/lib/commonjs/impersonate/hooks/useImpersonateHistory.js +1 -56
- package/lib/commonjs/impersonate/types/index.js +1 -16
- package/lib/commonjs/impersonate/types/types.js +1 -1
- package/lib/commonjs/impersonate/utils/impersonateListener.js +1 -350
- package/lib/commonjs/impersonate/utils/impersonateStore.js +1 -689
- package/lib/commonjs/index.js +1 -150
- package/lib/commonjs/preset.js +1 -232
- package/lib/commonjs/sync/impersonateSyncAdapter.js +1 -170
- package/lib/module/impersonate/components/DataNukeSettings.js +8 -670
- package/lib/module/impersonate/components/ImpersonateBanner.js +1 -215
- package/lib/module/impersonate/components/ImpersonateHistoryList.js +1 -176
- package/lib/module/impersonate/components/ImpersonateModal.js +1 -314
- package/lib/module/impersonate/components/ImpersonateOverlay.js +1 -21
- package/lib/module/impersonate/components/ImpersonateStatusBar.js +1 -125
- package/lib/module/impersonate/components/UserAvatar.js +1 -140
- package/lib/module/impersonate/components/UserCard.js +1 -196
- package/lib/module/impersonate/components/UserSearchView.js +1 -222
- package/lib/module/impersonate/hooks/asyncStoragePeer.js +1 -13
- package/lib/module/impersonate/hooks/asyncStoragePeer.web.js +1 -6
- package/lib/module/impersonate/hooks/useAutoClearAsyncStorage.js +1 -130
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.js +1 -151
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.web.js +1 -16
- package/lib/module/impersonate/hooks/useAutoClearRedux.js +1 -183
- package/lib/module/impersonate/hooks/useAutoClearRedux.web.js +1 -22
- package/lib/module/impersonate/hooks/useImpersonate.js +1 -212
- package/lib/module/impersonate/hooks/useImpersonateHistory.js +1 -52
- package/lib/module/impersonate/types/index.js +1 -3
- package/lib/module/impersonate/types/types.js +1 -1
- package/lib/module/impersonate/utils/impersonateListener.js +1 -341
- package/lib/module/impersonate/utils/impersonateStore.js +1 -686
- package/lib/module/index.js +1 -117
- package/lib/module/preset.js +1 -216
- package/lib/module/sync/impersonateSyncAdapter.js +1 -162
- package/lib/web/index.mjs +7 -8
- package/package.json +3 -6
- package/lib/typescript/impersonate/components/DataNukeSettings.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateBanner.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateHistoryList.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateModal.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateOverlay.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateStatusBar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserAvatar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserCard.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserSearchView.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearAsyncStorage.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonate.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonateHistory.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/index.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/types.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateListener.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateStore.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sync/impersonateSyncAdapter.d.ts.map +0 -1
|
@@ -1,314 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ImpersonateModal Component
|
|
5
|
-
*
|
|
6
|
-
* Main modal for the impersonation tool. Uses JsModal with ModalHeader
|
|
7
|
-
* pattern matching other Buoy dev tools (Network, Storage, etc.).
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React, { useState, useCallback, useRef, useEffect } from "react";
|
|
11
|
-
import { View, StyleSheet, TouchableOpacity } from "react-native";
|
|
12
|
-
import { JsModal as JsModalBase, TabSelector, ModalHeader, buoyColors, night, Search, TickProvider, windowDragProps } from "@buoy-gg/shared-ui";
|
|
13
|
-
import { useImpersonate } from "../hooks/useImpersonate";
|
|
14
|
-
import { useAutoClearReactQuery } from "../hooks/useAutoClearReactQuery";
|
|
15
|
-
import { useAutoClearRedux } from "../hooks/useAutoClearRedux";
|
|
16
|
-
import { useAutoClearAsyncStorage } from "../hooks/useAutoClearAsyncStorage";
|
|
17
|
-
import { UserSearchView } from "./UserSearchView";
|
|
18
|
-
import { ImpersonateHistoryList } from "./ImpersonateHistoryList";
|
|
19
|
-
import { DataNukeSettings as DataNukeSettingsComponent } from "./DataNukeSettings";
|
|
20
|
-
|
|
21
|
-
// Type assertion to work around React types compatibility issue with memo components
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
const JsModal = JsModalBase;
|
|
25
|
-
|
|
26
|
-
// Local Tab type (matches shared-ui's TabSelector)
|
|
27
|
-
|
|
28
|
-
const ALL_TABS = [{
|
|
29
|
-
key: "search",
|
|
30
|
-
label: "Search"
|
|
31
|
-
}, {
|
|
32
|
-
key: "history",
|
|
33
|
-
label: "History"
|
|
34
|
-
}, {
|
|
35
|
-
key: "settings",
|
|
36
|
-
label: "Settings"
|
|
37
|
-
}];
|
|
38
|
-
const TABS_WITHOUT_SETTINGS = [{
|
|
39
|
-
key: "search",
|
|
40
|
-
label: "Search"
|
|
41
|
-
}, {
|
|
42
|
-
key: "history",
|
|
43
|
-
label: "History"
|
|
44
|
-
}];
|
|
45
|
-
export function ImpersonateModal({
|
|
46
|
-
visible,
|
|
47
|
-
onClose,
|
|
48
|
-
onBack,
|
|
49
|
-
onMinimize,
|
|
50
|
-
onSearchUsers,
|
|
51
|
-
onClearReactQuery,
|
|
52
|
-
onClearRedux,
|
|
53
|
-
onClearAsyncStorage,
|
|
54
|
-
onClearMMKV,
|
|
55
|
-
showSettingsTab = true,
|
|
56
|
-
inline = false
|
|
57
|
-
}) {
|
|
58
|
-
// Select tabs based on showSettingsTab prop
|
|
59
|
-
const tabs = showSettingsTab ? ALL_TABS : TABS_WITHOUT_SETTINGS;
|
|
60
|
-
const [activeTab, setActiveTab] = useState("search");
|
|
61
|
-
const [isSearchActive, setIsSearchActive] = useState(false);
|
|
62
|
-
// True while the header's clear ✕ is being pressed. With a mouse, pressing
|
|
63
|
-
// the ✕ blurs the input FIRST, and the blur handler closes search — which
|
|
64
|
-
// unmounts the ✕ before its own press can fire, so the query was never
|
|
65
|
-
// cleared (desktop). Press-in lands before the blur, so the blur handler can
|
|
66
|
-
// tell this dismissal apart from a click elsewhere.
|
|
67
|
-
const clearPressRef = useRef(false);
|
|
68
|
-
const [searchText, setSearchText] = useState("");
|
|
69
|
-
const searchInputRef = useRef(null);
|
|
70
|
-
|
|
71
|
-
// Auto-detect React Query and get clear function if user didn't provide one
|
|
72
|
-
const {
|
|
73
|
-
clearCache: autoClearReactQuery,
|
|
74
|
-
isAvailable: isReactQueryDetected
|
|
75
|
-
} = useAutoClearReactQuery();
|
|
76
|
-
|
|
77
|
-
// Auto-detect Redux and get reset function if user didn't provide one
|
|
78
|
-
const {
|
|
79
|
-
resetStore: autoClearRedux,
|
|
80
|
-
isAvailable: isReduxDetected
|
|
81
|
-
} = useAutoClearRedux();
|
|
82
|
-
|
|
83
|
-
// Auto-detect AsyncStorage and get clear function if user didn't provide one
|
|
84
|
-
const {
|
|
85
|
-
clearStorage: autoClearAsyncStorage,
|
|
86
|
-
isAvailable: isAsyncStorageDetected
|
|
87
|
-
} = useAutoClearAsyncStorage();
|
|
88
|
-
|
|
89
|
-
// Use user-provided callbacks, or fall back to auto-detected ones
|
|
90
|
-
const effectiveClearReactQuery = onClearReactQuery ?? autoClearReactQuery ?? undefined;
|
|
91
|
-
const effectiveClearRedux = onClearRedux ?? autoClearRedux ?? undefined;
|
|
92
|
-
const effectiveClearAsyncStorage = onClearAsyncStorage ?? autoClearAsyncStorage ?? undefined;
|
|
93
|
-
|
|
94
|
-
// Detection status for settings display
|
|
95
|
-
// Shows "detected" if either user provided callback OR auto-detected
|
|
96
|
-
const detectionStatus = {
|
|
97
|
-
reactQuery: !!onClearReactQuery || isReactQueryDetected,
|
|
98
|
-
redux: !!onClearRedux || isReduxDetected,
|
|
99
|
-
asyncStorage: !!onClearAsyncStorage || isAsyncStorageDetected,
|
|
100
|
-
mmkv: !!onClearMMKV // TODO: implement auto-detection
|
|
101
|
-
};
|
|
102
|
-
const {
|
|
103
|
-
isActive,
|
|
104
|
-
currentUser,
|
|
105
|
-
headerKey,
|
|
106
|
-
dataNukeSettings,
|
|
107
|
-
showBanner,
|
|
108
|
-
searchQuery,
|
|
109
|
-
searchResults,
|
|
110
|
-
isSearching,
|
|
111
|
-
searchError,
|
|
112
|
-
searchUsers,
|
|
113
|
-
startImpersonation,
|
|
114
|
-
stopImpersonation,
|
|
115
|
-
updateHeaderKey,
|
|
116
|
-
updateDataNukeSettings,
|
|
117
|
-
updateShowBanner,
|
|
118
|
-
history,
|
|
119
|
-
removeFromHistory,
|
|
120
|
-
clearHistory
|
|
121
|
-
} = useImpersonate({
|
|
122
|
-
onSearchUsers,
|
|
123
|
-
onClearReactQuery: effectiveClearReactQuery,
|
|
124
|
-
onClearRedux: effectiveClearRedux,
|
|
125
|
-
onClearAsyncStorage: effectiveClearAsyncStorage,
|
|
126
|
-
onClearMMKV
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Focus input when search becomes active
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (isSearchActive && searchInputRef.current) {
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
searchInputRef.current?.focus();
|
|
134
|
-
}, 100);
|
|
135
|
-
}
|
|
136
|
-
}, [isSearchActive]);
|
|
137
|
-
|
|
138
|
-
// Reset to search tab if settings tab is hidden while active
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
if (!showSettingsTab && activeTab === "settings") {
|
|
141
|
-
setActiveTab("search");
|
|
142
|
-
}
|
|
143
|
-
}, [showSettingsTab, activeTab]);
|
|
144
|
-
const handleSearchTextChange = useCallback(text => {
|
|
145
|
-
setSearchText(text);
|
|
146
|
-
}, []);
|
|
147
|
-
const handleSubmitSearch = useCallback(() => {
|
|
148
|
-
if (searchText.trim()) {
|
|
149
|
-
searchUsers(searchText.trim());
|
|
150
|
-
}
|
|
151
|
-
setIsSearchActive(false);
|
|
152
|
-
}, [searchText, searchUsers]);
|
|
153
|
-
const handleSelectUser = useCallback(async user => {
|
|
154
|
-
await startImpersonation(user);
|
|
155
|
-
}, [startImpersonation]);
|
|
156
|
-
const handleSaveSettings = useCallback(async (newHeaderKey, settings, newShowBanner) => {
|
|
157
|
-
// Save header key, data nuke settings, and show banner
|
|
158
|
-
await updateHeaderKey(newHeaderKey);
|
|
159
|
-
await updateDataNukeSettings(settings);
|
|
160
|
-
await updateShowBanner(newShowBanner);
|
|
161
|
-
}, [updateHeaderKey, updateDataNukeSettings, updateShowBanner]);
|
|
162
|
-
const handleTabChange = useCallback(tabKey => {
|
|
163
|
-
setActiveTab(tabKey);
|
|
164
|
-
// Close search when switching tabs
|
|
165
|
-
setIsSearchActive(false);
|
|
166
|
-
}, []);
|
|
167
|
-
|
|
168
|
-
// Header content renderer (matching NetworkModal pattern)
|
|
169
|
-
const renderHeaderContent = () => {
|
|
170
|
-
return /*#__PURE__*/_jsxs(ModalHeader, {
|
|
171
|
-
children: [onBack && /*#__PURE__*/_jsx(ModalHeader.Navigation, {
|
|
172
|
-
onBack: onBack
|
|
173
|
-
}), /*#__PURE__*/_jsx(ModalHeader.Content, {
|
|
174
|
-
title: "",
|
|
175
|
-
children: isSearchActive ? /*#__PURE__*/_jsx(ModalHeader.Search, {
|
|
176
|
-
value: searchText,
|
|
177
|
-
onChangeText: handleSearchTextChange
|
|
178
|
-
// ✕ clears and closes; with no text it simply closes.
|
|
179
|
-
,
|
|
180
|
-
onCancel: () => {
|
|
181
|
-
setSearchText("");
|
|
182
|
-
setIsSearchActive(false);
|
|
183
|
-
},
|
|
184
|
-
onDismiss: () => setIsSearchActive(false),
|
|
185
|
-
dismissOnBlur: true,
|
|
186
|
-
placeholder: "Search by email, name, or ID...",
|
|
187
|
-
iconSize: 14,
|
|
188
|
-
testID: "buoy-impersonate-search-input",
|
|
189
|
-
inputProps: {
|
|
190
|
-
onSubmitEditing: handleSubmitSearch
|
|
191
|
-
}
|
|
192
|
-
}) : /*#__PURE__*/_jsx(TabSelector, {
|
|
193
|
-
tabs: tabs,
|
|
194
|
-
activeTab: activeTab,
|
|
195
|
-
onTabChange: handleTabChange
|
|
196
|
-
})
|
|
197
|
-
}), /*#__PURE__*/_jsx(ModalHeader.Actions, {
|
|
198
|
-
children: activeTab === "search" && !isSearchActive && /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
199
|
-
testID: "buoy-impersonate-search-toggle",
|
|
200
|
-
onPress: () => setIsSearchActive(true),
|
|
201
|
-
style: styles.headerActionButton,
|
|
202
|
-
children: /*#__PURE__*/_jsx(Search, {
|
|
203
|
-
size: 14,
|
|
204
|
-
color: night.color.textSecondary
|
|
205
|
-
})
|
|
206
|
-
})
|
|
207
|
-
})]
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
if (!visible) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
const body = /*#__PURE__*/_jsxs(View, {
|
|
214
|
-
style: styles.container,
|
|
215
|
-
children: [activeTab === "search" && /*#__PURE__*/_jsx(UserSearchView, {
|
|
216
|
-
currentUser: currentUser,
|
|
217
|
-
isActive: isActive,
|
|
218
|
-
searchQuery: searchQuery,
|
|
219
|
-
searchResults: searchResults,
|
|
220
|
-
isSearching: isSearching,
|
|
221
|
-
searchError: searchError,
|
|
222
|
-
onSelectUser: handleSelectUser,
|
|
223
|
-
onStopImpersonation: stopImpersonation,
|
|
224
|
-
searchAvailable: !!onSearchUsers
|
|
225
|
-
}), activeTab === "history" && /*#__PURE__*/_jsx(ImpersonateHistoryList, {
|
|
226
|
-
history: history,
|
|
227
|
-
currentUserId: currentUser?.id ?? null,
|
|
228
|
-
onSelectUser: handleSelectUser,
|
|
229
|
-
onStopImpersonation: stopImpersonation,
|
|
230
|
-
onRemoveFromHistory: removeFromHistory,
|
|
231
|
-
onClearHistory: clearHistory
|
|
232
|
-
}), activeTab === "settings" && /*#__PURE__*/_jsx(DataNukeSettingsComponent, {
|
|
233
|
-
headerKey: headerKey,
|
|
234
|
-
settings: dataNukeSettings,
|
|
235
|
-
showBanner: showBanner,
|
|
236
|
-
onSave: handleSaveSettings,
|
|
237
|
-
onShowBannerChange: updateShowBanner,
|
|
238
|
-
detectionStatus: detectionStatus
|
|
239
|
-
})]
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// The ONLY difference between the phone and the desktop dashboard is which
|
|
243
|
-
// shell the header and body go in. Everything above this line is shared.
|
|
244
|
-
if (inline) {
|
|
245
|
-
return /*#__PURE__*/_jsx(TickProvider, {
|
|
246
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
247
|
-
style: styles.inlineRoot,
|
|
248
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
249
|
-
style: styles.inlineHeader,
|
|
250
|
-
...windowDragProps,
|
|
251
|
-
children: renderHeaderContent()
|
|
252
|
-
}), body]
|
|
253
|
-
})
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return /*#__PURE__*/_jsx(TickProvider, {
|
|
257
|
-
children: /*#__PURE__*/_jsx(JsModal, {
|
|
258
|
-
visible: visible,
|
|
259
|
-
onClose: onClose,
|
|
260
|
-
onMinimize: onMinimize,
|
|
261
|
-
header: {
|
|
262
|
-
showToggleButton: true,
|
|
263
|
-
customContent: renderHeaderContent()
|
|
264
|
-
},
|
|
265
|
-
enablePersistence: true,
|
|
266
|
-
initialMode: "bottomSheet",
|
|
267
|
-
disableScrollWrapper: true,
|
|
268
|
-
children: body
|
|
269
|
-
})
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* The same impersonation tool as `ImpersonateModal`, rendered INLINE for hosts
|
|
275
|
-
* that place tools in a panel rather than a modal. Exists so there is exactly
|
|
276
|
-
* one implementation — the desktop dashboard used to ship its own copy of this
|
|
277
|
-
* component's header and tab router.
|
|
278
|
-
*/
|
|
279
|
-
export function ImpersonateToolView(props) {
|
|
280
|
-
return /*#__PURE__*/_jsx(ImpersonateModal, {
|
|
281
|
-
...props,
|
|
282
|
-
inline: true,
|
|
283
|
-
visible: true,
|
|
284
|
-
onClose: () => {}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
const styles = StyleSheet.create({
|
|
288
|
-
inlineRoot: {
|
|
289
|
-
flex: 1,
|
|
290
|
-
minHeight: 0,
|
|
291
|
-
// Transparent so the desktop workbench's hoisted sky (one field spanning
|
|
292
|
-
// sidebar + panel) shows through — the shell paints its base beneath it.
|
|
293
|
-
backgroundColor: "transparent"
|
|
294
|
-
},
|
|
295
|
-
inlineHeader: {
|
|
296
|
-
paddingHorizontal: 12,
|
|
297
|
-
paddingVertical: 8,
|
|
298
|
-
borderBottomWidth: 1,
|
|
299
|
-
borderBottomColor: buoyColors.border,
|
|
300
|
-
// Clear, like Bench — the host's hoisted sky shows through the header.
|
|
301
|
-
backgroundColor: "transparent"
|
|
302
|
-
},
|
|
303
|
-
container: {
|
|
304
|
-
flex: 1
|
|
305
|
-
},
|
|
306
|
-
headerActionButton: {
|
|
307
|
-
width: 28,
|
|
308
|
-
height: 28,
|
|
309
|
-
borderRadius: 6,
|
|
310
|
-
backgroundColor: night.color.buttonSurface,
|
|
311
|
-
justifyContent: "center",
|
|
312
|
-
alignItems: "center"
|
|
313
|
-
}
|
|
314
|
-
});
|
|
1
|
+
"use strict";import Qe,{useState as h,useCallback as a,useRef as Q,useEffect as N}from"react";import{View as m,StyleSheet as Se,TouchableOpacity as ye}from"react-native";import{JsModal as fe,TabSelector as pe,ModalHeader as s,buoyColors as ge,night as P,Search as be,TickProvider as j,windowDragProps as Ce}from"@buoy-gg/shared-ui";import{useImpersonate as ve}from"../hooks/useImpersonate";import{useAutoClearReactQuery as Ae}from"../hooks/useAutoClearReactQuery";import{useAutoClearRedux as Te}from"../hooks/useAutoClearRedux";import{useAutoClearAsyncStorage as xe}from"../hooks/useAutoClearAsyncStorage";import{UserSearchView as Re}from"./UserSearchView";import{ImpersonateHistoryList as Ie}from"./ImpersonateHistoryList";import{DataNukeSettings as ke}from"./DataNukeSettings";import{jsx as e,jsxs as S}from"react/jsx-runtime";const He=fe;const we=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}];const Be=[{key:"search",label:"Search"},{key:"history",label:"History"}];export function ImpersonateModal({visible:n,onClose:E,onBack:y,onMinimize:M,onSearchUsers:f,onClearReactQuery:p,onClearRedux:g,onClearAsyncStorage:b,onClearMMKV:C,showSettingsTab:u=true,inline:_=false}){const z=u?we:Be;const[t,v]=h("search");const[i,o]=h(false);const De=Q(false);const[c,A]=h("");const T=Q(null);const{clearCache:J,isAvailable:L}=Ae();const{resetStore:O,isAvailable:V}=Te();const{clearStorage:W,isAvailable:F}=xe();const K=p??J??void 0;const G=g??O??void 0;const q=b??W??void 0;const X={reactQuery:!!p||L,redux:!!g||V,asyncStorage:!!b||F,mmkv:!!C};const{isActive:Y,currentUser:x,headerKey:Z,dataNukeSettings:$,showBanner:ee,searchQuery:te,searchResults:re,isSearching:oe,searchError:ae,searchUsers:R,startImpersonation:I,stopImpersonation:k,updateHeaderKey:H,updateDataNukeSettings:w,updateShowBanner:d,history:se,removeFromHistory:ne,clearHistory:ie}=ve({onSearchUsers:f,onClearReactQuery:K,onClearRedux:G,onClearAsyncStorage:q,onClearMMKV:C});N(()=>{if(i&&T.current){setTimeout(()=>{T.current?.focus()},100)}},[i]);N(()=>{if(!u&&t==="settings"){v("search")}},[u,t]);const ce=a(r=>{A(r)},[]);const le=a(()=>{if(c.trim()){R(c.trim())}o(false)},[c,R]);const B=a(async r=>{await I(r)},[I]);const ue=a(async(r,he,me)=>{await H(r);await w(he);await d(me)},[H,w,d]);const de=a(r=>{v(r);o(false)},[]);const D=()=>{return S(s,{children:[y&&e(s.Navigation,{onBack:y}),e(s.Content,{title:"",children:i?e(s.Search,{value:c,onChangeText:ce,onCancel:()=>{A("");o(false)},onDismiss:()=>o(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:le}}):e(pe,{tabs:z,activeTab:t,onTabChange:de})}),e(s.Actions,{children:t==="search"&&!i&&e(ye,{testID:"buoy-impersonate-search-toggle",onPress:()=>o(true),style:l.headerActionButton,children:e(be,{size:14,color:P.color.textSecondary})})})]})};if(!n){return null}const U=S(m,{style:l.container,children:[t==="search"&&e(Re,{currentUser:x,isActive:Y,searchQuery:te,searchResults:re,isSearching:oe,searchError:ae,onSelectUser:B,onStopImpersonation:k,searchAvailable:!!f}),t==="history"&&e(Ie,{history:se,currentUserId:x?.id??null,onSelectUser:B,onStopImpersonation:k,onRemoveFromHistory:ne,onClearHistory:ie}),t==="settings"&&e(ke,{headerKey:Z,settings:$,showBanner:ee,onSave:ue,onShowBannerChange:d,detectionStatus:X})]});if(_){return e(j,{children:S(m,{style:l.inlineRoot,children:[e(m,{style:l.inlineHeader,...Ce,children:D()}),U]})})}return e(j,{children:e(He,{visible:n,onClose:E,onMinimize:M,header:{showToggleButton:true,customContent:D()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:U})})}export function ImpersonateToolView(n){return e(ImpersonateModal,{...n,inline:true,visible:true,onClose:()=>{}})}const l=Se.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ge.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:P.color.buttonSurface,justifyContent:"center",alignItems:"center"}});
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ImpersonateOverlay
|
|
5
|
-
*
|
|
6
|
-
* Auto-rendered by FloatingDevTools (`@buoy-gg/core`) when
|
|
7
|
-
* `@buoy-gg/impersonate` is installed — the host does NOT need to mount
|
|
8
|
-
* anything. It renders the floating impersonation banner, which self-gates
|
|
9
|
-
* on store state (only visible while an impersonation session is active and
|
|
10
|
-
* `showBanner` is enabled), so it's safe to mount unconditionally.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import React from "react";
|
|
14
|
-
import { ImpersonateBanner } from "./ImpersonateBanner";
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
export function ImpersonateOverlay() {
|
|
17
|
-
return /*#__PURE__*/_jsx(ImpersonateBanner, {
|
|
18
|
-
position: "top",
|
|
19
|
-
offset: 50
|
|
20
|
-
});
|
|
21
|
-
}
|
|
1
|
+
"use strict";import e from"react";import{ImpersonateBanner as o}from"./ImpersonateBanner";import{jsx as r}from"react/jsx-runtime";export function ImpersonateOverlay(){return r(o,{position:"top",offset:50})}
|
|
@@ -1,125 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ImpersonateStatusBar Component
|
|
5
|
-
*
|
|
6
|
-
* Shows the current impersonation status with user avatar, info and stop button.
|
|
7
|
-
* Displays at the top of the modal when impersonation is active.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
12
|
-
import { buoyColors, night, X } from "@buoy-gg/shared-ui";
|
|
13
|
-
import { UserAvatar } from "./UserAvatar";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
export function ImpersonateStatusBar({
|
|
16
|
-
user,
|
|
17
|
-
onStopImpersonation
|
|
18
|
-
}) {
|
|
19
|
-
const displayName = user.displayName || user.email || user.id;
|
|
20
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
21
|
-
style: styles.container,
|
|
22
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
23
|
-
style: styles.userSection,
|
|
24
|
-
children: [/*#__PURE__*/_jsx(UserAvatar, {
|
|
25
|
-
userId: user.id,
|
|
26
|
-
name: displayName,
|
|
27
|
-
size: "small",
|
|
28
|
-
showActiveIndicator: false
|
|
29
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
30
|
-
style: styles.userInfo,
|
|
31
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
32
|
-
style: styles.userName,
|
|
33
|
-
numberOfLines: 1,
|
|
34
|
-
children: displayName
|
|
35
|
-
})
|
|
36
|
-
})]
|
|
37
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
38
|
-
style: styles.statusPill,
|
|
39
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
40
|
-
style: styles.pulseDot
|
|
41
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
42
|
-
style: styles.statusText,
|
|
43
|
-
children: "Active"
|
|
44
|
-
})]
|
|
45
|
-
}), /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
46
|
-
style: styles.stopButton,
|
|
47
|
-
onPress: onStopImpersonation,
|
|
48
|
-
activeOpacity: 0.7,
|
|
49
|
-
children: [/*#__PURE__*/_jsx(X, {
|
|
50
|
-
size: 12,
|
|
51
|
-
color: night.color.danger
|
|
52
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
53
|
-
style: styles.stopButtonText,
|
|
54
|
-
children: "Stop"
|
|
55
|
-
})]
|
|
56
|
-
})]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const styles = StyleSheet.create({
|
|
60
|
-
container: {
|
|
61
|
-
flexDirection: "row",
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
justifyContent: "space-between",
|
|
64
|
-
paddingVertical: 10,
|
|
65
|
-
paddingHorizontal: 16,
|
|
66
|
-
backgroundColor: buoyColors.success + "10",
|
|
67
|
-
borderBottomWidth: 1,
|
|
68
|
-
borderBottomColor: buoyColors.success + "25",
|
|
69
|
-
gap: 12
|
|
70
|
-
},
|
|
71
|
-
userSection: {
|
|
72
|
-
flexDirection: "row",
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
flex: 1,
|
|
75
|
-
gap: 10,
|
|
76
|
-
minWidth: 0
|
|
77
|
-
},
|
|
78
|
-
userInfo: {
|
|
79
|
-
flex: 1,
|
|
80
|
-
minWidth: 0
|
|
81
|
-
},
|
|
82
|
-
userName: {
|
|
83
|
-
fontSize: 14,
|
|
84
|
-
fontWeight: "600",
|
|
85
|
-
color: night.color.text
|
|
86
|
-
},
|
|
87
|
-
statusPill: {
|
|
88
|
-
flexDirection: "row",
|
|
89
|
-
alignItems: "center",
|
|
90
|
-
gap: 6,
|
|
91
|
-
backgroundColor: buoyColors.success + "20",
|
|
92
|
-
paddingHorizontal: 10,
|
|
93
|
-
paddingVertical: 5,
|
|
94
|
-
borderRadius: 12
|
|
95
|
-
},
|
|
96
|
-
pulseDot: {
|
|
97
|
-
width: 6,
|
|
98
|
-
height: 6,
|
|
99
|
-
borderRadius: 3,
|
|
100
|
-
backgroundColor: buoyColors.success
|
|
101
|
-
},
|
|
102
|
-
statusText: {
|
|
103
|
-
fontSize: 11,
|
|
104
|
-
fontWeight: "600",
|
|
105
|
-
color: buoyColors.success,
|
|
106
|
-
textTransform: "uppercase",
|
|
107
|
-
letterSpacing: 0.5
|
|
108
|
-
},
|
|
109
|
-
stopButton: {
|
|
110
|
-
flexDirection: "row",
|
|
111
|
-
alignItems: "center",
|
|
112
|
-
gap: 4,
|
|
113
|
-
paddingHorizontal: 12,
|
|
114
|
-
paddingVertical: 6,
|
|
115
|
-
backgroundColor: night.color.dangerSoft,
|
|
116
|
-
borderRadius: 6,
|
|
117
|
-
borderWidth: 1,
|
|
118
|
-
borderColor: night.color.danger + "30"
|
|
119
|
-
},
|
|
120
|
-
stopButtonText: {
|
|
121
|
-
fontSize: 12,
|
|
122
|
-
fontWeight: "600",
|
|
123
|
-
color: night.color.danger
|
|
124
|
-
}
|
|
125
|
-
});
|
|
1
|
+
"use strict";import f from"react";import{View as o,Text as a,TouchableOpacity as d,StyleSheet as u}from"react-native";import{buoyColors as r,night as s,X as p}from"@buoy-gg/shared-ui";import{UserAvatar as g}from"./UserAvatar";import{jsx as t,jsxs as n}from"react/jsx-runtime";export function ImpersonateStatusBar({user:i,onStopImpersonation:c}){const l=i.displayName||i.email||i.id;return n(o,{style:e.container,children:[n(o,{style:e.userSection,children:[t(g,{userId:i.id,name:l,size:"small",showActiveIndicator:false}),t(o,{style:e.userInfo,children:t(a,{style:e.userName,numberOfLines:1,children:l})})]}),n(o,{style:e.statusPill,children:[t(o,{style:e.pulseDot}),t(a,{style:e.statusText,children:"Active"})]}),n(d,{style:e.stopButton,onPress:c,activeOpacity:.7,children:[t(p,{size:12,color:s.color.danger}),t(a,{style:e.stopButtonText,children:"Stop"})]})]})}const e=u.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,paddingHorizontal:16,backgroundColor:r.success+"10",borderBottomWidth:1,borderBottomColor:r.success+"25",gap:12},userSection:{flexDirection:"row",alignItems:"center",flex:1,gap:10,minWidth:0},userInfo:{flex:1,minWidth:0},userName:{fontSize:14,fontWeight:"600",color:s.color.text},statusPill:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:r.success+"20",paddingHorizontal:10,paddingVertical:5,borderRadius:12},pulseDot:{width:6,height:6,borderRadius:3,backgroundColor:r.success},statusText:{fontSize:11,fontWeight:"600",color:r.success,textTransform:"uppercase",letterSpacing:.5},stopButton:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:12,paddingVertical:6,backgroundColor:s.color.dangerSoft,borderRadius:6,borderWidth:1,borderColor:s.color.danger+"30"},stopButtonText:{fontSize:12,fontWeight:"600",color:s.color.danger}});
|
|
@@ -1,140 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* UserAvatar Component
|
|
5
|
-
*
|
|
6
|
-
* Displays a user avatar with initials and deterministic color.
|
|
7
|
-
* Supports size variants and active indicator.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React, { useMemo } from "react";
|
|
11
|
-
import { View, Text, StyleSheet } from "react-native";
|
|
12
|
-
import { buoyColors, night } from "@buoy-gg/shared-ui";
|
|
13
|
-
|
|
14
|
-
// Avatar background colors - deterministic based on user ID
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
const AVATAR_COLORS = ["#6366F1",
|
|
17
|
-
// Indigo
|
|
18
|
-
"#8B5CF6",
|
|
19
|
-
// Purple
|
|
20
|
-
"#EC4899",
|
|
21
|
-
// Pink
|
|
22
|
-
"#F43F5E",
|
|
23
|
-
// Rose
|
|
24
|
-
"#F97316",
|
|
25
|
-
// Orange
|
|
26
|
-
"#EAB308",
|
|
27
|
-
// Yellow
|
|
28
|
-
"#22C55E",
|
|
29
|
-
// Green
|
|
30
|
-
"#14B8A6",
|
|
31
|
-
// Teal
|
|
32
|
-
"#06B6D4",
|
|
33
|
-
// Cyan
|
|
34
|
-
"#3B82F6" // Blue
|
|
35
|
-
];
|
|
36
|
-
const SIZES = {
|
|
37
|
-
small: {
|
|
38
|
-
container: 24,
|
|
39
|
-
font: 10,
|
|
40
|
-
indicator: 8
|
|
41
|
-
},
|
|
42
|
-
medium: {
|
|
43
|
-
container: 36,
|
|
44
|
-
font: 14,
|
|
45
|
-
indicator: 10
|
|
46
|
-
},
|
|
47
|
-
large: {
|
|
48
|
-
container: 44,
|
|
49
|
-
font: 16,
|
|
50
|
-
indicator: 12
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Get initials from a name or email
|
|
55
|
-
*/
|
|
56
|
-
function getInitials(name) {
|
|
57
|
-
if (!name) return "?";
|
|
58
|
-
|
|
59
|
-
// If it's an email, use first letter before @
|
|
60
|
-
if (name.includes("@")) {
|
|
61
|
-
return name.charAt(0).toUpperCase();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Split by spaces and get first letter of first two words
|
|
65
|
-
const parts = name.trim().split(/\s+/);
|
|
66
|
-
if (parts.length === 1) {
|
|
67
|
-
return parts[0].charAt(0).toUpperCase();
|
|
68
|
-
}
|
|
69
|
-
return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get deterministic color based on user ID
|
|
74
|
-
*/
|
|
75
|
-
function getAvatarColor(userId) {
|
|
76
|
-
let hash = 0;
|
|
77
|
-
for (let i = 0; i < userId.length; i++) {
|
|
78
|
-
hash = userId.charCodeAt(i) + ((hash << 5) - hash);
|
|
79
|
-
}
|
|
80
|
-
return AVATAR_COLORS[Math.abs(hash) % AVATAR_COLORS.length];
|
|
81
|
-
}
|
|
82
|
-
export function UserAvatar({
|
|
83
|
-
userId,
|
|
84
|
-
name,
|
|
85
|
-
size = "medium",
|
|
86
|
-
showActiveIndicator = false,
|
|
87
|
-
backgroundColor
|
|
88
|
-
}) {
|
|
89
|
-
const sizeConfig = SIZES[size];
|
|
90
|
-
const avatarColor = useMemo(() => backgroundColor ?? getAvatarColor(userId), [userId, backgroundColor]);
|
|
91
|
-
const initials = useMemo(() => getInitials(name), [name]);
|
|
92
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
93
|
-
style: styles.wrapper,
|
|
94
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
95
|
-
style: [styles.container, {
|
|
96
|
-
width: sizeConfig.container,
|
|
97
|
-
height: sizeConfig.container,
|
|
98
|
-
borderRadius: sizeConfig.container / 2,
|
|
99
|
-
backgroundColor: avatarColor
|
|
100
|
-
}],
|
|
101
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
102
|
-
style: [styles.initials, {
|
|
103
|
-
fontSize: sizeConfig.font
|
|
104
|
-
}],
|
|
105
|
-
children: initials
|
|
106
|
-
})
|
|
107
|
-
}), showActiveIndicator && /*#__PURE__*/_jsx(View, {
|
|
108
|
-
style: [styles.indicator, {
|
|
109
|
-
width: sizeConfig.indicator,
|
|
110
|
-
height: sizeConfig.indicator,
|
|
111
|
-
borderRadius: sizeConfig.indicator / 2,
|
|
112
|
-
right: -1,
|
|
113
|
-
bottom: -1
|
|
114
|
-
}]
|
|
115
|
-
})]
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
const styles = StyleSheet.create({
|
|
119
|
-
wrapper: {
|
|
120
|
-
position: "relative"
|
|
121
|
-
},
|
|
122
|
-
container: {
|
|
123
|
-
alignItems: "center",
|
|
124
|
-
justifyContent: "center"
|
|
125
|
-
},
|
|
126
|
-
initials: {
|
|
127
|
-
color: "#FFFFFF",
|
|
128
|
-
fontWeight: "600",
|
|
129
|
-
letterSpacing: 0.5
|
|
130
|
-
},
|
|
131
|
-
indicator: {
|
|
132
|
-
position: "absolute",
|
|
133
|
-
backgroundColor: buoyColors.success,
|
|
134
|
-
borderWidth: 2,
|
|
135
|
-
borderColor: night.color.surface
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// Export helper functions for reuse
|
|
140
|
-
export { getInitials, getAvatarColor, AVATAR_COLORS };
|
|
1
|
+
"use strict";import x,{useMemo as l}from"react";import{View as n,Text as g,StyleSheet as C}from"react-native";import{buoyColors as m,night as A}from"@buoy-gg/shared-ui";import{jsx as a,jsxs as F}from"react/jsx-runtime";const s=["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#3B82F6"];const b={small:{container:24,font:10,indicator:8},medium:{container:36,font:14,indicator:10},large:{container:44,font:16,indicator:12}};function h(r){if(!r)return"?";if(r.includes("@")){return r.charAt(0).toUpperCase()}const t=r.trim().split(/\s+/);if(t.length===1){return t[0].charAt(0).toUpperCase()}return(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}function d(r){let t=0;for(let o=0;o<r.length;o++){t=r.charCodeAt(o)+((t<<5)-t)}return s[Math.abs(t)%s.length]}export function UserAvatar({userId:r,name:t,size:o="medium",showActiveIndicator:f=false,backgroundColor:c}){const i=b[o];const p=l(()=>c??d(r),[r,c]);const u=l(()=>h(t),[t]);return F(n,{style:e.wrapper,children:[a(n,{style:[e.container,{width:i.container,height:i.container,borderRadius:i.container/2,backgroundColor:p}],children:a(g,{style:[e.initials,{fontSize:i.font}],children:u})}),f&&a(n,{style:[e.indicator,{width:i.indicator,height:i.indicator,borderRadius:i.indicator/2,right:-1,bottom:-1}]})]})}const e=C.create({wrapper:{position:"relative"},container:{alignItems:"center",justifyContent:"center"},initials:{color:"#FFFFFF",fontWeight:"600",letterSpacing:.5},indicator:{position:"absolute",backgroundColor:m.success,borderWidth:2,borderColor:A.color.surface}});export{h as getInitials,d as getAvatarColor,s as AVATAR_COLORS};
|