feat: release asset upload, transfer, Actions secrets/variables/artifacts, admin, teams/projects, file search, reactions, attachments, package version delete

- client: multipart postForm; expo-document-picker + react-native-webview deps
- release assets: upload (DocumentPicker) and delete; run artifacts list
- repository transfer; Actions secrets + variables management screen
- admin (users/orgs/repos) screen gated on is_admin
- org teams, repo projects (read-only); find-file via recursive git tree
- issue reactions toggle and attachments list; package version delete
- endpoint tests (126 total)
This commit is contained in:
JustZoe101 committed 2026-10-09 18:40:08 +02:00
1 parent b2b44bca73
commit 587bf732b5
31 files changed
+1919 -46

No files matched your search

+16 -1
View File
@@ -16,12 +16,13 @@ import {
fetchActionRun,
listActionRunJobs,
listActionRuns,
listRunArtifacts,
listWorkflows,
rerunActionRun,
type ListActionRunsParams,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { ActionRun, ActionRunJob, ActionWorkflow } from '@/core/api/types';
import type { ActionArtifact, ActionRun, ActionRunJob, ActionWorkflow } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useWorkflows(owner: string, name: string) {
@@ -114,6 +115,20 @@ export function useActionRunControl(owner: string, name: string, run: number) {
return { rerun, cancel };
}
/** Artifacts produced by a workflow run. */
export function useRunArtifacts(owner: string, name: string, run: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionArtifact[]>({
queryKey: queryKeys.runArtifacts(accountId, owner, name, run),
enabled: Boolean(client) && Boolean(accountId) && run > 0,
queryFn: ({ signal }) =>
listRunArtifacts(client!, owner, name, run, { signal }).then((r) => r.artifacts ?? []),
staleTime: 60_000,
});
}
export function useActionJobLogs(owner: string, name: string, jobId: number, enabled = true) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
+55
View File
@@ -18,6 +18,7 @@ import {
import type { RawResponse } from '@/core/api/client';
import {
addIssueReaction,
createIssue,
createIssueComment,
createPull,
@@ -28,7 +29,9 @@ import {
fetchPull,
fetchPullDiff,
listCollaborators,
listIssueAttachments,
listIssueComments,
listIssueReactions,
listMilestones,
listPullFiles,
listPullReviews,
@@ -37,6 +40,7 @@ import {
listPulls,
listReviewComments,
mergePull,
removeIssueReaction,
replyToReviewComment,
searchIssues,
updateIssue,
@@ -59,6 +63,7 @@ import type {
PullRequest,
PullReview,
PullReviewComment,
Reaction,
User,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
@@ -491,3 +496,53 @@ export function useCreatePull(owner: string, name: string) {
export type { Issue, Label, PullRequest };
export type { ChangedFile, CombinedStatus, Comment, Milestone, PullReview, User };
// ---------------------------------------------------------------------------
// Issue reactions & attachments
// ---------------------------------------------------------------------------
export function useIssueReactions(owner: string, name: string, index: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Reaction[]>({
queryKey: queryKeys.issueReactions(accountId, owner, name, index),
enabled: Boolean(client) && Boolean(accountId) && index > 0,
queryFn: ({ signal }) => listIssueReactions(client!, owner, name, index, { signal }),
staleTime: 30_000,
});
}
/** Adds the reaction when absent, removes it when already present. */
export function useToggleIssueReaction(owner: string, name: string, index: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: async ({ content, mine }: { content: string; mine: boolean }): Promise<void> => {
if (mine) {
await removeIssueReaction(client!, owner, name, index, content);
} else {
await addIssueReaction(client!, owner, name, index, content);
}
},
onSuccess: () => {
void queryClient.invalidateQueries({
queryKey: queryKeys.issueReactions(accountId, owner, name, index),
});
},
});
}
export function useIssueAttachments(owner: string, name: string, index: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<{ id?: number; name?: string; size?: number; browser_download_url?: string }[]>({
queryKey: queryKeys.issueAttachments(accountId, owner, name, index),
enabled: Boolean(client) && Boolean(accountId) && index > 0,
queryFn: ({ signal }) => listIssueAttachments(client!, owner, name, index, { signal }),
staleTime: 60_000,
});
}
+62
View File
@@ -6,7 +6,12 @@ import type { RawResponse } from '@/core/api/client';
import {
createOrg,
deletePackage,
deletePackageVersion,
fetchAuthenticatedUser,
fetchUserSettings,
listAdminOrgs,
listAdminRepos,
listAdminUsers,
listOrgRepos,
listPackages,
listUserGpgKeys,
@@ -24,6 +29,7 @@ import type {
Package,
PublicKey,
Repository,
User,
UserSettings,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
@@ -49,6 +55,18 @@ function useAccountList<T>(
});
}
/** The signed-in user (used to gate admin-only UI on `is_admin`). */
export function useCurrentUser() {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<User>({
queryKey: queryKeys.me(accountId),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) => fetchAuthenticatedUser(client!, { signal }),
staleTime: 5 * 60_000,
});
}
export function useUserOrgs(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
@@ -152,3 +170,47 @@ export function useDeletePackage() {
},
});
}
export function useDeletePackageVersion() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name, version }: { owner: string; type: string; name: string; version: string }) =>
deletePackageVersion(client!, owner, type, name, version),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
// ---------------------------------------------------------------------------
// Admin (read-only)
// ---------------------------------------------------------------------------
export function useAdminUsers(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<User>(
[...queryKeys.account(accountId), 'admin', 'users', { limit }],
(page, signal) => listAdminUsers(client!, { page, limit }, { signal }),
);
}
export function useAdminOrgs(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Organization>(
[...queryKeys.account(accountId), 'admin', 'orgs', { limit }],
(page, signal) => listAdminOrgs(client!, { page, limit }, { signal }),
);
}
export function useAdminRepos(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Repository>(
[...queryKeys.account(accountId), 'admin', 'repos', { limit }],
(page, signal) => listAdminRepos(client!, { page, limit }, { signal }),
);
}
@@ -0,0 +1,114 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { Organization, Repository, User } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useAdminOrgs, useAdminRepos, useAdminUsers } from '@/features/profile/queries';
import { spacing } from '@/theme/tokens';
type Tab = 'users' | 'orgs' | 'repos';
/** Instance administration (read-only) for instance admins. */
export function AdminScreen() {
const { t } = useTranslation();
const [tab, setTab] = useState<Tab>('users');
const users = useAdminUsers();
const orgs = useAdminOrgs();
const repos = useAdminRepos();
return (
<Screen padded={false}>
<View style={styles.tabs}>
<SegmentedControl<Tab>
value={tab}
onChange={setTab}
accessibilityLabel={t('admin.title')}
options={[
{ value: 'users', label: t('admin.users') },
{ value: 'orgs', label: t('admin.orgs') },
{ value: 'repos', label: t('admin.repos') },
]}
/>
</View>
{tab === 'users' ? (
<QueryList<User>
query={users}
items={flattenPages(users.data)}
keyExtractor={(user) => String(user.id ?? user.login)}
renderItem={(user) => (
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{user.login}
</AppText>
{user.full_name ? (
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
{user.full_name}
</AppText>
) : null}
</View>
{user.is_admin ? <Badge tone="warning">{t('admin.adminBadge')}</Badge> : null}
</View>
)}
empty={<EmptyState icon="people" title={t('admin.emptyUsers')} />}
/>
) : null}
{tab === 'orgs' ? (
<QueryList<Organization>
query={orgs}
items={flattenPages(orgs.data)}
keyExtractor={(org) => String(org.id ?? org.username)}
renderItem={(org) => (
<View style={styles.row}>
<AppText variant="bodyMedium" numberOfLines={1}>
{org.username ?? org.name}
</AppText>
</View>
)}
empty={<EmptyState icon="people" title={t('admin.emptyOrgs')} />}
/>
) : null}
{tab === 'repos' ? (
<QueryList<Repository>
query={repos}
items={flattenPages(repos.data)}
keyExtractor={(repo) => String(repo.id)}
renderItem={(repo) => (
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{repo.full_name}
</AppText>
{repo.private ? <Badge tone="neutral">{t('repositories.private')}</Badge> : null}
</View>
</View>
)}
empty={<EmptyState icon="repo" title={t('admin.emptyRepos')} />}
/>
) : null}
</Screen>
);
}
const styles = StyleSheet.create({
tabs: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.md,
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
body: { flex: 1, gap: 2 },
});
@@ -0,0 +1,63 @@
import { StyleSheet, View } from 'react-native';
import { useRoute, type RouteProp } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useOrgTeams } from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { SettingsStackParamList } from '@/navigation/types';
/** Teams within an organization (read-only). */
export function OrgTeamsScreen() {
const { t } = useTranslation();
const route = useRoute<RouteProp<SettingsStackParamList, 'OrgTeams'>>();
const { org } = route.params;
const query = useOrgTeams(org);
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const teams = query.data ?? [];
if (teams.length === 0) return <EmptyState icon="people" title={t('organizations.noTeams')} />;
return (
<Screen scroll padded>
{teams.map((team) => (
<Card key={team.id ?? team.name}>
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{team.name}
</AppText>
{team.description ? (
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
{team.description}
</AppText>
) : null}
</View>
{team.permission ? <Badge tone="neutral">{team.permission}</Badge> : null}
</View>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
body: { flex: 1, gap: 2 },
});
@@ -7,6 +7,7 @@ import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import { IconButton } from '@/components/ui/icon-button';
import { EmptyState } from '@/components/ui/state-views';
import type { Organization } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
@@ -57,6 +58,11 @@ export function OrganizationsScreen() {
</AppText>
) : null}
</View>
<IconButton
name="people"
onPress={() => navigation.navigate('OrgTeams', { org: login })}
accessibilityLabel={t('organizations.teams')}
/>
</View>
);
}}
@@ -10,7 +10,7 @@ import { apiErrorMessage } from '@/core/api/error-text';
import type { Package } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format';
import { useDeletePackage, usePackages } from '@/features/profile/queries';
import { useDeletePackage, useDeletePackageVersion, usePackages } from '@/features/profile/queries';
import { useSession } from '@/features/accounts/use-session';
import { spacing } from '@/theme/tokens';
@@ -21,21 +21,35 @@ export function PackagesScreen() {
const login = account?.login ?? '';
const query = usePackages(login);
const deletePackage = useDeletePackage();
const deleteVersion = useDeletePackageVersion();
const packages: Package[] = flattenPages(query.data);
const confirmDelete = (pkg: Package) => {
Alert.alert(t('packages.deleteTitle'), t('packages.deleteBody', { name: pkg.name ?? '' }), [
{ text: t('common.cancel'), style: 'cancel' },
const buttons = [
{ text: t('common.cancel'), style: 'cancel' as const },
...(pkg.version
? [
{
text: t('packages.deleteVersion'),
onPress: () =>
deleteVersion.mutate(
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '', version: pkg.version as string },
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
),
},
]
: []),
{
text: t('common.delete'),
style: 'destructive',
text: t('packages.deleteAll'),
style: 'destructive' as const,
onPress: () =>
deletePackage.mutate(
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '' },
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
),
},
]);
];
Alert.alert(t('packages.deleteTitle'), t('packages.deleteBody', { name: pkg.name ?? '' }), buttons);
};
return (
+44
View File
@@ -32,10 +32,14 @@ import {
createRelease,
updateRelease,
deleteRelease,
uploadReleaseAsset,
deleteReleaseAsset,
fetchRepoTree,
type ForkRepoInput,
type ListMyReposParams,
type ReleaseInput,
type SearchReposParams,
type UploadFile,
} from '@/core/api/endpoints';
import type { RawResponse } from '@/core/api/client';
import { queryKeys } from '@/core/api/query-keys';
@@ -282,3 +286,43 @@ export function useDeleteRelease(owner: string, name: string, id: number) {
onSuccess: () => invalidateReleases(queryClient, accountId, owner, name),
});
}
export function useUploadReleaseAsset(owner: string, name: string, releaseId: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (file: UploadFile) => uploadReleaseAsset(client!, owner, name, releaseId, file),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.release(accountId, owner, name, releaseId) });
void queryClient.invalidateQueries({ queryKey: queryKeys.repo(accountId, owner, name) });
},
});
}
export function useDeleteReleaseAsset(owner: string, name: string, releaseId: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (assetId: number) => deleteReleaseAsset(client!, owner, name, releaseId, assetId),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.release(accountId, owner, name, releaseId) });
},
});
}
/** Recursive file tree for the "find file" search (keyed by ref). */
export function useRepoTree(owner: string, name: string, ref: string | undefined) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery({
queryKey: queryKeys.repoTree(accountId, owner, name, ref ?? ''),
enabled: Boolean(client) && Boolean(accountId) && Boolean(ref),
queryFn: ({ signal }) => fetchRepoTree(client!, owner, name, ref!, { signal }),
staleTime: 5 * 60_000,
});
}
+147 -1
View File
@@ -7,16 +7,25 @@ import {
addRepoKey,
createBranchProtection,
createRepo,
createRepoVariable,
createWebhook,
deleteBranchProtection,
deleteRepo,
deleteRepoKey,
deleteRepoSecret,
deleteRepoVariable,
deleteWebhook,
listBranchProtections,
listCollaborators,
listOrgTeams,
listRepoKeys,
listRepoProjects,
listRepoSecrets,
listRepoVariables,
listWebhooks,
putRepoSecret,
removeCollaborator,
transferRepo,
updateRepo,
type AddRepoKeyInput,
type CollaboratorPermission,
@@ -26,7 +35,16 @@ import {
type UpdateRepoInput,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { BranchProtection, DeployKey, User, Webhook } from '@/core/api/types';
import type {
ActionVariable,
BranchProtection,
DeployKey,
Project,
Secret,
Team,
User,
Webhook,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useCollaboratorsList(owner: string, name: string) {
@@ -226,3 +244,131 @@ export function useDeleteRepoKey(owner: string, name: string) {
void queryClient.invalidateQueries({ queryKey: queryKeys.repoKeys(accountId, owner, name) }),
});
}
// ---------------------------------------------------------------------------
// Transfer
// ---------------------------------------------------------------------------
export function useTransferRepo(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (newOwner: string) => transferRepo(client!, owner, name, newOwner),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
// ---------------------------------------------------------------------------
// Actions secrets & variables
// ---------------------------------------------------------------------------
export function useRepoSecrets(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Secret[]>({
queryKey: queryKeys.repoSecrets(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoSecrets(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function usePutRepoSecret(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ key, value }: { key: string; value: string }) =>
putRepoSecret(client!, owner, name, key, value),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoSecrets(accountId, owner, name) }),
});
}
export function useDeleteRepoSecret(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (key: string) => deleteRepoSecret(client!, owner, name, key),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoSecrets(accountId, owner, name) }),
});
}
export function useRepoVariables(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionVariable[]>({
queryKey: queryKeys.repoVariables(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoVariables(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateRepoVariable(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ key, value }: { key: string; value: string }) =>
createRepoVariable(client!, owner, name, key, value),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoVariables(accountId, owner, name),
}),
});
}
export function useDeleteRepoVariable(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (key: string) => deleteRepoVariable(client!, owner, name, key),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoVariables(accountId, owner, name),
}),
});
}
/** Read-only project list for the repository. */
export function useRepoProjects(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Project[]>({
queryKey: queryKeys.repoProjects(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoProjects(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
export function useOrgTeams(org: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Team[]>({
queryKey: [...queryKeys.account(accountId), 'org', org, 'teams'],
enabled: Boolean(client) && Boolean(accountId) && org.length > 0,
queryFn: ({ signal }) =>
listOrgTeams(client!, org, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
@@ -11,12 +11,13 @@ import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { ActionRunJob } from '@/core/api/types';
import { formatDateTime } from '@/core/utils/format';
import { formatBytes, formatDateTime } from '@/core/utils/format';
import {
useActionJobLogs,
useActionRun,
useActionRunControl,
useActionRunJobs,
useRunArtifacts,
} from '@/features/actions/queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
@@ -42,6 +43,7 @@ export function ActionRunDetailScreen({ route }: Props) {
const runQuery = useActionRun(owner, name, id);
const jobsQuery = useActionRunJobs(owner, name, id);
const control = useActionRunControl(owner, name, id);
const artifactsQuery = useRunArtifacts(owner, name, id);
if (runQuery.isPending) return <LoadingView />;
if (runQuery.isError) {
@@ -57,6 +59,7 @@ export function ActionRunDetailScreen({ route }: Props) {
const run = runQuery.data;
const jobs: ActionRunJob[] = jobsQuery.data ?? [];
const artifacts = artifactsQuery.data ?? [];
const state = run?.conclusion || run?.status || '';
const running = run?.status === 'running' || run?.status === 'waiting';
const canRerun = Boolean(run) && !running;
@@ -123,6 +126,30 @@ export function ActionRunDetailScreen({ route }: Props) {
) : (
jobs.map((job) => <JobRow key={job.id} owner={owner} name={name} job={job} />)
)}
{artifacts.length > 0 ? (
<>
<AppText variant="subheading">{t('actions.artifacts')}</AppText>
<Card padded={false} variant="flat">
{artifacts.map((artifact) => (
<ListItem
key={artifact.id}
leadingIcon="package"
title={artifact.name ?? ''}
subtitle={t('actions.artifactSize', {
size: formatBytes(artifact.size_in_bytes ?? 0),
})}
rightText={artifact.expired ? t('actions.expired') : undefined}
onPress={() =>
artifact.archive_download_url
? void Linking.openURL(artifact.archive_download_url).catch(() => undefined)
: undefined
}
/>
))}
</Card>
</>
) : null}
</Screen>
);
}
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Badge, type BadgeTone } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { ActionRun } from '@/core/api/types';
@@ -55,6 +56,15 @@ export function ActionsScreen({ navigation, route }: Props) {
{ value: 'running', label: t('actions.filterRunning') },
]}
/>
<View style={styles.settings}>
<Button
label={t('repoSettings.actionsSettings')}
variant="secondary"
iconLeft="gear"
fullWidth
onPress={() => navigation.navigate('ActionsSettings', { owner, name })}
/>
</View>
</View>
}
renderItem={(run) => {
@@ -91,6 +101,7 @@ export function ActionsScreen({ navigation, route }: Props) {
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
settings: { marginTop: spacing.sm },
row: { paddingHorizontal: spacing.lg, paddingVertical: spacing.md, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
@@ -0,0 +1,215 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Field } from '@/components/ui/field';
import { IconButton } from '@/components/ui/icon-button';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import {
useCreateRepoVariable,
useDeleteRepoSecret,
useDeleteRepoVariable,
usePutRepoSecret,
useRepoSecrets,
useRepoVariables,
} from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'ActionsSettings'>;
/** Repository Actions secrets and variables (secrets are write-only). */
export function ActionsSettingsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const secrets = useRepoSecrets(owner, name);
const variables = useRepoVariables(owner, name);
const putSecret = usePutRepoSecret(owner, name);
const deleteSecret = useDeleteRepoSecret(owner, name);
const createVariable = useCreateRepoVariable(owner, name);
const deleteVariable = useDeleteRepoVariable(owner, name);
const [secretName, setSecretName] = useState('');
const [secretValue, setSecretValue] = useState('');
const [varName, setVarName] = useState('');
const [varValue, setVarValue] = useState('');
if (secrets.isPending || variables.isPending) return <LoadingView />;
if (secrets.isError || variables.isError) {
const error = secrets.error ?? variables.error;
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(error, t)}
retryLabel={t('common.retry')}
onRetry={() => {
void secrets.refetch();
void variables.refetch();
}}
/>
);
}
const secretItems = secrets.data ?? [];
const variableItems = variables.data ?? [];
const addSecret = () => {
if (secretName.trim().length === 0 || secretValue.length === 0) return;
putSecret.mutate(
{ key: secretName.trim(), value: secretValue },
{
onSuccess: () => {
setSecretName('');
setSecretValue('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const addVariable = () => {
if (varName.trim().length === 0) return;
createVariable.mutate(
{ key: varName.trim(), value: varValue },
{
onSuccess: () => {
setVarName('');
setVarValue('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmSecretDelete = (key: string) => {
Alert.alert(t('repoSettings.deleteSecretTitle'), t('repoSettings.deleteSecretBody', { name: key }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteSecret.mutate(key, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
const confirmVariableDelete = (key: string) => {
Alert.alert(t('repoSettings.deleteVariableTitle'), t('repoSettings.deleteVariableBody', { name: key }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteVariable.mutate(key, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<AppText variant="subheading">{t('repoSettings.secrets')}</AppText>
<Card>
<Field
label={t('repoSettings.secretName')}
value={secretName}
onChangeText={setSecretName}
autoCapitalize="none"
autoCorrect={false}
/>
<Field
label={t('repoSettings.secretValue')}
value={secretValue}
onChangeText={setSecretValue}
secureTextEntry
autoCapitalize="none"
/>
<Button
label={t('common.add')}
onPress={addSecret}
loading={putSecret.isPending}
disabled={secretName.trim().length === 0 || secretValue.length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{secretItems.map((secret) => (
<Card key={secret.name}>
<View style={styles.row}>
<AppText variant="bodyMedium" style={styles.name} numberOfLines={1}>
{secret.name}
</AppText>
<IconButton
name="trash"
onPress={() => confirmSecretDelete(secret.name ?? '')}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))}
<AppText variant="subheading">{t('repoSettings.variables')}</AppText>
<Card>
<Field
label={t('repoSettings.variableName')}
value={varName}
onChangeText={setVarName}
autoCapitalize="none"
autoCorrect={false}
/>
<Field
label={t('repoSettings.variableValue')}
value={varValue}
onChangeText={setVarValue}
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('common.add')}
onPress={addVariable}
loading={createVariable.isPending}
disabled={varName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{variableItems.map((variable) => (
<Card key={variable.name}>
<View style={styles.row}>
<View style={styles.name}>
<AppText variant="bodyMedium" numberOfLines={1}>
{variable.name}
</AppText>
{variable.data ? (
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1}>
{variable.data}
</AppText>
) : null}
</View>
<IconButton
name="trash"
onPress={() => confirmVariableDelete(variable.name ?? '')}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
spaced: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
name: { flex: 1 },
});
@@ -0,0 +1,89 @@
import { useMemo, useState } from 'react';
import { Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { SearchBar } from '@/components/ui/search-bar';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository, useRepoTree } from '@/features/repositories/queries';
import { fontFamily, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'FindFile'>;
/** Find a file by path across the repository tree. */
export function FindFileScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name, ref } = route.params;
const repo = useRepository(owner, name);
const targetRef = ref ?? repo.data?.default_branch;
const tree = useRepoTree(owner, name, targetRef);
const [query, setQuery] = useState('');
const entries = useMemo(() => {
const all = tree.data?.entries ?? [];
const q = query.trim().toLowerCase();
return all
.filter((entry) => entry.type === 'blob' && (!q || (entry.path ?? '').toLowerCase().includes(q)))
.slice(0, 300);
}, [tree.data, query]);
return (
<Screen padded={false}>
<View style={styles.search}>
<SearchBar
value={query}
onChangeText={setQuery}
placeholder={t('files.findPlaceholder')}
/>
</View>
{tree.isPending ? (
<LoadingView />
) : tree.isError ? (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(tree.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void tree.refetch()}
/>
) : entries.length === 0 ? (
<AppText variant="secondary" tone="tertiary" style={styles.empty}>
{t('files.noMatches')}
</AppText>
) : (
entries.map((entry) => (
<Pressable
key={entry.path}
onPress={() =>
entry.path &&
navigation.navigate('FileViewer', { owner, name, path: entry.path, ref: targetRef })
}
accessibilityRole="button"
accessibilityLabel={entry.path}
style={styles.row}
>
<AppText variant="monoSmall" numberOfLines={1} style={styles.path}>
{entry.path}
</AppText>
</Pressable>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
search: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: {
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: 'rgba(128,128,128,0.2)',
},
path: { fontFamily: fontFamily.mono },
empty: { padding: spacing.xl, textAlign: 'center' },
});
@@ -1,4 +1,4 @@
import { StyleSheet, View } from 'react-native';
import { Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { CommentItem } from '@/components/git/comment';
@@ -12,6 +12,7 @@ import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { LabelChip } from '@/components/ui/label-chip';
import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { safeHost } from '@/core/api/instance-url';
@@ -22,7 +23,10 @@ import {
useCreateIssueComment,
useDeleteIssueComment,
useIssue,
useIssueAttachments,
useIssueComments,
useIssueReactions,
useToggleIssueReaction,
useUpdateIssue,
useUpdateIssueComment,
} from '@/features/issues/queries';
@@ -34,6 +38,17 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'IssueDetail'>;
const REACTION_EMOJI: Record<string, string> = {
'+1': '👍',
'-1': '👎',
laugh: '😄',
hooray: '🎉',
confused: '😕',
heart: '❤️',
rocket: '🚀',
eyes: '👀',
};
/** Full issue view: state, author, labels, milestone, body, comments and composer. */
export function IssueDetailScreen({ navigation, route }: Props) {
const { t } = useTranslation();
@@ -48,6 +63,9 @@ export function IssueDetailScreen({ navigation, route }: Props) {
const createComment = useCreateIssueComment(owner, name, index);
const updateComment = useUpdateIssueComment(owner, name, index);
const deleteComment = useDeleteIssueComment(owner, name, index);
const reactionsQuery = useIssueReactions(owner, name, index);
const toggleReaction = useToggleIssueReaction(owner, name, index);
const attachmentsQuery = useIssueAttachments(owner, name, index);
if (query.isPending) return <LoadingView />;
if (query.isError) {
@@ -153,11 +171,59 @@ export function IssueDetailScreen({ navigation, route }: Props) {
/>
</View>
{/* Reactions */}
<View style={styles.reactions}>
{Object.entries(REACTION_EMOJI).map(([content, emoji]) => {
const list = (reactionsQuery.data ?? []).filter((reaction) => reaction.content === content);
const mine = list.some((reaction) => reaction.user?.login === account?.login);
return (
<Pressable
key={content}
onPress={() => toggleReaction.mutate({ content, mine })}
accessibilityRole="button"
accessibilityLabel={content}
style={[
styles.reactionChip,
{
borderColor: mine ? colors.primary : colors.border,
backgroundColor: mine ? colors.primaryMuted : colors.surface,
},
]}
>
<AppText variant="caption">{emoji}</AppText>
{list.length > 0 ? (
<AppText variant="caption" tone={mine ? 'primary' : 'tertiary'}>
{list.length}
</AppText>
) : null}
</Pressable>
);
})}
</View>
{/* Attachments */}
{attachmentsQuery.data && attachmentsQuery.data.length > 0 ? (
<Card padded={false} variant="flat">
{attachmentsQuery.data.map((attachment, attachmentIndex) => (
<ListItem
key={attachment.id ?? attachment.name ?? attachmentIndex}
leadingIcon="file"
title={attachment.name ?? ''}
onPress={() =>
attachment.browser_download_url
? void Linking.openURL(attachment.browser_download_url).catch(() => undefined)
: undefined
}
divider={attachmentIndex < (attachmentsQuery.data?.length ?? 0) - 1}
/>
))}
</Card>
) : null}
{/* Comments */}
<AppText variant="subheading" style={styles.sectionTitle}>
{t('comments.title')}
</AppText>
{commentsQuery.isPending ? (
<LoadingView label={t('comments.loading')} />
) : commentsQuery.isError ? (
@@ -234,5 +300,16 @@ const styles = StyleSheet.create({
bodyCard: { minHeight: 80 },
metaGrid: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
reactions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
reactionChip: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.xs,
borderWidth: 1,
borderRadius: 999,
paddingHorizontal: spacing.sm,
paddingVertical: 2,
minHeight: 32,
},
sectionTitle: { marginTop: spacing.md },
});
@@ -0,0 +1,80 @@
import { Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepoProjects } from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Projects'>;
/** Repository projects (read-only list). */
export function ProjectsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useRepoProjects(owner, name);
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const projects = query.data ?? [];
if (projects.length === 0) return <EmptyState icon="dashboard" title={t('projects.empty')} />;
return (
<Screen scroll padded>
{projects.map((project) => (
<Card key={project.id}>
<Pressable
onPress={() =>
project.html_url
? void Linking.openURL(project.html_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={project.title}
>
<View style={styles.header}>
<AppText variant="bodyMedium" style={styles.title} numberOfLines={1}>
{project.title}
</AppText>
<Badge tone={project.is_closed ? 'neutral' : 'success'}>
{project.is_closed ? t('projects.closed') : t('projects.open')}
</Badge>
</View>
{project.description ? (
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
{project.description}
</AppText>
) : null}
<AppText variant="caption" tone="tertiary">
{t('projects.issues', {
open: project.num_open_issues ?? 0,
closed: project.num_closed_issues ?? 0,
})}
</AppText>
</Pressable>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
title: { flex: 1, fontWeight: '600' },
});
@@ -1,5 +1,6 @@
import { Alert, Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import * as DocumentPicker from 'expo-document-picker';
import { Markdown } from '@/components/git/markdown';
import { Screen } from '@/components/layout/screen';
@@ -9,10 +10,16 @@ import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { IconButton } from '@/components/ui/icon-button';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useSession } from '@/features/accounts/use-session';
import { useDeleteRelease, useRelease } from '@/features/repositories/queries';
import {
useDeleteRelease,
useDeleteReleaseAsset,
useRelease,
useUploadReleaseAsset,
} from '@/features/repositories/queries';
import { formatBytes, formatDateTime } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
@@ -30,8 +37,24 @@ export function ReleaseDetailScreen({ navigation, route }: Props) {
const query = useRelease(owner, name, id);
const deleteRelease = useDeleteRelease(owner, name, id);
const uploadAsset = useUploadReleaseAsset(owner, name, id);
const deleteAsset = useDeleteReleaseAsset(owner, name, id);
const release = query.data;
const pickAndUpload = async () => {
const result = await DocumentPicker.getDocumentAsync({ copyToCacheDirectory: true });
if (result.canceled || !result.assets || result.assets.length === 0) return;
const file = result.assets[0];
uploadAsset.mutate(
{
uri: file.uri,
name: file.name,
type: file.mimeType ?? 'application/octet-stream',
},
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
);
};
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
@@ -79,35 +102,71 @@ export function ReleaseDetailScreen({ navigation, route }: Props) {
<AppText variant="subheading">{t('releases.assets')}</AppText>
<Card padded={false} variant="flat">
{assets.map((asset, index) => (
<Pressable
<View
key={asset.id ?? asset.name ?? index}
onPress={() =>
asset.browser_download_url
? void Linking.openURL(asset.browser_download_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={asset.name}
style={[styles.assetRow, index < assets.length - 1 && styles.divider]}
>
<Icon name="download" size={18} color={colors.textTertiary} />
<View style={styles.assetBody}>
<AppText variant="bodyMedium" numberOfLines={1}>
{asset.name}
</AppText>
<AppText variant="caption" tone="tertiary">
{t('releases.downloads', {
size: formatBytes(asset.size ?? 0),
count: asset.download_count ?? 0,
})}
</AppText>
</View>
</Pressable>
<Pressable
onPress={() =>
asset.browser_download_url
? void Linking.openURL(asset.browser_download_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={asset.name}
style={styles.assetMain}
>
<Icon name="download" size={18} color={colors.textTertiary} />
<View style={styles.assetBody}>
<AppText variant="bodyMedium" numberOfLines={1}>
{asset.name}
</AppText>
<AppText variant="caption" tone="tertiary">
{t('releases.downloads', {
size: formatBytes(asset.size ?? 0),
count: asset.download_count ?? 0,
})}
</AppText>
</View>
</Pressable>
{asset.id ? (
<IconButton
name="trash"
onPress={() =>
Alert.alert(
t('releases.deleteAssetTitle'),
t('releases.deleteAssetBody', { name: asset.name ?? '' }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteAsset.mutate(asset.id as number, {
onError: (error) =>
Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
)
}
accessibilityLabel={t('common.delete')}
/>
) : null}
</View>
))}
</Card>
</>
) : null}
<Button
label={t('releases.uploadAsset')}
variant="secondary"
iconLeft="plus"
loading={uploadAsset.isPending}
onPress={() => void pickAndUpload()}
/>
{release.html_url ? (
<Button
label={t('repo.viewOnInstance')}
@@ -161,6 +220,7 @@ const styles = StyleSheet.create({
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
assetMain: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: spacing.md },
divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: 'rgba(128,128,128,0.25)' },
assetBody: { flex: 1, gap: 2 },
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
@@ -205,6 +205,11 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
title={t('repo.files')}
onPress={() => navigation.navigate('Files', { owner, name, ref: readmeRef })}
/>
<ListItem
leadingIcon="search"
title={t('files.findFile')}
onPress={() => navigation.navigate('FindFile', { owner, name, ref: readmeRef })}
/>
<ListItem
leadingIcon="commit"
title={t('repo.commits')}
@@ -241,6 +246,13 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
onPress={() => navigation.navigate('Actions', { owner, name })}
/>
) : null}
{repo.has_projects !== false ? (
<ListItem
leadingIcon="dashboard"
title={t('projects.title')}
onPress={() => navigation.navigate('Projects', { owner, name })}
/>
) : null}
{repo.has_issues !== false ? (
<ListItem
leadingIcon="issue"
@@ -13,6 +13,7 @@ import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository } from '@/features/repositories/queries';
import {
useDeleteRepo,
useTransferRepo,
useUpdateRepo,
} from '@/features/repositories/settings-queries';
import { useTheme } from '@/theme/theme-provider';
@@ -41,6 +42,8 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
const repo = repoQuery.data;
const updateRepo = useUpdateRepo(owner, name);
const deleteRepo = useDeleteRepo(owner, name);
const transferRepo = useTransferRepo(owner, name);
const [newOwner, setNewOwner] = useState('');
const [description, setDescription] = useState<string | null>(null);
const [website, setWebsite] = useState<string | null>(null);
@@ -186,6 +189,45 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
/>
</Card>
<AppText variant="subheading">{t('repoSettings.transfer')}</AppText>
<Card>
<Field
label={t('repoSettings.newOwner')}
value={newOwner}
onChangeText={setNewOwner}
placeholder={t('repoSettings.newOwnerPlaceholder')}
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('repoSettings.transferAction')}
variant="secondary"
iconLeft="arrowLeft"
disabled={newOwner.trim().length === 0}
loading={transferRepo.isPending}
onPress={() =>
Alert.alert(
t('repoSettings.transferTitle'),
t('repoSettings.transferBody', { name, owner: newOwner.trim() }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('repoSettings.transferAction'),
style: 'destructive',
onPress: () =>
transferRepo.mutate(newOwner.trim(), {
onSuccess: () => navigation.getParent()?.goBack(),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
)
}
fullWidth
style={styles.spaced}
/>
</Card>
<AppText variant="subheading" tone="error">
{t('repoSettings.dangerZone')}
</AppText>
@@ -15,6 +15,7 @@ import { queryClient } from '@/core/api/query-client';
import type { BiometricSupport } from '@/core/security/biometrics';
import { getBiometricSupport } from '@/core/security/biometrics';
import { useSettingsStore, type ThemePreference } from '@/features/settings/settings-store';
import { useCurrentUser } from '@/features/profile/queries';
import { useRootNavigation } from '@/navigation/use-root-navigation';
import type { LanguagePreference } from '@/i18n';
import { useTheme } from '@/theme/theme-provider';
@@ -45,6 +46,7 @@ export function SettingsScreen(_props: Props) {
const setNotificationPollSeconds = useSettingsStore((s) => s.setNotificationPollSeconds);
const editorUrlTemplate = useSettingsStore((s) => s.editorUrlTemplate);
const setEditorUrlTemplate = useSettingsStore((s) => s.setEditorUrlTemplate);
const currentUser = useCurrentUser();
const [support, setSupport] = useState<BiometricSupport | null>(null);
@@ -215,8 +217,16 @@ export function SettingsScreen(_props: Props) {
leadingIcon="lock"
title={t('credentials.title')}
onPress={() => stackNavigation.navigate('Credentials')}
divider={false}
divider={currentUser.data?.is_admin ? true : false}
/>
{currentUser.data?.is_admin ? (
<ListItem
leadingIcon="shield"
title={t('admin.title')}
onPress={() => stackNavigation.navigate('Admin')}
divider={false}
/>
) : null}
</Card>
</Section>