feat: labels/milestones CRUD, issue filters+sort, workflow enable/disable, package link/unlink

- labels screen (create/edit/delete) and milestones screen (create/close/delete)
- repo issues: label + milestone server-side filters and client-side sorting
- Actions settings: list workflows with enable/disable toggle
- packages: link/unlink to a repository
- endpoints/hooks/i18n (en/nl)
This commit is contained in:
JustZoe101 committed 2026-10-09 19:06:07 +02:00
1 parent 1226f154cc
commit a104d65978
14 files changed
+996 -44

No files matched your search

+131
View File
@@ -909,6 +909,8 @@ export interface ListRepoIssuesParams extends PageParams {
state?: 'open' | 'closed' | 'all'; state?: 'open' | 'closed' | 'all';
q?: string; q?: string;
labels?: string; labels?: string;
/** Comma-separated milestone names. */
milestones?: string;
} }
export function listRepoIssues( export function listRepoIssues(
@@ -926,6 +928,7 @@ export function listRepoIssues(
state: params.state ?? 'open', state: params.state ?? 'open',
q: params.q?.trim() || undefined, q: params.q?.trim() || undefined,
labels: params.labels, labels: params.labels,
milestones: params.milestones,
type: 'issues', type: 'issues',
}, },
}); });
@@ -1781,3 +1784,131 @@ export function deletePackageVersion(
options, options,
); );
} }
// ---------------------------------------------------------------------------
// Labels & milestones (CRUD)
// ---------------------------------------------------------------------------
export interface LabelInput {
name: string;
color?: string;
description?: string;
exclusive?: boolean;
}
export function createLabel(
client: GiteaClient,
owner: string,
repo: string,
input: LabelInput,
options?: RequestOptions,
): Promise<Label> {
return client.post<Label>(`${repoPath(owner, repo)}/labels`, input, options);
}
export function updateLabel(
client: GiteaClient,
owner: string,
repo: string,
id: number,
input: Partial<LabelInput>,
options?: RequestOptions,
): Promise<Label> {
return client.patch<Label>(`${repoPath(owner, repo)}/labels/${id}`, input, options);
}
export function deleteLabel(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/labels/${id}`, options);
}
export interface MilestoneInput {
title: string;
description?: string;
due_on?: string;
state?: 'open' | 'closed';
}
export function createMilestone(
client: GiteaClient,
owner: string,
repo: string,
input: MilestoneInput,
options?: RequestOptions,
): Promise<Milestone> {
return client.post<Milestone>(`${repoPath(owner, repo)}/milestones`, input, options);
}
export function updateMilestone(
client: GiteaClient,
owner: string,
repo: string,
id: number,
input: Partial<MilestoneInput>,
options?: RequestOptions,
): Promise<Milestone> {
return client.patch<Milestone>(`${repoPath(owner, repo)}/milestones/${id}`, input, options);
}
export function deleteMilestone(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/milestones/${id}`, options);
}
// ---------------------------------------------------------------------------
// Actions workflows (enable/disable) & package linking
// ---------------------------------------------------------------------------
export function setWorkflowEnabled(
client: GiteaClient,
owner: string,
repo: string,
workflowId: string,
enabled: boolean,
options?: RequestOptions,
): Promise<void> {
return client.put<void>(
`${repoPath(owner, repo)}/actions/workflows/${enc(workflowId)}/${enabled ? 'enable' : 'disable'}`,
undefined,
options,
);
}
export function linkPackageToRepo(
client: GiteaClient,
owner: string,
type: string,
name: string,
repoName: string,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(
`/packages/${enc(owner)}/${enc(type)}/${enc(name)}/-/link/${enc(repoName)}`,
undefined,
options,
);
}
export function unlinkPackageFromRepo(
client: GiteaClient,
owner: string,
type: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(
`/packages/${enc(owner)}/${enc(type)}/${enc(name)}/-/unlink`,
undefined,
options,
);
}
+15 -2
View File
@@ -131,17 +131,30 @@ export function useIssueSearch(filters: CrossIssueFilters, limit = 20) {
}); });
} }
export interface RepoIssueFilters {
labels?: string;
milestones?: string;
limit?: number;
}
/** Issues inside one repository (used on the repository Issues tab). */ /** Issues inside one repository (used on the repository Issues tab). */
export function useRepoIssues( export function useRepoIssues(
owner: string, owner: string,
name: string, name: string,
state: 'open' | 'closed' | 'all', state: 'open' | 'closed' | 'all',
search: string, search: string,
limit = 20, filters: RepoIssueFilters = {},
) { ) {
const { client, account } = useSession(); const { client, account } = useSession();
const accountId = account?.id ?? ''; const accountId = account?.id ?? '';
const params = { state, q: search.trim() || undefined, limit }; const limit = filters.limit ?? 20;
const params = {
state,
q: search.trim() || undefined,
labels: filters.labels || undefined,
milestones: filters.milestones || undefined,
limit,
};
return useInfiniteQuery< return useInfiniteQuery<
RawResponse<Issue[]>, RawResponse<Issue[]>,
+28
View File
@@ -18,6 +18,8 @@ import {
listUserKeys, listUserKeys,
listUserOrgs, listUserOrgs,
listUserTokens, listUserTokens,
linkPackageToRepo,
unlinkPackageFromRepo,
updateUserSettings, updateUserSettings,
type CreateOrgInput, type CreateOrgInput,
} from '@/core/api/endpoints'; } from '@/core/api/endpoints';
@@ -184,6 +186,32 @@ export function useDeletePackageVersion() {
}); });
} }
export function useLinkPackage() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name, repoName }: { owner: string; type: string; name: string; repoName: string }) =>
linkPackageToRepo(client!, owner, type, name, repoName),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useUnlinkPackage() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name }: { owner: string; type: string; name: string }) =>
unlinkPackageFromRepo(client!, owner, type, name),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Admin (read-only) // Admin (read-only)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1,16 +1,26 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native'; import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next'; 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 { Card } from '@/components/ui/card';
import { Field } from '@/components/ui/field';
import { IconButton } from '@/components/ui/icon-button'; import { IconButton } from '@/components/ui/icon-button';
import { EmptyState } from '@/components/ui/state-views'; import { EmptyState } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text'; import { apiErrorMessage } from '@/core/api/error-text';
import type { Package } from '@/core/api/types'; import type { Package } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite'; import { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format'; import { formatRelativeTime } from '@/core/utils/format';
import { useDeletePackage, useDeletePackageVersion, usePackages } from '@/features/profile/queries'; import {
useDeletePackage,
useDeletePackageVersion,
useLinkPackage,
usePackages,
useUnlinkPackage,
} from '@/features/profile/queries';
import { useSession } from '@/features/accounts/use-session'; import { useSession } from '@/features/accounts/use-session';
import { spacing } from '@/theme/tokens'; import { spacing } from '@/theme/tokens';
@@ -22,8 +32,13 @@ export function PackagesScreen() {
const query = usePackages(login); const query = usePackages(login);
const deletePackage = useDeletePackage(); const deletePackage = useDeletePackage();
const deleteVersion = useDeletePackageVersion(); const deleteVersion = useDeletePackageVersion();
const linkPackage = useLinkPackage();
const unlinkPackage = useUnlinkPackage();
const packages: Package[] = flattenPages(query.data); const packages: Package[] = flattenPages(query.data);
const [linkTarget, setLinkTarget] = useState<Package | null>(null);
const [repoName, setRepoName] = useState('');
const confirmDelete = (pkg: Package) => { const confirmDelete = (pkg: Package) => {
const buttons = [ const buttons = [
{ text: t('common.cancel'), style: 'cancel' as const }, { text: t('common.cancel'), style: 'cancel' as const },
@@ -57,6 +72,72 @@ export function PackagesScreen() {
query={query} query={query}
items={packages} items={packages}
keyExtractor={(pkg) => `${pkg.type ?? ''}-${pkg.name ?? ''}-${pkg.version ?? ''}`} keyExtractor={(pkg) => `${pkg.type ?? ''}-${pkg.name ?? ''}-${pkg.version ?? ''}`}
header={
linkTarget ? (
<Card style={styles.linkCard}>
<AppText variant="bodyMedium" numberOfLines={1}>
{linkTarget.name}
</AppText>
<Field
label={t('packages.linkRepo')}
value={repoName}
onChangeText={setRepoName}
placeholder={t('packages.linkRepoPlaceholder')}
autoCapitalize="none"
autoCorrect={false}
/>
<View style={styles.linkActions}>
<Button
label={t('common.cancel')}
variant="ghost"
size="md"
onPress={() => {
setLinkTarget(null);
setRepoName('');
}}
/>
<Button
label={t('packages.link')}
size="md"
loading={linkPackage.isPending}
disabled={repoName.trim().length === 0}
onPress={() =>
linkPackage.mutate(
{
owner: login,
type: linkTarget.type ?? '',
name: linkTarget.name ?? '',
repoName: repoName.trim(),
},
{
onSuccess: () => {
setLinkTarget(null);
setRepoName('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
)
}
/>
<Button
label={t('packages.unlink')}
variant="danger"
size="md"
loading={unlinkPackage.isPending}
onPress={() =>
unlinkPackage.mutate(
{ owner: login, type: linkTarget.type ?? '', name: linkTarget.name ?? '' },
{
onSuccess: () => setLinkTarget(null),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
)
}
/>
</View>
</Card>
) : undefined
}
renderItem={(pkg) => ( renderItem={(pkg) => (
<View style={styles.row}> <View style={styles.row}>
<View style={styles.body}> <View style={styles.body}>
@@ -77,6 +158,14 @@ export function PackagesScreen() {
) : null} ) : null}
</View> </View>
</View> </View>
<IconButton
name="externalLink"
onPress={() => {
setLinkTarget(pkg);
setRepoName('');
}}
accessibilityLabel={t('packages.link')}
/>
<IconButton <IconButton
name="trash" name="trash"
onPress={() => confirmDelete(pkg)} onPress={() => confirmDelete(pkg)}
@@ -99,4 +188,6 @@ const styles = StyleSheet.create({
}, },
body: { flex: 1, gap: spacing.xs }, body: { flex: 1, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' }, metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
linkCard: { gap: spacing.sm },
linkActions: { flexDirection: 'row', justifyContent: 'flex-end', gap: spacing.sm, flexWrap: 'wrap' },
}); });
@@ -6,10 +6,14 @@ import {
addCollaborator, addCollaborator,
addRepoKey, addRepoKey,
createBranchProtection, createBranchProtection,
createLabel,
createMilestone,
createRepo, createRepo,
createRepoVariable, createRepoVariable,
createWebhook, createWebhook,
deleteBranchProtection, deleteBranchProtection,
deleteLabel,
deleteMilestone,
deleteRepo, deleteRepo,
deleteRepoKey, deleteRepoKey,
deleteRepoSecret, deleteRepoSecret,
@@ -17,6 +21,7 @@ import {
deleteWebhook, deleteWebhook,
listBranchProtections, listBranchProtections,
listCollaborators, listCollaborators,
listMilestones,
listOrgTeams, listOrgTeams,
listRepoKeys, listRepoKeys,
listRepoProjects, listRepoProjects,
@@ -25,13 +30,18 @@ import {
listWebhooks, listWebhooks,
putRepoSecret, putRepoSecret,
removeCollaborator, removeCollaborator,
setWorkflowEnabled,
transferRepo, transferRepo,
updateLabel,
updateMilestone,
updateRepo, updateRepo,
type AddRepoKeyInput, type AddRepoKeyInput,
type CollaboratorPermission, type CollaboratorPermission,
type CreateBranchProtectionInput, type CreateBranchProtectionInput,
type CreateRepoInput, type CreateRepoInput,
type CreateWebhookInput, type CreateWebhookInput,
type LabelInput,
type MilestoneInput,
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';
@@ -39,6 +49,7 @@ import type {
ActionVariable, ActionVariable,
BranchProtection, BranchProtection,
DeployKey, DeployKey,
Milestone,
Project, Project,
Secret, Secret,
Team, Team,
@@ -372,3 +383,107 @@ export function useOrgTeams(org: string) {
staleTime: 60_000, staleTime: 60_000,
}); });
} }
// ---------------------------------------------------------------------------
// Labels & milestones (CRUD)
// ---------------------------------------------------------------------------
export function useCreateLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: LabelInput) => createLabel(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useUpdateLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ id, input }: { id: number; input: Partial<LabelInput> }) =>
updateLabel(client!, owner, name, id, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useDeleteLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteLabel(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useMilestonesAll(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Milestone[]>({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listMilestones(client!, owner, name, { state: 'all', limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: MilestoneInput) => createMilestone(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useUpdateMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ id, input }: { id: number; input: Partial<MilestoneInput> }) =>
updateMilestone(client!, owner, name, id, input),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useDeleteMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteMilestone(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useSetWorkflowState(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ workflowId, enabled }: { workflowId: string; enabled: boolean }) =>
setWorkflowEnabled(client!, owner, name, workflowId, enabled),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.actionsWorkflows(accountId, owner, name),
}),
});
}
@@ -8,6 +8,7 @@ import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card'; import { Card } from '@/components/ui/card';
import { ChipSelect } from '@/components/ui/chip-select'; import { ChipSelect } from '@/components/ui/chip-select';
import { Field } from '@/components/ui/field'; import { Field } from '@/components/ui/field';
import { ListItem } from '@/components/ui/list-item';
import { IconButton } from '@/components/ui/icon-button'; import { IconButton } from '@/components/ui/icon-button';
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';
@@ -18,6 +19,7 @@ import {
usePutRepoSecret, usePutRepoSecret,
useRepoSecrets, useRepoSecrets,
useRepoVariables, useRepoVariables,
useSetWorkflowState,
} from '@/features/repositories/settings-queries'; } from '@/features/repositories/settings-queries';
import { useDispatchWorkflow, useWorkflows } from '@/features/actions/queries'; import { useDispatchWorkflow, useWorkflows } from '@/features/actions/queries';
import { spacing } from '@/theme/tokens'; import { spacing } from '@/theme/tokens';
@@ -46,6 +48,7 @@ export function ActionsSettingsScreen({ route }: Props) {
const [selectedWorkflow, setSelectedWorkflow] = useState<string | null>(null); const [selectedWorkflow, setSelectedWorkflow] = useState<string | null>(null);
const [dispatchRefName, setDispatchRefName] = useState(''); const [dispatchRefName, setDispatchRefName] = useState('');
const dispatch = useDispatchWorkflow(owner, name, selectedWorkflow ?? ''); const dispatch = useDispatchWorkflow(owner, name, selectedWorkflow ?? '');
const setWorkflowState = useSetWorkflowState(owner, name);
if (secrets.isPending || variables.isPending) return <LoadingView />; if (secrets.isPending || variables.isPending) return <LoadingView />;
if (secrets.isError || variables.isError) { if (secrets.isError || variables.isError) {
@@ -159,6 +162,33 @@ export function ActionsSettingsScreen({ route }: Props) {
/> />
</Card> </Card>
{(workflows.data ?? []).length > 0 ? (
<>
<AppText variant="subheading">{t('repoSettings.workflows')}</AppText>
<Card padded={false} variant="flat">
{(workflows.data ?? []).map((workflow, index, all) => {
const enabled = workflow.state === 'active';
return (
<ListItem
key={workflow.id ?? workflow.path}
leadingIcon="autoRenew"
title={workflow.name ?? workflow.path ?? ''}
subtitle={workflow.path}
rightText={enabled ? t('repoSettings.enabled') : t('repoSettings.disabled')}
onPress={() =>
setWorkflowState.mutate(
{ workflowId: String(workflow.id), enabled: !enabled },
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
)
}
divider={index < all.length - 1}
/>
);
})}
</Card>
</>
) : null}
<AppText variant="subheading">{t('repoSettings.secrets')}</AppText> <AppText variant="subheading">{t('repoSettings.secrets')}</AppText>
<Card> <Card>
<Field <Field
@@ -0,0 +1,172 @@
import { useState } from 'react';
import { Alert, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { 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 { LabelChip } from '@/components/ui/label-chip';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Label } from '@/core/api/types';
import { useRepoLabels } from '@/features/issues/queries';
import {
useCreateLabel,
useDeleteLabel,
useUpdateLabel,
} 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, 'Labels'>;
/** Repository labels: create, rename/recolor, delete. */
export function LabelsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useRepoLabels(owner, name);
const createLabel = useCreateLabel(owner, name);
const updateLabel = useUpdateLabel(owner, name);
const deleteLabel = useDeleteLabel(owner, name);
const [labelName, setLabelName] = useState('');
const [color, setColor] = useState('#609926');
const [editingId, setEditingId] = useState<number | null>(null);
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 labels: Label[] = query.data ?? [];
const submit = () => {
const input = { name: labelName.trim(), color: color.replace('#', '') };
if (!input.name) return;
if (editingId != null) {
updateLabel.mutate(
{ id: editingId, input },
{
onSuccess: () => {
setEditingId(null);
setLabelName('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
} else {
createLabel.mutate(input, {
onSuccess: () => setLabelName(''),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
});
}
};
const confirmDelete = (label: Label) => {
if (!label.id) return;
Alert.alert(t('repoSettings.deleteLabelTitle'), t('repoSettings.deleteLabelBody', { name: label.name }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteLabel.mutate(label.id as number, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
const startEdit = (label: Label) => {
setEditingId(label.id ?? null);
setLabelName(label.name);
setColor(`#${label.color ?? '609926'}`);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('labels.name')}
value={labelName}
onChangeText={setLabelName}
autoCapitalize="none"
autoCorrect={false}
/>
<View style={styles.colorRow}>
<View style={[styles.swatch, { backgroundColor: color }]} />
<Field label={t('labels.color')} value={color} onChangeText={setColor} autoCapitalize="none" mono />
</View>
<Button
label={editingId != null ? t('common.save') : t('common.add')}
onPress={submit}
loading={createLabel.isPending || updateLabel.isPending}
disabled={labelName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
{editingId != null ? (
<Button
label={t('common.cancel')}
variant="ghost"
onPress={() => {
setEditingId(null);
setLabelName('');
}}
fullWidth
/>
) : null}
</Card>
{labels.length === 0 ? (
<EmptyState icon="tag" title={t('labels.empty')} />
) : (
labels.map((label) => (
<Card key={label.id ?? label.name}>
<View style={styles.row}>
<LabelChip name={label.name} color={label.color} />
<AppText variant="caption" tone="tertiary" numberOfLines={1} style={styles.desc}>
{label.description ?? ''}
</AppText>
<Pressable
onPress={() => startEdit(label)}
accessibilityRole="button"
accessibilityLabel={t('common.edit')}
hitSlop={8}
>
<AppText variant="caption" tone="link">
{t('common.edit')}
</AppText>
</Pressable>
<IconButton
name="trash"
onPress={() => confirmDelete(label)}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
colorRow: { flexDirection: 'row', alignItems: 'flex-end', gap: spacing.sm },
swatch: { width: 32, height: 32, borderRadius: 6, marginBottom: spacing.md },
spaced: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
desc: { flex: 1 },
});
@@ -0,0 +1,166 @@
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 { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Milestone } from '@/core/api/types';
import {
useCreateMilestone,
useDeleteMilestone,
useMilestonesAll,
useUpdateMilestone,
} 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, 'Milestones'>;
/** Repository milestones: create, close/reopen, delete. */
export function MilestonesScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useMilestonesAll(owner, name);
const createMilestone = useCreateMilestone(owner, name);
const updateMilestone = useUpdateMilestone(owner, name);
const deleteMilestone = useDeleteMilestone(owner, name);
const [title, setTitle] = useState('');
const [dueOn, setDueOn] = 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 milestones: Milestone[] = query.data ?? [];
const submit = () => {
if (title.trim().length === 0) return;
createMilestone.mutate(
{ title: title.trim(), due_on: dueOn.trim() || undefined },
{
onSuccess: () => {
setTitle('');
setDueOn('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const toggleState = (milestone: Milestone) => {
if (!milestone.id) return;
updateMilestone.mutate({
id: milestone.id,
input: { state: milestone.state === 'closed' ? 'open' : 'closed' },
});
};
const confirmDelete = (milestone: Milestone) => {
if (!milestone.id) return;
Alert.alert(
t('repoSettings.deleteMilestoneTitle'),
t('repoSettings.deleteMilestoneBody', { name: milestone.title }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteMilestone.mutate(milestone.id as number, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('milestones.titleLabel')}
value={title}
onChangeText={setTitle}
autoCapitalize="sentences"
/>
<Field
label={`${t('milestones.dueOn')} (${t('common.optional')})`}
value={dueOn}
onChangeText={setDueOn}
placeholder="2026-12-31T00:00:00Z"
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('common.add')}
onPress={submit}
loading={createMilestone.isPending}
disabled={title.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{milestones.length === 0 ? (
<EmptyState icon="tag" title={t('milestones.empty')} />
) : (
milestones.map((milestone) => (
<Card key={milestone.id ?? milestone.title}>
<View style={styles.header}>
<AppText variant="bodyMedium" style={styles.title} numberOfLines={1}>
{milestone.title}
</AppText>
<Badge tone={milestone.state === 'closed' ? 'neutral' : 'success'}>
{milestone.state === 'closed' ? t('milestones.closed') : t('milestones.open')}
</Badge>
</View>
<AppText variant="caption" tone="tertiary">
{t('milestones.progress', {
open: milestone.open_issues ?? 0,
closed: milestone.closed_issues ?? 0,
})}
</AppText>
<View style={styles.actions}>
<Button
label={milestone.state === 'closed' ? t('issues.reopen') : t('issues.close')}
variant="secondary"
size="md"
onPress={() => toggleState(milestone)}
/>
<Button
label={t('common.delete')}
variant="ghost"
size="md"
onPress={() => confirmDelete(milestone)}
/>
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
spaced: { marginTop: spacing.md },
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
title: { flex: 1, fontWeight: '600' },
actions: { flexDirection: 'row', gap: spacing.sm, marginTop: spacing.sm },
});
@@ -1,16 +1,17 @@
import { useState } from 'react'; import { useMemo, useState } from 'react';
import { StyleSheet, View } from 'react-native'; import { Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { IssueRow } from '@/components/git/issue-row'; import { IssueRow } from '@/components/git/issue-row';
import { QueryList } from '@/components/layout/query-list'; import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { SearchBar } from '@/components/ui/search-bar'; import { SearchBar } from '@/components/ui/search-bar';
import { SegmentedControl } from '@/components/ui/segmented'; import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views'; import { EmptyState } from '@/components/ui/state-views';
import type { Issue } from '@/core/api/types'; import type { Issue } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite'; import { flattenPages } from '@/core/utils/infinite';
import { useRepoIssues } from '@/features/issues/queries'; import { useMilestones, useRepoIssues, useRepoLabels } from '@/features/issues/queries';
import { spacing } from '@/theme/tokens'; import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types'; import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing'; import type { ScreenProps } from '@/navigation/typing';
@@ -18,52 +19,159 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoIssues'>; type Props = ScreenProps<RepositoryStackParamList, 'RepoIssues'>;
type StateKey = 'open' | 'closed' | 'all'; type StateKey = 'open' | 'closed' | 'all';
type SortKey = 'updated' | 'created' | 'comments';
/** Issues scoped to one repository. */ /** Issues scoped to one repository, with label/milestone filters and sorting. */
export function RepoIssuesScreen({ navigation, route }: Props) { export function RepoIssuesScreen({ navigation, route }: Props) {
const { t } = useTranslation(); const { t } = useTranslation();
const { owner, name } = route.params; const { owner, name } = route.params;
const [state, setState] = useState<StateKey>('open'); const [state, setState] = useState<StateKey>('open');
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const [selectedLabels, setSelectedLabels] = useState<string[]>([]);
const [milestone, setMilestone] = useState<string | null>(null);
const [sort, setSort] = useState<SortKey>('updated');
const [showFilters, setShowFilters] = useState(false);
const query = useRepoIssues(owner, name, state, search); const labelsQuery = useRepoLabels(owner, name);
const issues: Issue[] = flattenPages(query.data); const milestonesQuery = useMilestones(owner, name);
const query = useRepoIssues(owner, name, state, search, {
labels: selectedLabels.join(','),
milestones: milestone ?? undefined,
});
const rawIssues: Issue[] = flattenPages(query.data);
const issues = useMemo(() => {
const sorted = [...rawIssues];
switch (sort) {
case 'created':
sorted.sort((a, b) => (b.created_at ?? '').localeCompare(a.created_at ?? ''));
break;
case 'comments':
sorted.sort((a, b) => (b.comments ?? 0) - (a.comments ?? 0));
break;
case 'updated':
default:
sorted.sort((a, b) => (b.updated_at ?? '').localeCompare(a.updated_at ?? ''));
}
return sorted;
}, [rawIssues, sort]);
const toggleLabel = (label: string) =>
setSelectedLabels((prev) =>
prev.includes(label) ? prev.filter((x) => x !== label) : [...prev, label],
);
const header = (
<View>
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('issues.searchPlaceholder')}
/>
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('issues.title')}
options={[
{ value: 'open', label: t('issues.stateOpen') },
{ value: 'closed', label: t('issues.stateClosed') },
{ value: 'all', label: t('issues.stateAll') },
]}
/>
<SegmentedControl<SortKey>
value={sort}
onChange={setSort}
accessibilityLabel={t('issues.sort')}
options={[
{ value: 'updated', label: t('issues.sortUpdated') },
{ value: 'created', label: t('issues.sortCreated') },
{ value: 'comments', label: t('issues.sortComments') },
]}
/>
</View>
<View style={styles.filterToggle}>
<Button
label={showFilters ? t('issues.hideFilters') : t('issues.showFilters')}
variant="ghost"
size="md"
iconLeft="sortByDate"
onPress={() => setShowFilters((value) => !value)}
/>
</View>
{showFilters ? (
<View style={styles.filters}>
{(labelsQuery.data ?? []).length > 0 ? (
<View>
<AppText variant="label" tone="secondary">
{t('issues.labels')}
</AppText>
<View style={styles.chips}>
{(labelsQuery.data ?? []).map((label) => {
const active = selectedLabels.includes(label.name);
return (
<Pressable
key={label.id ?? label.name}
onPress={() => toggleLabel(label.name)}
accessibilityRole="checkbox"
accessibilityState={{ selected: active }}
style={[styles.chip, active && styles.chipActive]}
>
<AppText variant="caption" tone={active ? 'primary' : 'secondary'}>
{label.name}
</AppText>
</Pressable>
);
})}
</View>
</View>
) : null}
{(milestonesQuery.data ?? []).length > 0 ? (
<View>
<AppText variant="label" tone="secondary">
{t('issues.milestone')}
</AppText>
<View style={styles.chips}>
{(milestonesQuery.data ?? []).map((item) => {
const active = milestone === item.title;
return (
<Pressable
key={item.id ?? item.title}
onPress={() => setMilestone(active ? null : item.title)}
accessibilityRole="radio"
accessibilityState={{ selected: active }}
style={[styles.chip, active && styles.chipActive]}
>
<AppText variant="caption" tone={active ? 'primary' : 'secondary'}>
{item.title}
</AppText>
</Pressable>
);
})}
</View>
</View>
) : null}
</View>
) : null}
<View style={styles.newIssue}>
<Button
label={t('issues.compose.createTitle')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('IssueCompose', { owner, name })}
/>
</View>
</View>
);
return ( return (
<QueryList<Issue> <QueryList<Issue>
query={query} query={query}
items={issues} items={issues}
keyExtractor={(issue) => String(issue.id)} keyExtractor={(issue) => String(issue.id)}
header={ header={header}
<View>
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('issues.searchPlaceholder')}
/>
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('issues.title')}
options={[
{ value: 'open', label: t('issues.stateOpen') },
{ value: 'closed', label: t('issues.stateClosed') },
{ value: 'all', label: t('issues.stateAll') },
]}
/>
</View>
<View style={styles.newIssue}>
<Button
label={t('issues.compose.createTitle')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('IssueCompose', { owner, name })}
/>
</View>
</View>
}
renderItem={(issue) => ( renderItem={(issue) => (
<IssueRow <IssueRow
issue={issue} issue={issue}
@@ -76,6 +184,16 @@ export function RepoIssuesScreen({ navigation, route }: Props) {
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm }, filters: { gap: spacing.sm, paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
filterToggle: { paddingHorizontal: spacing.lg },
chips: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm, marginTop: spacing.xs },
chip: {
borderWidth: 1,
borderColor: 'rgba(128,128,128,0.4)',
borderRadius: 999,
paddingHorizontal: spacing.md,
paddingVertical: 2,
},
chipActive: { borderColor: '#609926', backgroundColor: 'rgba(96,153,38,0.14)' },
newIssue: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm }, newIssue: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
}); });
@@ -185,6 +185,16 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
leadingIcon="lock" leadingIcon="lock"
title={t('repoSettings.deployKeys')} title={t('repoSettings.deployKeys')}
onPress={() => navigation.navigate('DeployKeys', { owner, name })} onPress={() => navigation.navigate('DeployKeys', { owner, name })}
/>
<ListItem
leadingIcon="tag"
title={t('labels.title')}
onPress={() => navigation.navigate('Labels', { owner, name })}
/>
<ListItem
leadingIcon="dashboard"
title={t('milestones.title')}
onPress={() => navigation.navigate('Milestones', { owner, name })}
divider={false} divider={false}
/> />
</Card> </Card>
+34 -2
View File
@@ -241,6 +241,12 @@
"notFound": "This issue could not be found.", "notFound": "This issue could not be found.",
"subscribe": "Subscribe", "subscribe": "Subscribe",
"unsubscribe": "Unsubscribe", "unsubscribe": "Unsubscribe",
"sort": "Sort",
"sortUpdated": "Recently updated",
"sortCreated": "Recently created",
"sortComments": "Most comments",
"showFilters": "Filters",
"hideFilters": "Hide filters",
"reopen": "Reopen", "reopen": "Reopen",
"close": "Close", "close": "Close",
"compose": { "compose": {
@@ -456,7 +462,14 @@
"runWorkflow": "Run workflow", "runWorkflow": "Run workflow",
"noWorkflows": "No dispatchable workflows", "noWorkflows": "No dispatchable workflows",
"ref": "Ref (branch or tag)", "ref": "Ref (branch or tag)",
"dispatch": "Dispatch" "dispatch": "Dispatch",
"workflows": "Workflows",
"enabled": "Enabled",
"disabled": "Disabled",
"deleteLabelTitle": "Delete label?",
"deleteLabelBody": "Label {{name}} will be removed from all issues.",
"deleteMilestoneTitle": "Delete milestone?",
"deleteMilestoneBody": "Milestone {{name}} will be removed."
}, },
"createRepo": { "createRepo": {
"title": "New repository", "title": "New repository",
@@ -513,7 +526,26 @@
"deleteTitle": "Delete package?", "deleteTitle": "Delete package?",
"deleteBody": "Choose what to delete for {{name}}.", "deleteBody": "Choose what to delete for {{name}}.",
"deleteVersion": "Delete this version", "deleteVersion": "Delete this version",
"deleteAll": "Delete all versions" "deleteAll": "Delete all versions",
"link": "Link to repository",
"unlink": "Unlink",
"linkRepo": "Repository name",
"linkRepoPlaceholder": "my-repo"
},
"labels": {
"title": "Labels",
"name": "Label name",
"color": "Color",
"empty": "No labels"
},
"milestones": {
"title": "Milestones",
"titleLabel": "Milestone title",
"dueOn": "Due date",
"empty": "No milestones",
"open": "Open",
"closed": "Closed",
"progress": "{{open}} open · {{closed}} closed"
}, },
"credentials": { "credentials": {
"title": "Credentials", "title": "Credentials",
+34 -2
View File
@@ -241,6 +241,12 @@
"notFound": "Deze issue kon niet worden gevonden.", "notFound": "Deze issue kon niet worden gevonden.",
"subscribe": "Volgen", "subscribe": "Volgen",
"unsubscribe": "Niet meer volgen", "unsubscribe": "Niet meer volgen",
"sort": "Sorteren",
"sortUpdated": "Recent bijgewerkt",
"sortCreated": "Recent aangemaakt",
"sortComments": "Meeste reacties",
"showFilters": "Filters",
"hideFilters": "Filters verbergen",
"reopen": "Heropenen", "reopen": "Heropenen",
"close": "Sluiten", "close": "Sluiten",
"compose": { "compose": {
@@ -456,7 +462,14 @@
"runWorkflow": "Workflow uitvoeren", "runWorkflow": "Workflow uitvoeren",
"noWorkflows": "Geen uitvoerbare workflows", "noWorkflows": "Geen uitvoerbare workflows",
"ref": "Ref (branch of tag)", "ref": "Ref (branch of tag)",
"dispatch": "Starten" "dispatch": "Starten",
"workflows": "Workflows",
"enabled": "Ingeschakeld",
"disabled": "Uitgeschakeld",
"deleteLabelTitle": "Label verwijderen?",
"deleteLabelBody": "Label {{name}} wordt van alle issues verwijderd.",
"deleteMilestoneTitle": "Mijlpaal verwijderen?",
"deleteMilestoneBody": "Mijlpaal {{name}} wordt verwijderd."
}, },
"createRepo": { "createRepo": {
"title": "Nieuwe repository", "title": "Nieuwe repository",
@@ -513,7 +526,26 @@
"deleteTitle": "Package verwijderen?", "deleteTitle": "Package verwijderen?",
"deleteBody": "Kies wat je wilt verwijderen voor {{name}}.", "deleteBody": "Kies wat je wilt verwijderen voor {{name}}.",
"deleteVersion": "Deze versie verwijderen", "deleteVersion": "Deze versie verwijderen",
"deleteAll": "Alle versies verwijderen" "deleteAll": "Alle versies verwijderen",
"link": "Aan repository koppelen",
"unlink": "Ontkoppelen",
"linkRepo": "Naam van repository",
"linkRepoPlaceholder": "mijn-repo"
},
"labels": {
"title": "Labels",
"name": "Naam van label",
"color": "Kleur",
"empty": "Geen labels"
},
"milestones": {
"title": "Mijlpalen",
"titleLabel": "Titel van mijlpaal",
"dueOn": "Deadline",
"empty": "Geen mijlpalen",
"open": "Open",
"closed": "Gesloten",
"progress": "{{open}} open · {{closed}} gesloten"
}, },
"credentials": { "credentials": {
"title": "Inloggegevens", "title": "Inloggegevens",
+12
View File
@@ -21,6 +21,8 @@ import { FilesScreen } from '@/features/repository/screens/files-screen';
import { FindFileScreen } from '@/features/repository/screens/find-file-screen'; import { FindFileScreen } from '@/features/repository/screens/find-file-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 { LabelsScreen } from '@/features/repository/screens/labels-screen';
import { MilestonesScreen } from '@/features/repository/screens/milestones-screen';
import { ProjectsScreen } from '@/features/repository/screens/projects-screen'; import { ProjectsScreen } from '@/features/repository/screens/projects-screen';
import { ProtectionsScreen } from '@/features/repository/screens/protections-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';
@@ -221,6 +223,16 @@ export function RepositoryNavigator() {
component={ProjectsScreen} component={ProjectsScreen}
options={{ title: t('projects.title') }} options={{ title: t('projects.title') }}
/> />
<Stack.Screen
name="Labels"
component={LabelsScreen}
options={{ title: t('labels.title') }}
/>
<Stack.Screen
name="Milestones"
component={MilestonesScreen}
options={{ title: t('milestones.title') }}
/>
</Stack.Navigator> </Stack.Navigator>
); );
} }
+2
View File
@@ -66,6 +66,8 @@ export type RepositoryStackParamList = {
ActionsSettings: { owner: string; name: string }; ActionsSettings: { owner: string; name: string };
FindFile: { owner: string; name: string; ref?: string }; FindFile: { owner: string; name: string; ref?: string };
Projects: { owner: string; name: string }; Projects: { owner: string; name: string };
Labels: { owner: string; name: string };
Milestones: { owner: string; name: string };
}; };
export type RepositoriesStackParamList = { export type RepositoriesStackParamList = {