feat(phase5): actions, repo settings, collaborators, webhooks, protections, orgs, packages, credentials, release management

- API: Actions (workflows/runs/jobs/logs getText), repo create/edit/delete,
  collaborators, webhooks, branch protections, orgs, packages, user keys/GPG
  keys/tokens, release create/edit/delete
- hooks: features/actions, repositories/settings-queries, features/profile
- screens: Actions + run detail (expandable job logs), RepoSettings,
  Collaborators, Webhooks, Protections, CreateRepo, Organizations, OrgRepos,
  Packages, Credentials, ReleaseCompose; releases list/detail management
- navigation + i18n (en/nl) wired for all new screens
This commit is contained in:
JustZoe101 committed 2026-10-09 18:10:04 +02:00
1 parent 5e8c9492b3
commit fa1ebc9184
30 files changed
+3001 -9

No files matched your search

+370
View File
@@ -12,18 +12,27 @@
import { ApiError } from './errors'; import { ApiError } from './errors';
import type { GiteaClient, RequestOptions } from './client'; import type { GiteaClient, RequestOptions } from './client';
import type { import type {
AccessToken,
ActionRun,
ActionRunJob,
ActionWorkflow,
Activity, Activity,
Branch, Branch,
BranchProtection,
ChangedFile, ChangedFile,
CombinedStatus, CombinedStatus,
Comment, Comment,
Commit, Commit,
ContentsEntry, ContentsEntry,
GpgKey,
Issue, Issue,
Label, Label,
Milestone, Milestone,
NotificationCount, NotificationCount,
NotificationThread, NotificationThread,
Organization,
Package,
PublicKey,
PullRequest, PullRequest,
PullReview, PullReview,
Release, Release,
@@ -33,6 +42,7 @@ import type {
Subscription, Subscription,
Tag, Tag,
User, User,
Webhook,
} from './types'; } from './types';
export interface PageParams { export interface PageParams {
@@ -250,6 +260,366 @@ export function fetchRelease(
return client.get<Release>(`${repoPath(owner, repo)}/releases/${id}`, options); return client.get<Release>(`${repoPath(owner, repo)}/releases/${id}`, options);
} }
export interface ReleaseInput {
tag_name: string;
target_commitish?: string;
name?: string;
body?: string;
draft?: boolean;
prerelease?: boolean;
}
export function createRelease(
client: GiteaClient,
owner: string,
repo: string,
input: ReleaseInput,
options?: RequestOptions,
): Promise<Release> {
return client.post<Release>(`${repoPath(owner, repo)}/releases`, input, options);
}
export function updateRelease(
client: GiteaClient,
owner: string,
repo: string,
id: number,
input: Partial<ReleaseInput>,
options?: RequestOptions,
): Promise<Release> {
return client.patch<Release>(`${repoPath(owner, repo)}/releases/${id}`, input, options);
}
export function deleteRelease(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/releases/${id}`, options);
}
// ---------------------------------------------------------------------------
// Repository management, collaborators, webhooks, branch protections
// ---------------------------------------------------------------------------
export interface CreateRepoInput {
name: string;
description?: string;
private?: boolean;
auto_init?: boolean;
default_branch?: string;
gitignores?: string;
license?: string;
readme?: string;
}
export function createRepo(
client: GiteaClient,
input: CreateRepoInput,
options?: RequestOptions,
): Promise<Repository> {
return client.post<Repository>('/user/repos', input, options);
}
export interface UpdateRepoInput {
name?: string;
description?: string;
website?: string;
private?: boolean;
default_branch?: string;
has_issues?: boolean;
has_pull_requests?: boolean;
has_wiki?: boolean;
has_releases?: boolean;
has_projects?: boolean;
has_packages?: boolean;
has_actions?: boolean;
archived?: boolean;
}
export function updateRepo(
client: GiteaClient,
owner: string,
repo: string,
input: UpdateRepoInput,
options?: RequestOptions,
): Promise<Repository> {
return client.patch<Repository>(repoPath(owner, repo), input, options);
}
export function deleteRepo(
client: GiteaClient,
owner: string,
repo: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(repoPath(owner, repo), options);
}
export type CollaboratorPermission = 'read' | 'write' | 'admin';
export function addCollaborator(
client: GiteaClient,
owner: string,
repo: string,
collaborator: string,
permission: CollaboratorPermission = 'write',
options?: RequestOptions,
): Promise<void> {
return client.put<void>(
`${repoPath(owner, repo)}/collaborators/${enc(collaborator)}`,
{ permission },
options,
);
}
export function removeCollaborator(
client: GiteaClient,
owner: string,
repo: string,
collaborator: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/collaborators/${enc(collaborator)}`, options);
}
export function listWebhooks(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Webhook[]>(`${repoPath(owner, repo)}/hooks`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export interface CreateWebhookInput {
type: string;
config: Record<string, string>;
events?: string[];
active?: boolean;
branch_filter?: string;
}
export function createWebhook(
client: GiteaClient,
owner: string,
repo: string,
input: CreateWebhookInput,
options?: RequestOptions,
): Promise<Webhook> {
return client.post<Webhook>(`${repoPath(owner, repo)}/hooks`, input, options);
}
export function deleteWebhook(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/hooks/${id}`, options);
}
export function listBranchProtections(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<BranchProtection[]>(`${repoPath(owner, repo)}/branch_protections`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export interface CreateBranchProtectionInput {
branch_name: string;
required_approvals?: number;
enable_push?: boolean;
enable_status_check?: boolean;
status_check_contexts?: string[];
require_signed_commits?: boolean;
}
export function createBranchProtection(
client: GiteaClient,
owner: string,
repo: string,
input: CreateBranchProtectionInput,
options?: RequestOptions,
): Promise<BranchProtection> {
return client.post<BranchProtection>(`${repoPath(owner, repo)}/branch_protections`, input, options);
}
export function deleteBranchProtection(
client: GiteaClient,
owner: string,
repo: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/branch_protections/${enc(name)}`, options);
}
// ---------------------------------------------------------------------------
// Gitea Actions
// ---------------------------------------------------------------------------
export function listWorkflows(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<ActionWorkflow[]>(`${repoPath(owner, repo)}/actions/workflows`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export interface ListActionRunsParams extends PageParams {
event?: string;
branch?: string;
status?: string;
actor?: string;
}
export function listActionRuns(
client: GiteaClient,
owner: string,
repo: string,
params: ListActionRunsParams = {},
options?: RequestOptions,
) {
return client.raw<ActionRun[]>(`${repoPath(owner, repo)}/actions/runs`, {
...options,
query: {
page: params.page ?? 1,
limit: params.limit ?? 20,
event: params.event,
branch: params.branch,
status: params.status,
actor: params.actor,
},
});
}
export function fetchActionRun(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<ActionRun> {
return client.get<ActionRun>(`${repoPath(owner, repo)}/actions/runs/${id}`, options);
}
export function listActionRunJobs(
client: GiteaClient,
owner: string,
repo: string,
run: number,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<ActionRunJob[]>(`${repoPath(owner, repo)}/actions/runs/${run}/jobs`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
/** Fetch a single job's log as plain text (falls back to the browser when unavailable). */
export function fetchActionJobLogs(
client: GiteaClient,
owner: string,
repo: string,
jobId: number,
options?: RequestOptions,
): Promise<string> {
return client.getText(`${repoPath(owner, repo)}/actions/jobs/${jobId}/logs`, options);
}
// ---------------------------------------------------------------------------
// Organizations, packages, user credentials
// ---------------------------------------------------------------------------
export function listUserOrgs(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Organization[]>('/user/orgs', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 30 },
});
}
export function listOrgRepos(
client: GiteaClient,
org: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Repository[]>(`/orgs/${enc(org)}/repos`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 20 },
});
}
export function listPackages(
client: GiteaClient,
owner: string,
params: PageParams & { type?: string; q?: string } = {},
options?: RequestOptions,
) {
return client.raw<Package[]>(`/packages/${enc(owner)}`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 20, type: params.type, q: params.q },
});
}
export function listUserKeys(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<PublicKey[]>('/user/keys', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export function listUserGpgKeys(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<GpgKey[]>('/user/gpg_keys', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export function listUserTokens(
client: GiteaClient,
username: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<AccessToken[]>(`/users/${enc(username)}/tokens`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Contents, README, branches, tags // Contents, README, branches, tags
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
+39
View File
@@ -56,6 +56,45 @@ export const queryKeys = {
release: (accountId: string, owner: string, name: string, id: number) => release: (accountId: string, owner: string, name: string, id: number) =>
[...queryKeys.repo(accountId, owner, name), 'release', id] as const, [...queryKeys.repo(accountId, owner, name), 'release', id] as const,
// --- repository settings ------------------------------------------------
repoWebhooks: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'webhooks'] as const,
repoProtections: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'branch-protections'] as const,
// --- actions -------------------------------------------------------------
actionsWorkflows: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'workflows'] as const,
actionsRuns: (accountId: string, owner: string, name: string, params: Record<string, unknown>) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'runs', params] as const,
actionRun: (accountId: string, owner: string, name: string, id: number) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'run', id] as const,
actionJobs: (accountId: string, owner: string, name: string, run: number) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'run', run, 'jobs'] as const,
actionJobLogs: (accountId: string, owner: string, name: string, jobId: number) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'job', jobId, 'logs'] as const,
// --- account-level: orgs, packages, credentials -------------------------
orgs: (accountId: string) => [...queryKeys.account(accountId), 'orgs'] as const,
orgRepos: (accountId: string, org: string, params: Record<string, unknown>) =>
[...queryKeys.account(accountId), 'org', org, 'repos', params] as const,
packages: (accountId: string, owner: string, params: Record<string, unknown>) =>
[...queryKeys.account(accountId), 'packages', owner, params] as const,
userKeys: (accountId: string) => [...queryKeys.account(accountId), 'keys'] as const,
userGpgKeys: (accountId: string) => [...queryKeys.account(accountId), 'gpg-keys'] as const,
userTokens: (accountId: string, username: string) =>
[...queryKeys.account(accountId), 'tokens', username] as const,
contents: (accountId: string, owner: string, name: string, path: string, ref?: string) => contents: (accountId: string, owner: string, name: string, path: string, ref?: string) =>
[...queryKeys.repo(accountId, owner, name), 'contents', { path, ref }] as const, [...queryKeys.repo(accountId, owner, name), 'contents', { path, ref }] as const,
+176
View File
@@ -382,6 +382,182 @@ export interface Subscription {
ignored?: boolean; ignored?: boolean;
} }
// ---------------------------------------------------------------------------
// Gitea Actions
// ---------------------------------------------------------------------------
export interface ActionWorkflow {
id?: number;
name?: string;
path?: string;
state?: string;
html_url?: string;
badge_url?: string;
}
export interface ActionRunStep {
name?: string;
status?: string;
conclusion?: string;
number?: number;
started_at?: string;
stopped_at?: string;
}
export interface ActionRun {
id?: number;
title?: string;
status?: string;
conclusion?: string;
workflow_id?: string;
index?: number;
event?: string;
display_title?: string;
head_branch?: string;
head_sha?: string;
run_number?: number;
run_attempt?: number;
url?: string;
html_url?: string;
started_at?: string;
stopped_at?: string;
created_at?: string;
updated_at?: string;
actor?: User;
trigger_user?: User;
repository?: Repository;
}
export interface ActionRunJob {
id?: number;
name?: string;
run_id?: number;
status?: string;
conclusion?: string;
started_at?: string;
stopped_at?: string;
runner_id?: number;
labels?: string[];
steps?: ActionRunStep[];
html_url?: string;
}
// ---------------------------------------------------------------------------
// Repository settings
// ---------------------------------------------------------------------------
export interface BranchProtection {
branch_name?: string;
rule_name?: string;
enable_push?: boolean;
enable_push_whitelist?: boolean;
enable_merge_whitelist?: boolean;
enable_status_check?: boolean;
status_check_contexts?: string[];
required_approvals?: number;
enable_approvals_whitelist?: boolean;
require_signed_commits?: boolean;
block_on_rejected_reviews?: boolean;
block_on_outdated_branch?: boolean;
enable_force_push?: boolean;
priority?: number;
created_at?: string;
updated_at?: string;
}
export interface Webhook {
id?: number;
type?: string;
name?: string;
active?: boolean;
events?: string[];
config?: Record<string, string>;
branch_filter?: string;
created_at?: string;
updated_at?: string;
}
export interface DeployKey {
id?: number;
title?: string;
key?: string;
fingerprint?: string;
read_only?: boolean;
created_at?: string;
}
// ---------------------------------------------------------------------------
// Organizations & packages
// ---------------------------------------------------------------------------
export interface Organization {
id?: number;
name?: string;
username?: string;
full_name?: string;
avatar_url?: string;
description?: string;
location?: string;
website?: string;
visibility?: string;
}
export interface Package {
id?: number;
name?: string;
type?: string;
version?: string;
owner?: User;
creator?: User;
repository?: Repository;
html_url?: string;
created_at?: string;
}
// ---------------------------------------------------------------------------
// User credentials (read-only listings)
// ---------------------------------------------------------------------------
export interface PublicKey {
id?: number;
title?: string;
key?: string;
fingerprint?: string;
key_type?: string;
read_only?: boolean;
created_at?: string;
last_used_at?: string;
url?: string;
user?: User;
}
export interface GpgKeyEmail {
email?: string;
verified?: boolean;
}
export interface GpgKey {
id?: number;
key_id?: string;
primary_key_id?: string;
public_key?: string;
emails?: GpgKeyEmail[];
can_sign?: boolean;
can_certify?: boolean;
created_at?: string;
expires_at?: string;
verified?: boolean;
}
export interface AccessToken {
id?: number;
name?: string;
token_last_eight?: string;
scopes?: string[];
created_at?: string;
last_used_at?: string;
}
export interface Activity { export interface Activity {
id?: number; id?: number;
user_id?: number; user_id?: number;
+99
View File
@@ -0,0 +1,99 @@
/** Gitea Actions query hooks (workflows, runs, jobs, logs). */
import {
keepPreviousData,
useInfiniteQuery,
useQuery,
type InfiniteData,
} from '@tanstack/react-query';
import type { RawResponse } from '@/core/api/client';
import {
fetchActionJobLogs,
fetchActionRun,
listActionRunJobs,
listActionRuns,
listWorkflows,
type ListActionRunsParams,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { ActionRun, ActionRunJob, ActionWorkflow } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useWorkflows(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionWorkflow[]>({
queryKey: queryKeys.actionsWorkflows(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listWorkflows(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
export function useActionRuns(
owner: string,
name: string,
filters: Pick<ListActionRunsParams, 'status' | 'branch' | 'event'> = {},
limit = 20,
) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
const params = { ...filters, limit };
return useInfiniteQuery<
RawResponse<ActionRun[]>,
Error,
InfiniteData<RawResponse<ActionRun[]>>,
readonly unknown[],
number
>({
queryKey: queryKeys.actionsRuns(accountId, owner, name, params),
enabled: Boolean(client) && Boolean(accountId),
initialPageParam: 1,
queryFn: ({ pageParam, signal }) =>
listActionRuns(client!, owner, name, { ...params, page: pageParam }, { signal }),
getNextPageParam: (last, all) => (last.hasMore ? all.length + 1 : undefined),
placeholderData: keepPreviousData,
});
}
export function useActionRun(owner: string, name: string, id: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionRun>({
queryKey: queryKeys.actionRun(accountId, owner, name, id),
enabled: Boolean(client) && Boolean(accountId) && id > 0,
queryFn: ({ signal }) => fetchActionRun(client!, owner, name, id, { signal }),
staleTime: 30_000,
});
}
export function useActionRunJobs(owner: string, name: string, run: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionRunJob[]>({
queryKey: queryKeys.actionJobs(accountId, owner, name, run),
enabled: Boolean(client) && Boolean(accountId) && run > 0,
queryFn: ({ signal }) =>
listActionRunJobs(client!, owner, name, run, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useActionJobLogs(owner: string, name: string, jobId: number, enabled = true) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<string>({
queryKey: queryKeys.actionJobLogs(accountId, owner, name, jobId),
enabled: Boolean(client) && Boolean(accountId) && jobId > 0 && enabled,
queryFn: ({ signal }) => fetchActionJobLogs(client!, owner, name, jobId, { signal }),
staleTime: 60_000,
retry: false,
});
}
+91
View File
@@ -0,0 +1,91 @@
/** Account-level data: organizations, packages and credential listings. */
import { useInfiniteQuery, type InfiniteData } from '@tanstack/react-query';
import type { RawResponse } from '@/core/api/client';
import {
listOrgRepos,
listPackages,
listUserGpgKeys,
listUserKeys,
listUserOrgs,
listUserTokens,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { AccessToken, GpgKey, Organization, Package, PublicKey, Repository } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
function useAccountList<T>(
key: readonly unknown[],
load: (
page: number,
signal: AbortSignal,
) => Promise<RawResponse<T[]>>,
) {
return useInfiniteQuery<
RawResponse<T[]>,
Error,
InfiniteData<RawResponse<T[]>>,
readonly unknown[],
number
>({
queryKey: key,
initialPageParam: 1,
queryFn: ({ pageParam, signal }) => load(pageParam, signal),
getNextPageParam: (last, all) => (last.hasMore ? all.length + 1 : undefined),
});
}
export function useUserOrgs(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Organization>(
[...queryKeys.orgs(accountId), { limit }],
(page, signal) => listUserOrgs(client!, { page, limit }, { signal }),
);
}
export function useOrgRepos(org: string, limit = 20) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Repository>(
queryKeys.orgRepos(accountId, org, { limit }),
(page, signal) => listOrgRepos(client!, org, { page, limit }, { signal }),
);
}
export function usePackages(owner: string, limit = 20) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Package>(
queryKeys.packages(accountId, owner, { limit }),
(page, signal) => listPackages(client!, owner, { page, limit }, { signal }),
);
}
export function useUserKeys(limit = 50) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<PublicKey>(
[...queryKeys.userKeys(accountId), { limit }],
(page, signal) => listUserKeys(client!, { page, limit }, { signal }),
);
}
export function useUserGpgKeys(limit = 50) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<GpgKey>(
[...queryKeys.userGpgKeys(accountId), { limit }],
(page, signal) => listUserGpgKeys(client!, { page, limit }, { signal }),
);
}
export function useUserTokens(username: string, limit = 50) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<AccessToken>(
queryKeys.userTokens(accountId, username),
(page, signal) => listUserTokens(client!, username, { page, limit }, { signal }),
);
}
@@ -0,0 +1,136 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import type { ReactNode } from 'react';
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 { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format';
import { useSession } from '@/features/accounts/use-session';
import { useUserGpgKeys, useUserKeys, useUserTokens } from '@/features/profile/queries';
import { fontFamily, spacing } from '@/theme/tokens';
/** Read-only listings of the account's SSH keys, GPG keys and access tokens. */
export function CredentialsScreen() {
const { t } = useTranslation();
const { account, client } = useSession();
const keys = useUserKeys();
const gpgKeys = useUserGpgKeys();
const tokens = useUserTokens(account?.login ?? '');
if (keys.isError || gpgKeys.isError || tokens.isError) {
const error = keys.error ?? gpgKeys.error ?? tokens.error;
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(error, t)}
retryLabel={t('common.retry')}
onRetry={() => {
void keys.refetch();
void gpgKeys.refetch();
void tokens.refetch();
}}
/>
);
}
if (!client || (keys.isPending && gpgKeys.isPending && tokens.isPending)) {
return <LoadingView />;
}
const keyItems = flattenPages(keys.data);
const gpgItems = flattenPages(gpgKeys.data);
const tokenItems = flattenPages(tokens.data);
return (
<Screen scroll padded>
<Section title={t('credentials.sshKeys')}>
{keyItems.length === 0 ? (
<EmptyState icon="lock" title={t('credentials.noSshKeys')} />
) : (
keyItems.map((key) => (
<Card key={key.id ?? key.title}>
<AppText variant="bodyMedium" numberOfLines={1}>
{key.title}
</AppText>
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1}>
{key.fingerprint ?? key.key}
</AppText>
{key.read_only ? <Badge tone="neutral">{t('credentials.readOnly')}</Badge> : null}
</Card>
))
)}
</Section>
<Section title={t('credentials.gpgKeys')}>
{gpgItems.length === 0 ? (
<EmptyState icon="verified" title={t('credentials.noGpgKeys')} />
) : (
gpgItems.map((key) => (
<Card key={key.id ?? key.key_id}>
<View style={styles.row}>
<AppText variant="monoSmall" numberOfLines={1} style={styles.keyId}>
{key.key_id}
</AppText>
{key.verified ? <Badge tone="success" icon="verified">{t('commits.verified')}</Badge> : null}
</View>
{key.emails && key.emails.length > 0 ? (
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
{key.emails.map((email) => email.email).filter(Boolean).join(', ')}
</AppText>
) : null}
</Card>
))
)}
</Section>
<Section title={t('credentials.tokens')}>
{tokenItems.length === 0 ? (
<EmptyState icon="lock" title={t('credentials.noTokens')} />
) : (
tokenItems.map((token) => (
<Card key={token.id ?? token.name}>
<AppText variant="bodyMedium" numberOfLines={1}>
{token.name}
</AppText>
<View style={styles.metaRow}>
<AppText variant="monoSmall" tone="tertiary">
••••{token.token_last_eight ?? ''}
</AppText>
{token.last_used_at ? (
<AppText variant="caption" tone="tertiary">
{formatRelativeTime(token.last_used_at, t)}
</AppText>
) : null}
</View>
</Card>
))
)}
</Section>
<AppText variant="caption" tone="tertiary">
{t('credentials.notice')}
</AppText>
</Screen>
);
}
const styles = StyleSheet.create({
section: { gap: spacing.sm },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
keyId: { flex: 1, fontFamily: fontFamily.mono },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
function Section({ title, children }: { title: string; children: ReactNode }) {
return (
<View style={styles.section}>
<AppText variant="subheading">{title}</AppText>
{children}
</View>
);
}
@@ -0,0 +1,41 @@
import { useRoute, type RouteProp } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
import { RepoListItem } from '@/components/git/repo-list-item';
import { QueryList } from '@/components/layout/query-list';
import { EmptyState } from '@/components/ui/state-views';
import type { Repository } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useOrgRepos } from '@/features/profile/queries';
import type { SettingsStackParamList } from '@/navigation/types';
import { useRootNavigation } from '@/navigation/use-root-navigation';
/** Repositories belonging to one organization. */
export function OrgReposScreen() {
const { t } = useTranslation();
const route = useRoute<RouteProp<SettingsStackParamList, 'OrgRepos'>>();
const navigation = useRootNavigation();
const { org } = route.params;
const query = useOrgRepos(org);
const repos: Repository[] = flattenPages(query.data);
return (
<QueryList<Repository>
query={query}
items={repos}
keyExtractor={(repo) => String(repo.id)}
renderItem={(repo) => (
<RepoListItem
repo={repo}
onPress={() =>
navigation.navigate('Repository', {
screen: 'RepoOverview',
params: { owner: repo.owner?.login ?? org, name: repo.name },
})
}
/>
)}
empty={<EmptyState icon="repo" title={t('repositories.empty')} />}
/>
);
}
@@ -0,0 +1,65 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { useNavigation } from '@react-navigation/native';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { EmptyState } from '@/components/ui/state-views';
import type { Organization } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useUserOrgs } from '@/features/profile/queries';
import { spacing } from '@/theme/tokens';
import type { SettingsStackParamList } from '@/navigation/types';
/** Organizations the signed-in user belongs to. */
export function OrganizationsScreen() {
const { t } = useTranslation();
const navigation = useNavigation<NativeStackNavigationProp<SettingsStackParamList>>();
const query = useUserOrgs();
const orgs: Organization[] = flattenPages(query.data);
return (
<QueryList<Organization>
query={query}
items={orgs}
keyExtractor={(org) => String(org.id ?? org.username)}
renderItem={(org) => {
const login = org.username ?? org.name ?? '';
return (
<View style={styles.row}>
<Avatar url={org.avatar_url} name={login} size={40} />
<View style={styles.body}>
<AppText
variant="bodyMedium"
numberOfLines={1}
onPress={() => navigation.navigate('OrgRepos', { org: login })}
accessibilityRole="button"
>
{login}
</AppText>
{org.description ? (
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
{org.description}
</AppText>
) : null}
</View>
</View>
);
}}
empty={<EmptyState icon="people" title={t('organizations.empty')} />}
/>
);
}
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.md,
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
body: { flex: 1, gap: 2 },
});
@@ -0,0 +1,58 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { EmptyState } from '@/components/ui/state-views';
import type { Package } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format';
import { usePackages } from '@/features/profile/queries';
import { useSession } from '@/features/accounts/use-session';
import { spacing } from '@/theme/tokens';
/** Packages published by the authenticated user. */
export function PackagesScreen() {
const { t } = useTranslation();
const { account } = useSession();
const query = usePackages(account?.login ?? '');
const packages: Package[] = flattenPages(query.data);
return (
<QueryList<Package>
query={query}
items={packages}
keyExtractor={(pkg) => `${pkg.type ?? ''}-${pkg.name ?? ''}-${pkg.version ?? ''}`}
renderItem={(pkg) => (
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{pkg.name}
</AppText>
<View style={styles.metaRow}>
{pkg.type ? <Badge tone="neutral">{pkg.type}</Badge> : null}
{pkg.version ? (
<AppText variant="caption" tone="tertiary">
{pkg.version}
</AppText>
) : null}
{pkg.created_at ? (
<AppText variant="caption" tone="tertiary">
{formatRelativeTime(pkg.created_at, t)}
</AppText>
) : null}
</View>
</View>
</View>
)}
empty={<EmptyState icon="package" title={t('packages.empty')} />}
/>
);
}
const styles = StyleSheet.create({
row: { paddingHorizontal: spacing.lg, paddingVertical: spacing.md },
body: { gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
+46
View File
@@ -29,8 +29,12 @@ import {
unstarRepo, unstarRepo,
unwatchRepo, unwatchRepo,
watchRepo, watchRepo,
createRelease,
updateRelease,
deleteRelease,
type ForkRepoInput, type ForkRepoInput,
type ListMyReposParams, type ListMyReposParams,
type ReleaseInput,
type SearchReposParams, type SearchReposParams,
} from '@/core/api/endpoints'; } from '@/core/api/endpoints';
import type { RawResponse } from '@/core/api/client'; import type { RawResponse } from '@/core/api/client';
@@ -236,3 +240,45 @@ export function useRelease(owner: string, name: string, id: number) {
queryFn: ({ signal }) => fetchRelease(client!, owner, name, id, { signal }), queryFn: ({ signal }) => fetchRelease(client!, owner, name, id, { signal }),
}); });
} }
function invalidateReleases(
queryClient: ReturnType<typeof useQueryClient>,
accountId: string,
owner: string,
name: string,
) {
void queryClient.invalidateQueries({ queryKey: queryKeys.repo(accountId, owner, name) });
}
export function useCreateRelease(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: ReleaseInput) => createRelease(client!, owner, name, input),
onSuccess: () => invalidateReleases(queryClient, accountId, owner, name),
});
}
export function useUpdateRelease(owner: string, name: string, id: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: Partial<ReleaseInput>) => updateRelease(client!, owner, name, id, input),
onSuccess: () => invalidateReleases(queryClient, accountId, owner, name),
});
}
export function useDeleteRelease(owner: string, name: string, id: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: () => deleteRelease(client!, owner, name, id),
onSuccess: () => invalidateReleases(queryClient, accountId, owner, name),
});
}
@@ -0,0 +1,122 @@
import { useState } from 'react';
import { Alert, StyleSheet, Switch, 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 { apiErrorMessage } from '@/core/api/error-text';
import { useCreateRepo } from '@/features/repositories/settings-queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoriesStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoriesStackParamList, 'CreateRepo'>;
/** Create a repository under the authenticated user. */
export function CreateRepoScreen({ navigation }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const create = useCreateRepo();
const [name, setName] = useState('');
const [description, setDescription] = useState('');
const [isPrivate, setIsPrivate] = useState(false);
const [autoInit, setAutoInit] = useState(true);
const [submitted, setSubmitted] = useState(false);
const nameError = submitted && name.trim().length === 0 ? t('createRepo.nameRequired') : undefined;
const submit = () => {
setSubmitted(true);
if (name.trim().length === 0) return;
create.mutate(
{
name: name.trim(),
description: description.trim() || undefined,
private: isPrivate,
auto_init: autoInit,
},
{
onSuccess: () => navigation.goBack(),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
return (
<Screen scroll padded>
<Field
label={t('createRepo.name')}
value={name}
onChangeText={setName}
placeholder={t('createRepo.namePlaceholder')}
showError={Boolean(nameError)}
error={nameError}
autoCapitalize="none"
autoCorrect={false}
testID="repo-name"
/>
<Field
label={t('repo.description')}
value={description}
onChangeText={setDescription}
autoCapitalize="sentences"
/>
<Card>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('repositories.private')}
</AppText>
<Switch
value={isPrivate}
onValueChange={setIsPrivate}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
<View style={styles.switchRow}>
<View style={styles.switchLabel}>
<AppText variant="bodyMedium">{t('createRepo.autoInit')}</AppText>
<AppText variant="caption" tone="tertiary">
{t('createRepo.autoInitHelp')}
</AppText>
</View>
<Switch
value={autoInit}
onValueChange={setAutoInit}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
</Card>
{create.isError ? (
<AppText variant="caption" tone="error">
{apiErrorMessage(create.error, t)}
</AppText>
) : null}
<Button
label={t('createRepo.submit')}
onPress={submit}
loading={create.isPending}
disabled={name.trim().length === 0}
fullWidth
testID="repo-create-submit"
/>
</Screen>
);
}
const styles = StyleSheet.create({
switchRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: spacing.md,
marginTop: spacing.sm,
},
switchLabel: { flex: 1 },
});
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { RepoListItem } from '@/components/git/repo-list-item'; import { RepoListItem } from '@/components/git/repo-list-item';
import { QueryList } from '@/components/layout/query-list'; import { QueryList } from '@/components/layout/query-list';
import { Button } from '@/components/ui/button';
import { SearchBar } from '@/components/ui/search-bar'; import { SearchBar } from '@/components/ui/search-bar';
import { EmptyState } from '@/components/ui/state-views'; import { EmptyState } from '@/components/ui/state-views';
import { SegmentedControl } from '@/components/ui/segmented'; import { SegmentedControl } from '@/components/ui/segmented';
@@ -93,6 +94,15 @@ export function RepositoryListScreen({ navigation }: Props) {
/> />
) : null} ) : null}
</View> </View>
<View style={styles.newRepo}>
<Button
label={t('createRepo.title')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('CreateRepo')}
/>
</View>
</View> </View>
); );
@@ -130,4 +140,5 @@ export function RepositoryListScreen({ navigation }: Props) {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
filters: { gap: spacing.sm, paddingHorizontal: spacing.lg, paddingBottom: spacing.sm }, filters: { gap: spacing.sm, paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
newRepo: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
}); });
@@ -0,0 +1,183 @@
/** Repository settings: edit/delete, collaborators, webhooks, branch protections. */
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import {
addCollaborator,
createBranchProtection,
createRepo,
createWebhook,
deleteBranchProtection,
deleteRepo,
deleteWebhook,
listBranchProtections,
listCollaborators,
listWebhooks,
removeCollaborator,
updateRepo,
type CollaboratorPermission,
type CreateBranchProtectionInput,
type CreateRepoInput,
type CreateWebhookInput,
type UpdateRepoInput,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { BranchProtection, User, Webhook } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useCollaboratorsList(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<User[]>({
queryKey: queryKeys.repoCollaborators(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listCollaborators(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
export function useAddCollaborator(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ username, permission }: { username: string; permission: CollaboratorPermission }) =>
addCollaborator(client!, owner, name, username, permission),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoCollaborators(accountId, owner, name) }),
});
}
export function useRemoveCollaborator(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (username: string) => removeCollaborator(client!, owner, name, username),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoCollaborators(accountId, owner, name) }),
});
}
export function useWebhooks(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Webhook[]>({
queryKey: queryKeys.repoWebhooks(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listWebhooks(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateWebhook(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: CreateWebhookInput) => createWebhook(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoWebhooks(accountId, owner, name) }),
});
}
export function useDeleteWebhook(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteWebhook(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoWebhooks(accountId, owner, name) }),
});
}
export function useBranchProtections(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<BranchProtection[]>({
queryKey: queryKeys.repoProtections(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listBranchProtections(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateBranchProtection(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: CreateBranchProtectionInput) =>
createBranchProtection(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoProtections(accountId, owner, name),
}),
});
}
export function useDeleteBranchProtection(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (rule: string) => deleteBranchProtection(client!, owner, name, rule),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoProtections(accountId, owner, name),
}),
});
}
export function useUpdateRepo(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: UpdateRepoInput) => updateRepo(client!, owner, name, input),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.repoDetail(accountId, owner, name) });
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useDeleteRepo(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: () => deleteRepo(client!, owner, name),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useCreateRepo() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: CreateRepoInput) => createRepo(client!, input),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
@@ -0,0 +1,152 @@
import { useState } from 'react';
import { Linking, ScrollView, 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, type BadgeTone } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
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 {
useActionJobLogs,
useActionRun,
useActionRunJobs,
} from '@/features/actions/queries';
import { useTheme } from '@/theme/theme-provider';
import { fontFamily, fontSize, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'ActionRunDetail'>;
const STATUS_TONE: Record<string, BadgeTone> = {
success: 'success',
failure: 'error',
cancelled: 'warning',
skipped: 'neutral',
running: 'info',
waiting: 'warning',
};
/** A run's jobs; each job can expand to show its log (plain text). */
export function ActionRunDetailScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name, id } = route.params;
const runQuery = useActionRun(owner, name, id);
const jobsQuery = useActionRunJobs(owner, name, id);
if (runQuery.isPending) return <LoadingView />;
if (runQuery.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(runQuery.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void runQuery.refetch()}
/>
);
}
const run = runQuery.data;
const jobs: ActionRunJob[] = jobsQuery.data ?? [];
const state = run?.conclusion || run?.status || '';
return (
<Screen scroll padded>
<View style={styles.titleBlock}>
<AppText variant="heading">{run?.display_title || run?.title || `#${id}`}</AppText>
<View style={styles.metaRow}>
<Badge tone={STATUS_TONE[state] ?? 'neutral'}>
{t(`actions.state_${state}`, state)}
</Badge>
{run?.head_branch ? <Badge tone="neutral" icon="branch">{run.head_branch}</Badge> : null}
{run?.created_at ? (
<AppText variant="caption" tone="tertiary">
{formatDateTime(run.created_at)}
</AppText>
) : null}
</View>
</View>
{run?.html_url ? (
<Button
label={t('actions.openRun')}
variant="secondary"
iconLeft="externalLink"
onPress={() => void Linking.openURL(run.html_url as string).catch(() => undefined)}
/>
) : null}
<AppText variant="subheading">{t('actions.jobs')}</AppText>
{jobsQuery.isPending ? (
<LoadingView label={t('actions.loadingJobs')} />
) : jobs.length === 0 ? (
<AppText variant="secondary" tone="tertiary">
{t('actions.noJobs')}
</AppText>
) : (
jobs.map((job) => <JobRow key={job.id} owner={owner} name={name} job={job} />)
)}
</Screen>
);
}
function JobRow({ owner, name, job }: { owner: string; name: string; job: ActionRunJob }) {
const { t } = useTranslation();
const { colors } = useTheme();
const [expanded, setExpanded] = useState(false);
const logsQuery = useActionJobLogs(owner, name, job.id ?? 0, expanded);
const state = job.conclusion || job.status || '';
return (
<Card padded={false}>
<ListItem
title={job.name ?? t('actions.unnamedJob')}
subtitle={state ? t(`actions.state_${state}`, state) : undefined}
leadingIcon="code"
rightText={expanded ? t('actions.hideLogs') : t('actions.showLogs')}
onPress={() => setExpanded((value) => !value)}
divider={expanded}
/>
{expanded ? (
<View style={styles.logs}>
{logsQuery.isPending ? (
<AppText variant="caption" tone="tertiary">
{t('actions.loadingLogs')}
</AppText>
) : logsQuery.isError ? (
<AppText variant="caption" tone="tertiary">
{t('actions.logsUnavailable')}
</AppText>
) : (
<ScrollView horizontal showsHorizontalScrollIndicator>
<AppText variant="monoSmall" selectable style={{ color: colors.text }}>
{logsQuery.data && logsQuery.data.length > 0
? logsQuery.data
: t('actions.emptyLogs')}
</AppText>
</ScrollView>
)}
</View>
) : null}
</Card>
);
}
const styles = StyleSheet.create({
titleBlock: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
logs: {
paddingHorizontal: spacing.md,
paddingBottom: spacing.md,
maxHeight: 320,
},
logText: { fontFamily: fontFamily.mono, fontSize: fontSize.xs },
});
@@ -0,0 +1,96 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
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 { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { ActionRun } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format';
import { useActionRuns } from '@/features/actions/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Actions'>;
type StatusKey = 'all' | 'success' | 'failure' | 'running';
const STATUS_TONE: Record<string, BadgeTone> = {
success: 'success',
failure: 'error',
cancelled: 'warning',
skipped: 'neutral',
running: 'info',
waiting: 'warning',
};
/** Gitea Actions runs for a repository, filterable by status. */
export function ActionsScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const [status, setStatus] = useState<StatusKey>('all');
const query = useActionRuns(owner, name, status === 'all' ? {} : { status });
const runs: ActionRun[] = flattenPages(query.data);
return (
<QueryList<ActionRun>
query={query}
items={runs}
keyExtractor={(run) => String(run.id)}
header={
<View style={styles.filters}>
<SegmentedControl<StatusKey>
value={status}
onChange={setStatus}
accessibilityLabel={t('actions.title')}
options={[
{ value: 'all', label: t('actions.filterAll') },
{ value: 'success', label: t('actions.filterSuccess') },
{ value: 'failure', label: t('actions.filterFailure') },
{ value: 'running', label: t('actions.filterRunning') },
]}
/>
</View>
}
renderItem={(run) => {
const state = run.conclusion || run.status || '';
return (
<View style={styles.row}>
<AppText
variant="bodyMedium"
numberOfLines={2}
onPress={() => run.id && navigation.navigate('ActionRunDetail', { owner, name, id: run.id })}
accessibilityRole="button"
>
{run.display_title || run.title || `#${run.run_number ?? run.id}`}
</AppText>
<View style={styles.metaRow}>
<Badge tone={STATUS_TONE[state] ?? 'neutral'}>{t(`actions.state_${state}`, state)}</Badge>
{run.head_branch ? <Badge tone="neutral" icon="branch">{run.head_branch}</Badge> : null}
{run.event ? (
<AppText variant="caption" tone="tertiary">
{run.event}
</AppText>
) : null}
<AppText variant="caption" tone="tertiary">
{formatRelativeTime(run.created_at ?? run.started_at, t)}
</AppText>
</View>
</View>
);
}}
empty={<EmptyState icon="autoRenew" title={t('actions.empty')} />}
/>
);
}
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingVertical: 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,140 @@
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 { Avatar } from '@/components/ui/avatar';
import { Badge } from '@/components/ui/badge';
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 { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { CollaboratorPermission } from '@/core/api/endpoints';
import {
useAddCollaborator,
useCollaboratorsList,
useRemoveCollaborator,
} 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, 'Collaborators'>;
/** Repository collaborators: list, add by username, remove. */
export function CollaboratorsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useCollaboratorsList(owner, name);
const add = useAddCollaborator(owner, name);
const remove = useRemoveCollaborator(owner, name);
const [username, setUsername] = useState('');
const [permission, setPermission] = useState<CollaboratorPermission>('write');
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 collaborators = query.data ?? [];
const submit = () => {
const login = username.trim();
if (login.length === 0) return;
add.mutate(
{ username: login, permission },
{
onSuccess: () => setUsername(''),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmRemove = (login: string) => {
Alert.alert(t('repoSettings.removeCollaboratorTitle'), t('repoSettings.removeCollaboratorBody', { name: login }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.remove'),
style: 'destructive',
onPress: () =>
remove.mutate(login, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('repoSettings.addCollaborator')}
value={username}
onChangeText={setUsername}
placeholder={t('repoSettings.usernamePlaceholder')}
autoCapitalize="none"
autoCorrect={false}
/>
<View style={styles.permission}>
<SegmentedControl<CollaboratorPermission>
value={permission}
onChange={setPermission}
accessibilityLabel={t('repoSettings.permission')}
options={[
{ value: 'read', label: t('repoSettings.read') },
{ value: 'write', label: t('repoSettings.write') },
{ value: 'admin', label: t('repoSettings.admin') },
]}
/>
</View>
<Button
label={t('common.add')}
onPress={submit}
loading={add.isPending}
disabled={username.trim().length === 0}
fullWidth
/>
</Card>
{collaborators.length === 0 ? (
<EmptyState icon="people" title={t('repoSettings.noCollaborators')} />
) : (
collaborators.map((user) => (
<Card key={user.id ?? user.login}>
<View style={styles.row}>
<Avatar url={user.avatar_url} name={user.login} size={32} />
<AppText variant="bodyMedium" style={styles.login} numberOfLines={1}>
{user.login}
</AppText>
{user.is_admin ? <Badge tone="warning">{t('repoSettings.admin')}</Badge> : null}
<IconButton
name="trash"
onPress={() => confirmRemove(user.login)}
accessibilityLabel={t('common.remove')}
/>
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
permission: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
login: { flex: 1, fontWeight: '600' },
});
@@ -0,0 +1,188 @@
import { useState } from 'react';
import { Alert, StyleSheet, Switch, 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 { 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 { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import {
useBranchProtections,
useCreateBranchProtection,
useDeleteBranchProtection,
} from '@/features/repositories/settings-queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Protections'>;
/** Branch protection rules: list, create a basic rule, delete. */
export function ProtectionsScreen({ route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { owner, name } = route.params;
const query = useBranchProtections(owner, name);
const create = useCreateBranchProtection(owner, name);
const remove = useDeleteBranchProtection(owner, name);
const [branchName, setBranchName] = useState('');
const [requiredApprovals, setRequiredApprovals] = useState('1');
const [signedCommits, setSignedCommits] = useState(false);
const [statusCheck, setStatusCheck] = useState(false);
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 rules = query.data ?? [];
const submit = () => {
const pattern = branchName.trim();
if (pattern.length === 0) return;
create.mutate(
{
branch_name: pattern,
required_approvals: Number(requiredApprovals) || 0,
enable_push: false,
require_signed_commits: signedCommits,
enable_status_check: statusCheck,
},
{
onSuccess: () => setBranchName(''),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmDelete = (rule: string) => {
Alert.alert(t('repoSettings.deleteRuleTitle'), t('repoSettings.deleteRuleBody', { name: rule }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
remove.mutate(rule, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('repoSettings.branchName')}
value={branchName}
onChangeText={setBranchName}
placeholder="main"
autoCapitalize="none"
autoCorrect={false}
mono
/>
<Field
label={t('repoSettings.requiredApprovals')}
value={requiredApprovals}
onChangeText={setRequiredApprovals}
keyboardType="number-pad"
/>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('repoSettings.requireSignedCommits')}
</AppText>
<Switch
value={signedCommits}
onValueChange={setSignedCommits}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('repoSettings.requireStatusChecks')}
</AppText>
<Switch
value={statusCheck}
onValueChange={setStatusCheck}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
<Button
label={t('common.add')}
onPress={submit}
loading={create.isPending}
disabled={branchName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{rules.length === 0 ? (
<EmptyState icon="shield" title={t('repoSettings.noProtections')} />
) : (
rules.map((rule) => {
const label = rule.rule_name || rule.branch_name || '';
return (
<Card key={rule.rule_name ?? rule.branch_name}>
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{label}
</AppText>
<View style={styles.metaRow}>
{rule.enable_push === false ? (
<Badge tone="warning">{t('repoSettings.pushRestricted')}</Badge>
) : null}
{rule.required_approvals ? (
<Badge tone="info">
{t('repoSettings.approvalsBadge', { count: rule.required_approvals })}
</Badge>
) : null}
{rule.require_signed_commits ? (
<Badge tone="success">{t('repoSettings.signedBadge')}</Badge>
) : null}
</View>
</View>
<IconButton
name="trash"
onPress={() => confirmDelete(label)}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
);
})
)}
</Screen>
);
}
const styles = StyleSheet.create({
switchRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: spacing.md,
marginTop: spacing.md,
},
switchLabel: { flex: 1 },
spaced: { marginTop: spacing.lg },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
body: { flex: 1, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
@@ -0,0 +1,177 @@
import { useState } from 'react';
import { Alert, StyleSheet, Switch, 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 { TextArea } from '@/components/ui/text-area';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Release } from '@/core/api/types';
import { useCreateRelease, useRelease, useUpdateRelease } from '@/features/repositories/queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'ReleaseCompose'>;
/** Create (no id) or edit (id) a release. */
export function ReleaseComposeScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name, id } = route.params;
const editing = typeof id === 'number' && id > 0;
const releaseQuery = useRelease(owner, name, editing ? (id as number) : 0);
if (editing && releaseQuery.isPending) return <LoadingView />;
if (editing && releaseQuery.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(releaseQuery.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void releaseQuery.refetch()}
/>
);
}
return (
<ReleaseForm
key={editing ? `edit-${id}` : 'new'}
owner={owner}
name={name}
release={editing ? releaseQuery.data : undefined}
editing={editing}
releaseId={editing ? (id as number) : 0}
onDone={() => navigation.goBack()}
/>
);
}
interface FormProps {
owner: string;
name: string;
release?: Release;
editing: boolean;
releaseId: number;
onDone: () => void;
}
function ReleaseForm({ owner, name, release, editing, releaseId, onDone }: FormProps) {
const { t } = useTranslation();
const { colors } = useTheme();
const createRelease = useCreateRelease(owner, name);
const updateRelease = useUpdateRelease(owner, name, releaseId);
const mutation = editing ? updateRelease : createRelease;
const [tag, setTag] = useState(release?.tag_name ?? '');
const [title, setTitle] = useState(release?.name ?? '');
const [body, setBody] = useState(release?.body ?? '');
const [prerelease, setPrerelease] = useState(release?.prerelease ?? false);
const [draft, setDraft] = useState(release?.draft ?? false);
const [submitted, setSubmitted] = useState(false);
const tagError = submitted && !editing && tag.trim().length === 0 ? t('releases.tagRequired') : undefined;
const submit = () => {
setSubmitted(true);
if (!editing && tag.trim().length === 0) return;
mutation.mutate(
{
tag_name: tag.trim(),
name: title.trim() || undefined,
body: body.trim() || undefined,
prerelease,
draft,
},
{
onSuccess: onDone,
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
return (
<Screen scroll padded>
<Field
label={t('releases.tag')}
value={tag}
onChangeText={setTag}
placeholder="v1.0.0"
showError={Boolean(tagError)}
error={tagError}
autoCapitalize="none"
autoCorrect={false}
mono
editable={!editing}
testID="release-tag"
/>
<Field
label={t('releases.name')}
value={title}
onChangeText={setTitle}
autoCapitalize="sentences"
/>
<TextArea
label={t('releases.notes')}
value={body}
onChangeText={setBody}
autoCapitalize="sentences"
autoCorrect
minHeight={140}
/>
<Card>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('releases.prerelease')}
</AppText>
<Switch
value={prerelease}
onValueChange={setPrerelease}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('releases.draft')}
</AppText>
<Switch
value={draft}
onValueChange={setDraft}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
</Card>
{mutation.isError ? (
<AppText variant="caption" tone="error">
{apiErrorMessage(mutation.error, t)}
</AppText>
) : null}
<Button
label={editing ? t('common.save') : t('releases.create')}
onPress={submit}
loading={mutation.isPending}
disabled={!editing && tag.trim().length === 0}
fullWidth
testID="release-submit"
/>
</Screen>
);
}
const styles = StyleSheet.create({
switchRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: spacing.md,
marginTop: spacing.sm,
},
switchLabel: { flex: 1 },
});
@@ -1,4 +1,4 @@
import { Linking, Pressable, StyleSheet, View } from 'react-native'; import { Alert, Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Markdown } from '@/components/git/markdown'; import { Markdown } from '@/components/git/markdown';
@@ -12,7 +12,7 @@ import { Icon } from '@/components/ui/icon';
import { ErrorState, LoadingView } from '@/components/ui/state-views'; import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text'; import { apiErrorMessage } from '@/core/api/error-text';
import { useSession } from '@/features/accounts/use-session'; import { useSession } from '@/features/accounts/use-session';
import { useRelease } from '@/features/repositories/queries'; import { useDeleteRelease, useRelease } from '@/features/repositories/queries';
import { formatBytes, formatDateTime } from '@/core/utils/format'; import { formatBytes, formatDateTime } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider'; import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens'; import { spacing } from '@/theme/tokens';
@@ -22,13 +22,14 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'ReleaseDetail'>; type Props = ScreenProps<RepositoryStackParamList, 'ReleaseDetail'>;
/** One release: metadata, notes and downloadable assets. */ /** One release: metadata, notes and downloadable assets. */
export function ReleaseDetailScreen({ route }: Props) { export function ReleaseDetailScreen({ navigation, route }: Props) {
const { t } = useTranslation(); const { t } = useTranslation();
const { colors } = useTheme(); const { colors } = useTheme();
const { instance } = useSession(); const { instance } = useSession();
const { owner, name, id } = route.params; const { owner, name, id } = route.params;
const query = useRelease(owner, name, id); const query = useRelease(owner, name, id);
const deleteRelease = useDeleteRelease(owner, name, id);
const release = query.data; const release = query.data;
if (query.isPending) return <LoadingView />; if (query.isPending) return <LoadingView />;
@@ -115,6 +116,35 @@ export function ReleaseDetailScreen({ route }: Props) {
onPress={() => void Linking.openURL(release.html_url as string).catch(() => undefined)} onPress={() => void Linking.openURL(release.html_url as string).catch(() => undefined)}
/> />
) : null} ) : null}
<View style={styles.actions}>
<Button
label={t('common.edit')}
variant="secondary"
iconLeft="edit"
onPress={() => navigation.navigate('ReleaseCompose', { owner, name, id })}
/>
<Button
label={t('common.delete')}
variant="danger"
iconLeft="trash"
loading={deleteRelease.isPending}
onPress={() =>
Alert.alert(t('releases.deleteTitle'), t('releases.deleteBody', { tag: release.tag_name ?? '' }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteRelease.mutate(undefined, {
onSuccess: () => navigation.goBack(),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
])
}
/>
</View>
</Screen> </Screen>
); );
} }
@@ -133,4 +163,5 @@ const styles = StyleSheet.create({
}, },
divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: 'rgba(128,128,128,0.25)' }, divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: 'rgba(128,128,128,0.25)' },
assetBody: { flex: 1, gap: 2 }, assetBody: { flex: 1, gap: 2 },
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
}); });
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list'; import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text'; import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { EmptyState } from '@/components/ui/state-views'; import { EmptyState } from '@/components/ui/state-views';
import type { Release } from '@/core/api/types'; import type { Release } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite'; import { flattenPages } from '@/core/utils/infinite';
@@ -28,6 +29,17 @@ export function ReleasesScreen({ navigation, route }: Props) {
query={query} query={query}
items={releases} items={releases}
keyExtractor={(release) => String(release.id ?? release.tag_name)} keyExtractor={(release) => String(release.id ?? release.tag_name)}
header={
<View style={styles.header}>
<Button
label={t('releases.create')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('ReleaseCompose', { owner, name })}
/>
</View>
}
renderItem={(release) => ( renderItem={(release) => (
<View style={styles.row}> <View style={styles.row}>
<AppText <AppText
@@ -57,6 +69,7 @@ export function ReleasesScreen({ navigation, route }: Props) {
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
header: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: { row: {
paddingHorizontal: spacing.lg, paddingHorizontal: spacing.lg,
paddingVertical: spacing.md, paddingVertical: spacing.md,
@@ -234,6 +234,13 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
onPress={() => void Linking.openURL(`${repoUrl}/wiki`).catch(() => undefined)} onPress={() => void Linking.openURL(`${repoUrl}/wiki`).catch(() => undefined)}
/> />
) : null} ) : null}
{repo.has_actions !== false ? (
<ListItem
leadingIcon="autoRenew"
title={t('actions.title')}
onPress={() => navigation.navigate('Actions', { owner, name })}
/>
) : null}
{repo.has_issues !== false ? ( {repo.has_issues !== false ? (
<ListItem <ListItem
leadingIcon="issue" leadingIcon="issue"
@@ -254,6 +261,23 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
</Card> </Card>
</View> </View>
{/* Manage */}
{repo.permissions?.push || repo.permissions?.admin || repo.permissions?.pull ? (
<View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}>
{t('repo.manage')}
</AppText>
<Card padded={false} variant="flat" style={styles.card}>
<ListItem
leadingIcon="gear"
title={t('repoSettings.title')}
onPress={() => navigation.navigate('RepoSettings', { owner, name })}
divider={false}
/>
</Card>
</View>
) : null}
{/* Statistics */} {/* Statistics */}
<View style={styles.section}> <View style={styles.section}>
<AppText variant="subheading" style={styles.sectionTitle}> <AppText variant="subheading" style={styles.sectionTitle}>
@@ -0,0 +1,203 @@
import { useState } from 'react';
import { Alert, StyleSheet, Switch, 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 { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository } from '@/features/repositories/queries';
import {
useDeleteRepo,
useUpdateRepo,
} from '@/features/repositories/settings-queries';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoSettings'>;
type FeatureKey =
| 'has_issues'
| 'has_pull_requests'
| 'has_wiki'
| 'has_releases'
| 'has_projects'
| 'has_packages'
| 'has_actions';
/** Repository settings: metadata, feature toggles, danger zone and sub-sections. */
export function RepoSettingsScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { owner, name } = route.params;
const repoQuery = useRepository(owner, name);
const repo = repoQuery.data;
const updateRepo = useUpdateRepo(owner, name);
const deleteRepo = useDeleteRepo(owner, name);
const [description, setDescription] = useState<string | null>(null);
const [website, setWebsite] = useState<string | null>(null);
const [isPrivate, setIsPrivate] = useState<boolean | null>(null);
const [features, setFeatures] = useState<Partial<Record<FeatureKey, boolean>>>({});
if (repoQuery.isPending) return <LoadingView />;
if (repoQuery.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(repoQuery.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void repoQuery.refetch()}
/>
);
}
if (!repo) return null;
const descriptionValue = description ?? repo.description ?? '';
const websiteValue = website ?? repo.website ?? '';
const privateValue = isPrivate ?? repo.private ?? false;
const featureValue = (key: FeatureKey) => features[key] ?? repo[key] ?? true;
const save = () => {
updateRepo.mutate(
{
description: descriptionValue,
website: websiteValue,
private: privateValue,
has_issues: featureValue('has_issues'),
has_pull_requests: featureValue('has_pull_requests'),
has_wiki: featureValue('has_wiki'),
has_releases: featureValue('has_releases'),
has_projects: featureValue('has_projects'),
has_packages: featureValue('has_packages'),
has_actions: featureValue('has_actions'),
},
{
onSuccess: () => {
Alert.alert(t('repoSettings.savedTitle'), t('repoSettings.savedBody'));
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmDelete = () => {
Alert.alert(t('repoSettings.deleteTitle'), t('repoSettings.deleteBody', { name }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteRepo.mutate(undefined, {
onSuccess: () => navigation.getParent()?.goBack(),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
const featureRows: { key: FeatureKey; label: string }[] = [
{ key: 'has_issues', label: t('repo.issuesTab') },
{ key: 'has_pull_requests', label: t('repo.pullsTab') },
{ key: 'has_wiki', label: t('repo.wiki') },
{ key: 'has_releases', label: t('releases.title') },
{ key: 'has_projects', label: t('repoSettings.projects') },
{ key: 'has_packages', label: t('packages.title') },
{ key: 'has_actions', label: t('actions.title') },
];
return (
<Screen scroll padded>
<Field label={t('repo.description')} value={descriptionValue} onChangeText={setDescription} />
<Field
label={t('repoSettings.website')}
value={websiteValue}
onChangeText={setWebsite}
autoCapitalize="none"
autoCorrect={false}
/>
<Card>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('repositories.private')}
</AppText>
<Switch
value={privateValue}
onValueChange={setIsPrivate}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
</Card>
<AppText variant="subheading">{t('repoSettings.features')}</AppText>
<Card>
{featureRows.map((row, index) => (
<View key={row.key} style={[styles.switchRow, index > 0 && styles.spaced]}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{row.label}
</AppText>
<Switch
value={featureValue(row.key)}
onValueChange={(value) => setFeatures((prev) => ({ ...prev, [row.key]: value }))}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
))}
</Card>
<Button
label={t('common.save')}
onPress={save}
loading={updateRepo.isPending}
fullWidth
testID="repo-save"
/>
<AppText variant="subheading">{t('repoSettings.sections')}</AppText>
<Card padded={false} variant="flat">
<ListItem
leadingIcon="people"
title={t('repoSettings.collaborators')}
onPress={() => navigation.navigate('Collaborators', { owner, name })}
/>
<ListItem
leadingIcon="globe"
title={t('repoSettings.webhooks')}
onPress={() => navigation.navigate('Webhooks', { owner, name })}
/>
<ListItem
leadingIcon="shield"
title={t('repoSettings.protections')}
onPress={() => navigation.navigate('Protections', { owner, name })}
divider={false}
/>
</Card>
<AppText variant="subheading" tone="error">
{t('repoSettings.dangerZone')}
</AppText>
<Button
label={t('repoSettings.deleteRepo')}
variant="danger"
iconLeft="trash"
loading={deleteRepo.isPending}
onPress={confirmDelete}
fullWidth
/>
</Screen>
);
}
const styles = StyleSheet.create({
switchRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: spacing.md },
switchLabel: { flex: 1 },
spaced: { marginTop: spacing.md },
});
@@ -0,0 +1,201 @@
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 { Badge } from '@/components/ui/badge';
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 { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useCreateWebhook, useDeleteWebhook, useWebhooks } 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, 'Webhooks'>;
type HookType = 'gitea' | 'slack' | 'discord';
type ContentType = 'json' | 'form';
/** Repository webhooks: list, add a common type, delete. */
export function WebhooksScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useWebhooks(owner, name);
const createWebhook = useCreateWebhook(owner, name);
const deleteWebhook = useDeleteWebhook(owner, name);
const [type, setType] = useState<HookType>('gitea');
const [url, setUrl] = useState('');
const [contentType, setContentType] = useState<ContentType>('json');
const [secret, setSecret] = useState('');
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 hooks = query.data ?? [];
const submit = () => {
const target = url.trim();
if (target.length === 0) return;
createWebhook.mutate(
{
type,
config: {
url: target,
content_type: contentType,
...(secret.trim() ? { secret: secret.trim() } : {}),
},
events: ['push', 'issues', 'pull_request', 'release'],
active: true,
},
{
onSuccess: () => {
setUrl('');
setSecret('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmDelete = (id: number) => {
Alert.alert(t('repoSettings.deleteWebhookTitle'), t('repoSettings.deleteWebhookBody'), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteWebhook.mutate(id, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<Card>
<AppText variant="label" tone="secondary">
{t('repoSettings.webhookType')}
</AppText>
<View style={styles.spaced}>
<SegmentedControl<HookType>
value={type}
onChange={setType}
accessibilityLabel={t('repoSettings.webhookType')}
options={[
{ value: 'gitea', label: 'Gitea' },
{ value: 'slack', label: 'Slack' },
{ value: 'discord', label: 'Discord' },
]}
/>
</View>
<View style={styles.field}>
<Field
label={t('repoSettings.webhookUrl')}
value={url}
onChangeText={setUrl}
placeholder="https://example.com/hook"
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
/>
</View>
{type === 'gitea' ? (
<>
<AppText variant="label" tone="secondary" style={styles.spaced}>
{t('repoSettings.contentType')}
</AppText>
<View style={styles.spaced}>
<SegmentedControl<ContentType>
value={contentType}
onChange={setContentType}
accessibilityLabel={t('repoSettings.contentType')}
options={[
{ value: 'json', label: 'JSON' },
{ value: 'form', label: 'form' },
]}
/>
</View>
<View style={styles.field}>
<Field
label={`${t('repoSettings.secret')} (${t('common.optional')})`}
value={secret}
onChangeText={setSecret}
autoCapitalize="none"
autoCorrect={false}
secureTextEntry
/>
</View>
</>
) : null}
<Button
label={t('common.add')}
onPress={submit}
loading={createWebhook.isPending}
disabled={url.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{hooks.length === 0 ? (
<EmptyState icon="globe" title={t('repoSettings.noWebhooks')} />
) : (
hooks.map((hook) => (
<Card key={hook.id}>
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{hook.config?.url ?? hook.name ?? `#${hook.id}`}
</AppText>
<View style={styles.metaRow}>
<Badge tone="neutral">{hook.type ?? 'gitea'}</Badge>
{hook.active === false ? (
<Badge tone="warning">{t('repoSettings.inactive')}</Badge>
) : null}
{hook.events?.length ? (
<AppText variant="caption" tone="tertiary">
{t('repoSettings.events', { count: hook.events.length })}
</AppText>
) : null}
</View>
</View>
{hook.id ? (
<IconButton
name="trash"
onPress={() => confirmDelete(hook.id as number)}
accessibilityLabel={t('common.delete')}
/>
) : null}
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
spaced: { marginTop: spacing.sm },
field: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
body: { flex: 1, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
@@ -2,6 +2,8 @@ import Constants from 'expo-constants';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Alert, Linking, StyleSheet, Switch, View } from 'react-native'; import { Alert, Linking, StyleSheet, Switch, View } from 'react-native';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useNavigation } from '@react-navigation/native';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { Screen } from '@/components/layout/screen'; import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text'; import { AppText } from '@/components/ui/app-text';
@@ -29,6 +31,7 @@ const GITEA_HOME_URL = 'https://gitea.com';
/** App settings: appearance, language, security, notifications, data, about. */ /** App settings: appearance, language, security, notifications, data, about. */
export function SettingsScreen(_props: Props) { export function SettingsScreen(_props: Props) {
const navigation = useRootNavigation(); const navigation = useRootNavigation();
const stackNavigation = useNavigation<NativeStackNavigationProp<SettingsStackParamList>>();
const { t } = useTranslation(); const { t } = useTranslation();
const { colors } = useTheme(); const { colors } = useTheme();
@@ -190,6 +193,28 @@ export function SettingsScreen(_props: Props) {
</Card> </Card>
</Section> </Section>
{/* Account data */}
<Section title={t('settings.accountData')}>
<Card padded={false} variant="flat">
<ListItem
leadingIcon="people"
title={t('organizations.title')}
onPress={() => stackNavigation.navigate('Organizations')}
/>
<ListItem
leadingIcon="package"
title={t('packages.title')}
onPress={() => stackNavigation.navigate('Packages')}
/>
<ListItem
leadingIcon="lock"
title={t('credentials.title')}
onPress={() => stackNavigation.navigate('Credentials')}
divider={false}
/>
</Card>
</Section>
{/* About */} {/* About */}
<Section title={t('settings.about')}> <Section title={t('settings.about')}>
<Card padded={false} variant="flat"> <Card padded={false} variant="flat">
+108 -1
View File
@@ -164,6 +164,7 @@
"forkedTitle": "Forked", "forkedTitle": "Forked",
"forkedBody": "Created {{name}}.", "forkedBody": "Created {{name}}.",
"wiki": "Wiki", "wiki": "Wiki",
"manage": "Manage",
"browse": "Browse", "browse": "Browse",
"empty": "This repository is empty", "empty": "This repository is empty",
"noReadme": "No README file", "noReadme": "No README file",
@@ -332,7 +333,112 @@
"prerelease": "Pre-release", "prerelease": "Pre-release",
"draft": "Draft", "draft": "Draft",
"assets": "Assets", "assets": "Assets",
"downloads": "{{size}} · {{count}} downloads" "downloads": "{{size}} · {{count}} downloads",
"tag": "Tag",
"name": "Title",
"notes": "Release notes",
"create": "New release",
"edit": "Edit release",
"tagRequired": "A tag is required.",
"deleteTitle": "Delete release?",
"deleteBody": "Release {{tag}} will be deleted."
},
"actions": {
"title": "Actions",
"runTitle": "Workflow run",
"empty": "No workflow runs",
"filterAll": "All",
"filterSuccess": "Success",
"filterFailure": "Failed",
"filterRunning": "Running",
"state_success": "Success",
"state_failure": "Failed",
"state_running": "Running",
"state_waiting": "Waiting",
"state_cancelled": "Cancelled",
"state_skipped": "Skipped",
"openRun": "Open run in browser",
"jobs": "Jobs",
"loadingJobs": "Loading jobs…",
"noJobs": "No jobs",
"unnamedJob": "Job",
"showLogs": "Logs",
"hideLogs": "Hide",
"loadingLogs": "Loading logs…",
"logsUnavailable": "Logs are not available here — open the run in the browser.",
"emptyLogs": "No log output."
},
"repoSettings": {
"title": "Repository settings",
"website": "Website",
"features": "Features",
"sections": "Management",
"collaborators": "Collaborators",
"webhooks": "Webhooks",
"protections": "Branch protections",
"projects": "Projects",
"dangerZone": "Danger zone",
"deleteRepo": "Delete repository",
"savedTitle": "Saved",
"savedBody": "Repository settings updated.",
"deleteTitle": "Delete repository?",
"deleteBody": "{{name}} and all of its data will be permanently deleted. This cannot be undone.",
"addCollaborator": "Add collaborator",
"usernamePlaceholder": "username",
"permission": "Permission",
"read": "Read",
"write": "Write",
"admin": "Admin",
"noCollaborators": "No collaborators",
"removeCollaboratorTitle": "Remove collaborator?",
"removeCollaboratorBody": "{{name}} will lose access to this repository.",
"webhookType": "Type",
"webhookUrl": "Payload URL",
"contentType": "Content type",
"secret": "Secret",
"noWebhooks": "No webhooks",
"inactive": "Inactive",
"events": "{{count}} events",
"deleteWebhookTitle": "Delete webhook?",
"deleteWebhookBody": "The webhook will stop sending events.",
"branchName": "Branch name pattern",
"requiredApprovals": "Required approvals",
"requireSignedCommits": "Require signed commits",
"requireStatusChecks": "Require status checks",
"noProtections": "No branch protections",
"pushRestricted": "Push restricted",
"approvalsBadge": "{{count}} approvals",
"signedBadge": "Signed",
"deleteRuleTitle": "Delete rule?",
"deleteRuleBody": "The protection rule for {{name}} will be removed."
},
"createRepo": {
"title": "New repository",
"name": "Name",
"namePlaceholder": "my-project",
"nameRequired": "A name is required.",
"autoInit": "Initialize repository",
"autoInitHelp": "Add a default branch and README.",
"submit": "Create repository"
},
"organizations": {
"title": "Organizations",
"empty": "No organizations"
},
"packages": {
"title": "Packages",
"empty": "No packages"
},
"credentials": {
"title": "Credentials",
"sshKeys": "SSH keys",
"noSshKeys": "No SSH keys",
"readOnly": "Read-only",
"gpgKeys": "GPG keys",
"noGpgKeys": "No GPG keys",
"tokens": "Access tokens",
"noTokens": "No access tokens",
"notice": "Read-only overview. Create or revoke credentials in the Gitea web interface."
}, },
"checks": { "checks": {
"success": "Checks passed", "success": "Checks passed",
@@ -408,6 +514,7 @@
"clearCacheConfirm": "This removes all cached repository data. Your accounts stay signed in.", "clearCacheConfirm": "This removes all cached repository data. Your accounts stay signed in.",
"clearCacheDone": "Cached data cleared", "clearCacheDone": "Cached data cleared",
"accounts": "Accounts and instances", "accounts": "Accounts and instances",
"accountData": "Account data",
"about": "About", "about": "About",
"version": "Version {{version}}", "version": "Version {{version}}",
"aboutBody": "Gitea Native is an unofficial, open-source client for Gitea. It is not affiliated with, endorsed by, or connected to the Gitea project or Codeberg.", "aboutBody": "Gitea Native is an unofficial, open-source client for Gitea. It is not affiliated with, endorsed by, or connected to the Gitea project or Codeberg.",
+108 -1
View File
@@ -164,6 +164,7 @@
"forkedTitle": "Geforkt", "forkedTitle": "Geforkt",
"forkedBody": "{{name}} is aangemaakt.", "forkedBody": "{{name}} is aangemaakt.",
"wiki": "Wiki", "wiki": "Wiki",
"manage": "Beheren",
"browse": "Bladeren", "browse": "Bladeren",
"empty": "Deze repository is leeg", "empty": "Deze repository is leeg",
"noReadme": "Geen README-bestand", "noReadme": "Geen README-bestand",
@@ -332,7 +333,112 @@
"prerelease": "Pre-release", "prerelease": "Pre-release",
"draft": "Concept", "draft": "Concept",
"assets": "Bestanden", "assets": "Bestanden",
"downloads": "{{size}} · {{count}} downloads" "downloads": "{{size}} · {{count}} downloads",
"tag": "Tag",
"name": "Titel",
"notes": "Release-opmerkingen",
"create": "Nieuwe release",
"edit": "Release bewerken",
"tagRequired": "Een tag is verplicht.",
"deleteTitle": "Release verwijderen?",
"deleteBody": "Release {{tag}} wordt verwijderd."
},
"actions": {
"title": "Actions",
"runTitle": "Workflow-run",
"empty": "Geen workflow-runs",
"filterAll": "Alle",
"filterSuccess": "Geslaagd",
"filterFailure": "Mislukt",
"filterRunning": "Actief",
"state_success": "Geslaagd",
"state_failure": "Mislukt",
"state_running": "Actief",
"state_waiting": "Wachtend",
"state_cancelled": "Geannuleerd",
"state_skipped": "Overgeslagen",
"openRun": "Run openen in browser",
"jobs": "Jobs",
"loadingJobs": "Jobs laden…",
"noJobs": "Geen jobs",
"unnamedJob": "Job",
"showLogs": "Logs",
"hideLogs": "Verbergen",
"loadingLogs": "Logs laden…",
"logsUnavailable": "Logs zijn hier niet beschikbaar — open de run in de browser.",
"emptyLogs": "Geen logregels."
},
"repoSettings": {
"title": "Repository-instellingen",
"website": "Website",
"features": "Functies",
"sections": "Beheer",
"collaborators": "Medewerkers",
"webhooks": "Webhooks",
"protections": "Branch-bescherming",
"projects": "Projecten",
"dangerZone": "Gevarenzone",
"deleteRepo": "Repository verwijderen",
"savedTitle": "Opgeslagen",
"savedBody": "Repository-instellingen bijgewerkt.",
"deleteTitle": "Repository verwijderen?",
"deleteBody": "{{name}} en alle gegevens worden permanent verwijderd. Dit kan niet ongedaan worden gemaakt.",
"addCollaborator": "Medewerker toevoegen",
"usernamePlaceholder": "gebruikersnaam",
"permission": "Rechten",
"read": "Lezen",
"write": "Schrijven",
"admin": "Beheer",
"noCollaborators": "Geen medewerkers",
"removeCollaboratorTitle": "Medewerker verwijderen?",
"removeCollaboratorBody": "{{name}} verliest toegang tot deze repository.",
"webhookType": "Type",
"webhookUrl": "Payload-URL",
"contentType": "Inhoudstype",
"secret": "Secret",
"noWebhooks": "Geen webhooks",
"inactive": "Inactief",
"events": "{{count}} gebeurtenissen",
"deleteWebhookTitle": "Webhook verwijderen?",
"deleteWebhookBody": "De webhook stopt met het verzenden van gebeurtenissen.",
"branchName": "Patroon branchnaam",
"requiredApprovals": "Vereiste goedkeuringen",
"requireSignedCommits": "Ondertekende commits vereisen",
"requireStatusChecks": "Statuschecks vereisen",
"noProtections": "Geen branch-bescherming",
"pushRestricted": "Push beperkt",
"approvalsBadge": "{{count}} goedkeuringen",
"signedBadge": "Ondertekend",
"deleteRuleTitle": "Regel verwijderen?",
"deleteRuleBody": "De beschermingsregel voor {{name}} wordt verwijderd."
},
"createRepo": {
"title": "Nieuwe repository",
"name": "Naam",
"namePlaceholder": "mijn-project",
"nameRequired": "Een naam is verplicht.",
"autoInit": "Repository initialiseren",
"autoInitHelp": "Voeg een standaardbranch en README toe.",
"submit": "Repository aanmaken"
},
"organizations": {
"title": "Organisaties",
"empty": "Geen organisaties"
},
"packages": {
"title": "Packages",
"empty": "Geen packages"
},
"credentials": {
"title": "Inloggegevens",
"sshKeys": "SSH-sleutels",
"noSshKeys": "Geen SSH-sleutels",
"readOnly": "Alleen lezen",
"gpgKeys": "GPG-sleutels",
"noGpgKeys": "Geen GPG-sleutels",
"tokens": "Toegangstokens",
"noTokens": "Geen toegangstokens",
"notice": "Alleen-lezen overzicht. Maak of trek inloggegevens in via de Gitea-webinterface."
}, },
"checks": { "checks": {
"success": "Checks geslaagd", "success": "Checks geslaagd",
@@ -408,6 +514,7 @@
"clearCacheConfirm": "Dit verwijdert alle gecachte repository-gegevens. Je accounts blijven ingelogd.", "clearCacheConfirm": "Dit verwijdert alle gecachte repository-gegevens. Je accounts blijven ingelogd.",
"clearCacheDone": "Cache gewist", "clearCacheDone": "Cache gewist",
"accounts": "Accounts en instances", "accounts": "Accounts en instances",
"accountData": "Accountgegevens",
"about": "Over", "about": "Over",
"version": "Versie {{version}}", "version": "Versie {{version}}",
"aboutBody": "Gitea Native is een onofficiële client met open broncode voor Gitea. Het project is niet gelieerd aan, en niet door het Gitea-project of Codeberg goedgekeurd.", "aboutBody": "Gitea Native is een onofficiële client met open broncode voor Gitea. Het project is niet gelieerd aan, en niet door het Gitea-project of Codeberg goedgekeurd.",
+49
View File
@@ -7,7 +7,10 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { HeaderAccountAndSettings } from '@/components/layout/header-buttons'; import { HeaderAccountAndSettings } from '@/components/layout/header-buttons';
import { ActionsScreen } from '@/features/repository/screens/actions-screen';
import { ActionRunDetailScreen } from '@/features/repository/screens/action-run-detail-screen';
import { BranchesScreen } from '@/features/repository/screens/branches-screen'; import { BranchesScreen } from '@/features/repository/screens/branches-screen';
import { CollaboratorsScreen } from '@/features/repository/screens/collaborators-screen';
import { CommitDetailScreen } from '@/features/repository/screens/commit-detail-screen'; import { CommitDetailScreen } from '@/features/repository/screens/commit-detail-screen';
import { CommitsScreen } from '@/features/repository/screens/commits-screen'; import { CommitsScreen } from '@/features/repository/screens/commits-screen';
import { FileEditScreen } from '@/features/repository/screens/file-edit-screen'; import { FileEditScreen } from '@/features/repository/screens/file-edit-screen';
@@ -15,16 +18,20 @@ import { FileViewerScreen } from '@/features/repository/screens/file-viewer-scre
import { FilesScreen } from '@/features/repository/screens/files-screen'; import { FilesScreen } from '@/features/repository/screens/files-screen';
import { IssueComposeScreen } from '@/features/repository/screens/issue-compose-screen'; import { IssueComposeScreen } from '@/features/repository/screens/issue-compose-screen';
import { IssueDetailScreen } from '@/features/repository/screens/issue-detail-screen'; import { IssueDetailScreen } from '@/features/repository/screens/issue-detail-screen';
import { ProtectionsScreen } from '@/features/repository/screens/protections-screen';
import { PullDetailScreen } from '@/features/repository/screens/pull-detail-screen'; import { PullDetailScreen } from '@/features/repository/screens/pull-detail-screen';
import { PullDiffScreen } from '@/features/repository/screens/pull-diff-screen'; import { PullDiffScreen } from '@/features/repository/screens/pull-diff-screen';
import { PullFilesScreen } from '@/features/repository/screens/pull-files-screen'; import { PullFilesScreen } from '@/features/repository/screens/pull-files-screen';
import { PullReviewScreen } from '@/features/repository/screens/pull-review-screen'; import { PullReviewScreen } from '@/features/repository/screens/pull-review-screen';
import { ReleaseComposeScreen } from '@/features/repository/screens/release-compose-screen';
import { RepoIssuesScreen } from '@/features/repository/screens/repo-issues-screen'; import { RepoIssuesScreen } from '@/features/repository/screens/repo-issues-screen';
import { RepoOverviewScreen } from '@/features/repository/screens/repo-overview-screen'; import { RepoOverviewScreen } from '@/features/repository/screens/repo-overview-screen';
import { RepoPullsScreen } from '@/features/repository/screens/repo-pulls-screen'; import { RepoPullsScreen } from '@/features/repository/screens/repo-pulls-screen';
import { RepoSettingsScreen } from '@/features/repository/screens/repo-settings-screen';
import { ReleaseDetailScreen } from '@/features/repository/screens/release-detail-screen'; import { ReleaseDetailScreen } from '@/features/repository/screens/release-detail-screen';
import { ReleasesScreen } from '@/features/repository/screens/releases-screen'; import { ReleasesScreen } from '@/features/repository/screens/releases-screen';
import { TagsScreen } from '@/features/repository/screens/tags-screen'; import { TagsScreen } from '@/features/repository/screens/tags-screen';
import { WebhooksScreen } from '@/features/repository/screens/webhooks-screen';
import { shortSha } from '@/core/utils/format'; import { shortSha } from '@/core/utils/format';
import { useStackScreenOptions } from '@/navigation/header-options'; import { useStackScreenOptions } from '@/navigation/header-options';
import type { RepositoryStackParamList } from '@/navigation/types'; import type { RepositoryStackParamList } from '@/navigation/types';
@@ -148,6 +155,48 @@ export function RepositoryNavigator() {
: t('pulls.comment'), : t('pulls.comment'),
})} })}
/> />
<Stack.Screen
name="ReleaseCompose"
component={ReleaseComposeScreen}
options={({ route }) => ({
title: route.params.id ? t('releases.edit') : t('releases.create'),
})}
/>
<Stack.Screen
name="RepoIssues"
component={RepoIssuesScreen}
options={{ title: t('repo.issuesTab') }}
/>
<Stack.Screen
name="RepoSettings"
component={RepoSettingsScreen}
options={{ title: t('repoSettings.title') }}
/>
<Stack.Screen
name="Collaborators"
component={CollaboratorsScreen}
options={{ title: t('repoSettings.collaborators') }}
/>
<Stack.Screen
name="Webhooks"
component={WebhooksScreen}
options={{ title: t('repoSettings.webhooks') }}
/>
<Stack.Screen
name="Protections"
component={ProtectionsScreen}
options={{ title: t('repoSettings.protections') }}
/>
<Stack.Screen
name="Actions"
component={ActionsScreen}
options={{ title: t('actions.title') }}
/>
<Stack.Screen
name="ActionRunDetail"
component={ActionRunDetailScreen}
options={{ title: t('actions.runTitle') }}
/>
</Stack.Navigator> </Stack.Navigator>
); );
} }
+24
View File
@@ -1,6 +1,10 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { CredentialsScreen } from '@/features/profile/screens/credentials-screen';
import { OrgReposScreen } from '@/features/profile/screens/org-repos-screen';
import { OrganizationsScreen } from '@/features/profile/screens/organizations-screen';
import { PackagesScreen } from '@/features/profile/screens/packages-screen';
import { SettingsScreen } from '@/features/settings/screens/settings-screen'; import { SettingsScreen } from '@/features/settings/screens/settings-screen';
import { useStackScreenOptions } from '@/navigation/header-options'; import { useStackScreenOptions } from '@/navigation/header-options';
import type { SettingsStackParamList } from '@/navigation/types'; import type { SettingsStackParamList } from '@/navigation/types';
@@ -18,6 +22,26 @@ export function SettingsNavigator() {
component={SettingsScreen} component={SettingsScreen}
options={{ title: t('settings.title') }} options={{ title: t('settings.title') }}
/> />
<Stack.Screen
name="Organizations"
component={OrganizationsScreen}
options={{ title: t('organizations.title') }}
/>
<Stack.Screen
name="OrgRepos"
component={OrgReposScreen}
options={({ route }) => ({ title: route.params.org })}
/>
<Stack.Screen
name="Packages"
component={PackagesScreen}
options={{ title: t('packages.title') }}
/>
<Stack.Screen
name="Credentials"
component={CredentialsScreen}
options={{ title: t('credentials.title') }}
/>
</Stack.Navigator> </Stack.Navigator>
); );
} }
+6
View File
@@ -12,6 +12,7 @@ import { HomeScreen } from '@/features/home/screens/home-screen';
import { InboxScreen } from '@/features/inbox/screens/inbox-screen'; import { InboxScreen } from '@/features/inbox/screens/inbox-screen';
import { IssuesScreen } from '@/features/issues/screens/issues-screen'; import { IssuesScreen } from '@/features/issues/screens/issues-screen';
import { PullRequestsScreen } from '@/features/pulls/screens/pull-requests-screen'; import { PullRequestsScreen } from '@/features/pulls/screens/pull-requests-screen';
import { CreateRepoScreen } from '@/features/repositories/screens/create-repo-screen';
import { RepositoryListScreen } from '@/features/repositories/screens/repository-list-screen'; import { RepositoryListScreen } from '@/features/repositories/screens/repository-list-screen';
import { useStackScreenOptions } from '@/navigation/header-options'; import { useStackScreenOptions } from '@/navigation/header-options';
import type { import type {
@@ -52,6 +53,11 @@ export function RepositoriesStackNavigator() {
component={RepositoryListScreen} component={RepositoryListScreen}
options={{ title: t('tabs.repositories') }} options={{ title: t('tabs.repositories') }}
/> />
<RepositoriesStack.Screen
name="CreateRepo"
component={CreateRepoScreen}
options={{ title: t('createRepo.title') }}
/>
</RepositoriesStack.Navigator> </RepositoriesStack.Navigator>
); );
} }
+16 -4
View File
@@ -16,10 +16,6 @@ export type HomeStackParamList = {
Home: undefined; Home: undefined;
}; };
export type RepositoriesStackParamList = {
RepositoryList: undefined;
};
export type IssuesStackParamList = { export type IssuesStackParamList = {
Issues: undefined; Issues: undefined;
}; };
@@ -59,10 +55,26 @@ export type RepositoryStackParamList = {
PullFiles: { owner: string; name: string; index: number }; PullFiles: { owner: string; name: string; index: number };
PullDiff: { owner: string; name: string; index: number; path?: string }; PullDiff: { owner: string; name: string; index: number; path?: string };
PullReview: { owner: string; name: string; index: number; event: ReviewEvent }; PullReview: { owner: string; name: string; index: number; event: ReviewEvent };
ReleaseCompose: { owner: string; name: string; id?: number };
RepoSettings: { owner: string; name: string };
Collaborators: { owner: string; name: string };
Webhooks: { owner: string; name: string };
Protections: { owner: string; name: string };
Actions: { owner: string; name: string };
ActionRunDetail: { owner: string; name: string; id: number };
};
export type RepositoriesStackParamList = {
RepositoryList: undefined;
CreateRepo: undefined;
}; };
export type SettingsStackParamList = { export type SettingsStackParamList = {
Settings: undefined; Settings: undefined;
Organizations: undefined;
OrgRepos: { org: string };
Packages: undefined;
Credentials: undefined;
}; };
export type AccountsStackParamList = { export type AccountsStackParamList = {