feat: integrate admin panel into the mobile app (#37) #115

Merged
EgorEast merged 54 commits from feat/admin-interface into main 2026-09-30 22:28:35 +00:00
Owner

Summary

Integrates the admin panel directly into the mobile app under /admin, replacing
the separate Svelte admin application's functionality on mobile.

Closes #37.

What's included

  • /admin area with a tab bar: Разделы, Плейлисты, Проповеди, Медиа, Пользователи
  • Full CRUD for all admin resources, including drag-reorder
  • File uploads with progress reporting
  • Login flow with secure token storage — expo-secure-store on native, AES-GCM + IndexedDB on web
  • Admin entry points from Настройки / Еще
  • Required-field validation across admin forms
  • UX patterns: skeletons, marquee, safe-area handling
  • Docs ported and adapted from the admin project

Verification

  • lint / check:types / check:unused (knip) / check:fsd / check:circular — all green
  • Full jest suite passing
  • gradle assembleDevDebug — BUILD SUCCESSFUL
  • Prebuild churn clean
## Summary Integrates the admin panel directly into the mobile app under `/admin`, replacing the separate Svelte admin application's functionality on mobile. Closes #37. ### What's included - **`/admin` area** with a tab bar: Разделы, Плейлисты, Проповеди, Медиа, Пользователи - **Full CRUD** for all admin resources, including drag-reorder - **File uploads** with progress reporting - **Login flow** with secure token storage — `expo-secure-store` on native, AES-GCM + IndexedDB on web - **Admin entry points** from Настройки / Еще - **Required-field validation** across admin forms - **UX patterns**: skeletons, marquee, safe-area handling - **Docs ported and adapted** from the admin project ### Verification - `lint` / `check:types` / `check:unused` (knip) / `check:fsd` / `check:circular` — all green - Full jest suite passing - `gradle assembleDevDebug` — **BUILD SUCCESSFUL** - Prebuild churn clean
Add expo-secure-store for encrypted JWT storage on native, register the
in-memory mock for jest (jest-expo resolves the native implementation) and
record the storage decision in docs/decisions.md. Regenerated Android
strings.xml drops the obsolete system-UI style entry.
Introduce secureTokenStorage with platform resolution: expo-secure-store
on native, AES-GCM over WebCrypto with a non-extractable key in IndexedDB
on web (in-memory fallback, never plaintext), AsyncStorage in the generic
fallback. SecureStore keys/validation live in secureTokenStorageShared;
axiosInstance.tokenStorage delegates to it.

Add the auth entity: signIn/restoreSession/signOut actions, auth atoms,
role guards (canAccessAdmin/isAdminUser) and the useAdminEntry /
useRequireAdminRole hooks.
Add the /admin route area: a guarded Stack (restoreSession + redirect to
/admin/login), the AdminLoginScreen and a Tabs layout reusing CustomTabBar.
Generalise the tab bar with getTabLabel/TabIcon so it serves both public
and admin tabs.

Each admin CRUD section is its own page slice (admin-sections, admin-playlists,
admin-sermons, admin-upload, admin-media, admin-users) rendering a themed
placeholder; admin-users enforces the admin role via useRequireAdminRole.
Add the admin dashboard (entity counters via generated API, quick actions,
sign-out) and the public entry points: a prominent "В админ панель" button on
the More tab, plus a Settings item that offers admin entry when logged out and
"Выйти из аккаунта админа" (signOut) when logged in. The Settings header keeps
the shield icon opening the same flow. Covered by tests.
Document the /admin area, its screens, the six admin section slices, the
public entry points (More button, Settings item/header) and the platform
secure token storage (expo-secure-store / WebCrypto+IndexedDB). Update the
storage, REST, native-module contracts and the admin CRUD debt entry.
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Expo Router treats any file under app/ as a route and warns that
_useHardwareBackCascade.ts / admin/_useSectionScreens.tsx are missing a
default export. Relocate them to their owning slices:
- useHardwareBackCascade -> widgets/expandable-player/lib/
- useSectionScreens -> pages/admin-section-form/lib/

Update the imports in app/_RootLayout.tsx and app/admin/_layout.tsx, the
slice barrels, and the two stale path references (player docs, collapse
cascade comment).

Signed-off-by: egoreast <egor.east@yandex.ru>
- The header button inherited TouchableItem's width:100%, stretching
  across the row and vertically; give it a fixed touch-height and
  content width instead.
- The DraggableFlatList lacked a bottom inset, hiding the last row under
  the tab bar and mini-player; copy the paddingBottom pattern used by
  the listen and playlist-list screens.
- Memoize the detail screen's Stack.Screen options so expo-router's
  setOptions does not see a fresh object every render (render loop).

Signed-off-by: egoreast <egor.east@yandex.ru>
A catch-all cleared the stored tokens on any profile-verification error,
so a transient network failure or 5xx signed the admin out destructively.
Clear tokens only when the server explicitly rejects the session
(401/403); otherwise keep them for the next launch and surface the error
via reportError.

Add getHttpStatus to error-utils — a type-guard read of axios'
response.status without an 'as' assertion — and cover the branch matrix
with a restoreSession unit test.

Signed-off-by: egoreast <egor.east@yandex.ru>
- axiosInstance: tokenStorage comment referenced the old web storage;
  it is now AES-GCM over WebCrypto with a non-extractable key in IndexedDB.
- sectionFormState.parseItemsRows: Number() accepted decimals and
  exponent notation ('1e3' -> 1000); guard with a digit-only pattern so
  only positive integers pass, and extend the test.

Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Port the Svelte Covers page: GET /files image catalog grid with the used
badge, multipart upload with progress (shared/api/uploadFile), image delete
with a 409 'used as artwork' toast, and an opt-in orphaned-files scan plus
best-effort cleanup with a deleted/failed result banner.

Unify the playlist-form cover picker onto widgets/admin-form-pickers
CoverPicker (now uploads directly), removing the local duplicate. Closes the
'orphaned files' and 'playlist cover upload deferred' debt entries.

Signed-off-by: egoreast <egor.east@yandex.ru>
Port the Svelte Users and UserDetail pages: paginated list
(GET /users?page&limit=20) with a debounced client-side filter across loaded
pages, plus a detail screen with a stat grid, password change via
PATCH /users/{id}/password and delete via DELETE /users/{id} (the delete
action is hidden for the authenticated account). Role labels move to
entities/auth (ROLE_LABELS), reused across the users screens.

Signed-off-by: egoreast <egor.east@yandex.ru>
Port the Svelte UserForm: POST /users sends name/email/username/password/role
(role always, default user), PATCH /users/{id} sends only the changed fields
(name/email/username/role, no password). Password is only shown in create mode;
it is changed on the detail screen. Registers the create/detail/edit user
screens in the /admin stack via useUserScreens.

Signed-off-by: egoreast <egor.east@yandex.ru>
Section detail playlist rows now open /admin/playlists/[id] instead of
the user-facing /listen/playlist. Playlist detail sermon rows become
tappable and open /admin/sermons/[id]. Docs updated.

Signed-off-by: egoreast <egor.east@yandex.ru>
Create/edit headers now read: back arrow — page title — save. Set
«Создать/Редактировать раздел/плейлист/проповедь/пользователя» titles
in the memoized screens hooks.

Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Unify all admin forms (section/playlist/sermon/user, create and edit) on a
shared SaveButton with a floppy-disk icon (Ionicons save-outline) in the
header, replacing the checkmark and the per-slice Playlist/Sermon/User
save buttons. Section edit loses its bottom submit button.

Extract useAdminFormHeader (widgets/admin-form-header) so every form header
carries back + title + save, with memoized options and a ref-held onSave.
Playlist/sermon edit headers now show back arrow + title like the rest.

Widen spacing between top-level field groups (INDENTS.high) versus the gap
between a group title and its inputs (INDENTS.low) in SermonForm,
PlaylistForm and SectionForm; wrap the sermon/playlist main fields in titled
groups.

Signed-off-by: egoreast <egor.east@yandex.ru>
Add shared/ui/form/EditableUrlField: the value is shown read-only inside the
input frame with an embedded pencil icon button; tapping it switches to an
editable TextInput, blur (or the checkmark) returns to read-only. Wire it into
the sermon YouTube URL field; the remaining admin URL fields (artwork, audio,
text) move to it in the following picker change.

FormField, EditableUrlField and raw admin search/URL inputs already render
placeholders in currentTheme.textMuted so they no longer read as values.

Signed-off-by: egoreast <egor.east@yandex.ru>
Move the "edit" action out of the page body into the header (headerRight,
Ionicons create-outline, accessibilityLabel='Редактировать') on section,
playlist, sermon and user detail screens via a new useAdminDetailHeader hook;
delete stays in the body. Update the sermon detail test to press the header
icon instead of the removed body button.

Reserve MIN_TOUCH_TARGET header height on the "Еще" screen so the admin
shield button appearing after the access check no longer shifts the header.

Signed-off-by: egoreast <egor.east@yandex.ru>
Give shared/ui/modal safe-area insets plus a small gap, a web-only 90%
content height (no flush viewport), and onRequestClose so Android hardware
back closes it. Extract FileLibraryModal for the admin file/cover galleries:
titled header with an X close button (accessibilityLabel='Закрыть'), loading/
error/empty states, and a shared list layout. Put 'Выбрать из библиотеки' and
'Загрузить …' side by side in a row with equal flex, and switch the picker URL
fields to EditableUrlField (muted placeholder when empty).

Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
- Playlist form: SECTION picker («Разделы») now precedes the sermons picker
  («Проповеди»).
- File/Cover picker: «Выбрать из библиотеки» label uses the same FONT_SIZES.base
  as the «Загрузить …» label.
- Forms (sermon/playlist/section/user): inter-group spacing raised to
  INDENTS.highest for a clearer separation between field groups.

Signed-off-by: egoreast <egor.east@yandex.ru>
- Add a dedicated `placeholder` slot to ThemeColors (Light/Dark/dynamic),
  dimmer than textMuted, so placeholders no longer read as real values.
- FormField/EditableUrlField use currentTheme.placeholder for
  placeholderTextColor and show a primary border (borderWidth 2) on focus,
  keeping the subtle textMuted border when unfocused.

Signed-off-by: egoreast <egor.east@yandex.ru>
- Add shared FormScrollView (shared/ui/form): wraps the form ScrollView in a
  KeyboardAvoidingView on iOS (behavior padding, offset from safe-area top +
  stack header height) so content stays reachable above the keyboard.
- Reuse it in the sermon/playlist/section/user forms.
- Android needs no extra avoidance: MainActivity already uses
  windowSoftInputMode=adjustResize, so app.config.ts is unchanged.

Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Replace the cycling sort button in admin list headers with a modal
select (AdminSelect, mirroring the form SelectField pattern); the
asc/desc order toggle stays an icon button.

Keep headers and filters mounted while lists load and show skeleton
rows instead of a full-screen spinner: AdminSermonRowSkeleton,
AdminPlaylistRowSkeleton, AdminSectionRowSkeleton,
AdminUserRowSkeleton, AdminMediaGridSkeleton and AdminContentSkeleton
in shared/ui/admin-skeleton (pulsing via the shared useSkeletonPulse).
Load-more and reorder show a footer skeleton row; admin-home stat
cards show a skeleton number. Button spinners (login, upload, scan,
form submit) are unchanged.

Update docs/features/admin.md and the admin screen docs.

Signed-off-by: egoreast <egor.east@yandex.ru>
Reuse the shared MovingText (MarqueeText drag-gated marquee, same
component as the player and slider cards) for long titles in admin
list rows: sermons, playlists, sections, users and the playlist/
section/sermon detail rows. Overflowing titles now scroll instead of
truncating statically; short titles stay static.

Note the other two commits.

Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Signed-off-by: egoreast <egor.east@yandex.ru>
Drop the «Загрузить» tab (app/admin/(tabs)/upload.tsx and its Tabs.Screen
entry). Sermons are now created only from the «Загрузить проповедь» button
in the sermons list header and the admin-home quick action, both routing to
/admin/sermons/create.

Back from the create screen returns to the previous admin screen via
router.back() (goBackToAdmin/HeaderBackButton onPress), falling back to
/admin/sermons when there is no history, so no loop is possible. Docs for
admin-home, admin-sermons, features/admin, navigation and architecture
updated accordingly.

Signed-off-by: egoreast <egor.east@yandex.ru>
Replace the big body upload button with an in-screen header (AdminMediaHeader):
«Медиа» title on the left and a cloud-upload-outline icon button
(accessibilityLabel='Загрузить файл') on the right, mirroring the playlists
screen pattern. Progress bar stays.

Render images as smallish square tiles in an adaptive grid (2–3 columns from
screen width, INDENTS gaps); tapping a tile opens a full-screen viewer
(MediaViewerModal: RN Modal + expo-image contain, closed by X, backdrop tap
and Android hardware back via onRequestClose). Move the orphans scan/cleanup
section above the grid.

Signed-off-by: egoreast <egor.east@yandex.ru>
Add AdminUsersHeader with the «Пользователи» title on the left and a
person-add-outline icon button (accessibilityLabel='Создать пользователя')
on the right; remove the body create button. The header action routes to
/admin/users/create.

Signed-off-by: egoreast <egor.east@yandex.ru>
Add a required prop to the shared form primitives (FormField, SelectField,
FormGroupTitle) that renders a red asterisk (RequiredAsterisk) after the
label. Controllers track touched fields through a shared useFormTouched hook
(markTouched on blur, markAllTouched on submit) and paint a touched-but-empty
required field with the red error border immediately, before any submit
attempt; submit stays blocked by the existing toast validation as fallback.

Required fields: section/playlist title; sermon title and artist; user name,
email, username and password (create only), aligned with the generated DTOs.

Signed-off-by: egoreast <egor.east@yandex.ru>
fix(admin): safe-area on media and users tabs
Some checks failed
CI / dco (pull_request) Failing after 9s
CI / checks (pull_request) Has been skipped
a37baa16d9
Signed-off-by: egoreast <egor.east@yandex.ru>
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Slovo_Propovedi/slovo-propovedi-mobile!115
No description provided.