@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
|
@@ -52,20 +52,56 @@ jest.mock('react-i18next', () => ({
|
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
54
|
// --- openpeeps context + server info --------------------------------------
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
// `useEventDisplayTimeZone` is stubbed as a thin pass-through over these two
|
|
56
|
+
// mocked values, so the RN suite exercises the same contract as the real hook:
|
|
57
|
+
// profile settings -> community default -> event zone; no device-zone tier.
|
|
58
|
+
let mockProfileSettingsTimeZone: string | undefined = undefined;
|
|
59
|
+
const setProfileSettingsTimeZone = (timeZone?: string) => {
|
|
60
|
+
mockProfileSettingsTimeZone = timeZone;
|
|
61
|
+
};
|
|
62
|
+
let mockCommunityDefaultTimeZone: string | undefined = undefined;
|
|
63
|
+
const setCommunityDefaultTimeZone = (timeZone?: string) => {
|
|
64
|
+
mockCommunityDefaultTimeZone = timeZone;
|
|
65
|
+
};
|
|
66
|
+
jest.mock('@openpeepshq/react', () => {
|
|
67
|
+
return {
|
|
68
|
+
useOpenpeeps: () => ({
|
|
69
|
+
currentProfile: mockProfile,
|
|
70
|
+
openpeepsApi: {
|
|
71
|
+
rsvpManageAction: () => ({}),
|
|
72
|
+
useJamAttendance: () => ({ isSuccess: false, data: [] }),
|
|
73
|
+
useJamState: () => ({ data: mockJamState }),
|
|
74
|
+
usePostRecordings: () => ({ data: [] }),
|
|
75
|
+
usePostContext: () => ({ data: undefined }),
|
|
76
|
+
},
|
|
77
|
+
client: mockClient,
|
|
78
|
+
}),
|
|
79
|
+
useServerInfo: mockUseServerInfo,
|
|
80
|
+
// Pass-through over the mocked tiers, gated by Intl's own IANA check —
|
|
81
|
+
// the ESM @openpeepshq/common dist cannot be required under the jest node
|
|
82
|
+
// env, so this mirrors eventDisplayTimeZone's isIanaTimeZone gate only.
|
|
83
|
+
useEventDisplayTimeZone: (eventTimeZone?: string | null) => {
|
|
84
|
+
const isIana = (tz?: string | null): tz is string => {
|
|
85
|
+
if (!tz) return false;
|
|
86
|
+
try {
|
|
87
|
+
new Intl.DateTimeFormat('en-US', { timeZone: tz });
|
|
88
|
+
return true;
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return (
|
|
94
|
+
(isIana(mockProfileSettingsTimeZone)
|
|
95
|
+
? mockProfileSettingsTimeZone
|
|
96
|
+
: undefined) ??
|
|
97
|
+
(isIana(mockCommunityDefaultTimeZone)
|
|
98
|
+
? mockCommunityDefaultTimeZone
|
|
99
|
+
: undefined) ??
|
|
100
|
+
(isIana(eventTimeZone) ? eventTimeZone : undefined)
|
|
101
|
+
);
|
|
64
102
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
useServerInfo: mockUseServerInfo,
|
|
68
|
-
}));
|
|
103
|
+
};
|
|
104
|
+
});
|
|
69
105
|
|
|
70
106
|
// --- shared (pure) helpers -------------------------------------------------
|
|
71
107
|
jest.mock('@openpeepshq/common', () => ({
|
|
@@ -76,8 +112,17 @@ jest.mock('@openpeepshq/common/lib', () => ({
|
|
|
76
112
|
canAccessJamRecordings: () => false,
|
|
77
113
|
canModerateJam: () => false,
|
|
78
114
|
canViewJamAttendees: () => false,
|
|
79
|
-
effectiveEventTimes: (
|
|
80
|
-
|
|
115
|
+
effectiveEventTimes: (event?: { start?: string }) =>
|
|
116
|
+
event?.start ? { start: event.start } : {},
|
|
117
|
+
eventTimeZoneOptions: (timeZone?: string | null) => {
|
|
118
|
+
if (typeof timeZone !== 'string') return {};
|
|
119
|
+
try {
|
|
120
|
+
new Intl.DateTimeFormat('en-US', { timeZone });
|
|
121
|
+
return { timeZone };
|
|
122
|
+
} catch {
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
81
126
|
formatEventClockTime: () => '',
|
|
82
127
|
formatEventRecurrence: () => '',
|
|
83
128
|
listRsvpOccurrences: () => [],
|
|
@@ -308,6 +353,8 @@ function render(
|
|
|
308
353
|
beforeEach(() => {
|
|
309
354
|
mockJamState = undefined;
|
|
310
355
|
mockProfile = { id: 'u-1', displayName: 'Att', handle: 'att' };
|
|
356
|
+
mockProfileSettingsTimeZone = undefined;
|
|
357
|
+
mockCommunityDefaultTimeZone = undefined;
|
|
311
358
|
mockUseServerInfo.mockReset();
|
|
312
359
|
mockUseServerInfo.mockReturnValue({ jams: { livekit: { enabled: true } } });
|
|
313
360
|
});
|
|
@@ -466,3 +513,76 @@ describe('tappable Jam URL', () => {
|
|
|
466
513
|
tree.unmount();
|
|
467
514
|
});
|
|
468
515
|
});
|
|
516
|
+
|
|
517
|
+
// Display time zone (issue #2129): FullEvent resolves the viewer's zone via
|
|
518
|
+
// useEventDisplayTimeZone (profile settings -> community default -> event
|
|
519
|
+
// zone) and appends the "in your time zone" suffix whenever the resolved zone
|
|
520
|
+
// is a resolvable zone that differs from the event's own zone.
|
|
521
|
+
describe('event display time zone', () => {
|
|
522
|
+
const timedPost = {
|
|
523
|
+
...BASE_POST,
|
|
524
|
+
data: {
|
|
525
|
+
...BASE_POST.data,
|
|
526
|
+
timeZone: 'America/New_York',
|
|
527
|
+
start: '2026-06-15T14:30:00Z',
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
test('12. profile settings time zone differing from the event zone -> suffix renders', () => {
|
|
532
|
+
setProfileSettingsTimeZone('Europe/Berlin');
|
|
533
|
+
const tree = render(timedPost);
|
|
534
|
+
const json = JSON.stringify(tree.toJSON());
|
|
535
|
+
expect(json).toContain('in your time zone');
|
|
536
|
+
expect(json).toContain('(Europe/Berlin)');
|
|
537
|
+
tree.unmount();
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
test('13. display zone matching the event zone -> no suffix', () => {
|
|
541
|
+
setProfileSettingsTimeZone('America/New_York');
|
|
542
|
+
const tree = render(timedPost);
|
|
543
|
+
const json = JSON.stringify(tree.toJSON());
|
|
544
|
+
expect(json).not.toContain('in your time zone');
|
|
545
|
+
tree.unmount();
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
test('14. no profile settings time zone -> falls back to event zone, no suffix', () => {
|
|
549
|
+
setProfileSettingsTimeZone(undefined);
|
|
550
|
+
const tree = render(timedPost);
|
|
551
|
+
const json = JSON.stringify(tree.toJSON());
|
|
552
|
+
expect(json).not.toContain('in your time zone');
|
|
553
|
+
tree.unmount();
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
test('15. community default time zone used when the profile has none -> suffix renders', () => {
|
|
557
|
+
setProfileSettingsTimeZone(undefined);
|
|
558
|
+
setCommunityDefaultTimeZone('Europe/Berlin');
|
|
559
|
+
const tree = render(timedPost);
|
|
560
|
+
const json = JSON.stringify(tree.toJSON());
|
|
561
|
+
expect(json).toContain('in your time zone');
|
|
562
|
+
expect(json).toContain('(Europe/Berlin)');
|
|
563
|
+
tree.unmount();
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
test('16. unresolvable zones -> no suffix and no zone label', () => {
|
|
567
|
+
setProfileSettingsTimeZone('Not/AZone');
|
|
568
|
+
const tree = render({
|
|
569
|
+
...timedPost,
|
|
570
|
+
data: { ...timedPost.data, timeZone: undefined },
|
|
571
|
+
});
|
|
572
|
+
const json = JSON.stringify(tree.toJSON());
|
|
573
|
+
expect(json).not.toContain('in your time zone');
|
|
574
|
+
expect(json).not.toContain('Not/AZone');
|
|
575
|
+
tree.unmount();
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
test('17. invalid profile zone ignored, community default wins -> suffix renders', () => {
|
|
579
|
+
setProfileSettingsTimeZone('Not/AZone');
|
|
580
|
+
setCommunityDefaultTimeZone('Europe/Berlin');
|
|
581
|
+
const tree = render(timedPost);
|
|
582
|
+
const json = JSON.stringify(tree.toJSON());
|
|
583
|
+
expect(json).toContain('in your time zone');
|
|
584
|
+
expect(json).toContain('(Europe/Berlin)');
|
|
585
|
+
expect(json).not.toContain('Not/AZone');
|
|
586
|
+
tree.unmount();
|
|
587
|
+
});
|
|
588
|
+
});
|
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
import { ThemedView } from '../../../ui/themed-view';
|
|
69
69
|
import { EventOccurrenceList } from '../../pieces/EventOccurrenceList';
|
|
70
70
|
import { EventRsvpList } from '../../pieces/EventRsvpList';
|
|
71
|
+
import { useEventDisplayTimeZone } from '@openpeepshq/react';
|
|
71
72
|
|
|
72
73
|
import {
|
|
73
74
|
EventMenu,
|
|
@@ -128,7 +129,8 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
const times = effectiveEventTimes(event, occurrence);
|
|
131
|
-
const
|
|
132
|
+
const displayTz = useEventDisplayTimeZone(event?.timeZone);
|
|
133
|
+
const tz = eventTimeZoneOptions(displayTz);
|
|
132
134
|
const recurrenceLabel = event?.recurrence
|
|
133
135
|
? formatEventRecurrence(event.recurrence, t, event.start)
|
|
134
136
|
: '';
|
|
@@ -310,16 +312,21 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
310
312
|
</ThemedText>
|
|
311
313
|
<ThemedText className="text-muted-foreground mt-2">
|
|
312
314
|
{formatEventClockTime(times.start, {
|
|
313
|
-
timeZone:
|
|
315
|
+
timeZone: displayTz,
|
|
314
316
|
locale: 'en-US',
|
|
315
317
|
})}
|
|
316
318
|
{times.end
|
|
317
319
|
? ` - ${formatEventClockTime(times.end, {
|
|
318
|
-
timeZone:
|
|
320
|
+
timeZone: displayTz,
|
|
319
321
|
locale: 'en-US',
|
|
320
322
|
})}`
|
|
321
323
|
: ''}
|
|
322
324
|
{tz.timeZone ? ` (${tz.timeZone})` : ''}
|
|
325
|
+
{displayTz && displayTz !== event?.timeZone
|
|
326
|
+
? ` — ${t('events.inYourTimeZone', {
|
|
327
|
+
defaultValue: 'in your time zone',
|
|
328
|
+
})}`
|
|
329
|
+
: ''}
|
|
323
330
|
</ThemedText>
|
|
324
331
|
</View>
|
|
325
332
|
</View>
|
|
@@ -393,6 +400,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
393
400
|
occurrences={upcomingOccurrences}
|
|
394
401
|
currentOccurrenceId={occurrence}
|
|
395
402
|
recurrenceLabel={recurrenceLabel}
|
|
403
|
+
timeZone={displayTz}
|
|
396
404
|
/>
|
|
397
405
|
) : null}
|
|
398
406
|
<EventRsvpButton post={post as PublicPost} recurrenceId={occurrence} />
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for the ProfileSelector sheet title (issue #1666).
|
|
3
|
+
*
|
|
4
|
+
* The sheet used to hard-code the English string "Add members", so every
|
|
5
|
+
* caller that omitted `title` (jam moderators, group members, event
|
|
6
|
+
* moderators) rendered untranslated copy, and the audience picker could be
|
|
7
|
+
* re-titled to a non-matching string. Web defaults to
|
|
8
|
+
* `profile.selector.title` ("Select profiles"); RN must match.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const React = require('react');
|
|
12
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
13
|
+
|
|
14
|
+
const mockT = (key: string) => MESSAGES[key] ?? key;
|
|
15
|
+
|
|
16
|
+
const MESSAGES: Record<string, string> = {
|
|
17
|
+
'profile.selector.title': 'Select profiles',
|
|
18
|
+
'profile.search.placeholder': 'Search profiles',
|
|
19
|
+
'profile.search.noResults': 'No results found',
|
|
20
|
+
'common.members.addSuccess': 'Added',
|
|
21
|
+
'common.members.addError': 'Failed',
|
|
22
|
+
'common.members.adding': 'Adding',
|
|
23
|
+
'common.actions.add': 'Add',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
jest.mock('react-native', () => ({
|
|
27
|
+
View: (props: { children?: unknown }) =>
|
|
28
|
+
React.createElement('View', null, props.children),
|
|
29
|
+
ScrollView: (props: { children?: unknown }) =>
|
|
30
|
+
React.createElement('ScrollView', null, props.children),
|
|
31
|
+
ActivityIndicator: () => null,
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
jest.mock('react-i18next', () => ({
|
|
35
|
+
useTranslation: () => ({ t: mockT }),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
39
|
+
useOpenpeeps: () => ({
|
|
40
|
+
openpeepsApi: {
|
|
41
|
+
// Stable array identity: the component's effect depends on `profiles`
|
|
42
|
+
// and a fresh literal each render would loop forever.
|
|
43
|
+
useProfiles: () => ({ data: PROFILES, isLoading: false }),
|
|
44
|
+
},
|
|
45
|
+
currentProfile: null,
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const PROFILES: unknown[] = [];
|
|
50
|
+
|
|
51
|
+
jest.mock('../../lib/utils', () => ({
|
|
52
|
+
profileMatchesQuery: () => true,
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
jest.mock('../icons/index', () => ({
|
|
56
|
+
CheckIcon: () => React.createElement('CheckIcon'),
|
|
57
|
+
SearchIcon: () => React.createElement('SearchIcon'),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
jest.mock('../ui/input', () => ({
|
|
61
|
+
Input: () => null,
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
jest.mock('../ui/themed-text', () => ({
|
|
65
|
+
ThemedText: (props: Record<string, unknown>) =>
|
|
66
|
+
React.createElement('ThemedText', props, props.children),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
jest.mock('../custom/modals/common', () => ({
|
|
70
|
+
BaseSheet: (props: { children?: unknown }) =>
|
|
71
|
+
React.createElement('BaseSheet', null, props.children),
|
|
72
|
+
SheetFooter: () => null,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
jest.mock('react-native-toast-message', () => ({ show: jest.fn() }));
|
|
76
|
+
|
|
77
|
+
jest.mock('../../lib/bottom-sheet-ref', () => ({
|
|
78
|
+
bottomSheetClose: jest.fn(),
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
jest.mock('./ProfileCard', () => ({
|
|
82
|
+
MiniProfileCard: () => null,
|
|
83
|
+
ProfileCard: () => null,
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
import type { ProfilePickerSheetProps } from './ProfileSelector';
|
|
87
|
+
import { ProfileSelector } from './ProfileSelector';
|
|
88
|
+
|
|
89
|
+
const renderSelector = (props: Partial<ProfilePickerSheetProps> = {}) => {
|
|
90
|
+
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
91
|
+
ReactTestRenderer.act(() => {
|
|
92
|
+
tree = ReactTestRenderer.create(
|
|
93
|
+
React.createElement(ProfileSelector, props as ProfilePickerSheetProps)
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
return tree;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const titleText = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
|
|
100
|
+
tree.root
|
|
101
|
+
.findAllByType('ThemedText')
|
|
102
|
+
.map((node: { props: { children?: unknown } }) => node.props.children)
|
|
103
|
+
.find((child) => typeof child === 'string');
|
|
104
|
+
|
|
105
|
+
describe('ProfileSelector sheet title (issue #1666)', () => {
|
|
106
|
+
it('falls back to the localized profile.selector.title when no title is passed', () => {
|
|
107
|
+
const tree = renderSelector();
|
|
108
|
+
expect(titleText(tree)).toBe('Select profiles');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('uses an explicit title when the caller passes one', () => {
|
|
112
|
+
const tree = renderSelector({ title: 'Add members to Test Group' });
|
|
113
|
+
expect(titleText(tree)).toBe('Add members to Test Group');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -33,7 +33,7 @@ export const ProfileSelector = forwardRef<
|
|
|
33
33
|
{
|
|
34
34
|
onSelect,
|
|
35
35
|
asynOnSelect,
|
|
36
|
-
title
|
|
36
|
+
title,
|
|
37
37
|
profilesToExclude,
|
|
38
38
|
selectType = 'sync',
|
|
39
39
|
initialProfiles,
|
|
@@ -131,7 +131,7 @@ export const ProfileSelector = forwardRef<
|
|
|
131
131
|
|
|
132
132
|
<View className="w-full">
|
|
133
133
|
<ThemedText className="text-center text-xl font-semibold mb-6">
|
|
134
|
-
{title}
|
|
134
|
+
{title ?? t('profile.selector.title')}
|
|
135
135
|
</ThemedText>
|
|
136
136
|
<View className="flex-row items-center mb-4 w-full">
|
|
137
137
|
<View className="rounded-l-md bg-surface p-3">
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import type { CategoryNode } from '@openpeepshq/common/lib';
|
|
4
|
+
import { categoryPathKey } from '@openpeepshq/common/lib';
|
|
5
|
+
import { Input } from '../ui/input';
|
|
6
|
+
import { ThemedText } from '../ui/themed-text';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
export interface CategoryPathPickerProps {
|
|
10
|
+
path: string[];
|
|
11
|
+
tree: CategoryNode[];
|
|
12
|
+
onChange: (path: string[]) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NodeList = ({
|
|
16
|
+
nodes,
|
|
17
|
+
selected,
|
|
18
|
+
onSelect,
|
|
19
|
+
}: {
|
|
20
|
+
nodes: CategoryNode[];
|
|
21
|
+
selected: string[];
|
|
22
|
+
onSelect: (path: string[]) => void;
|
|
23
|
+
}) => (
|
|
24
|
+
<View className="ml-3 border-l border-border pl-3">
|
|
25
|
+
{nodes.map((node) => {
|
|
26
|
+
const active =
|
|
27
|
+
selected.length === node.path.length &&
|
|
28
|
+
node.path.every((segment, index) => selected[index] === segment);
|
|
29
|
+
return (
|
|
30
|
+
<View key={categoryPathKey(node.path)} className="py-0.5">
|
|
31
|
+
<Pressable onPress={() => onSelect(node.path)}>
|
|
32
|
+
<ThemedText
|
|
33
|
+
className={`text-sm ${
|
|
34
|
+
active
|
|
35
|
+
? 'font-semibold text-foreground'
|
|
36
|
+
: 'text-muted-foreground'
|
|
37
|
+
}`}
|
|
38
|
+
>
|
|
39
|
+
{node.name}
|
|
40
|
+
</ThemedText>
|
|
41
|
+
</Pressable>
|
|
42
|
+
{node.children.length ? (
|
|
43
|
+
<NodeList
|
|
44
|
+
nodes={node.children}
|
|
45
|
+
selected={selected}
|
|
46
|
+
onSelect={onSelect}
|
|
47
|
+
/>
|
|
48
|
+
) : null}
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const CategoryPathPicker = ({
|
|
56
|
+
path,
|
|
57
|
+
tree,
|
|
58
|
+
onChange,
|
|
59
|
+
}: CategoryPathPickerProps) => {
|
|
60
|
+
const { t } = useTranslation();
|
|
61
|
+
const [level, setLevel] = useState('');
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View className="gap-y-2">
|
|
65
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
66
|
+
{path.length
|
|
67
|
+
? path.join(' / ')
|
|
68
|
+
: t('resources.form.uncategorized', {
|
|
69
|
+
defaultValue: 'Uncategorized',
|
|
70
|
+
})}
|
|
71
|
+
</ThemedText>
|
|
72
|
+
{tree.length ? (
|
|
73
|
+
<NodeList nodes={tree} selected={path} onSelect={onChange} />
|
|
74
|
+
) : null}
|
|
75
|
+
<View className="flex-row gap-2">
|
|
76
|
+
<Input
|
|
77
|
+
value={level}
|
|
78
|
+
onChangeText={setLevel}
|
|
79
|
+
placeholder={t('resources.form.addLevel', {
|
|
80
|
+
defaultValue: 'Add a folder',
|
|
81
|
+
})}
|
|
82
|
+
/>
|
|
83
|
+
<Pressable
|
|
84
|
+
className="border-border rounded-md border bg-background px-3 py-1.5"
|
|
85
|
+
onPress={() => {
|
|
86
|
+
const name = level.trim();
|
|
87
|
+
if (!name) return;
|
|
88
|
+
onChange([...path, name]);
|
|
89
|
+
setLevel('');
|
|
90
|
+
}}
|
|
91
|
+
accessibilityRole="button"
|
|
92
|
+
accessibilityLabel={t('common.actions.add', {
|
|
93
|
+
defaultValue: 'Add',
|
|
94
|
+
})}
|
|
95
|
+
>
|
|
96
|
+
<ThemedText className="text-sm text-foreground">
|
|
97
|
+
{t('common.actions.add', { defaultValue: 'Add' })}
|
|
98
|
+
</ThemedText>
|
|
99
|
+
</Pressable>
|
|
100
|
+
{path.length ? (
|
|
101
|
+
<Pressable
|
|
102
|
+
className="px-3 py-1.5"
|
|
103
|
+
onPress={() => onChange([])}
|
|
104
|
+
accessibilityRole="button"
|
|
105
|
+
accessibilityLabel={t('resources.form.clearPath', {
|
|
106
|
+
defaultValue: 'Clear',
|
|
107
|
+
})}
|
|
108
|
+
>
|
|
109
|
+
<ThemedText className="text-sm text-muted-foreground">
|
|
110
|
+
{t('resources.form.clearPath', { defaultValue: 'Clear' })}
|
|
111
|
+
</ThemedText>
|
|
112
|
+
</Pressable>
|
|
113
|
+
) : null}
|
|
114
|
+
</View>
|
|
115
|
+
</View>
|
|
116
|
+
);
|
|
117
|
+
};
|