feat(phase5): deploy keys, profile editing, organization creation

- API: repo deploy keys (list/add/delete), user settings GET/PATCH, org create
- hooks: useRepoKeys/useAddRepoKey/useDeleteRepoKey; useUserSettings,
  useUpdateUserSettings, useCreateOrg
- screens: DeployKeys, Profile (edit), CreateOrg; wired into RepoSettings,
  Settings and Organizations
- endpoint body-shape tests for repo update, release, deploy key, user settings,
  org create and Action run filters (120 tests total)
This commit is contained in:
JustZoe101 committed 2026-10-09 18:13:54 +02:00
1 parent fa1ebc9184
commit 6d0b536009
17 files changed
+738 -8

No files matched your search

+59 -1
View File
@@ -6,7 +6,16 @@
*/ */
import { GiteaClient } from './client'; import { GiteaClient } from './client';
import { createPullReview, mergePull } from './endpoints'; import {
addRepoKey,
createOrg,
createRelease,
createPullReview,
listActionRuns,
mergePull,
updateRepo,
updateUserSettings,
} from './endpoints';
function response(body = '{}', status = 200): Response { function response(body = '{}', status = 200): Response {
return { return {
@@ -47,4 +56,53 @@ describe('endpoint request bodies', () => {
expect(body.event).toBe('REQUEST_CHANGES'); expect(body.event).toBe('REQUEST_CHANGES');
expect(body.body).toBe('please'); expect(body.body).toBe('please');
}); });
it('patches repository settings', async () => {
const { fetchImpl, client } = capture();
await updateRepo(client, 'octo', 'repo', { description: 'D', private: true, has_wiki: false });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo');
expect(postedBody(fetchImpl)).toMatchObject({
description: 'D',
private: true,
has_wiki: false,
});
});
it('creates a release with a tag', async () => {
const { fetchImpl, client } = capture();
await createRelease(client, 'octo', 'repo', { tag_name: 'v1.2.0', name: 'R', draft: false });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/releases');
expect(postedBody(fetchImpl)).toMatchObject({ tag_name: 'v1.2.0', name: 'R' });
});
it('adds a deploy key with read-only flag', async () => {
const { fetchImpl, client } = capture();
await addRepoKey(client, 'octo', 'repo', { title: 'CI', key: 'ssh-ed25519 AAAA', read_only: true });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/keys');
expect(postedBody(fetchImpl)).toMatchObject({ title: 'CI', key: 'ssh-ed25519 AAAA', read_only: true });
});
it('updates user profile settings', async () => {
const { fetchImpl, client } = capture();
await updateUserSettings(client, { full_name: 'Alice', location: 'NL' });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/user/settings');
expect(fetchImpl.mock.calls[0][1].method).toBe('PATCH');
expect(postedBody(fetchImpl)).toMatchObject({ full_name: 'Alice', location: 'NL' });
});
it('creates an organization', async () => {
const { fetchImpl, client } = capture();
await createOrg(client, { username: 'acme', visibility: 'private' });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/orgs');
expect(postedBody(fetchImpl)).toMatchObject({ username: 'acme', visibility: 'private' });
});
it('builds Action run filter query parameters', async () => {
const { fetchImpl, client } = capture();
await listActionRuns(client, 'octo', 'repo', { status: 'success', branch: 'main', limit: 10 });
const url = fetchImpl.mock.calls[0][0] as string;
expect(url).toContain('/repos/octo/repo/actions/runs?');
expect(url).toContain('status=success');
expect(url).toContain('branch=main');
});
}); });
+81
View File
@@ -24,6 +24,7 @@ import type {
Comment, Comment,
Commit, Commit,
ContentsEntry, ContentsEntry,
DeployKey,
GpgKey, GpgKey,
Issue, Issue,
Label, Label,
@@ -42,6 +43,7 @@ import type {
Subscription, Subscription,
Tag, Tag,
User, User,
UserSettings,
Webhook, Webhook,
} from './types'; } from './types';
@@ -620,6 +622,85 @@ export function listUserTokens(
}); });
} }
// ---------------------------------------------------------------------------
// Repository deploy keys
// ---------------------------------------------------------------------------
export function listRepoKeys(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<DeployKey[]>(`${repoPath(owner, repo)}/keys`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export interface AddRepoKeyInput {
title: string;
key: string;
read_only?: boolean;
}
export function addRepoKey(
client: GiteaClient,
owner: string,
repo: string,
input: AddRepoKeyInput,
options?: RequestOptions,
): Promise<DeployKey> {
return client.post<DeployKey>(`${repoPath(owner, repo)}/keys`, input, options);
}
export function deleteRepoKey(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/keys/${id}`, options);
}
// ---------------------------------------------------------------------------
// User profile settings & organizations (write)
// ---------------------------------------------------------------------------
export function fetchUserSettings(
client: GiteaClient,
options?: RequestOptions,
): Promise<UserSettings> {
return client.get<UserSettings>('/user/settings', options);
}
export function updateUserSettings(
client: GiteaClient,
input: Partial<UserSettings>,
options?: RequestOptions,
): Promise<UserSettings> {
return client.patch<UserSettings>('/user/settings', input, options);
}
export interface CreateOrgInput {
username: string;
full_name?: string;
description?: string;
website?: string;
location?: string;
visibility?: 'public' | 'limited' | 'private';
}
export function createOrg(
client: GiteaClient,
input: CreateOrgInput,
options?: RequestOptions,
): Promise<Organization> {
return client.post<Organization>('/orgs', input, options);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Contents, README, branches, tags // Contents, README, branches, tags
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
+3
View File
@@ -63,6 +63,9 @@ export const queryKeys = {
repoProtections: (accountId: string, owner: string, name: string) => repoProtections: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'branch-protections'] as const, [...queryKeys.repo(accountId, owner, name), 'branch-protections'] as const,
repoKeys: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'keys'] as const,
// --- actions ------------------------------------------------------------- // --- actions -------------------------------------------------------------
actionsWorkflows: (accountId: string, owner: string, name: string) => actionsWorkflows: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'workflows'] as const, [...queryKeys.repo(accountId, owner, name), 'actions', 'workflows'] as const,
+10
View File
@@ -558,6 +558,16 @@ export interface AccessToken {
last_used_at?: string; last_used_at?: string;
} }
/** Editable user profile fields (GET/PATCH /user/settings). */
export interface UserSettings {
full_name?: string;
website?: string;
location?: string;
description?: string;
language?: string;
theme?: string;
}
export interface Activity { export interface Activity {
id?: number; id?: number;
user_id?: number; user_id?: number;
+51 -2
View File
@@ -1,18 +1,30 @@
/** Account-level data: organizations, packages and credential listings. */ /** Account-level data: organizations, packages and credential listings. */
import { useInfiniteQuery, type InfiniteData } from '@tanstack/react-query'; import { useInfiniteQuery, useMutation, useQuery, useQueryClient, type InfiniteData } from '@tanstack/react-query';
import type { RawResponse } from '@/core/api/client'; import type { RawResponse } from '@/core/api/client';
import { import {
createOrg,
fetchUserSettings,
listOrgRepos, listOrgRepos,
listPackages, listPackages,
listUserGpgKeys, listUserGpgKeys,
listUserKeys, listUserKeys,
listUserOrgs, listUserOrgs,
listUserTokens, listUserTokens,
updateUserSettings,
type CreateOrgInput,
} from '@/core/api/endpoints'; } from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys'; import { queryKeys } from '@/core/api/query-keys';
import type { AccessToken, GpgKey, Organization, Package, PublicKey, Repository } from '@/core/api/types'; import type {
AccessToken,
GpgKey,
Organization,
Package,
PublicKey,
Repository,
UserSettings,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session'; import { useSession } from '@/features/accounts/use-session';
function useAccountList<T>( function useAccountList<T>(
@@ -89,3 +101,40 @@ export function useUserTokens(username: string, limit = 50) {
(page, signal) => listUserTokens(client!, username, { page, limit }, { signal }), (page, signal) => listUserTokens(client!, username, { page, limit }, { signal }),
); );
} }
/** Editable profile settings for the signed-in user. */
export function useUserSettings() {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<UserSettings>({
queryKey: [...queryKeys.account(accountId), 'settings'],
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) => fetchUserSettings(client!, { signal }),
staleTime: 5 * 60_000,
});
}
export function useUpdateUserSettings() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: Partial<UserSettings>) => updateUserSettings(client!, input),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: [...queryKeys.account(accountId), 'settings'] });
void queryClient.invalidateQueries({ queryKey: queryKeys.me(accountId) });
},
});
}
export function useCreateOrg() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: CreateOrgInput) => createOrg(client!, input),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
@@ -0,0 +1,118 @@
import { useState } from 'react';
import { Alert, 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 { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Field } from '@/components/ui/field';
import { SegmentedControl } from '@/components/ui/segmented';
import { apiErrorMessage } from '@/core/api/error-text';
import { useCreateOrg } from '@/features/profile/queries';
import { spacing } from '@/theme/tokens';
import type { SettingsStackParamList } from '@/navigation/types';
type Visibility = 'public' | 'limited' | 'private';
/** Create an organization. */
export function CreateOrgScreen() {
const { t } = useTranslation();
const navigation = useNavigation<NativeStackNavigationProp<SettingsStackParamList>>();
const create = useCreateOrg();
const [username, setUsername] = useState('');
const [fullName, setFullName] = useState('');
const [location, setLocation] = useState('');
const [visibility, setVisibility] = useState<Visibility>('public');
const [submitted, setSubmitted] = useState(false);
const usernameError =
submitted && username.trim().length === 0 ? t('organizations.usernameRequired') : undefined;
const submit = () => {
setSubmitted(true);
if (username.trim().length === 0) return;
create.mutate(
{
username: username.trim(),
full_name: fullName.trim() || undefined,
location: location.trim() || undefined,
visibility,
},
{
onSuccess: () => {
Alert.alert(t('organizations.createdTitle'), t('organizations.createdBody'));
navigation.goBack();
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
return (
<Screen scroll padded>
<Field
label={t('organizations.username')}
value={username}
onChangeText={setUsername}
placeholder={t('organizations.usernamePlaceholder')}
showError={Boolean(usernameError)}
error={usernameError}
autoCapitalize="none"
autoCorrect={false}
testID="org-username"
/>
<Field
label={t('profile.fullName')}
value={fullName}
onChangeText={setFullName}
autoCapitalize="words"
/>
<Field
label={t('profile.location')}
value={location}
onChangeText={setLocation}
autoCapitalize="words"
/>
<View style={styles.visibility}>
<AppText variant="label" tone="secondary">
{t('organizations.visibility')}
</AppText>
<View style={styles.visibilityControl}>
<SegmentedControl<Visibility>
value={visibility}
onChange={setVisibility}
accessibilityLabel={t('organizations.visibility')}
options={[
{ value: 'public', label: t('organizations.visPublic') },
{ value: 'limited', label: t('organizations.visLimited') },
{ value: 'private', label: t('organizations.visPrivate') },
]}
/>
</View>
</View>
{create.isError ? (
<AppText variant="caption" tone="error">
{apiErrorMessage(create.error, t)}
</AppText>
) : null}
<Button
label={t('organizations.create')}
onPress={submit}
loading={create.isPending}
disabled={username.trim().length === 0}
fullWidth
testID="org-submit"
/>
</Screen>
);
}
const styles = StyleSheet.create({
visibility: { gap: spacing.xs },
visibilityControl: { marginTop: spacing.xs },
});
@@ -6,6 +6,7 @@ import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
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 { Avatar } from '@/components/ui/avatar'; import { Avatar } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import { EmptyState } from '@/components/ui/state-views'; import { EmptyState } from '@/components/ui/state-views';
import type { Organization } from '@/core/api/types'; import type { Organization } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite'; import { flattenPages } from '@/core/utils/infinite';
@@ -25,6 +26,17 @@ export function OrganizationsScreen() {
query={query} query={query}
items={orgs} items={orgs}
keyExtractor={(org) => String(org.id ?? org.username)} keyExtractor={(org) => String(org.id ?? org.username)}
header={
<View style={styles.header}>
<Button
label={t('organizations.create')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('CreateOrg')}
/>
</View>
}
renderItem={(org) => { renderItem={(org) => {
const login = org.username ?? org.name ?? ''; const login = org.username ?? org.name ?? '';
return ( return (
@@ -54,6 +66,7 @@ export function OrganizationsScreen() {
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
header: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: { row: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
@@ -0,0 +1,101 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { 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 { UserSettings } from '@/core/api/types';
import { useUpdateUserSettings, useUserSettings } from '@/features/profile/queries';
import { spacing } from '@/theme/tokens';
/** Edit the signed-in user's public profile. */
export function ProfileScreen() {
const { t } = useTranslation();
const query = useUserSettings();
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()}
/>
);
}
return <ProfileForm key={query.dataUpdatedAt} settings={query.data ?? {}} />;
}
function ProfileForm({ settings }: { settings: UserSettings }) {
const { t } = useTranslation();
const update = useUpdateUserSettings();
const [fullName, setFullName] = useState(settings.full_name ?? '');
const [bio, setBio] = useState(settings.description ?? '');
const [website, setWebsite] = useState(settings.website ?? '');
const [location, setLocation] = useState(settings.location ?? '');
const save = () => {
update.mutate(
{
full_name: fullName.trim(),
description: bio.trim(),
website: website.trim(),
location: location.trim(),
},
{
onSuccess: () => Alert.alert(t('repoSettings.savedTitle'), t('profile.savedBody')),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
return (
<Screen scroll padded>
<Field label={t('profile.fullName')} value={fullName} onChangeText={setFullName} autoCapitalize="words" />
<TextArea
label={t('profile.bio')}
value={bio}
onChangeText={setBio}
autoCapitalize="sentences"
autoCorrect
minHeight={100}
/>
<Field
label={t('repoSettings.website')}
value={website}
onChangeText={setWebsite}
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
/>
<Field label={t('profile.location')} value={location} onChangeText={setLocation} autoCapitalize="words" />
{update.isError ? (
<AppText variant="caption" tone="error">
{apiErrorMessage(update.error, t)}
</AppText>
) : null}
<Button
label={t('common.save')}
onPress={save}
loading={update.isPending}
fullWidth
testID="profile-save"
/>
<View style={styles.spacer} />
</Screen>
);
}
const styles = StyleSheet.create({
spacer: { height: spacing.xl },
});
+46 -1
View File
@@ -4,17 +4,21 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { import {
addCollaborator, addCollaborator,
addRepoKey,
createBranchProtection, createBranchProtection,
createRepo, createRepo,
createWebhook, createWebhook,
deleteBranchProtection, deleteBranchProtection,
deleteRepo, deleteRepo,
deleteRepoKey,
deleteWebhook, deleteWebhook,
listBranchProtections, listBranchProtections,
listCollaborators, listCollaborators,
listRepoKeys,
listWebhooks, listWebhooks,
removeCollaborator, removeCollaborator,
updateRepo, updateRepo,
type AddRepoKeyInput,
type CollaboratorPermission, type CollaboratorPermission,
type CreateBranchProtectionInput, type CreateBranchProtectionInput,
type CreateRepoInput, type CreateRepoInput,
@@ -22,7 +26,7 @@ import {
type UpdateRepoInput, type UpdateRepoInput,
} from '@/core/api/endpoints'; } from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys'; import { queryKeys } from '@/core/api/query-keys';
import type { BranchProtection, User, Webhook } from '@/core/api/types'; import type { BranchProtection, DeployKey, User, Webhook } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session'; import { useSession } from '@/features/accounts/use-session';
export function useCollaboratorsList(owner: string, name: string) { export function useCollaboratorsList(owner: string, name: string) {
@@ -181,3 +185,44 @@ export function useCreateRepo() {
}, },
}); });
} }
// ---------------------------------------------------------------------------
// Deploy keys
// ---------------------------------------------------------------------------
export function useRepoKeys(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<DeployKey[]>({
queryKey: queryKeys.repoKeys(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoKeys(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useAddRepoKey(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: AddRepoKeyInput) => addRepoKey(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoKeys(accountId, owner, name) }),
});
}
export function useDeleteRepoKey(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteRepoKey(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoKeys(accountId, owner, name) }),
});
}
@@ -0,0 +1,171 @@
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 { TextArea } from '@/components/ui/text-area';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import {
useAddRepoKey,
useDeleteRepoKey,
useRepoKeys,
} 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, 'DeployKeys'>;
/** Repository deploy keys: list, add, delete. */
export function DeployKeysScreen({ route }: Props) {
const { t } = useTranslation();
const { colors } = useTheme();
const { owner, name } = route.params;
const query = useRepoKeys(owner, name);
const add = useAddRepoKey(owner, name);
const remove = useDeleteRepoKey(owner, name);
const [title, setTitle] = useState('');
const [key, setKey] = useState('');
const [readOnly, setReadOnly] = useState(true);
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 keys = query.data ?? [];
const submit = () => {
if (title.trim().length === 0 || key.trim().length === 0) return;
add.mutate(
{ title: title.trim(), key: key.trim(), read_only: readOnly },
{
onSuccess: () => {
setTitle('');
setKey('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmRemove = (id: number) => {
Alert.alert(t('repoSettings.deleteKeyTitle'), t('repoSettings.deleteKeyBody'), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
remove.mutate(id, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('repoSettings.keyTitle')}
value={title}
onChangeText={setTitle}
placeholder={t('repoSettings.keyTitlePlaceholder')}
/>
<View style={styles.keyField}>
<TextArea
label={t('repoSettings.keyValue')}
value={key}
onChangeText={setKey}
placeholder="ssh-ed25519 AAAA…"
mono
autoCapitalize="none"
autoCorrect={false}
minHeight={90}
/>
</View>
<View style={styles.switchRow}>
<AppText variant="bodyMedium" style={styles.switchLabel}>
{t('credentials.readOnly')}
</AppText>
<Switch
value={readOnly}
onValueChange={setReadOnly}
trackColor={{ true: colors.primary, false: colors.border }}
/>
</View>
<Button
label={t('common.add')}
onPress={submit}
loading={add.isPending}
disabled={title.trim().length === 0 || key.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{keys.length === 0 ? (
<EmptyState icon="lock" title={t('repoSettings.noDeployKeys')} />
) : (
keys.map((deployKey) => (
<Card key={deployKey.id ?? deployKey.title}>
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{deployKey.title}
</AppText>
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1}>
{deployKey.fingerprint ?? ''}
</AppText>
</View>
{deployKey.read_only ? (
<Badge tone="neutral">{t('credentials.readOnly')}</Badge>
) : (
<Badge tone="warning">{t('repoSettings.writeAccess')}</Badge>
)}
{deployKey.id ? (
<IconButton
name="trash"
onPress={() => confirmRemove(deployKey.id as number)}
accessibilityLabel={t('common.delete')}
/>
) : null}
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
keyField: { marginTop: spacing.md },
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.sm },
body: { flex: 1, gap: 2 },
});
@@ -177,6 +177,11 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
leadingIcon="shield" leadingIcon="shield"
title={t('repoSettings.protections')} title={t('repoSettings.protections')}
onPress={() => navigation.navigate('Protections', { owner, name })} onPress={() => navigation.navigate('Protections', { owner, name })}
/>
<ListItem
leadingIcon="lock"
title={t('repoSettings.deployKeys')}
onPress={() => navigation.navigate('DeployKeys', { owner, name })}
divider={false} divider={false}
/> />
</Card> </Card>
@@ -196,6 +196,11 @@ export function SettingsScreen(_props: Props) {
{/* Account data */} {/* Account data */}
<Section title={t('settings.accountData')}> <Section title={t('settings.accountData')}>
<Card padded={false} variant="flat"> <Card padded={false} variant="flat">
<ListItem
leadingIcon="person"
title={t('profile.title')}
onPress={() => stackNavigation.navigate('Profile')}
/>
<ListItem <ListItem
leadingIcon="people" leadingIcon="people"
title={t('organizations.title')} title={t('organizations.title')}
+27 -2
View File
@@ -410,7 +410,15 @@
"approvalsBadge": "{{count}} approvals", "approvalsBadge": "{{count}} approvals",
"signedBadge": "Signed", "signedBadge": "Signed",
"deleteRuleTitle": "Delete rule?", "deleteRuleTitle": "Delete rule?",
"deleteRuleBody": "The protection rule for {{name}} will be removed." "deleteRuleBody": "The protection rule for {{name}} will be removed.",
"deployKeys": "Deploy keys",
"keyTitle": "Key title",
"keyTitlePlaceholder": "CI deploy key",
"keyValue": "Public key",
"noDeployKeys": "No deploy keys",
"deleteKeyTitle": "Delete deploy key?",
"deleteKeyBody": "The deploy key will be removed.",
"writeAccess": "Write"
}, },
"createRepo": { "createRepo": {
"title": "New repository", "title": "New repository",
@@ -423,7 +431,24 @@
}, },
"organizations": { "organizations": {
"title": "Organizations", "title": "Organizations",
"empty": "No organizations" "empty": "No organizations",
"create": "New organization",
"username": "Organization name",
"usernamePlaceholder": "my-org",
"usernameRequired": "A name is required.",
"visibility": "Visibility",
"visPublic": "Public",
"visLimited": "Limited",
"visPrivate": "Private",
"createdTitle": "Created",
"createdBody": "The organization was created."
},
"profile": {
"title": "Profile",
"fullName": "Display name",
"bio": "Bio",
"location": "Location",
"savedBody": "Your profile was updated."
}, },
"packages": { "packages": {
"title": "Packages", "title": "Packages",
+27 -2
View File
@@ -410,7 +410,15 @@
"approvalsBadge": "{{count}} goedkeuringen", "approvalsBadge": "{{count}} goedkeuringen",
"signedBadge": "Ondertekend", "signedBadge": "Ondertekend",
"deleteRuleTitle": "Regel verwijderen?", "deleteRuleTitle": "Regel verwijderen?",
"deleteRuleBody": "De beschermingsregel voor {{name}} wordt verwijderd." "deleteRuleBody": "De beschermingsregel voor {{name}} wordt verwijderd.",
"deployKeys": "Deploy-sleutels",
"keyTitle": "Titel van sleutel",
"keyTitlePlaceholder": "CI deploy-sleutel",
"keyValue": "Publieke sleutel",
"noDeployKeys": "Geen deploy-sleutels",
"deleteKeyTitle": "Deploy-sleutel verwijderen?",
"deleteKeyBody": "De deploy-sleutel wordt verwijderd.",
"writeAccess": "Schrijven"
}, },
"createRepo": { "createRepo": {
"title": "Nieuwe repository", "title": "Nieuwe repository",
@@ -423,7 +431,24 @@
}, },
"organizations": { "organizations": {
"title": "Organisaties", "title": "Organisaties",
"empty": "Geen organisaties" "empty": "Geen organisaties",
"create": "Nieuwe organisatie",
"username": "Naam van organisatie",
"usernamePlaceholder": "mijn-org",
"usernameRequired": "Een naam is verplicht.",
"visibility": "Zichtbaarheid",
"visPublic": "Openbaar",
"visLimited": "Beperkt",
"visPrivate": "Privé",
"createdTitle": "Aangemaakt",
"createdBody": "De organisatie is aangemaakt."
},
"profile": {
"title": "Profiel",
"fullName": "Weergavenaam",
"bio": "Bio",
"location": "Locatie",
"savedBody": "Je profiel is bijgewerkt."
}, },
"packages": { "packages": {
"title": "Packages", "title": "Packages",
+6
View File
@@ -13,6 +13,7 @@ import { BranchesScreen } from '@/features/repository/screens/branches-screen';
import { CollaboratorsScreen } from '@/features/repository/screens/collaborators-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 { DeployKeysScreen } from '@/features/repository/screens/deploy-keys-screen';
import { FileEditScreen } from '@/features/repository/screens/file-edit-screen'; import { FileEditScreen } from '@/features/repository/screens/file-edit-screen';
import { FileViewerScreen } from '@/features/repository/screens/file-viewer-screen'; import { FileViewerScreen } from '@/features/repository/screens/file-viewer-screen';
import { FilesScreen } from '@/features/repository/screens/files-screen'; import { FilesScreen } from '@/features/repository/screens/files-screen';
@@ -187,6 +188,11 @@ export function RepositoryNavigator() {
component={ProtectionsScreen} component={ProtectionsScreen}
options={{ title: t('repoSettings.protections') }} options={{ title: t('repoSettings.protections') }}
/> />
<Stack.Screen
name="DeployKeys"
component={DeployKeysScreen}
options={{ title: t('repoSettings.deployKeys') }}
/>
<Stack.Screen <Stack.Screen
name="Actions" name="Actions"
component={ActionsScreen} component={ActionsScreen}
+12
View File
@@ -2,9 +2,11 @@ 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 { CredentialsScreen } from '@/features/profile/screens/credentials-screen';
import { CreateOrgScreen } from '@/features/profile/screens/create-org-screen';
import { OrgReposScreen } from '@/features/profile/screens/org-repos-screen'; import { OrgReposScreen } from '@/features/profile/screens/org-repos-screen';
import { OrganizationsScreen } from '@/features/profile/screens/organizations-screen'; import { OrganizationsScreen } from '@/features/profile/screens/organizations-screen';
import { PackagesScreen } from '@/features/profile/screens/packages-screen'; import { PackagesScreen } from '@/features/profile/screens/packages-screen';
import { ProfileScreen } from '@/features/profile/screens/profile-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';
@@ -42,6 +44,16 @@ export function SettingsNavigator() {
component={CredentialsScreen} component={CredentialsScreen}
options={{ title: t('credentials.title') }} options={{ title: t('credentials.title') }}
/> />
<Stack.Screen
name="Profile"
component={ProfileScreen}
options={{ title: t('profile.title') }}
/>
<Stack.Screen
name="CreateOrg"
component={CreateOrgScreen}
options={{ title: t('organizations.create') }}
/>
</Stack.Navigator> </Stack.Navigator>
); );
} }
+3
View File
@@ -60,6 +60,7 @@ export type RepositoryStackParamList = {
Collaborators: { owner: string; name: string }; Collaborators: { owner: string; name: string };
Webhooks: { owner: string; name: string }; Webhooks: { owner: string; name: string };
Protections: { owner: string; name: string }; Protections: { owner: string; name: string };
DeployKeys: { owner: string; name: string };
Actions: { owner: string; name: string }; Actions: { owner: string; name: string };
ActionRunDetail: { owner: string; name: string; id: number }; ActionRunDetail: { owner: string; name: string; id: number };
}; };
@@ -75,6 +76,8 @@ export type SettingsStackParamList = {
OrgRepos: { org: string }; OrgRepos: { org: string };
Packages: undefined; Packages: undefined;
Credentials: undefined; Credentials: undefined;
Profile: undefined;
CreateOrg: undefined;
}; };
export type AccountsStackParamList = { export type AccountsStackParamList = {