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:
1 parent
5e8c9492b3
commit
fa1ebc9184
30 files changed
+3001
-9
No files matched your search
@@ -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' },
|
||||
});
|
||||
Reference in new issue
Block a user