feat: release asset upload, transfer, Actions secrets/variables/artifacts, admin, teams/projects, file search, reactions, attachments, package version delete
- client: multipart postForm; expo-document-picker + react-native-webview deps - release assets: upload (DocumentPicker) and delete; run artifacts list - repository transfer; Actions secrets + variables management screen - admin (users/orgs/repos) screen gated on is_admin - org teams, repo projects (read-only); find-file via recursive git tree - issue reactions toggle and attachments list; package version delete - endpoint tests (126 total)
This commit is contained in:
1 parent
b2b44bca73
commit
587bf732b5
31 files changed
+1919
-46
No files matched your search
@@ -6,7 +6,12 @@ import type { RawResponse } from '@/core/api/client';
|
||||
import {
|
||||
createOrg,
|
||||
deletePackage,
|
||||
deletePackageVersion,
|
||||
fetchAuthenticatedUser,
|
||||
fetchUserSettings,
|
||||
listAdminOrgs,
|
||||
listAdminRepos,
|
||||
listAdminUsers,
|
||||
listOrgRepos,
|
||||
listPackages,
|
||||
listUserGpgKeys,
|
||||
@@ -24,6 +29,7 @@ import type {
|
||||
Package,
|
||||
PublicKey,
|
||||
Repository,
|
||||
User,
|
||||
UserSettings,
|
||||
} from '@/core/api/types';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
@@ -49,6 +55,18 @@ function useAccountList<T>(
|
||||
});
|
||||
}
|
||||
|
||||
/** The signed-in user (used to gate admin-only UI on `is_admin`). */
|
||||
export function useCurrentUser() {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
return useQuery<User>({
|
||||
queryKey: queryKeys.me(accountId),
|
||||
enabled: Boolean(client) && Boolean(accountId),
|
||||
queryFn: ({ signal }) => fetchAuthenticatedUser(client!, { signal }),
|
||||
staleTime: 5 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUserOrgs(limit = 30) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
@@ -152,3 +170,47 @@ export function useDeletePackage() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeletePackageVersion() {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
return useMutation({
|
||||
mutationFn: ({ owner, type, name, version }: { owner: string; type: string; name: string; version: string }) =>
|
||||
deletePackageVersion(client!, owner, type, name, version),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Admin (read-only)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function useAdminUsers(limit = 30) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
return useAccountList<User>(
|
||||
[...queryKeys.account(accountId), 'admin', 'users', { limit }],
|
||||
(page, signal) => listAdminUsers(client!, { page, limit }, { signal }),
|
||||
);
|
||||
}
|
||||
|
||||
export function useAdminOrgs(limit = 30) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
return useAccountList<Organization>(
|
||||
[...queryKeys.account(accountId), 'admin', 'orgs', { limit }],
|
||||
(page, signal) => listAdminOrgs(client!, { page, limit }, { signal }),
|
||||
);
|
||||
}
|
||||
|
||||
export function useAdminRepos(limit = 30) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
return useAccountList<Repository>(
|
||||
[...queryKeys.account(accountId), 'admin', 'repos', { limit }],
|
||||
(page, signal) => listAdminRepos(client!, { page, limit }, { signal }),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useState } from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { QueryList } from '@/components/layout/query-list';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { SegmentedControl } from '@/components/ui/segmented';
|
||||
import { EmptyState } from '@/components/ui/state-views';
|
||||
import type { Organization, Repository, User } from '@/core/api/types';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { useAdminOrgs, useAdminRepos, useAdminUsers } from '@/features/profile/queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
type Tab = 'users' | 'orgs' | 'repos';
|
||||
|
||||
/** Instance administration (read-only) for instance admins. */
|
||||
export function AdminScreen() {
|
||||
const { t } = useTranslation();
|
||||
const [tab, setTab] = useState<Tab>('users');
|
||||
|
||||
const users = useAdminUsers();
|
||||
const orgs = useAdminOrgs();
|
||||
const repos = useAdminRepos();
|
||||
|
||||
return (
|
||||
<Screen padded={false}>
|
||||
<View style={styles.tabs}>
|
||||
<SegmentedControl<Tab>
|
||||
value={tab}
|
||||
onChange={setTab}
|
||||
accessibilityLabel={t('admin.title')}
|
||||
options={[
|
||||
{ value: 'users', label: t('admin.users') },
|
||||
{ value: 'orgs', label: t('admin.orgs') },
|
||||
{ value: 'repos', label: t('admin.repos') },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{tab === 'users' ? (
|
||||
<QueryList<User>
|
||||
query={users}
|
||||
items={flattenPages(users.data)}
|
||||
keyExtractor={(user) => String(user.id ?? user.login)}
|
||||
renderItem={(user) => (
|
||||
<View style={styles.row}>
|
||||
<View style={styles.body}>
|
||||
<AppText variant="bodyMedium" numberOfLines={1}>
|
||||
{user.login}
|
||||
</AppText>
|
||||
{user.full_name ? (
|
||||
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
|
||||
{user.full_name}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
{user.is_admin ? <Badge tone="warning">{t('admin.adminBadge')}</Badge> : null}
|
||||
</View>
|
||||
)}
|
||||
empty={<EmptyState icon="people" title={t('admin.emptyUsers')} />}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{tab === 'orgs' ? (
|
||||
<QueryList<Organization>
|
||||
query={orgs}
|
||||
items={flattenPages(orgs.data)}
|
||||
keyExtractor={(org) => String(org.id ?? org.username)}
|
||||
renderItem={(org) => (
|
||||
<View style={styles.row}>
|
||||
<AppText variant="bodyMedium" numberOfLines={1}>
|
||||
{org.username ?? org.name}
|
||||
</AppText>
|
||||
</View>
|
||||
)}
|
||||
empty={<EmptyState icon="people" title={t('admin.emptyOrgs')} />}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{tab === 'repos' ? (
|
||||
<QueryList<Repository>
|
||||
query={repos}
|
||||
items={flattenPages(repos.data)}
|
||||
keyExtractor={(repo) => String(repo.id)}
|
||||
renderItem={(repo) => (
|
||||
<View style={styles.row}>
|
||||
<View style={styles.body}>
|
||||
<AppText variant="bodyMedium" numberOfLines={1}>
|
||||
{repo.full_name}
|
||||
</AppText>
|
||||
{repo.private ? <Badge tone="neutral">{t('repositories.private')}</Badge> : null}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
empty={<EmptyState icon="repo" title={t('admin.emptyRepos')} />}
|
||||
/>
|
||||
) : null}
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabs: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
|
||||
row: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: spacing.md,
|
||||
paddingHorizontal: spacing.lg,
|
||||
paddingVertical: spacing.md,
|
||||
},
|
||||
body: { flex: 1, gap: 2 },
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useRoute, type RouteProp } from '@react-navigation/native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { useOrgTeams } from '@/features/repositories/settings-queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { SettingsStackParamList } from '@/navigation/types';
|
||||
|
||||
/** Teams within an organization (read-only). */
|
||||
export function OrgTeamsScreen() {
|
||||
const { t } = useTranslation();
|
||||
const route = useRoute<RouteProp<SettingsStackParamList, 'OrgTeams'>>();
|
||||
const { org } = route.params;
|
||||
const query = useOrgTeams(org);
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(query.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void query.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const teams = query.data ?? [];
|
||||
if (teams.length === 0) return <EmptyState icon="people" title={t('organizations.noTeams')} />;
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
{teams.map((team) => (
|
||||
<Card key={team.id ?? team.name}>
|
||||
<View style={styles.row}>
|
||||
<View style={styles.body}>
|
||||
<AppText variant="bodyMedium" numberOfLines={1}>
|
||||
{team.name}
|
||||
</AppText>
|
||||
{team.description ? (
|
||||
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
|
||||
{team.description}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
{team.permission ? <Badge tone="neutral">{team.permission}</Badge> : null}
|
||||
</View>
|
||||
</Card>
|
||||
))}
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
|
||||
body: { flex: 1, gap: 2 },
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import { QueryList } from '@/components/layout/query-list';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { IconButton } from '@/components/ui/icon-button';
|
||||
import { EmptyState } from '@/components/ui/state-views';
|
||||
import type { Organization } from '@/core/api/types';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
@@ -57,6 +58,11 @@ export function OrganizationsScreen() {
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
<IconButton
|
||||
name="people"
|
||||
onPress={() => navigation.navigate('OrgTeams', { org: login })}
|
||||
accessibilityLabel={t('organizations.teams')}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { Package } from '@/core/api/types';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
import { useDeletePackage, usePackages } from '@/features/profile/queries';
|
||||
import { useDeletePackage, useDeletePackageVersion, usePackages } from '@/features/profile/queries';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
@@ -21,21 +21,35 @@ export function PackagesScreen() {
|
||||
const login = account?.login ?? '';
|
||||
const query = usePackages(login);
|
||||
const deletePackage = useDeletePackage();
|
||||
const deleteVersion = useDeletePackageVersion();
|
||||
const packages: Package[] = flattenPages(query.data);
|
||||
|
||||
const confirmDelete = (pkg: Package) => {
|
||||
Alert.alert(t('packages.deleteTitle'), t('packages.deleteBody', { name: pkg.name ?? '' }), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
const buttons = [
|
||||
{ text: t('common.cancel'), style: 'cancel' as const },
|
||||
...(pkg.version
|
||||
? [
|
||||
{
|
||||
text: t('packages.deleteVersion'),
|
||||
onPress: () =>
|
||||
deleteVersion.mutate(
|
||||
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '', version: pkg.version as string },
|
||||
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
text: t('common.delete'),
|
||||
style: 'destructive',
|
||||
text: t('packages.deleteAll'),
|
||||
style: 'destructive' as const,
|
||||
onPress: () =>
|
||||
deletePackage.mutate(
|
||||
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '' },
|
||||
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
|
||||
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
|
||||
),
|
||||
},
|
||||
]);
|
||||
];
|
||||
Alert.alert(t('packages.deleteTitle'), t('packages.deleteBody', { name: pkg.name ?? '' }), buttons);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user