@openpeepshq/rn-components 0.12.4 → 0.12.5
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/package.json +3 -3
- package/src/components/custom/modals/media/image-picker-sheet.test.tsx +201 -0
- package/src/components/custom/modals/media/image-picker-sheet.tsx +27 -17
- package/src/components/groups/GroupMembersList.test.tsx +156 -0
- package/src/components/post/pieces/EventOccurrenceList.tsx +7 -2
- package/src/components/post/post-form/ResourceForm.tsx +16 -16
- package/src/components/post/post-form/VisibilitySheet.tsx +3 -1
- package/src/components/post/types/event/FullEvent.test.tsx +135 -15
- package/src/components/post/types/event/FullEvent.tsx +11 -3
- package/src/components/profile/ProfileSelector.test.tsx +115 -0
- package/src/components/profile/ProfileSelector.tsx +2 -2
- package/src/components/resources/CategoryPathPicker.tsx +117 -0
- package/src/components/resources/ResourceLibrary.test.tsx +334 -0
- package/src/components/resources/ResourceLibrary.tsx +5 -5
- package/src/components/resources/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/common": "^0.6.
|
|
146
|
-
"@openpeepshq/react": "^0.11.
|
|
145
|
+
"@openpeepshq/common": "^0.6.4",
|
|
146
|
+
"@openpeepshq/react": "^0.11.2"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@babel/core": "^7.26.7",
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the ImagePickerSheet error paths (#1789).
|
|
3
|
+
*
|
|
4
|
+
* The sheet is the single gate for image picks: every library/camera pick
|
|
5
|
+
* must go through the cropper, a crop failure must upload nothing and show
|
|
6
|
+
* the form.imageInput.cropError toast (the sheet closes so the retry
|
|
7
|
+
* surface is clean), and a cancel must be silent.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const React = require('react');
|
|
11
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
12
|
+
|
|
13
|
+
let mockTranslations: Record<string, string> = {};
|
|
14
|
+
|
|
15
|
+
const toastShow = jest.fn();
|
|
16
|
+
jest.mock('react-native-toast-message', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
default: { show: (options: unknown) => toastShow(options) },
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('react-native', () => ({
|
|
22
|
+
View: (props: { children?: unknown }) =>
|
|
23
|
+
React.createElement('View', null, props.children),
|
|
24
|
+
Text: (props: { children?: unknown }) =>
|
|
25
|
+
React.createElement('Text', null, props.children),
|
|
26
|
+
ActivityIndicator: () => React.createElement('ActivityIndicator'),
|
|
27
|
+
Platform: { OS: 'android' },
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
jest.mock('react-i18next', () => ({
|
|
31
|
+
useTranslation: () => ({
|
|
32
|
+
t: (key: string) => mockTranslations[key] ?? key,
|
|
33
|
+
}),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
37
|
+
useOpenpeeps: () => ({
|
|
38
|
+
openpeepsApi: {
|
|
39
|
+
createMediaAttachmentAction: () => jest.fn(),
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
jest.mock('../../../../theme/OpenPeepsThemeProvider', () => ({
|
|
45
|
+
useOpenPeepsTheme: () => ({
|
|
46
|
+
colors: { background: '#fff', foreground: '#000' },
|
|
47
|
+
isDark: false,
|
|
48
|
+
}),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
jest.mock('react-native-image-crop-picker', () => ({
|
|
52
|
+
__esModule: true,
|
|
53
|
+
default: {
|
|
54
|
+
openCropper: jest.fn(),
|
|
55
|
+
openCamera: jest.fn(),
|
|
56
|
+
openPicker: jest.fn(),
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
jest.mock('react-native-image-picker', () => ({
|
|
61
|
+
launchCamera: jest.fn(),
|
|
62
|
+
launchImageLibrary: jest.fn(),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
jest.mock('../../../../lib/uploadMedia', () => ({
|
|
66
|
+
uploadMedia: jest.fn(),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
jest.mock('../../../../lib/bottom-sheet-ref', () => ({
|
|
70
|
+
bottomSheetClose: jest.fn(),
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
jest.mock('../../../../lib/mediaUriHelpers', () => ({
|
|
74
|
+
dismissSheetForNativeModal: jest.fn(async () => {}),
|
|
75
|
+
isPickerCancelled: (error: unknown): boolean =>
|
|
76
|
+
(error as { code?: string })?.code === 'E_PICKER_CANCELLED',
|
|
77
|
+
toCropperPath: jest.fn(async (uri: string) => uri),
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
jest.mock('../common', () => ({
|
|
81
|
+
BaseSheet: (props: { children?: unknown }) =>
|
|
82
|
+
React.createElement('BaseSheet', null, props.children),
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
jest.mock('../../../ui/button', () => ({
|
|
86
|
+
Button: (props: {
|
|
87
|
+
children?: unknown;
|
|
88
|
+
onPress?: () => void;
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
}) =>
|
|
91
|
+
React.createElement(
|
|
92
|
+
'Button',
|
|
93
|
+
{ onPress: props.onPress, disabled: props.disabled },
|
|
94
|
+
props.children
|
|
95
|
+
),
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
jest.mock('../../../icons/index', () => ({
|
|
99
|
+
CameraIcon: () => React.createElement('CameraIcon'),
|
|
100
|
+
ImageIcon: () => React.createElement('ImageIcon'),
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
import { ImagePickerSheet } from './image-picker-sheet';
|
|
104
|
+
|
|
105
|
+
const openCropper = require('react-native-image-crop-picker').default
|
|
106
|
+
.openCropper;
|
|
107
|
+
const launchImageLibrary =
|
|
108
|
+
require('react-native-image-picker').launchImageLibrary;
|
|
109
|
+
const uploadMedia = require('../../../../lib/uploadMedia').uploadMedia;
|
|
110
|
+
const bottomSheetClose =
|
|
111
|
+
require('../../../../lib/bottom-sheet-ref').bottomSheetClose;
|
|
112
|
+
|
|
113
|
+
const renderSheet = (onSelect: (attachments: unknown[]) => void) => {
|
|
114
|
+
let tree!: ReturnType<typeof ReactTestRenderer.create>;
|
|
115
|
+
ReactTestRenderer.act(() => {
|
|
116
|
+
tree = ReactTestRenderer.create(
|
|
117
|
+
React.createElement(ImagePickerSheet, {
|
|
118
|
+
ref: { current: null },
|
|
119
|
+
onSelect,
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
return tree;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// The Library button is the second outline Button in the sheet. Drain the
|
|
127
|
+
// pick promise chain inside act so the sheet's state updates stay wrapped.
|
|
128
|
+
const pressLibrary = async (
|
|
129
|
+
tree: ReturnType<typeof ReactTestRenderer.create>
|
|
130
|
+
) => {
|
|
131
|
+
const buttons = tree.root.findAll(
|
|
132
|
+
(node) =>
|
|
133
|
+
typeof node.type === 'string' &&
|
|
134
|
+
node.type === 'Button' &&
|
|
135
|
+
!node.props.disabled
|
|
136
|
+
);
|
|
137
|
+
await ReactTestRenderer.act(async () => {
|
|
138
|
+
buttons[buttons.length - 1].props.onPress();
|
|
139
|
+
for (let i = 0; i < 15; i++) {
|
|
140
|
+
await Promise.resolve();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
describe('ImagePickerSheet error paths', () => {
|
|
146
|
+
beforeEach(() => {
|
|
147
|
+
mockTranslations = { 'form.imageInput.cropError': 'Crop failed' };
|
|
148
|
+
toastShow.mockClear();
|
|
149
|
+
uploadMedia.mockClear();
|
|
150
|
+
bottomSheetClose.mockClear();
|
|
151
|
+
openCropper.mockReset();
|
|
152
|
+
launchImageLibrary.mockReset();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('uploads nothing, toasts, and closes the sheet on a crop failure', async () => {
|
|
156
|
+
launchImageLibrary.mockResolvedValue({
|
|
157
|
+
didCancel: false,
|
|
158
|
+
assets: [{ uri: 'file:///tmp/pick.jpg' }],
|
|
159
|
+
});
|
|
160
|
+
openCropper.mockRejectedValue(new Error('cropper blew up'));
|
|
161
|
+
|
|
162
|
+
const tree = renderSheet(jest.fn());
|
|
163
|
+
await pressLibrary(tree);
|
|
164
|
+
|
|
165
|
+
expect(uploadMedia).not.toHaveBeenCalled();
|
|
166
|
+
expect(toastShow).toHaveBeenCalledWith(
|
|
167
|
+
expect.objectContaining({ text1: 'Crop failed' })
|
|
168
|
+
);
|
|
169
|
+
expect(bottomSheetClose).toHaveBeenCalled();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('stays silent on a cancelled pick', async () => {
|
|
173
|
+
launchImageLibrary.mockResolvedValue({ didCancel: true, assets: [] });
|
|
174
|
+
|
|
175
|
+
const tree = renderSheet(jest.fn());
|
|
176
|
+
await pressLibrary(tree);
|
|
177
|
+
|
|
178
|
+
expect(toastShow).not.toHaveBeenCalled();
|
|
179
|
+
expect(openCropper).not.toHaveBeenCalled();
|
|
180
|
+
expect(uploadMedia).not.toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('resolves exactly one asset and uploads exactly one attachment', async () => {
|
|
184
|
+
launchImageLibrary.mockResolvedValue({
|
|
185
|
+
didCancel: false,
|
|
186
|
+
assets: [{ uri: 'file:///tmp/pick.jpg' }],
|
|
187
|
+
});
|
|
188
|
+
openCropper.mockResolvedValue({ path: '/tmp/cropped.jpg' });
|
|
189
|
+
uploadMedia.mockResolvedValue({ id: 'att-1', type: 'image' });
|
|
190
|
+
const onSelect = jest.fn();
|
|
191
|
+
|
|
192
|
+
const tree = renderSheet(onSelect);
|
|
193
|
+
await pressLibrary(tree);
|
|
194
|
+
|
|
195
|
+
expect(uploadMedia).toHaveBeenCalledTimes(1);
|
|
196
|
+
expect(onSelect).toHaveBeenCalledWith([{ id: 'att-1', type: 'image' }]);
|
|
197
|
+
expect(launchImageLibrary).toHaveBeenCalledWith(
|
|
198
|
+
expect.objectContaining({ selectionLimit: 1 })
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -38,6 +38,14 @@ export const ImagePickerSheet = forwardRef<
|
|
|
38
38
|
const createAttachment = openpeepsApi.createMediaAttachmentAction();
|
|
39
39
|
const { colors, isDark } = useOpenPeepsTheme();
|
|
40
40
|
|
|
41
|
+
const onCropError = (error: unknown) => {
|
|
42
|
+
// Never bypass the cropper with an uncropped fallback upload.
|
|
43
|
+
console.error('Image crop failed:', error);
|
|
44
|
+
Toast.show({ type: 'error', text1: t('form.imageInput.cropError') });
|
|
45
|
+
// Retry surface: leave nothing interactive on top of the form (#1789).
|
|
46
|
+
bottomSheetClose(ref);
|
|
47
|
+
};
|
|
48
|
+
|
|
41
49
|
const cropImage = async (uri: string) => {
|
|
42
50
|
const path = await toCropperPath(uri);
|
|
43
51
|
return ImagePicker.openCropper(
|
|
@@ -99,35 +107,35 @@ export const ImagePickerSheet = forwardRef<
|
|
|
99
107
|
} catch (error) {
|
|
100
108
|
if (!isPickerCancelled(error)) {
|
|
101
109
|
console.error('iOS library pick failed:', error);
|
|
110
|
+
onCropError(error);
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
return;
|
|
105
114
|
}
|
|
106
115
|
|
|
116
|
+
// Single pick (parity with web, #1789) so the cropper can be shown for
|
|
117
|
+
// every image, including gallery resources.
|
|
107
118
|
const result = await launchImageLibrary({
|
|
108
119
|
mediaType: 'photo',
|
|
109
|
-
selectionLimit:
|
|
120
|
+
selectionLimit: 1,
|
|
110
121
|
quality: 1,
|
|
111
122
|
});
|
|
112
123
|
if (result.didCancel || !result.assets?.length) {
|
|
113
124
|
return;
|
|
114
125
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
.filter((uri): uri is string => Boolean(uri));
|
|
118
|
-
if (uris.length === 1) {
|
|
119
|
-
try {
|
|
120
|
-
const cropped = await cropImage(uris[0]);
|
|
121
|
-
await finalize([cropped.path]);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (isPickerCancelled(error)) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
await finalize(uris);
|
|
127
|
-
}
|
|
126
|
+
const uri = result.assets[0]?.uri;
|
|
127
|
+
if (!uri) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
try {
|
|
131
|
+
const cropped = await cropImage(uri);
|
|
132
|
+
await finalize([cropped.path]);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
if (isPickerCancelled(error)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
onCropError(error);
|
|
138
|
+
}
|
|
131
139
|
};
|
|
132
140
|
|
|
133
141
|
const handleCamera = async () => {
|
|
@@ -145,7 +153,9 @@ export const ImagePickerSheet = forwardRef<
|
|
|
145
153
|
}
|
|
146
154
|
const result = await launchCamera({ mediaType: 'photo', quality: 1 });
|
|
147
155
|
if (result.errorCode) {
|
|
148
|
-
|
|
156
|
+
// No dedicated camera key exists; reuse the cropError copy so the
|
|
157
|
+
// toast resolves instead of rendering a missing key (i18n scan, #1789).
|
|
158
|
+
Toast.show({ type: 'error', text1: t('form.imageInput.cropError') });
|
|
149
159
|
return;
|
|
150
160
|
}
|
|
151
161
|
const uri = result.assets?.[0]?.uri;
|
|
@@ -159,7 +169,7 @@ export const ImagePickerSheet = forwardRef<
|
|
|
159
169
|
if (isPickerCancelled(error)) {
|
|
160
170
|
return;
|
|
161
171
|
}
|
|
162
|
-
|
|
172
|
+
onCropError(error);
|
|
163
173
|
}
|
|
164
174
|
} catch (error) {
|
|
165
175
|
if (!isPickerCancelled(error)) {
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for the GroupMembersList row geometry (issue #1666).
|
|
3
|
+
*
|
|
4
|
+
* The member row must mirror the web list's geometry: a 48 dp avatar slot
|
|
5
|
+
* (`size-12`, matching web's `Avatar size={3}`) and the standard `p-4` row
|
|
6
|
+
* padding. A previous pass shrank the avatar to `size-10` and cut the row
|
|
7
|
+
* padding to `py-2 pl-4 pr-1`, which moved the avatar away from web parity
|
|
8
|
+
* and shrank the dropdown-menu trigger's hit target.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const React = require('react');
|
|
12
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
13
|
+
|
|
14
|
+
jest.mock('react-native', () => ({
|
|
15
|
+
View: (props: { children?: unknown }) =>
|
|
16
|
+
React.createElement('View', props, props.children),
|
|
17
|
+
Pressable: (props: { children?: unknown }) =>
|
|
18
|
+
React.createElement('Pressable', props, props.children),
|
|
19
|
+
ActivityIndicator: () => null,
|
|
20
|
+
TextInput: () => null,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('react-i18next', () => ({
|
|
24
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
jest.mock('@react-navigation/native', () => ({
|
|
28
|
+
useNavigation: () => ({ navigate: jest.fn() }),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock('@openpeepshq/common/lib', () => ({
|
|
32
|
+
// Mirrored from platform/common/src/lib — the built package ships ESM
|
|
33
|
+
// which Jest's node transform doesn't cover.
|
|
34
|
+
canChangeMemberRole: () => false,
|
|
35
|
+
canRemoveMember: () => false,
|
|
36
|
+
matchesQuery: () => true,
|
|
37
|
+
sortGroupMembers: (members: unknown) => members,
|
|
38
|
+
truncateText: (text: string) => text,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
42
|
+
useCurrentProfile: () => null,
|
|
43
|
+
useOpenpeeps: () => ({
|
|
44
|
+
openpeepsApi: {
|
|
45
|
+
useGroupMembers: () => ({ data: MEMBERS, isLoading: false }),
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
jest.mock('../conversations/CreateNewConversationContext', () => ({
|
|
51
|
+
useCreateNewConversation: () => ({ openCreateConversation: jest.fn() }),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
jest.mock('../icons/index', () => ({
|
|
55
|
+
MessageSquareTextIcon: () => React.createElement('Icon'),
|
|
56
|
+
MoreHorizontalIcon: () => React.createElement('Icon'),
|
|
57
|
+
UserCogIcon: () => React.createElement('Icon'),
|
|
58
|
+
UserMinusIcon: () => React.createElement('Icon'),
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('../profile/Avatar', () => ({
|
|
62
|
+
ProfileAvatar: (props: Record<string, unknown>) =>
|
|
63
|
+
React.createElement('ProfileAvatar', props),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
jest.mock('../ui/dropdown-menu', () => ({
|
|
67
|
+
DropdownMenu: (props: { children?: unknown }) =>
|
|
68
|
+
React.createElement('DropdownMenu', null, props.children),
|
|
69
|
+
DropdownMenuContent: (props: { children?: unknown }) =>
|
|
70
|
+
React.createElement('DropdownMenuContent', null, props.children),
|
|
71
|
+
DropdownMenuGroup: (props: { children?: unknown }) =>
|
|
72
|
+
React.createElement('DropdownMenuGroup', null, props.children),
|
|
73
|
+
DropdownMenuItem: (props: { children?: unknown }) =>
|
|
74
|
+
React.createElement('DropdownMenuItem', null, props.children),
|
|
75
|
+
DropdownMenuTrigger: (props: { children?: unknown }) =>
|
|
76
|
+
React.createElement('DropdownMenuTrigger', null, props.children),
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
jest.mock('../ui/input', () => ({ Input: () => null }));
|
|
80
|
+
|
|
81
|
+
jest.mock('../ui/themed-text', () => ({
|
|
82
|
+
ThemedText: (props: Record<string, unknown>) =>
|
|
83
|
+
React.createElement('ThemedText', props, props.children),
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
jest.mock('../../theme/useThemeOpacity', () => ({
|
|
87
|
+
useThemeOpacity: () => ({
|
|
88
|
+
themeOpacity: 1,
|
|
89
|
+
setThemeOpacity: jest.fn(),
|
|
90
|
+
}),
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
jest.mock('./ChangeGroupRolesModal', () => ({
|
|
94
|
+
ChangeGroupRolesModal: () => null,
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
jest.mock('./ConfirmMemberRemovalModal', () => ({
|
|
98
|
+
ConfirmMemberRemovalModal: () => null,
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
import type { GroupMembersListProps } from './GroupMembersList';
|
|
102
|
+
import { GroupMembersList } from './GroupMembersList';
|
|
103
|
+
|
|
104
|
+
const MEMBERS = [
|
|
105
|
+
{
|
|
106
|
+
profile: {
|
|
107
|
+
id: 'p1',
|
|
108
|
+
handle: 'ada.example',
|
|
109
|
+
displayName: 'Ada Lovelace',
|
|
110
|
+
},
|
|
111
|
+
roles: [],
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
const group = {
|
|
116
|
+
id: 'g1',
|
|
117
|
+
name: 'Test Group',
|
|
118
|
+
} as unknown as GroupMembersListProps['group'];
|
|
119
|
+
|
|
120
|
+
const renderList = () => {
|
|
121
|
+
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
122
|
+
ReactTestRenderer.act(() => {
|
|
123
|
+
tree = ReactTestRenderer.create(
|
|
124
|
+
React.createElement(GroupMembersList, { group })
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
return tree;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
describe('GroupMembersList row geometry (issue #1666)', () => {
|
|
131
|
+
it('renders the member avatar at web parity (size-12 = 48 dp, web Avatar size={3})', () => {
|
|
132
|
+
const tree = renderList();
|
|
133
|
+
const avatar = tree.root
|
|
134
|
+
.findAllByType('ProfileAvatar')
|
|
135
|
+
.find(
|
|
136
|
+
(node: { props: { className?: string } }) =>
|
|
137
|
+
typeof node.props.className === 'string'
|
|
138
|
+
);
|
|
139
|
+
expect(avatar).toBeDefined();
|
|
140
|
+
expect(avatar.props.className).toContain('size-12');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('keeps the standard p-4 row padding so the menu trigger keeps its hit target', () => {
|
|
144
|
+
const tree = renderList();
|
|
145
|
+
const rows = tree.root
|
|
146
|
+
.findAllByType('View')
|
|
147
|
+
.filter(
|
|
148
|
+
(node: { props: { className?: string } }) =>
|
|
149
|
+
typeof node.props.className === 'string' &&
|
|
150
|
+
node.props.className.includes('border-b')
|
|
151
|
+
);
|
|
152
|
+
expect(rows.length).toBe(1);
|
|
153
|
+
expect(rows[0].props.className).toContain('p-4');
|
|
154
|
+
expect(rows[0].props.className).not.toContain('pr-1');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
|
|
7
7
|
import {
|
|
8
8
|
countYesRsvps,
|
|
9
|
+
eventTimeZoneOptions,
|
|
9
10
|
isCapacityEvent,
|
|
10
11
|
sameRecurrenceId,
|
|
11
12
|
} from '@openpeepshq/common/lib';
|
|
@@ -20,9 +21,11 @@ export interface EventOccurrenceListProps {
|
|
|
20
21
|
occurrences: ExpandedOccurrence[];
|
|
21
22
|
currentOccurrenceId?: string;
|
|
22
23
|
recurrenceLabel: string;
|
|
24
|
+
/** IANA zone the occurrence timestamps render in. */
|
|
25
|
+
timeZone?: string;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
const formatOccurrenceStart = (start: string) =>
|
|
28
|
+
const formatOccurrenceStart = (start: string, timeZone?: string) =>
|
|
26
29
|
new Date(start).toLocaleString(undefined, {
|
|
27
30
|
weekday: 'short',
|
|
28
31
|
month: 'short',
|
|
@@ -30,6 +33,7 @@ const formatOccurrenceStart = (start: string) =>
|
|
|
30
33
|
year: 'numeric',
|
|
31
34
|
hour: '2-digit',
|
|
32
35
|
minute: '2-digit',
|
|
36
|
+
...eventTimeZoneOptions(timeZone),
|
|
33
37
|
});
|
|
34
38
|
|
|
35
39
|
export const EventOccurrenceList: React.FC<EventOccurrenceListProps> = ({
|
|
@@ -38,6 +42,7 @@ export const EventOccurrenceList: React.FC<EventOccurrenceListProps> = ({
|
|
|
38
42
|
occurrences,
|
|
39
43
|
currentOccurrenceId,
|
|
40
44
|
recurrenceLabel,
|
|
45
|
+
timeZone,
|
|
41
46
|
}) => {
|
|
42
47
|
const { t } = useTranslation();
|
|
43
48
|
const event = post.data?.type === 'event' ? post.data : undefined;
|
|
@@ -100,7 +105,7 @@ export const EventOccurrenceList: React.FC<EventOccurrenceListProps> = ({
|
|
|
100
105
|
occurrence.recurrenceId,
|
|
101
106
|
currentOccurrenceId
|
|
102
107
|
);
|
|
103
|
-
const label = formatOccurrenceStart(occurrence.start);
|
|
108
|
+
const label = formatOccurrenceStart(occurrence.start, timeZone);
|
|
104
109
|
const capacity =
|
|
105
110
|
showCapacity && event?.maxAttendees !== undefined
|
|
106
111
|
? ` ${t('events.occurrence.capacity', {
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
normalizeResourceTags,
|
|
15
15
|
resourceFormIssues,
|
|
16
16
|
} from '@openpeepshq/common/lib';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
applyAudienceSetting,
|
|
19
|
+
useCurrentProfile,
|
|
20
|
+
useResourceLibrary,
|
|
21
|
+
} from '@openpeepshq/react';
|
|
18
22
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
19
23
|
import {
|
|
20
24
|
AudioPickerSheet,
|
|
@@ -28,6 +32,7 @@ import { ThemedText } from '../../ui/themed-text';
|
|
|
28
32
|
import { ComposeAttachments } from './ComposeAttachments';
|
|
29
33
|
import { OpenpeepsMarkdownInput } from './OpenpeepsMarkdownInput';
|
|
30
34
|
import { VisibilitySelector } from './VisibilitySelector';
|
|
35
|
+
import { CategoryPathPicker } from '../../resources/CategoryPathPicker';
|
|
31
36
|
|
|
32
37
|
export interface ResourceFormProps {
|
|
33
38
|
postData: PostCreationData;
|
|
@@ -47,6 +52,10 @@ export const ResourceForm = ({
|
|
|
47
52
|
const me = useCurrentProfile();
|
|
48
53
|
const resource = postData.data as ResourcePost;
|
|
49
54
|
const [tagDraft, setTagDraft] = useState('');
|
|
55
|
+
const library = useResourceLibrary(
|
|
56
|
+
postData.groupId ?? undefined,
|
|
57
|
+
!postData.groupId
|
|
58
|
+
);
|
|
50
59
|
const imageRef = useRef<BottomSheetModal>(null);
|
|
51
60
|
const videoRef = useRef<BottomSheetModal>(null);
|
|
52
61
|
const audioRef = useRef<BottomSheetModal>(null);
|
|
@@ -211,7 +220,8 @@ export const ResourceForm = ({
|
|
|
211
220
|
</>
|
|
212
221
|
) : (
|
|
213
222
|
<>
|
|
214
|
-
{/*
|
|
223
|
+
{/* Every image pick is single-file so the crop/alt-text dialog
|
|
224
|
+
shows for every image; galleries stay open for further picks (#1789). */}
|
|
215
225
|
{resource.resourceKind === 'gallery' ||
|
|
216
226
|
(resource.attachments ?? []).length === 0 ? (
|
|
217
227
|
<Pressable
|
|
@@ -297,19 +307,10 @@ export const ResourceForm = ({
|
|
|
297
307
|
defaultValue: 'Place in the library',
|
|
298
308
|
})}
|
|
299
309
|
</ThemedText>
|
|
300
|
-
<
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
categoryPath: value
|
|
305
|
-
.split('/')
|
|
306
|
-
.map((segment) => segment.trim())
|
|
307
|
-
.filter(Boolean),
|
|
308
|
-
})
|
|
309
|
-
}
|
|
310
|
-
placeholder={t('resources.form.addLevel', {
|
|
311
|
-
defaultValue: 'Add a folder',
|
|
312
|
-
})}
|
|
310
|
+
<CategoryPathPicker
|
|
311
|
+
path={resource.categoryPath ?? []}
|
|
312
|
+
tree={library.tree}
|
|
313
|
+
onChange={(categoryPath: string[]) => patchResource({ categoryPath })}
|
|
313
314
|
/>
|
|
314
315
|
|
|
315
316
|
<ThemedText className="text-sm font-medium">
|
|
@@ -347,7 +348,6 @@ export const ResourceForm = ({
|
|
|
347
348
|
) : null}
|
|
348
349
|
</View>
|
|
349
350
|
<ImagePickerSheet ref={imageRef} onSelect={addAttachments} />
|
|
350
|
-
{/* Only galleries take more than one file; other kinds pick one. */}
|
|
351
351
|
<VideoPickerSheet
|
|
352
352
|
ref={videoRef}
|
|
353
353
|
multiple={false}
|
|
@@ -230,7 +230,9 @@ export const VisibilitySheet = forwardRef<
|
|
|
230
230
|
<ProfileSelector
|
|
231
231
|
ref={audiencePickerModalRef}
|
|
232
232
|
onSelect={setSelectedProfiles}
|
|
233
|
-
title=
|
|
233
|
+
title={t('posts.form.audienceTitle', {
|
|
234
|
+
defaultValue: 'Who can see this?',
|
|
235
|
+
})}
|
|
234
236
|
initialProfiles={selectedAudience.audience ?? []}
|
|
235
237
|
editMode
|
|
236
238
|
/>
|