feat(phase3): comments, issue compose, PR diff viewer, reviews, merge, checks
- API: comments CRUD, create/edit issue, milestones, collaborators, pull files, raw unified diff (getText), reviews, merge, combined commit status - hooks: comment thread + composer mutations, issue compose mutations, pull files/diff/reviews, create review, merge, combined status - UI: TextArea, ChipSelect, CommentItem, CommentComposer, native DiffView (parseDiff), StatusChecks - screens: IssueCompose (create/edit), PullFiles, PullDiff, PullReview; issue detail gains thread + close/reopen; PR detail gains reviews, merge, files, checks; commit detail shows checks - navigation/types + i18n (en/nl) updated; centralized safeHost helper - tests: diff parser, endpoint body shapes (merge capitalisation), client getText
This commit is contained in:
1 parent
f641238b6f
commit
ddd834b7ac
32 files changed
+2546
-68
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { useState } from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { TextArea } from '@/components/ui/text-area';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
export interface CommentComposerProps {
|
||||
onSubmit: (body: string) => Promise<unknown> | void;
|
||||
pending?: boolean;
|
||||
errorMessage?: string | null;
|
||||
}
|
||||
|
||||
/** Reusable comment box for issue and pull-request threads. */
|
||||
export function CommentComposer({ onSubmit, pending = false, errorMessage }: CommentComposerProps) {
|
||||
const { t } = useTranslation();
|
||||
const [text, setText] = useState('');
|
||||
|
||||
const submit = async () => {
|
||||
const body = text.trim();
|
||||
if (body.length === 0) return;
|
||||
await onSubmit(body);
|
||||
setText('');
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<TextArea
|
||||
label={t('comments.add')}
|
||||
value={text}
|
||||
onChangeText={setText}
|
||||
placeholder={t('comments.placeholder')}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
minHeight={96}
|
||||
testID="comment-input"
|
||||
/>
|
||||
{errorMessage ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{errorMessage}
|
||||
</AppText>
|
||||
) : null}
|
||||
<View style={styles.actions}>
|
||||
<Button
|
||||
label={t('comments.submit')}
|
||||
onPress={() => void submit()}
|
||||
loading={pending}
|
||||
disabled={text.trim().length === 0}
|
||||
testID="comment-submit"
|
||||
/>
|
||||
</View>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
actions: { flexDirection: 'row', justifyContent: 'flex-end', marginTop: spacing.sm },
|
||||
});
|
||||
@@ -0,0 +1,162 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, Pressable, StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Icon } from '@/components/ui/icon';
|
||||
import { TextArea } from '@/components/ui/text-area';
|
||||
import type { Comment } from '@/core/api/types';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
export interface CommentItemProps {
|
||||
comment: Comment;
|
||||
baseUrl?: string | null;
|
||||
token?: string | null;
|
||||
host?: string | null;
|
||||
/** The signed-in user authored this comment (enables edit/delete). */
|
||||
isOwn: boolean;
|
||||
updating?: boolean;
|
||||
onUpdate?: (body: string) => Promise<unknown> | void;
|
||||
onDelete?: () => Promise<unknown> | void;
|
||||
}
|
||||
|
||||
/** One comment on an issue or pull request, with inline edit/delete for the author. */
|
||||
export function CommentItem({
|
||||
comment,
|
||||
baseUrl,
|
||||
token,
|
||||
host,
|
||||
isOwn,
|
||||
updating = false,
|
||||
onUpdate,
|
||||
onDelete,
|
||||
}: CommentItemProps) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [draft, setDraft] = useState(comment.body ?? '');
|
||||
|
||||
const author = comment.user;
|
||||
const edited =
|
||||
comment.updated_at && comment.created_at && comment.updated_at !== comment.created_at;
|
||||
|
||||
const confirmDelete = () => {
|
||||
if (!onDelete) return;
|
||||
Alert.alert(t('comments.deleteTitle'), t('comments.deleteBody'), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
{ text: t('common.delete'), style: 'destructive', onPress: () => void onDelete() },
|
||||
]);
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
if (!onUpdate || draft.trim().length === 0) return;
|
||||
await onUpdate(draft.trim());
|
||||
setEditing(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<View style={styles.header}>
|
||||
<Avatar
|
||||
url={author?.avatar_url}
|
||||
name={author?.login ?? '?'}
|
||||
size={28}
|
||||
token={token}
|
||||
host={host}
|
||||
/>
|
||||
<AppText variant="bodyMedium" style={styles.login} numberOfLines={1}>
|
||||
{author?.login ?? t('common.unknown')}
|
||||
</AppText>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{formatRelativeTime(comment.created_at, t)}
|
||||
{edited ? ` · ${t('comments.edited')}` : ''}
|
||||
</AppText>
|
||||
</View>
|
||||
|
||||
{editing ? (
|
||||
<View style={styles.editBox}>
|
||||
<TextArea value={draft} onChangeText={setDraft} autoFocus minHeight={100} />
|
||||
<View style={styles.editActions}>
|
||||
<Button
|
||||
label={t('common.cancel')}
|
||||
variant="ghost"
|
||||
size="md"
|
||||
onPress={() => {
|
||||
setDraft(comment.body ?? '');
|
||||
setEditing(false);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
label={t('common.save')}
|
||||
size="md"
|
||||
loading={updating}
|
||||
disabled={draft.trim().length === 0}
|
||||
onPress={() => void save()}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
) : comment.body && comment.body.trim().length > 0 ? (
|
||||
<Markdown content={comment.body} baseUrl={baseUrl ?? undefined} />
|
||||
) : (
|
||||
<AppText variant="secondary" tone="tertiary">
|
||||
{t('comments.emptyBody')}
|
||||
</AppText>
|
||||
)}
|
||||
|
||||
{isOwn && !editing && (onUpdate || onDelete) ? (
|
||||
<View style={[styles.actions, { borderTopColor: colors.border }]}>
|
||||
{onUpdate ? (
|
||||
<Pressable
|
||||
onPress={() => setEditing(true)}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={t('common.edit')}
|
||||
hitSlop={8}
|
||||
style={styles.actionButton}
|
||||
>
|
||||
<Icon name="edit" size={15} color={colors.textTertiary} />
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('common.edit')}
|
||||
</AppText>
|
||||
</Pressable>
|
||||
) : null}
|
||||
{onDelete ? (
|
||||
<Pressable
|
||||
onPress={confirmDelete}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={t('common.delete')}
|
||||
hitSlop={8}
|
||||
style={styles.actionButton}
|
||||
>
|
||||
<Icon name="trash" size={15} color={colors.error} />
|
||||
<AppText variant="caption" tone="error">
|
||||
{t('common.delete')}
|
||||
</AppText>
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, marginBottom: spacing.sm },
|
||||
login: { flexShrink: 1, fontWeight: '600' },
|
||||
editBox: { gap: spacing.sm },
|
||||
editActions: { flexDirection: 'row', justifyContent: 'flex-end', gap: spacing.sm },
|
||||
actions: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-end',
|
||||
gap: spacing.lg,
|
||||
borderTopWidth: StyleSheet.hairlineWidth,
|
||||
marginTop: spacing.md,
|
||||
paddingTop: spacing.sm,
|
||||
},
|
||||
actionButton: { flexDirection: 'row', alignItems: 'center', gap: spacing.xs },
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
/** Unified-diff parser used by the pull request diff viewer. */
|
||||
|
||||
import { parseDiff } from './diff';
|
||||
|
||||
const SINGLE = [
|
||||
'diff --git a/src/a.ts b/src/a.ts',
|
||||
'index 123..456 100644',
|
||||
'--- a/src/a.ts',
|
||||
'+++ b/src/a.ts',
|
||||
'@@ -1,3 +1,4 @@',
|
||||
' export const a = 1;',
|
||||
'-export const b = 2;',
|
||||
'+export const b = 3;',
|
||||
'+export const c = 4;',
|
||||
' export const d = 5;',
|
||||
'',
|
||||
].join('\n');
|
||||
|
||||
describe('parseDiff', () => {
|
||||
it('returns an empty array for empty input', () => {
|
||||
expect(parseDiff('')).toEqual([]);
|
||||
});
|
||||
|
||||
it('parses file headers, hunks and line types', () => {
|
||||
const [file] = parseDiff(SINGLE);
|
||||
expect(file.path).toBe('src/a.ts');
|
||||
expect(file.additions).toBe(2);
|
||||
expect(file.deletions).toBe(1);
|
||||
|
||||
const types = file.lines.map((line) => line.type);
|
||||
expect(types).toContain('hunk');
|
||||
expect(types.filter((type) => type === 'add')).toHaveLength(2);
|
||||
expect(types.filter((type) => type === 'del')).toHaveLength(1);
|
||||
expect(types.filter((type) => type === 'context')).toHaveLength(3);
|
||||
|
||||
const add = file.lines.find((line) => line.type === 'add');
|
||||
expect(add?.text).toBe('export const b = 3;');
|
||||
});
|
||||
|
||||
it('tracks old and new line numbers', () => {
|
||||
const [file] = parseDiff(SINGLE);
|
||||
const del = file.lines.find((line) => line.type === 'del');
|
||||
const add = file.lines.find((line) => line.type === 'add');
|
||||
expect(del?.oldNumber).toBe(2);
|
||||
expect(add?.newNumber).toBe(2);
|
||||
});
|
||||
|
||||
it('parses multiple files in one diff', () => {
|
||||
const multi = `${SINGLE}diff --git a/b.ts b/b.ts\n--- a/b.ts\n+++ b/b.ts\n@@ -1 +1 @@\n-old\n+new\n`;
|
||||
const files = parseDiff(multi);
|
||||
expect(files).toHaveLength(2);
|
||||
expect(files.map((file) => file.path)).toEqual(['src/a.ts', 'b.ts']);
|
||||
});
|
||||
|
||||
it('captures previous paths for renames', () => {
|
||||
const rename = [
|
||||
'diff --git a/old.ts b/new.ts',
|
||||
'similarity index 90%',
|
||||
'rename from old.ts',
|
||||
'rename to new.ts',
|
||||
'--- a/old.ts',
|
||||
'+++ b/new.ts',
|
||||
'@@ -1 +1 @@',
|
||||
'-a',
|
||||
'+b',
|
||||
].join('\n');
|
||||
const [file] = parseDiff(rename);
|
||||
expect(file.path).toBe('new.ts');
|
||||
expect(file.previousPath).toBe('old.ts');
|
||||
});
|
||||
|
||||
it('keeps unknown metadata lines instead of dropping them', () => {
|
||||
const [file] = parseDiff('diff --git a/x b/x\nnew file mode 100644\n');
|
||||
expect(file.lines.some((line) => line.type === 'meta')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,196 @@
|
||||
/**
|
||||
* Unified-diff parsing and rendering.
|
||||
*
|
||||
* Gitea serves pull-request diffs as plain text (`GET /pulls/{index}.diff`).
|
||||
* We parse them into typed lines so they can be rendered natively (no WebView),
|
||||
* with the theme's diff colors. `parseDiff` is pure and unit-tested.
|
||||
*/
|
||||
|
||||
import { ScrollView, StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { fontFamily, fontSize, spacing } from '@/theme/tokens';
|
||||
|
||||
export type DiffLineType = 'add' | 'del' | 'context' | 'hunk' | 'meta';
|
||||
|
||||
export interface DiffLine {
|
||||
type: DiffLineType;
|
||||
text: string;
|
||||
oldNumber?: number;
|
||||
newNumber?: number;
|
||||
}
|
||||
|
||||
export interface DiffFile {
|
||||
path: string;
|
||||
previousPath?: string;
|
||||
pending: boolean;
|
||||
lines: DiffLine[];
|
||||
additions: number;
|
||||
deletions: number;
|
||||
}
|
||||
|
||||
function stripPrefix(value: string): string {
|
||||
return value.startsWith('a/') || value.startsWith('b/') ? value.slice(2) : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a unified diff into per-file hunks. Unknown/`index`/mode lines are kept
|
||||
* as `meta` (dimmed) so no content is silently dropped.
|
||||
*/
|
||||
export function parseDiff(raw: string): DiffFile[] {
|
||||
if (!raw) return [];
|
||||
const files: DiffFile[] = [];
|
||||
let current: DiffFile | null = null;
|
||||
let oldLine = 0;
|
||||
let newLine = 0;
|
||||
|
||||
const startFile = (): DiffFile => {
|
||||
const file: DiffFile = { path: '', pending: true, lines: [], additions: 0, deletions: 0 };
|
||||
files.push(file);
|
||||
return file;
|
||||
};
|
||||
|
||||
for (const line of raw.split('\n')) {
|
||||
if (line.startsWith('diff --git ')) {
|
||||
current = startFile();
|
||||
const match = line.match(/ b\/(.+)$/);
|
||||
if (match) {
|
||||
current.path = match[1];
|
||||
current.pending = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!current) continue;
|
||||
|
||||
if (line.startsWith('--- ')) {
|
||||
const path = stripPrefix(line.slice(4).trim());
|
||||
if (path !== '/dev/null') {
|
||||
current.previousPath = path;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('+++ ')) {
|
||||
const path = stripPrefix(line.slice(4).trim());
|
||||
if (path !== '/dev/null') {
|
||||
current.path = path;
|
||||
current.pending = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('@@')) {
|
||||
const match = line.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
|
||||
oldLine = match ? Number(match[1]) : 0;
|
||||
newLine = match ? Number(match[2]) : 0;
|
||||
current.lines.push({ type: 'hunk', text: line });
|
||||
continue;
|
||||
}
|
||||
|
||||
const first = line.charAt(0);
|
||||
if (first === '+') {
|
||||
current.lines.push({ type: 'add', text: line.slice(1), newNumber: newLine++ });
|
||||
current.additions += 1;
|
||||
} else if (first === '-') {
|
||||
current.lines.push({ type: 'del', text: line.slice(1), oldNumber: oldLine++ });
|
||||
current.deletions += 1;
|
||||
} else if (first === ' ' || line === '') {
|
||||
// A completely empty line is treated as context (some servers trim it).
|
||||
current.lines.push({ type: 'context', text: line.slice(1), oldNumber: oldLine++, newNumber: newLine++ });
|
||||
} else if (first === '\\') {
|
||||
current.lines.push({ type: 'meta', text: line });
|
||||
} else {
|
||||
current.lines.push({ type: 'meta', text: line });
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
function DiffLineRow({ line }: { line: DiffLine }) {
|
||||
const { colors } = useTheme();
|
||||
const style = {
|
||||
add: { backgroundColor: colors.diffAdd, color: colors.diffAddText, sign: '+' },
|
||||
del: { backgroundColor: colors.diffDel, color: colors.diffDelText, sign: '−' },
|
||||
context: { backgroundColor: 'transparent', color: colors.textSecondary, sign: ' ' },
|
||||
hunk: { backgroundColor: colors.infoMuted, color: colors.info, sign: '' },
|
||||
meta: { backgroundColor: 'transparent', color: colors.textTertiary, sign: '' },
|
||||
}[line.type];
|
||||
|
||||
return (
|
||||
<View style={[styles.line, { backgroundColor: style.backgroundColor }]}>
|
||||
<Text style={[styles.sign, { color: style.color }]}>{style.sign}</Text>
|
||||
<Text style={[styles.code, { color: style.color }]} selectable>
|
||||
{line.text.length > 0 ? line.text : ' '}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export interface DiffViewProps {
|
||||
raw: string;
|
||||
/** When set, only the matching file's hunks are rendered. */
|
||||
pathFilter?: string;
|
||||
emptyLabel: string;
|
||||
}
|
||||
|
||||
/** Horizontally scrollable, color-coded unified diff. Place inside a non-scroll Screen. */
|
||||
export function DiffView({ raw, pathFilter, emptyLabel }: DiffViewProps) {
|
||||
const files = parseDiff(raw).filter((file) => !pathFilter || file.path === pathFilter);
|
||||
|
||||
if (files.length === 0) {
|
||||
return (
|
||||
<View style={styles.empty}>
|
||||
<AppText variant="secondary" tone="tertiary" style={{ textAlign: 'center' }}>
|
||||
{emptyLabel}
|
||||
</AppText>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerStyle={styles.container}>
|
||||
{files.map((file) => (
|
||||
<View key={file.path || 'file'}>
|
||||
<View style={styles.fileHeader}>
|
||||
<AppText variant="label" numberOfLines={2} style={styles.filePath}>
|
||||
{file.previousPath && file.previousPath !== file.path
|
||||
? `${file.previousPath} → ${file.path}`
|
||||
: file.path}
|
||||
</AppText>
|
||||
</View>
|
||||
<ScrollView horizontal showsHorizontalScrollIndicator>
|
||||
<View>
|
||||
{file.lines.map((line, index) => (
|
||||
<DiffLineRow key={index} line={line} />
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { paddingBottom: spacing.xxl },
|
||||
empty: { padding: spacing.xl },
|
||||
fileHeader: {
|
||||
paddingHorizontal: spacing.md,
|
||||
paddingVertical: spacing.sm,
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
filePath: { fontFamily: fontFamily.mono },
|
||||
line: { flexDirection: 'row', minHeight: 18 },
|
||||
sign: {
|
||||
width: 16,
|
||||
textAlign: 'center',
|
||||
fontFamily: fontFamily.mono,
|
||||
fontSize: fontSize.xs,
|
||||
},
|
||||
code: {
|
||||
fontFamily: fontFamily.mono,
|
||||
fontSize: fontSize.xs,
|
||||
lineHeight: 18,
|
||||
paddingRight: spacing.lg,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Badge, type BadgeTone } from '@/components/ui/badge';
|
||||
import { Icon, type IconName } from '@/components/ui/icon';
|
||||
import type { CombinedStatus, CommitStatusState } from '@/core/api/types';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
|
||||
type AnyState = CommitStatusState | 'no_status' | undefined;
|
||||
|
||||
function toneFor(state: AnyState): BadgeTone {
|
||||
switch (state) {
|
||||
case 'success':
|
||||
return 'success';
|
||||
case 'pending':
|
||||
return 'warning';
|
||||
case 'warning':
|
||||
return 'warning';
|
||||
case 'error':
|
||||
case 'failure':
|
||||
return 'error';
|
||||
case 'skipped':
|
||||
return 'neutral';
|
||||
default:
|
||||
return 'neutral';
|
||||
}
|
||||
}
|
||||
|
||||
function iconFor(state: AnyState): IconName {
|
||||
switch (state) {
|
||||
case 'success':
|
||||
return 'check';
|
||||
case 'error':
|
||||
case 'failure':
|
||||
return 'close';
|
||||
case 'pending':
|
||||
return 'autoRenew';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
}
|
||||
|
||||
function keyFor(state: AnyState): string {
|
||||
if (!state || state === 'no_status') return 'noStatus';
|
||||
return state;
|
||||
}
|
||||
|
||||
/** Combined CI status for a commit / pull-request head, with per-check detail. */
|
||||
export function StatusChecks({ status }: { status: CombinedStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const checks = status.statuses ?? [];
|
||||
if (checks.length === 0 && (!status.state || status.state === 'no_status')) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.headerRow}>
|
||||
<Badge tone={toneFor(status.state)} icon={iconFor(status.state)}>
|
||||
{t(`checks.${keyFor(status.state)}`)}
|
||||
</Badge>
|
||||
{checks.length > 0 ? (
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('checks.count', { count: checks.length })}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
{checks.map((check, index) => (
|
||||
<View key={`${check.context ?? 'check'}-${index}`} style={styles.checkRow}>
|
||||
<Icon
|
||||
name={iconFor(check.status)}
|
||||
size={14}
|
||||
color={
|
||||
toneFor(check.status) === 'success'
|
||||
? colors.success
|
||||
: toneFor(check.status) === 'error'
|
||||
? colors.error
|
||||
: colors.textTertiary
|
||||
}
|
||||
/>
|
||||
<View style={styles.checkBody}>
|
||||
<AppText variant="caption" style={styles.context} numberOfLines={1}>
|
||||
{check.context ?? t('checks.unnamed')}
|
||||
</AppText>
|
||||
{check.description ? (
|
||||
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
|
||||
{check.description}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { gap: spacing.sm },
|
||||
headerRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
checkRow: { flexDirection: 'row', alignItems: 'flex-start', gap: spacing.sm },
|
||||
checkBody: { flex: 1 },
|
||||
context: { fontWeight: '600' },
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Pressable, StyleSheet, View } from 'react-native';
|
||||
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Icon } from '@/components/ui/icon';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { HIT_TARGET, radius, spacing } from '@/theme/tokens';
|
||||
|
||||
export interface ChipOption {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ChipSelectProps {
|
||||
options: ChipOption[];
|
||||
selectedIds: string[];
|
||||
onToggle: (id: string) => void;
|
||||
emptyLabel?: string;
|
||||
/** Allow only one selected option (radio-like). */
|
||||
single?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi/single-select chip row used by the issue composer for labels,
|
||||
* assignees and milestones. Keeps a 44pt touch target and clear selected state.
|
||||
*/
|
||||
export function ChipSelect({
|
||||
options,
|
||||
selectedIds,
|
||||
onToggle,
|
||||
emptyLabel,
|
||||
single = false,
|
||||
}: ChipSelectProps) {
|
||||
const { colors } = useTheme();
|
||||
const selected = new Set(selectedIds);
|
||||
|
||||
if (options.length === 0) {
|
||||
return emptyLabel ? (
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{emptyLabel}
|
||||
</AppText>
|
||||
) : null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.row}>
|
||||
{options.map((option) => {
|
||||
const active = selected.has(option.id);
|
||||
return (
|
||||
<Pressable
|
||||
key={option.id}
|
||||
onPress={() => onToggle(option.id)}
|
||||
accessibilityRole={single ? 'radio' : 'checkbox'}
|
||||
accessibilityState={{ selected: active }}
|
||||
accessibilityLabel={option.label}
|
||||
style={({ pressed }) => [
|
||||
styles.chip,
|
||||
{
|
||||
borderColor: active ? colors.primary : colors.border,
|
||||
backgroundColor: active ? colors.primaryMuted : colors.surface,
|
||||
},
|
||||
pressed && !active && { backgroundColor: colors.surfacePressed },
|
||||
]}
|
||||
>
|
||||
{active ? <Icon name="check" size={12} color={colors.primary} /> : null}
|
||||
<AppText
|
||||
variant="caption"
|
||||
style={{ color: active ? colors.primary : colors.textSecondary, fontWeight: '600' }}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{option.label}
|
||||
</AppText>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
row: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
chip: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: spacing.xs,
|
||||
borderWidth: 1,
|
||||
borderRadius: radius.pill,
|
||||
paddingHorizontal: spacing.md,
|
||||
minHeight: Math.min(HIT_TARGET, 36),
|
||||
maxWidth: 220,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,101 @@
|
||||
import { Platform, StyleSheet, TextInput, View } from 'react-native';
|
||||
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { fontSize, radius, spacing } from '@/theme/tokens';
|
||||
|
||||
export interface TextAreaProps {
|
||||
label?: string;
|
||||
value: string;
|
||||
onChangeText: (text: string) => void;
|
||||
placeholder?: string;
|
||||
helper?: string;
|
||||
error?: string;
|
||||
/** Red border + error message. */
|
||||
showError?: boolean;
|
||||
editable?: boolean;
|
||||
minHeight?: number;
|
||||
autoFocus?: boolean;
|
||||
mono?: boolean;
|
||||
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
|
||||
autoCorrect?: boolean;
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
/** Labeled multiline input for issue/PR bodies and comments. */
|
||||
export function TextArea({
|
||||
label,
|
||||
value,
|
||||
onChangeText,
|
||||
placeholder,
|
||||
helper,
|
||||
error,
|
||||
showError = false,
|
||||
editable = true,
|
||||
minHeight = 120,
|
||||
autoFocus = false,
|
||||
mono = false,
|
||||
autoCapitalize = 'sentences',
|
||||
autoCorrect = true,
|
||||
testID,
|
||||
}: TextAreaProps) {
|
||||
const { colors } = useTheme();
|
||||
const borderColor = showError && error ? colors.error : colors.border;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{label ? (
|
||||
<AppText variant="label" tone="secondary">
|
||||
{label}
|
||||
</AppText>
|
||||
) : null}
|
||||
<View
|
||||
style={[
|
||||
styles.box,
|
||||
{ backgroundColor: colors.surface, borderColor, borderRadius: radius.md, minHeight },
|
||||
!editable && styles.disabled,
|
||||
]}
|
||||
>
|
||||
<TextInput
|
||||
testID={testID}
|
||||
value={value}
|
||||
onChangeText={onChangeText}
|
||||
placeholder={placeholder}
|
||||
placeholderTextColor={colors.textTertiary}
|
||||
editable={editable}
|
||||
autoFocus={autoFocus}
|
||||
multiline
|
||||
autoCapitalize={autoCapitalize}
|
||||
autoCorrect={autoCorrect}
|
||||
textAlignVertical="top"
|
||||
maxFontSizeMultiplier={2}
|
||||
style={[
|
||||
styles.input,
|
||||
{ color: colors.text, fontSize: fontSize.md, minHeight },
|
||||
mono && { fontFamily: Platform.select({ ios: 'ui-monospace', android: 'monospace' }) },
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
{showError && error ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{error}
|
||||
</AppText>
|
||||
) : helper ? (
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{helper}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { gap: spacing.xs },
|
||||
box: {
|
||||
borderWidth: 1,
|
||||
paddingHorizontal: spacing.md,
|
||||
paddingVertical: spacing.sm,
|
||||
},
|
||||
input: { padding: 0 },
|
||||
disabled: { opacity: 0.6 },
|
||||
});
|
||||
@@ -99,6 +99,33 @@ describe('GiteaClient pagination', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GiteaClient getText', () => {
|
||||
it('returns raw text and sends the token only in the Authorization header', async () => {
|
||||
const diff = 'diff --git a/x b/x\n+added\n';
|
||||
const fetchImpl = jest.fn(async () => response(diff)) as unknown as jest.Mock;
|
||||
|
||||
const text = await client(fetchImpl).getText('/repos/o/r/pulls/1.diff');
|
||||
|
||||
expect(text).toBe(diff);
|
||||
const [url, init] = fetchImpl.mock.calls[0];
|
||||
expect(url).toBe('https://codeberg.org/api/v1/repos/o/r/pulls/1.diff');
|
||||
expect(init.headers.Authorization).toBe(`token ${TOKEN}`);
|
||||
expect(url).not.toContain(TOKEN);
|
||||
});
|
||||
|
||||
it('maps a non-2xx response to an ApiError without leaking the token', async () => {
|
||||
const fetchImpl = jest.fn(async () => response('nope', 404)) as unknown as jest.Mock;
|
||||
const error = await client(fetchImpl)
|
||||
.getText('/repos/o/r/pulls/1.diff')
|
||||
.then(() => null)
|
||||
.catch((e: unknown) => e as ApiError);
|
||||
|
||||
expect(error).toBeInstanceOf(ApiError);
|
||||
expect(error?.kind).toBe('not-found');
|
||||
expect(String(error?.message)).not.toContain(TOKEN);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GiteaClient error mapping', () => {
|
||||
it('maps 401 to an unauthorized ApiError', async () => {
|
||||
const fetchImpl = jest.fn(async () =>
|
||||
|
||||
@@ -117,6 +117,66 @@ export class GiteaClient {
|
||||
return raw.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a plain-text response (e.g. a pull request `.diff`).
|
||||
*
|
||||
* Shares the timeout/abort/error-normalization contract of {@link raw}, but
|
||||
* deliberately does not parse JSON. A non-2xx response is still mapped to an
|
||||
* {@link ApiError} that never contains the URL or the token.
|
||||
*/
|
||||
async getText(path: string, options: Omit<RequestOptions, 'method' | 'body'> = {}): Promise<string> {
|
||||
const url = `${this.apiRoot}${path}${buildQuery(options.query ?? {})}`;
|
||||
const headers: Record<string, string> = { Accept: 'text/plain' };
|
||||
if (this.token) headers.Authorization = `token ${this.token}`;
|
||||
|
||||
const controller = new AbortController();
|
||||
let timedOut = false;
|
||||
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
||||
const timer = setTimeout(() => {
|
||||
timedOut = true;
|
||||
controller.abort();
|
||||
}, timeoutMs);
|
||||
const onCallerAbort = () => controller.abort();
|
||||
if (options.signal) {
|
||||
if (options.signal.aborted) {
|
||||
clearTimeout(timer);
|
||||
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
|
||||
}
|
||||
options.signal.addEventListener('abort', onCallerAbort);
|
||||
}
|
||||
|
||||
let response: Response;
|
||||
try {
|
||||
response = await this.fetchImpl(url, { method: 'GET', headers, signal: controller.signal });
|
||||
} catch (error) {
|
||||
if (timedOut) {
|
||||
throw new ApiError({
|
||||
kind: 'timeout',
|
||||
status: 0,
|
||||
message: 'The server took too long to respond.',
|
||||
});
|
||||
}
|
||||
if (options.signal?.aborted) {
|
||||
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
|
||||
}
|
||||
throw toApiError(error);
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
options.signal?.removeEventListener('abort', onCallerAbort);
|
||||
}
|
||||
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
const kind = ApiError.kindForStatus(response.status);
|
||||
throw new ApiError({
|
||||
kind,
|
||||
status: response.status,
|
||||
message: messageForStatus(kind, response.status, null),
|
||||
});
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a request and returns data plus pagination metadata.
|
||||
* `hasMore` uses `X-Total-Count` when present, otherwise a length heuristic
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Endpoint body-shape guards.
|
||||
*
|
||||
* Gitea's merge API is a known exception to its lowercase JSON conventions
|
||||
* (`Do`, `MergeTitleField`, … are capitalised), so it is worth pinning down.
|
||||
*/
|
||||
|
||||
import { GiteaClient } from './client';
|
||||
import { createPullReview, mergePull } from './endpoints';
|
||||
|
||||
function response(body = '{}', status = 200): Response {
|
||||
return {
|
||||
ok: status >= 200 && status < 300,
|
||||
status,
|
||||
headers: { get: () => null },
|
||||
text: async () => body,
|
||||
} as unknown as Response;
|
||||
}
|
||||
|
||||
function capture() {
|
||||
const fetchImpl = jest.fn(async () => response()) as unknown as jest.Mock;
|
||||
const client = new GiteaClient({ baseUrl: 'https://codeberg.org', token: 'tok', fetchImpl });
|
||||
return { fetchImpl, client };
|
||||
}
|
||||
|
||||
function postedBody(fetchImpl: jest.Mock): Record<string, unknown> {
|
||||
return JSON.parse(fetchImpl.mock.calls[0][1].body as string) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
describe('endpoint request bodies', () => {
|
||||
it('uses Gitea\'s capitalised merge field names', async () => {
|
||||
const { fetchImpl, client } = capture();
|
||||
await mergePull(client, 'octo', 'repo', 7, { style: 'squash', title: 'T', message: 'M' });
|
||||
const body = postedBody(fetchImpl);
|
||||
|
||||
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/pulls/7/merge');
|
||||
expect(body.Do).toBe('squash');
|
||||
expect(body.MergeTitleField).toBe('T');
|
||||
expect(body.MergeMessageField).toBe('M');
|
||||
});
|
||||
|
||||
it('submits a review with an event and body', async () => {
|
||||
const { fetchImpl, client } = capture();
|
||||
await createPullReview(client, 'octo', 'repo', 7, { event: 'REQUEST_CHANGES', body: 'please' });
|
||||
const body = postedBody(fetchImpl);
|
||||
|
||||
expect(body.event).toBe('REQUEST_CHANGES');
|
||||
expect(body.body).toBe('please');
|
||||
});
|
||||
});
|
||||
@@ -13,14 +13,20 @@ import type { GiteaClient, RequestOptions } from './client';
|
||||
import type {
|
||||
Activity,
|
||||
Branch,
|
||||
ChangedFile,
|
||||
CombinedStatus,
|
||||
Comment,
|
||||
Commit,
|
||||
ContentsEntry,
|
||||
Issue,
|
||||
Label,
|
||||
Milestone,
|
||||
NotificationCount,
|
||||
NotificationThread,
|
||||
PullRequest,
|
||||
PullReview,
|
||||
Repository,
|
||||
ReviewEvent,
|
||||
ServerVersion,
|
||||
Tag,
|
||||
User,
|
||||
@@ -388,6 +394,240 @@ export function fetchPull(
|
||||
return client.get<PullRequest>(`${repoPath(owner, repo)}/pulls/${index}`, options);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Issues, comments, labels, milestones, collaborators (write paths)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface CreateIssueInput {
|
||||
title: string;
|
||||
body?: string;
|
||||
labels?: number[];
|
||||
assignees?: string[];
|
||||
milestone?: number;
|
||||
closed?: boolean;
|
||||
}
|
||||
|
||||
export function createIssue(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
input: CreateIssueInput,
|
||||
options?: RequestOptions,
|
||||
): Promise<Issue> {
|
||||
return client.post<Issue>(`${repoPath(owner, repo)}/issues`, input, options);
|
||||
}
|
||||
|
||||
export interface EditIssueInput {
|
||||
title?: string;
|
||||
body?: string;
|
||||
state?: 'open' | 'closed';
|
||||
labels?: number[];
|
||||
assignees?: string[];
|
||||
milestone?: number | null;
|
||||
}
|
||||
|
||||
export function updateIssue(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
input: EditIssueInput,
|
||||
options?: RequestOptions,
|
||||
): Promise<Issue> {
|
||||
return client.patch<Issue>(`${repoPath(owner, repo)}/issues/${index}`, input, options);
|
||||
}
|
||||
|
||||
/** Issue and pull-request comments share this endpoint (PRs are issues in Gitea). */
|
||||
export function listIssueComments(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
params: PageParams = {},
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
return client.raw<Comment[]>(`${repoPath(owner, repo)}/issues/${index}/comments`, {
|
||||
...options,
|
||||
query: { page: params.page ?? 1, limit: params.limit ?? 30 },
|
||||
});
|
||||
}
|
||||
|
||||
export function createIssueComment(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
body: string,
|
||||
options?: RequestOptions,
|
||||
): Promise<Comment> {
|
||||
return client.post<Comment>(
|
||||
`${repoPath(owner, repo)}/issues/${index}/comments`,
|
||||
{ body },
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
export function updateIssueComment(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
commentId: number,
|
||||
body: string,
|
||||
options?: RequestOptions,
|
||||
): Promise<Comment> {
|
||||
return client.patch<Comment>(
|
||||
`${repoPath(owner, repo)}/issues/comments/${commentId}`,
|
||||
{ body },
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteIssueComment(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
commentId: number,
|
||||
options?: RequestOptions,
|
||||
): Promise<void> {
|
||||
return client.delete<void>(`${repoPath(owner, repo)}/issues/comments/${commentId}`, options);
|
||||
}
|
||||
|
||||
export function listMilestones(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
params: PageParams & { state?: 'open' | 'closed' | 'all' } = {},
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
return client.raw<Milestone[]>(`${repoPath(owner, repo)}/milestones`, {
|
||||
...options,
|
||||
query: { page: params.page ?? 1, limit: params.limit ?? 50, state: params.state ?? 'open' },
|
||||
});
|
||||
}
|
||||
|
||||
export function listCollaborators(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
params: PageParams = {},
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
return client.raw<User[]>(`${repoPath(owner, repo)}/collaborators`, {
|
||||
...options,
|
||||
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pull request files, diffs, reviews, merge
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function listPullFiles(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
params: PageParams = {},
|
||||
options?: RequestOptions,
|
||||
): Promise<ChangedFile[]> {
|
||||
return client.get<ChangedFile[]>(`${repoPath(owner, repo)}/pulls/${index}/files`, {
|
||||
...options,
|
||||
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
|
||||
});
|
||||
}
|
||||
|
||||
/** Raw unified diff for a pull request (`Accept: text/plain`). */
|
||||
export function fetchPullDiff(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
options?: RequestOptions,
|
||||
): Promise<string> {
|
||||
return client.getText(`${repoPath(owner, repo)}/pulls/${index}.diff`, options);
|
||||
}
|
||||
|
||||
export function listPullReviews(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
params: PageParams = {},
|
||||
options?: RequestOptions,
|
||||
) {
|
||||
return client.raw<PullReview[]>(`${repoPath(owner, repo)}/pulls/${index}/reviews`, {
|
||||
...options,
|
||||
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
|
||||
});
|
||||
}
|
||||
|
||||
export interface CreateReviewInput {
|
||||
event: ReviewEvent;
|
||||
body?: string;
|
||||
commitId?: string;
|
||||
}
|
||||
|
||||
export function createPullReview(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
input: CreateReviewInput,
|
||||
options?: RequestOptions,
|
||||
): Promise<PullReview> {
|
||||
return client.post<PullReview>(
|
||||
`${repoPath(owner, repo)}/pulls/${index}/reviews`,
|
||||
{ event: input.event, body: input.body ?? '', commit_id: input.commitId },
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
export type MergeStyle = 'merge' | 'squash' | 'rebase' | 'rebase-merge' | 'fast-forward-only';
|
||||
|
||||
export interface MergePullInput {
|
||||
style: MergeStyle;
|
||||
title?: string;
|
||||
message?: string;
|
||||
deleteBranchAfterMerge?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges a pull request. A 409 means the branch moved (stale head SHA) and a
|
||||
* 405 means the request is not in a mergeable state.
|
||||
*/
|
||||
export function mergePull(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
index: number,
|
||||
input: MergePullInput,
|
||||
options?: RequestOptions,
|
||||
): Promise<void> {
|
||||
return client.post<void>(
|
||||
`${repoPath(owner, repo)}/pulls/${index}/merge`,
|
||||
{
|
||||
Do: input.style,
|
||||
MergeTitleField: input.title,
|
||||
MergeMessageField: input.message,
|
||||
delete_branch_after_merge: input.deleteBranchAfterMerge,
|
||||
},
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
export function fetchCombinedStatus(
|
||||
client: GiteaClient,
|
||||
owner: string,
|
||||
repo: string,
|
||||
ref: string,
|
||||
options?: RequestOptions,
|
||||
): Promise<CombinedStatus> {
|
||||
return client.get<CombinedStatus>(
|
||||
`${repoPath(owner, repo)}/commits/${enc(ref)}/status`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Notifications
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -90,3 +90,13 @@ export function instanceHostLabel(instanceUrl: string): string {
|
||||
return instanceUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the host (including port) of a URL, or null when it cannot be parsed. */
|
||||
export function safeHost(value: string | null | undefined): string | null {
|
||||
if (!value) return null;
|
||||
try {
|
||||
return new URL(value).host;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -69,28 +69,69 @@ export const queryKeys = {
|
||||
[...queryKeys.repo(accountId, owner, name), 'commit', sha] as const,
|
||||
|
||||
// --- issues & pull requests ------------------------------------------------
|
||||
issueSearchRoot: (accountId: string) =>
|
||||
[...queryKeys.account(accountId), 'issues', 'search'] as const,
|
||||
|
||||
issueSearch: (accountId: string, params: Record<string, unknown>) =>
|
||||
[...queryKeys.account(accountId), 'issues', 'search', params] as const,
|
||||
[...queryKeys.issueSearchRoot(accountId), params] as const,
|
||||
|
||||
repoIssuesRoot: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'issues'] as const,
|
||||
|
||||
repoIssues: (
|
||||
accountId: string,
|
||||
owner: string,
|
||||
name: string,
|
||||
params: Record<string, unknown>,
|
||||
) => [...queryKeys.repo(accountId, owner, name), 'issues', params] as const,
|
||||
) => [...queryKeys.repoIssuesRoot(accountId, owner, name), params] as const,
|
||||
|
||||
issue: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'issue', index] as const,
|
||||
|
||||
issueCommentsRoot: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.issue(accountId, owner, name, index), 'comments'] as const,
|
||||
|
||||
issueComments: (
|
||||
accountId: string,
|
||||
owner: string,
|
||||
name: string,
|
||||
index: number,
|
||||
params: Record<string, unknown>,
|
||||
) => [...queryKeys.issueCommentsRoot(accountId, owner, name, index), params] as const,
|
||||
|
||||
repoMilestones: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'milestones'] as const,
|
||||
|
||||
repoCollaborators: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'collaborators'] as const,
|
||||
|
||||
repoLabels: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'labels'] as const,
|
||||
|
||||
pullsRoot: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'pulls'] as const,
|
||||
|
||||
pulls: (accountId: string, owner: string, name: string, params: Record<string, unknown>) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'pulls', params] as const,
|
||||
[...queryKeys.pullsRoot(accountId, owner, name), params] as const,
|
||||
|
||||
pull: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'pull', index] as const,
|
||||
|
||||
pullFiles: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.pull(accountId, owner, name, index), 'files'] as const,
|
||||
|
||||
pullDiff: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.pull(accountId, owner, name, index), 'diff'] as const,
|
||||
|
||||
pullReviews: (accountId: string, owner: string, name: string, index: number) =>
|
||||
[...queryKeys.pull(accountId, owner, name, index), 'reviews'] as const,
|
||||
|
||||
combinedStatus: (accountId: string, owner: string, name: string, ref: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'status', ref] as const,
|
||||
|
||||
commitsRoot: (accountId: string, owner: string, name: string) =>
|
||||
[...queryKeys.repo(accountId, owner, name), 'commits'] as const,
|
||||
|
||||
// --- notifications ---------------------------------------------------------
|
||||
notificationsRoot: (accountId: string) =>
|
||||
[...queryKeys.account(accountId), 'notifications'] as const,
|
||||
|
||||
@@ -375,6 +375,63 @@ export interface Comment {
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
/** A changed file in a pull request (GET /repos/{owner}/{repo}/pulls/{index}/files). */
|
||||
export interface ChangedFile {
|
||||
filename?: string;
|
||||
previous_filename?: string;
|
||||
status?: 'added' | 'removed' | 'modified' | 'renamed' | 'copied' | 'changed' | 'unchanged';
|
||||
additions?: number;
|
||||
deletions?: number;
|
||||
changes?: number;
|
||||
html_url?: string;
|
||||
raw_url?: string;
|
||||
contents_url?: string;
|
||||
}
|
||||
|
||||
/** A review left on a pull request. */
|
||||
export type ReviewState = 'APPROVED' | 'PENDING' | 'COMMENT' | 'REQUEST_CHANGES';
|
||||
export type ReviewEvent = 'APPROVE' | 'REQUEST_CHANGES' | 'COMMENT';
|
||||
|
||||
export interface PullReview {
|
||||
id?: number;
|
||||
user?: User;
|
||||
state?: ReviewState;
|
||||
body?: string;
|
||||
commit_id?: string;
|
||||
submitted_at?: string;
|
||||
updated_at?: string;
|
||||
stale?: boolean;
|
||||
dismissed?: boolean;
|
||||
official?: boolean;
|
||||
comments_count?: number;
|
||||
html_url?: string;
|
||||
}
|
||||
|
||||
export type CommitStatusState = 'pending' | 'success' | 'error' | 'failure' | 'warning' | 'skipped';
|
||||
|
||||
/** A single CI status (Gitea Actions or an external checker). */
|
||||
export interface CommitStatus {
|
||||
id?: number;
|
||||
status?: CommitStatusState;
|
||||
context?: string;
|
||||
description?: string;
|
||||
target_url?: string;
|
||||
url?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
creator?: User;
|
||||
}
|
||||
|
||||
/** Aggregated status of all checks for one commit. */
|
||||
export interface CombinedStatus {
|
||||
state?: CommitStatusState | 'no_status';
|
||||
sha?: string;
|
||||
total_count?: number;
|
||||
statuses?: CommitStatus[];
|
||||
commit_url?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
/** Generic pagination metadata parsed from response headers. */
|
||||
export interface PageMeta {
|
||||
page: number;
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Card } from '@/components/ui/card';
|
||||
import { IconButton } from '@/components/ui/icon-button';
|
||||
import { ListItem } from '@/components/ui/list-item';
|
||||
import { EmptyState } from '@/components/ui/state-views';
|
||||
import { safeHost } from '@/core/api/instance-url';
|
||||
import type { AccountRecord, InstanceRecord } from '@/core/accounts/types';
|
||||
import { useAccountsStore } from '@/core/accounts/accounts-store';
|
||||
import { useAccountActions } from '@/features/accounts/use-account-actions';
|
||||
@@ -158,14 +159,6 @@ export function AccountsScreen(_props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function safeHost(baseUrl: string): string | null {
|
||||
try {
|
||||
return new URL(baseUrl).host;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
group: { gap: spacing.sm },
|
||||
groupHeader: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Icon, type IconName } from '@/components/ui/icon';
|
||||
import { ListItem } from '@/components/ui/list-item';
|
||||
import { EmptyState } from '@/components/ui/state-views';
|
||||
import type { Activity, Issue } from '@/core/api/types';
|
||||
import { safeHost } from '@/core/api/instance-url';
|
||||
import { useAccountsStore } from '@/core/accounts/accounts-store';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
@@ -368,14 +369,6 @@ function InlineEmpty({
|
||||
);
|
||||
}
|
||||
|
||||
function safeHost(baseUrl: string): string | null {
|
||||
try {
|
||||
return new URL(baseUrl).host;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
pad: { paddingHorizontal: spacing.lg },
|
||||
section: { gap: spacing.sm },
|
||||
|
||||
@@ -3,27 +3,59 @@
|
||||
*
|
||||
* Cross-repo lists (the Issues / Pull Requests tabs) go through Gitea's
|
||||
* `/repos/issues/search`, which also powers PR search via `type=pulls`.
|
||||
* Write paths (comments, compose, reviews, merge) invalidate the relevant
|
||||
* account-scoped keys on success.
|
||||
*/
|
||||
|
||||
import {
|
||||
keepPreviousData,
|
||||
useInfiniteQuery,
|
||||
useMutation,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
type InfiniteData,
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import type { RawResponse } from '@/core/api/client';
|
||||
import {
|
||||
createIssue,
|
||||
createIssueComment,
|
||||
createPullReview,
|
||||
deleteIssueComment,
|
||||
fetchCombinedStatus,
|
||||
fetchIssue,
|
||||
fetchPull,
|
||||
fetchPullDiff,
|
||||
listCollaborators,
|
||||
listIssueComments,
|
||||
listMilestones,
|
||||
listPullFiles,
|
||||
listPullReviews,
|
||||
listRepoIssues,
|
||||
listRepoLabels,
|
||||
listPulls,
|
||||
mergePull,
|
||||
searchIssues,
|
||||
updateIssue,
|
||||
updateIssueComment,
|
||||
type CreateIssueInput,
|
||||
type CreateReviewInput,
|
||||
type EditIssueInput,
|
||||
type IssueSearchParams,
|
||||
type MergePullInput,
|
||||
} from '@/core/api/endpoints';
|
||||
import { queryKeys } from '@/core/api/query-keys';
|
||||
import type { Issue, Label, PullRequest } from '@/core/api/types';
|
||||
import type {
|
||||
ChangedFile,
|
||||
CombinedStatus,
|
||||
Comment,
|
||||
Issue,
|
||||
Label,
|
||||
Milestone,
|
||||
PullRequest,
|
||||
PullReview,
|
||||
User,
|
||||
} from '@/core/api/types';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
|
||||
export type IssueScope = 'assigned' | 'created' | 'reviewRequested';
|
||||
@@ -178,4 +210,232 @@ export function usePull(owner: string, name: string, index: number) {
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Comments (issues and pull requests share the endpoint)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function useIssueComments(owner: string, name: string, index: number, limit = 30) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
const params = { limit };
|
||||
|
||||
return useInfiniteQuery<
|
||||
RawResponse<Comment[]>,
|
||||
Error,
|
||||
InfiniteData<RawResponse<Comment[]>>,
|
||||
readonly unknown[],
|
||||
number
|
||||
>({
|
||||
queryKey: queryKeys.issueComments(accountId, owner, name, index, params),
|
||||
enabled: Boolean(client) && Boolean(accountId) && index > 0,
|
||||
initialPageParam: 1,
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
listIssueComments(client!, owner, name, index, { ...params, page: pageParam }, { signal }),
|
||||
getNextPageParam: (last, all) => (last.hasMore ? all.length + 1 : undefined),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
function invalidateThread(
|
||||
queryClient: ReturnType<typeof useQueryClient>,
|
||||
accountId: string,
|
||||
owner: string,
|
||||
name: string,
|
||||
index: number,
|
||||
) {
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.issueCommentsRoot(accountId, owner, name, index),
|
||||
});
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issue(accountId, owner, name, index) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.pull(accountId, owner, name, index) });
|
||||
}
|
||||
|
||||
export function useCreateIssueComment(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (body: string) => createIssueComment(client!, owner, name, index, body),
|
||||
onSuccess: () => invalidateThread(queryClient, accountId, owner, name, index),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateIssueComment(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ id, body }: { id: number; body: string }) =>
|
||||
updateIssueComment(client!, owner, name, id, body),
|
||||
onSuccess: () => invalidateThread(queryClient, accountId, owner, name, index),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteIssueComment(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => deleteIssueComment(client!, owner, name, id),
|
||||
onSuccess: () => invalidateThread(queryClient, accountId, owner, name, index),
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Compose (create / edit issues)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function useCreateIssue(owner: string, name: string) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: CreateIssueInput) => createIssue(client!, owner, name, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.repoIssuesRoot(accountId, owner, name),
|
||||
});
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issueSearchRoot(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateIssue(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: EditIssueInput) => updateIssue(client!, owner, name, index, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issue(accountId, owner, name, index) });
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.repoIssuesRoot(accountId, owner, name),
|
||||
});
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issueSearchRoot(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useMilestones(owner: string, name: string) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery({
|
||||
queryKey: queryKeys.repoMilestones(accountId, owner, name),
|
||||
enabled: Boolean(client) && Boolean(accountId),
|
||||
queryFn: ({ signal }) =>
|
||||
listMilestones(client!, owner, name, { state: 'open', limit: 50 }, { signal }).then(
|
||||
(r) => r.data,
|
||||
),
|
||||
staleTime: 5 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCollaborators(owner: string, name: string) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery({
|
||||
queryKey: queryKeys.repoCollaborators(accountId, owner, name),
|
||||
enabled: Boolean(client) && Boolean(accountId),
|
||||
queryFn: ({ signal }) =>
|
||||
listCollaborators(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
|
||||
staleTime: 5 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pull request files, diff, reviews, merge, checks
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function usePullFiles(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery<ChangedFile[]>({
|
||||
queryKey: queryKeys.pullFiles(accountId, owner, name, index),
|
||||
enabled: Boolean(client) && Boolean(accountId) && index > 0,
|
||||
queryFn: ({ signal }) => listPullFiles(client!, owner, name, index, { limit: 50 }, { signal }),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePullDiff(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery<string>({
|
||||
queryKey: queryKeys.pullDiff(accountId, owner, name, index),
|
||||
enabled: Boolean(client) && Boolean(accountId) && index > 0,
|
||||
queryFn: ({ signal }) => fetchPullDiff(client!, owner, name, index, { signal }),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePullReviews(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery<PullReview[]>({
|
||||
queryKey: queryKeys.pullReviews(accountId, owner, name, index),
|
||||
enabled: Boolean(client) && Boolean(accountId) && index > 0,
|
||||
queryFn: ({ signal }) =>
|
||||
listPullReviews(client!, owner, name, index, { limit: 50 }, { signal }).then((r) => r.data),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreatePullReview(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: CreateReviewInput) => createPullReview(client!, owner, name, index, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.pullReviews(accountId, owner, name, index),
|
||||
});
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.pull(accountId, owner, name, index) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issueSearchRoot(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useMergePull(owner: string, name: string, index: number) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: MergePullInput) => mergePull(client!, owner, name, index, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.pull(accountId, owner, name, index) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.pullsRoot(accountId, owner, name) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.repoDetail(accountId, owner, name) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issueSearchRoot(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** Aggregated CI status for a commit / PR head. */
|
||||
export function useCombinedStatus(owner: string, name: string, ref: string | undefined) {
|
||||
const { client, account } = useSession();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useQuery<CombinedStatus>({
|
||||
queryKey: queryKeys.combinedStatus(accountId, owner, name, ref ?? ''),
|
||||
enabled: Boolean(client) && Boolean(accountId) && Boolean(ref),
|
||||
queryFn: ({ signal }) => fetchCombinedStatus(client!, owner, name, ref!, { signal }),
|
||||
staleTime: 30_000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export type { Issue, Label, PullRequest };
|
||||
export type { ChangedFile, CombinedStatus, Comment, Milestone, PullReview, User };
|
||||
@@ -2,6 +2,7 @@ import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { StatusChecks } from '@/components/git/status-checks';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -9,6 +10,7 @@ import { Card } from '@/components/ui/card';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { CommitAffectedFile } from '@/core/api/types';
|
||||
import { useCombinedStatus } from '@/features/issues/queries';
|
||||
import { useCommit } from '@/features/repository/queries';
|
||||
import { formatDateTime, shortSha } from '@/core/utils/format';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
@@ -26,6 +28,7 @@ export function CommitDetailScreen({ route }: Props) {
|
||||
|
||||
const query = useCommit(owner, name, sha);
|
||||
const commit = query.data;
|
||||
const checks = useCombinedStatus(owner, name, commit?.sha ?? sha);
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
@@ -92,6 +95,8 @@ export function CommitDetailScreen({ route }: Props) {
|
||||
</Badge>
|
||||
) : null}
|
||||
|
||||
{checks.data ? <StatusChecks status={checks.data} /> : null}
|
||||
|
||||
{files.map((file, index) => (
|
||||
<FileDiff key={`${file.filename ?? index}`} file={file} />
|
||||
))}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { AppText } from '@/components/ui/app-text';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { safeHost } from '@/core/api/instance-url';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { decodeBase64, useFile } from '@/features/repository/queries';
|
||||
import { formatBytes } from '@/core/utils/format';
|
||||
@@ -134,14 +135,6 @@ export function FileViewerScreen({ route }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function safeHost(url: string): string | null {
|
||||
try {
|
||||
return new URL(url).host;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
notice: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
|
||||
markdownWrap: { paddingHorizontal: spacing.lg },
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { 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 { ChipSelect } from '@/components/ui/chip-select';
|
||||
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 {
|
||||
useCollaborators,
|
||||
useCreateIssue,
|
||||
useIssue,
|
||||
useMilestones,
|
||||
useRepoLabels,
|
||||
useUpdateIssue,
|
||||
} from '@/features/issues/queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'IssueCompose'>;
|
||||
|
||||
/** Create a new issue, or edit an existing one (title, body, labels, assignees, milestone). */
|
||||
export function IssueComposeScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name, index } = route.params;
|
||||
const editing = typeof index === 'number' && index > 0;
|
||||
|
||||
const issueQuery = useIssue(owner, name, editing ? (index as number) : 0);
|
||||
const labelsQuery = useRepoLabels(owner, name);
|
||||
const milestonesQuery = useMilestones(owner, name);
|
||||
const collaboratorsQuery = useCollaborators(owner, name);
|
||||
|
||||
const createMutation = useCreateIssue(owner, name);
|
||||
const updateMutation = useUpdateIssue(owner, name, editing ? (index as number) : 0);
|
||||
|
||||
const [title, setTitle] = useState('');
|
||||
const [body, setBody] = useState('');
|
||||
const [labelIds, setLabelIds] = useState<string[]>([]);
|
||||
const [assignees, setAssignees] = useState<string[]>([]);
|
||||
const [milestoneId, setMilestoneId] = useState<string | null>(null);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
const prefilled = useRef(false);
|
||||
|
||||
const issue = issueQuery.data;
|
||||
useEffect(() => {
|
||||
if (!editing || !issue || prefilled.current) return;
|
||||
prefilled.current = true;
|
||||
setTitle(issue.title ?? '');
|
||||
setBody(issue.body ?? '');
|
||||
setLabelIds((issue.labels ?? []).map((label) => String(label.id)).filter(Boolean));
|
||||
setAssignees((issue.assignees ?? []).map((user) => user.login).filter(Boolean));
|
||||
setMilestoneId(issue.milestone?.id ? String(issue.milestone.id) : null);
|
||||
}, [editing, issue]);
|
||||
|
||||
const labelOptions = useMemo(
|
||||
() => (labelsQuery.data ?? []).map((label) => ({ id: String(label.id), label: label.name })),
|
||||
[labelsQuery.data],
|
||||
);
|
||||
const assigneeOptions = useMemo(
|
||||
() => (collaboratorsQuery.data ?? []).map((user) => ({ id: user.login, label: user.login })),
|
||||
[collaboratorsQuery.data],
|
||||
);
|
||||
const milestoneOptions = useMemo(
|
||||
() => (milestonesQuery.data ?? []).map((m) => ({ id: String(m.id), label: m.title })),
|
||||
[milestonesQuery.data],
|
||||
);
|
||||
|
||||
const toggle = (setter: (fn: (prev: string[]) => string[]) => void) => (id: string) =>
|
||||
setter((prev) => (prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]));
|
||||
|
||||
const titleError = submitted && title.trim().length === 0 ? t('issues.compose.titleRequired') : undefined;
|
||||
const mutation = editing ? updateMutation : createMutation;
|
||||
|
||||
const submit = () => {
|
||||
setSubmitted(true);
|
||||
if (title.trim().length === 0) return;
|
||||
const payload = {
|
||||
title: title.trim(),
|
||||
body: body.trim() || undefined,
|
||||
labels: labelIds.map(Number).filter((n) => Number.isFinite(n)),
|
||||
assignees,
|
||||
milestone: milestoneId ? Number(milestoneId) : undefined,
|
||||
};
|
||||
if (editing) {
|
||||
updateMutation.mutate(payload, { onSuccess: () => navigation.goBack() });
|
||||
} else {
|
||||
createMutation.mutate(payload, {
|
||||
onSuccess: (created) =>
|
||||
navigation.replace('IssueDetail', { owner, name, index: created.number }),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (editing && issueQuery.isPending) return <LoadingView />;
|
||||
if (editing && issueQuery.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(issueQuery.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void issueQuery.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<Field
|
||||
label={t('issues.compose.title')}
|
||||
value={title}
|
||||
onChangeText={setTitle}
|
||||
placeholder={t('issues.compose.titlePlaceholder')}
|
||||
showError={Boolean(titleError)}
|
||||
error={titleError}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
testID="issue-title"
|
||||
/>
|
||||
|
||||
<TextArea
|
||||
label={t('issues.compose.body')}
|
||||
value={body}
|
||||
onChangeText={setBody}
|
||||
placeholder={t('issues.compose.bodyPlaceholder')}
|
||||
helper={t('issues.compose.bodyHelp')}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
testID="issue-body"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
<AppText variant="label" tone="secondary" style={styles.sectionLabel}>
|
||||
{t('issues.labels')}
|
||||
</AppText>
|
||||
<ChipSelect
|
||||
options={labelOptions}
|
||||
selectedIds={labelIds}
|
||||
onToggle={toggle(setLabelIds)}
|
||||
emptyLabel={t('issues.compose.noLabels')}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<AppText variant="label" tone="secondary" style={styles.sectionLabel}>
|
||||
{t('issues.compose.assignees')}
|
||||
</AppText>
|
||||
<ChipSelect
|
||||
options={assigneeOptions}
|
||||
selectedIds={assignees}
|
||||
onToggle={toggle(setAssignees)}
|
||||
emptyLabel={t('issues.compose.noAssignees')}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<AppText variant="label" tone="secondary" style={styles.sectionLabel}>
|
||||
{t('issues.milestone')}
|
||||
</AppText>
|
||||
<ChipSelect
|
||||
options={milestoneOptions}
|
||||
selectedIds={milestoneId ? [milestoneId] : []}
|
||||
onToggle={(id) => setMilestoneId((prev) => (prev === id ? null : id))}
|
||||
emptyLabel={t('issues.compose.noMilestones')}
|
||||
single
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{mutation.isError ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{apiErrorMessage(mutation.error, t)}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
label={editing ? t('issues.compose.save') : t('issues.compose.create')}
|
||||
onPress={submit}
|
||||
loading={mutation.isPending}
|
||||
disabled={title.trim().length === 0}
|
||||
fullWidth
|
||||
testID="issue-submit"
|
||||
/>
|
||||
<View style={styles.spacer} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
sectionLabel: { marginBottom: spacing.sm },
|
||||
spacer: { height: spacing.xl },
|
||||
});
|
||||
@@ -1,18 +1,31 @@
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { CommentItem } from '@/components/git/comment';
|
||||
import { CommentComposer } from '@/components/git/comment-composer';
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Badge, StatusBadge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Icon } from '@/components/ui/icon';
|
||||
import { LabelChip } from '@/components/ui/label-chip';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { safeHost } from '@/core/api/instance-url';
|
||||
import type { Comment } from '@/core/api/types';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { useIssue } from '@/features/issues/queries';
|
||||
import {
|
||||
useCreateIssueComment,
|
||||
useDeleteIssueComment,
|
||||
useIssue,
|
||||
useIssueComments,
|
||||
useUpdateIssue,
|
||||
useUpdateIssueComment,
|
||||
} from '@/features/issues/queries';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
@@ -21,15 +34,20 @@ import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'IssueDetail'>;
|
||||
|
||||
/** Full issue view: state, author, labels, milestone and rendered body. */
|
||||
export function IssueDetailScreen({ route }: Props) {
|
||||
/** Full issue view: state, author, labels, milestone, body, comments and composer. */
|
||||
export function IssueDetailScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const { instance } = useSession();
|
||||
const { instance, account, token } = useSession();
|
||||
const { owner, name, index } = route.params;
|
||||
|
||||
const query = useIssue(owner, name, index);
|
||||
const issue = query.data;
|
||||
const commentsQuery = useIssueComments(owner, name, index);
|
||||
const updateIssue = useUpdateIssue(owner, name, index);
|
||||
const createComment = useCreateIssueComment(owner, name, index);
|
||||
const updateComment = useUpdateIssueComment(owner, name, index);
|
||||
const deleteComment = useDeleteIssueComment(owner, name, index);
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
@@ -46,6 +64,12 @@ export function IssueDetailScreen({ route }: Props) {
|
||||
|
||||
const author = issue.user;
|
||||
const state = issue.state === 'closed' ? 'closed' : 'open';
|
||||
const host = instance ? safeHost(instance.baseUrl) : null;
|
||||
const comments: Comment[] = flattenPages(commentsQuery.data);
|
||||
|
||||
const toggleState = () => {
|
||||
updateIssue.mutate({ state: state === 'closed' ? 'open' : 'closed' });
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
@@ -63,6 +87,24 @@ export function IssueDetailScreen({ route }: Props) {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={styles.actionRow}>
|
||||
<Button
|
||||
label={t('common.edit')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="edit"
|
||||
onPress={() => navigation.navigate('IssueCompose', { owner, name, index })}
|
||||
/>
|
||||
<Button
|
||||
label={state === 'closed' ? t('issues.reopen') : t('issues.close')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft={state === 'closed' ? 'refresh' : 'check'}
|
||||
loading={updateIssue.isPending}
|
||||
onPress={toggleState}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={styles.authorRow}>
|
||||
<Avatar url={author?.avatar_url} name={author?.login ?? '?'} size={28} />
|
||||
<AppText variant="bodyMedium" style={styles.authorName}>
|
||||
@@ -72,8 +114,12 @@ export function IssueDetailScreen({ route }: Props) {
|
||||
|
||||
{issue.labels && issue.labels.length > 0 ? (
|
||||
<View style={styles.labels}>
|
||||
{issue.labels.map((label, index2) => (
|
||||
<LabelChip key={label.id ?? `${label.name}-${index2}`} name={label.name} color={label.color} />
|
||||
{issue.labels.map((label, labelIndex) => (
|
||||
<LabelChip
|
||||
key={label.id ?? `${label.name}-${labelIndex}`}
|
||||
name={label.name}
|
||||
color={label.color}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
@@ -97,18 +143,76 @@ export function IssueDetailScreen({ route }: Props) {
|
||||
})}
|
||||
/>
|
||||
) : null}
|
||||
{issue.milestone ? <MetaRow icon="tag" label={`${t('issues.milestone')}: ${issue.milestone.title}`} /> : null}
|
||||
{issue.milestone ? (
|
||||
<MetaRow icon="tag" label={`${t('issues.milestone')}: ${issue.milestone.title}`} />
|
||||
) : null}
|
||||
<MetaRow
|
||||
icon="mail"
|
||||
label={t('issues.comments', { count: issue.comments ?? 0 })}
|
||||
label={t('issues.comments', { count: issue.comments ?? comments.length })}
|
||||
color={colors.textSecondary}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* Comments */}
|
||||
<AppText variant="subheading" style={styles.sectionTitle}>
|
||||
{t('comments.title')}
|
||||
</AppText>
|
||||
|
||||
{commentsQuery.isPending ? (
|
||||
<LoadingView label={t('comments.loading')} />
|
||||
) : commentsQuery.isError ? (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(commentsQuery.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void commentsQuery.refetch()}
|
||||
/>
|
||||
) : comments.length === 0 ? (
|
||||
<AppText variant="secondary" tone="tertiary">
|
||||
{t('comments.empty')}
|
||||
</AppText>
|
||||
) : (
|
||||
comments.map((comment) => {
|
||||
const isOwn = Boolean(account?.login && comment.user?.login === account.login);
|
||||
const commentId = comment.id;
|
||||
return (
|
||||
<CommentItem
|
||||
key={commentId}
|
||||
comment={comment}
|
||||
baseUrl={instance?.baseUrl}
|
||||
token={token}
|
||||
host={host}
|
||||
isOwn={isOwn}
|
||||
updating={updateComment.isPending}
|
||||
onUpdate={
|
||||
commentId
|
||||
? (body) => updateComment.mutateAsync({ id: commentId, body })
|
||||
: undefined
|
||||
}
|
||||
onDelete={commentId ? () => deleteComment.mutateAsync(commentId) : undefined}
|
||||
/>
|
||||
);
|
||||
})
|
||||
)}
|
||||
|
||||
<CommentComposer
|
||||
onSubmit={(body) => createComment.mutateAsync(body)}
|
||||
pending={createComment.isPending}
|
||||
errorMessage={createComment.isError ? apiErrorMessage(createComment.error, t) : null}
|
||||
/>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
function MetaRow({ icon, label, color }: { icon: 'person' | 'tag' | 'mail'; label: string; color?: string }) {
|
||||
function MetaRow({
|
||||
icon,
|
||||
label,
|
||||
color,
|
||||
}: {
|
||||
icon: 'person' | 'tag' | 'mail';
|
||||
label: string;
|
||||
color?: string;
|
||||
}) {
|
||||
const { colors } = useTheme();
|
||||
return (
|
||||
<View style={styles.metaRow}>
|
||||
@@ -123,10 +227,12 @@ function MetaRow({ icon, label, color }: { icon: 'person' | 'tag' | 'mail'; labe
|
||||
const styles = StyleSheet.create({
|
||||
titleBlock: { gap: spacing.sm },
|
||||
stateRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
|
||||
actionRow: { flexDirection: 'row', gap: spacing.sm, flexWrap: 'wrap' },
|
||||
authorRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
authorName: { flex: 1 },
|
||||
labels: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
bodyCard: { minHeight: 80 },
|
||||
metaGrid: { gap: spacing.sm },
|
||||
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
sectionTitle: { marginTop: spacing.md },
|
||||
});
|
||||
@@ -1,17 +1,33 @@
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import { Alert, StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { CommentItem } from '@/components/git/comment';
|
||||
import { CommentComposer } from '@/components/git/comment-composer';
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
import { StatusChecks } from '@/components/git/status-checks';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Avatar } from '@/components/ui/avatar';
|
||||
import { Badge, StatusBadge } from '@/components/ui/badge';
|
||||
import { Badge, type BadgeTone, StatusBadge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { LabelChip } from '@/components/ui/label-chip';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { safeHost } from '@/core/api/instance-url';
|
||||
import type { Comment, PullReview } from '@/core/api/types';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { usePull } from '@/features/issues/queries';
|
||||
import {
|
||||
useCombinedStatus,
|
||||
useCreateIssueComment,
|
||||
useDeleteIssueComment,
|
||||
useIssueComments,
|
||||
useMergePull,
|
||||
usePull,
|
||||
usePullReviews,
|
||||
useUpdateIssueComment,
|
||||
} from '@/features/issues/queries';
|
||||
import { formatRelativeTime } from '@/core/utils/format';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
@@ -19,14 +35,41 @@ import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'PullDetail'>;
|
||||
|
||||
/** Full pull request view: state, branches, reviewers, stats and body. */
|
||||
export function PullDetailScreen({ route }: Props) {
|
||||
const REVIEW_TONE: Record<string, BadgeTone> = {
|
||||
APPROVED: 'success',
|
||||
REQUEST_CHANGES: 'error',
|
||||
COMMENT: 'neutral',
|
||||
PENDING: 'warning',
|
||||
};
|
||||
|
||||
function reviewKey(state: string | undefined): string {
|
||||
switch (state) {
|
||||
case 'APPROVED':
|
||||
return 'pulls.reviewStateApproved';
|
||||
case 'REQUEST_CHANGES':
|
||||
return 'pulls.reviewStateChanges';
|
||||
case 'COMMENT':
|
||||
return 'pulls.reviewStateComment';
|
||||
default:
|
||||
return 'pulls.reviewStatePending';
|
||||
}
|
||||
}
|
||||
|
||||
/** Full pull request view: state, branches, checks, reviews, comments, review/merge actions. */
|
||||
export function PullDetailScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { instance } = useSession();
|
||||
const { instance, account, token } = useSession();
|
||||
const { owner, name, index } = route.params;
|
||||
|
||||
const query = usePull(owner, name, index);
|
||||
const pull = query.data;
|
||||
const checks = useCombinedStatus(owner, name, pull?.head?.sha);
|
||||
const reviewsQuery = usePullReviews(owner, name, index);
|
||||
const commentsQuery = useIssueComments(owner, name, index);
|
||||
const createComment = useCreateIssueComment(owner, name, index);
|
||||
const updateComment = useUpdateIssueComment(owner, name, index);
|
||||
const deleteComment = useDeleteIssueComment(owner, name, index);
|
||||
const merge = useMergePull(owner, name, index);
|
||||
|
||||
if (query.isPending) return <LoadingView />;
|
||||
if (query.isError) {
|
||||
@@ -56,6 +99,30 @@ export function PullDetailScreen({ route }: Props) {
|
||||
draft: t('pulls.draft'),
|
||||
}[state];
|
||||
|
||||
const host = instance ? safeHost(instance.baseUrl) : null;
|
||||
const comments: Comment[] = flattenPages(commentsQuery.data);
|
||||
const reviews: PullReview[] = reviewsQuery.data ?? [];
|
||||
const canAct = state === 'open';
|
||||
const mergeDisabled = merge.isPending || pull.mergeable === false;
|
||||
|
||||
const doMerge = (style: 'merge' | 'squash' | 'rebase') => {
|
||||
merge.mutate(
|
||||
{ style, deleteBranchAfterMerge: false },
|
||||
{
|
||||
onSuccess: () => Alert.alert(t('pulls.mergeSuccessTitle'), t('pulls.mergeSuccessBody')),
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const confirmMerge = () => {
|
||||
Alert.alert(t('pulls.mergeConfirmTitle'), t('pulls.mergeConfirmBody'), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
{ text: t('pulls.mergeSquash'), onPress: () => doMerge('squash') },
|
||||
{ text: t('pulls.mergeCreate'), onPress: () => doMerge('merge') },
|
||||
]);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<View style={styles.titleBlock}>
|
||||
@@ -76,10 +143,72 @@ export function PullDetailScreen({ route }: Props) {
|
||||
</AppText>
|
||||
</View>
|
||||
|
||||
{/* Checks */}
|
||||
{checks.data ? <StatusChecks status={checks.data} /> : null}
|
||||
|
||||
{/* Actions */}
|
||||
<View style={styles.actionRow}>
|
||||
<Button
|
||||
label={t('pulls.files', { count: pull.changed_files ?? 0 })}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="file"
|
||||
onPress={() => navigation.navigate('PullFiles', { owner, name, index })}
|
||||
/>
|
||||
{canAct ? (
|
||||
<>
|
||||
<Button
|
||||
label={t('pulls.approve')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="check"
|
||||
onPress={() =>
|
||||
navigation.navigate('PullReview', { owner, name, index, event: 'APPROVE' })
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
label={t('pulls.requestChanges')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="close"
|
||||
onPress={() =>
|
||||
navigation.navigate('PullReview', { owner, name, index, event: 'REQUEST_CHANGES' })
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
label={t('pulls.comment')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="mail"
|
||||
onPress={() =>
|
||||
navigation.navigate('PullReview', { owner, name, index, event: 'COMMENT' })
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
label={t('pulls.merge')}
|
||||
size="md"
|
||||
iconLeft="pullRequest"
|
||||
loading={merge.isPending}
|
||||
disabled={mergeDisabled}
|
||||
onPress={confirmMerge}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
{pull.mergeable === false && canAct ? (
|
||||
<AppText variant="caption" tone="warning">
|
||||
{t('pulls.notMergeable')}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
{pull.labels && pull.labels.length > 0 ? (
|
||||
<View style={styles.labels}>
|
||||
{pull.labels.map((label, labelIndex) => (
|
||||
<LabelChip key={label.id ?? `${label.name}-${labelIndex}`} name={label.name} color={label.color} />
|
||||
<LabelChip
|
||||
key={label.id ?? `${label.name}-${labelIndex}`}
|
||||
name={label.name}
|
||||
color={label.color}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
@@ -101,7 +230,7 @@ export function PullDetailScreen({ route }: Props) {
|
||||
{t('pulls.changedFiles', { count: pull.changed_files ?? 0 })}
|
||||
</AppText>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('issues.comments', { count: pull.comments ?? 0 })}
|
||||
{t('issues.comments', { count: pull.comments ?? comments.length })}
|
||||
</AppText>
|
||||
</View>
|
||||
|
||||
@@ -122,6 +251,71 @@ export function PullDetailScreen({ route }: Props) {
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{/* Reviews */}
|
||||
{reviews.length > 0 ? (
|
||||
<>
|
||||
<AppText variant="subheading" style={styles.sectionTitle}>
|
||||
{t('pulls.reviews')}
|
||||
</AppText>
|
||||
{reviews.map((review, reviewIndex) => (
|
||||
<Card key={review.id ?? reviewIndex}>
|
||||
<View style={styles.reviewHeader}>
|
||||
<Avatar url={review.user?.avatar_url} name={review.user?.login ?? '?'} size={24} />
|
||||
<AppText variant="bodyMedium" style={styles.reviewerName} numberOfLines={1}>
|
||||
{review.user?.login ?? t('common.unknown')}
|
||||
</AppText>
|
||||
<Badge tone={REVIEW_TONE[review.state ?? 'PENDING'] ?? 'neutral'}>
|
||||
{t(reviewKey(review.state))}
|
||||
</Badge>
|
||||
</View>
|
||||
{review.body && review.body.trim().length > 0 ? (
|
||||
<Markdown content={review.body} baseUrl={instance?.baseUrl} />
|
||||
) : null}
|
||||
</Card>
|
||||
))}
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{/* Comments */}
|
||||
<AppText variant="subheading" style={styles.sectionTitle}>
|
||||
{t('comments.title')}
|
||||
</AppText>
|
||||
{commentsQuery.isPending ? (
|
||||
<LoadingView label={t('comments.loading')} />
|
||||
) : comments.length === 0 ? (
|
||||
<AppText variant="secondary" tone="tertiary">
|
||||
{t('comments.empty')}
|
||||
</AppText>
|
||||
) : (
|
||||
comments.map((comment) => {
|
||||
const isOwn = Boolean(account?.login && comment.user?.login === account.login);
|
||||
const commentId = comment.id;
|
||||
return (
|
||||
<CommentItem
|
||||
key={commentId}
|
||||
comment={comment}
|
||||
baseUrl={instance?.baseUrl}
|
||||
token={token}
|
||||
host={host}
|
||||
isOwn={isOwn}
|
||||
updating={updateComment.isPending}
|
||||
onUpdate={
|
||||
commentId
|
||||
? (body) => updateComment.mutateAsync({ id: commentId, body })
|
||||
: undefined
|
||||
}
|
||||
onDelete={commentId ? () => deleteComment.mutateAsync(commentId) : undefined}
|
||||
/>
|
||||
);
|
||||
})
|
||||
)}
|
||||
|
||||
<CommentComposer
|
||||
onSubmit={(body) => createComment.mutateAsync(body)}
|
||||
pending={createComment.isPending}
|
||||
errorMessage={createComment.isError ? apiErrorMessage(createComment.error, t) : null}
|
||||
/>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
@@ -129,10 +323,14 @@ export function PullDetailScreen({ route }: Props) {
|
||||
const styles = StyleSheet.create({
|
||||
titleBlock: { gap: spacing.sm },
|
||||
stateRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
|
||||
actionRow: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
labels: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
bodyCard: { minHeight: 80 },
|
||||
stats: { flexDirection: 'row', alignItems: 'center', gap: spacing.md, flexWrap: 'wrap' },
|
||||
reviewers: { gap: spacing.sm },
|
||||
reviewerRow: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.lg },
|
||||
reviewer: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
reviewHeader: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
reviewerName: { flexShrink: 1, flex: 1, fontWeight: '600' },
|
||||
sectionTitle: { marginTop: spacing.md },
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { DiffView } from '@/components/git/diff';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { usePullDiff } from '@/features/issues/queries';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'PullDiff'>;
|
||||
|
||||
/** Native unified diff for a pull request (all files, or a single `path`). */
|
||||
export function PullDiffScreen({ route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name, index, path } = route.params;
|
||||
const query = usePullDiff(owner, name, index);
|
||||
|
||||
if (query.isPending) return <LoadingView label={t('pulls.loadingDiff')} />;
|
||||
if (query.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(query.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void query.refetch()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Screen padded={false} scroll={false}>
|
||||
<DiffView raw={query.data ?? ''} pathFilter={path} emptyLabel={t('pulls.noChanges')} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import { 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 { Badge, type BadgeTone } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Icon } from '@/components/ui/icon';
|
||||
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { ChangedFile } from '@/core/api/types';
|
||||
import { usePullFiles } from '@/features/issues/queries';
|
||||
import { fontFamily, spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'PullFiles'>;
|
||||
|
||||
const STATUS_TONE: Record<string, BadgeTone> = {
|
||||
added: 'success',
|
||||
removed: 'error',
|
||||
modified: 'warning',
|
||||
renamed: 'info',
|
||||
copied: 'info',
|
||||
changed: 'warning',
|
||||
unchanged: 'neutral',
|
||||
};
|
||||
|
||||
function statusKey(status: string | undefined): string {
|
||||
switch (status) {
|
||||
case 'added':
|
||||
return 'pulls.fileAdded';
|
||||
case 'removed':
|
||||
return 'pulls.fileRemoved';
|
||||
case 'renamed':
|
||||
return 'pulls.fileRenamed';
|
||||
case 'copied':
|
||||
return 'pulls.fileCopied';
|
||||
case 'modified':
|
||||
case 'changed':
|
||||
return 'pulls.fileModified';
|
||||
default:
|
||||
return 'pulls.fileChanged';
|
||||
}
|
||||
}
|
||||
|
||||
/** Changed files in a pull request; tapping a file opens its diff. */
|
||||
export function PullFilesScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name, index } = route.params;
|
||||
const query = usePullFiles(owner, name, index);
|
||||
|
||||
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 files: ChangedFile[] = query.data ?? [];
|
||||
|
||||
if (files.length === 0) {
|
||||
return (
|
||||
<EmptyState icon="file" title={t('pulls.noChangedFiles')} body={t('pulls.noChangesBody')} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<Button
|
||||
label={t('pulls.viewFullDiff')}
|
||||
variant="secondary"
|
||||
iconLeft="code"
|
||||
fullWidth
|
||||
onPress={() => navigation.navigate('PullDiff', { owner, name, index })}
|
||||
/>
|
||||
<Card padded={false} variant="flat">
|
||||
{files.map((file, fileIndex) => {
|
||||
const key = file.filename ?? `file-${fileIndex}`;
|
||||
return (
|
||||
<Pressable
|
||||
key={key}
|
||||
onPress={() =>
|
||||
navigation.navigate('PullDiff', { owner, name, index, path: file.filename })
|
||||
}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={file.filename}
|
||||
style={({ pressed }) => [
|
||||
styles.row,
|
||||
fileIndex < files.length - 1 && styles.divider,
|
||||
pressed && styles.pressed,
|
||||
]}
|
||||
>
|
||||
<Icon name="file" size={16} style={styles.icon} />
|
||||
<View style={styles.body}>
|
||||
<AppText variant="bodyMedium" numberOfLines={2} style={styles.path}>
|
||||
{file.filename}
|
||||
</AppText>
|
||||
<View style={styles.meta}>
|
||||
<Badge tone={STATUS_TONE[file.status ?? 'unchanged'] ?? 'neutral'}>
|
||||
{t(statusKey(file.status))}
|
||||
</Badge>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{`+${file.additions ?? 0} −${file.deletions ?? 0}`}
|
||||
</AppText>
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
})}
|
||||
</Card>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
row: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'flex-start',
|
||||
gap: spacing.md,
|
||||
paddingHorizontal: spacing.lg,
|
||||
paddingVertical: spacing.md,
|
||||
},
|
||||
divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: 'rgba(128,128,128,0.25)' },
|
||||
pressed: { opacity: 0.6 },
|
||||
icon: { marginTop: 2 },
|
||||
body: { flex: 1, gap: spacing.xs },
|
||||
path: { fontFamily: fontFamily.mono },
|
||||
meta: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
import { useState } from 'react';
|
||||
import { 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 { TextArea } from '@/components/ui/text-area';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { ReviewEvent } from '@/core/api/types';
|
||||
import { useCreatePullReview } from '@/features/issues/queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'PullReview'>;
|
||||
|
||||
/** Submit a pull-request review: approve, request changes, or leave a comment. */
|
||||
export function PullReviewScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name, index, event } = route.params;
|
||||
const [body, setBody] = useState('');
|
||||
const mutation = useCreatePullReview(owner, name, index);
|
||||
|
||||
const requiresBody = event === 'REQUEST_CHANGES';
|
||||
const canSubmit = !requiresBody || body.trim().length > 0;
|
||||
|
||||
const submit = () => {
|
||||
if (!canSubmit) return;
|
||||
mutation.mutate(
|
||||
{ event: event as ReviewEvent, body: body.trim() || undefined },
|
||||
{ onSuccess: () => navigation.goBack() },
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<AppText variant="secondary" tone="tertiary">
|
||||
{t(`pulls.review.${event.toLowerCase()}`)}
|
||||
</AppText>
|
||||
<TextArea
|
||||
label={t('pulls.review.body')}
|
||||
value={body}
|
||||
onChangeText={setBody}
|
||||
placeholder={t('pulls.review.placeholder')}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
minHeight={140}
|
||||
testID="review-body"
|
||||
/>
|
||||
{mutation.isError ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{apiErrorMessage(mutation.error, t)}
|
||||
</AppText>
|
||||
) : null}
|
||||
<Button
|
||||
label={t('pulls.review.submit')}
|
||||
onPress={submit}
|
||||
loading={mutation.isPending}
|
||||
disabled={!canSubmit}
|
||||
fullWidth
|
||||
testID="review-submit"
|
||||
/>
|
||||
<View style={styles.spacer} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
spacer: { height: spacing.xl },
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { IssueRow } from '@/components/git/issue-row';
|
||||
import { QueryList } from '@/components/layout/query-list';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SearchBar } from '@/components/ui/search-bar';
|
||||
import { SegmentedControl } from '@/components/ui/segmented';
|
||||
import { EmptyState } from '@/components/ui/state-views';
|
||||
@@ -52,6 +53,15 @@ export function RepoIssuesScreen({ navigation, route }: Props) {
|
||||
]}
|
||||
/>
|
||||
</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) => (
|
||||
@@ -67,4 +77,5 @@ export function RepoIssuesScreen({ navigation, route }: Props) {
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
filters: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
|
||||
newIssue: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
|
||||
});
|
||||
@@ -223,7 +223,25 @@
|
||||
"labels": "Labels",
|
||||
"milestone": "Milestone",
|
||||
"noDescription": "No description provided",
|
||||
"notFound": "This issue could not be found."
|
||||
"notFound": "This issue could not be found.",
|
||||
"reopen": "Reopen",
|
||||
"close": "Close",
|
||||
"compose": {
|
||||
"createTitle": "New issue",
|
||||
"editTitle": "Edit issue",
|
||||
"title": "Title",
|
||||
"titlePlaceholder": "Short, descriptive title",
|
||||
"titleRequired": "A title is required.",
|
||||
"body": "Description",
|
||||
"bodyPlaceholder": "Describe the issue…",
|
||||
"bodyHelp": "Markdown is supported.",
|
||||
"assignees": "Assignees",
|
||||
"noLabels": "No labels available",
|
||||
"noAssignees": "No collaborators available",
|
||||
"noMilestones": "No open milestones",
|
||||
"create": "Create issue",
|
||||
"save": "Save changes"
|
||||
}
|
||||
},
|
||||
"pulls": {
|
||||
"title": "Pull requests",
|
||||
@@ -244,7 +262,68 @@
|
||||
"reviewers": "Reviewers",
|
||||
"noDescription": "No description provided",
|
||||
"changedFiles": "{{count}} files changed",
|
||||
"notFound": "This pull request could not be found."
|
||||
"notFound": "This pull request could not be found.",
|
||||
"files": "Files ({{count}})",
|
||||
"changedFilesTitle": "Changed files",
|
||||
"diff": "Diff",
|
||||
"viewFullDiff": "View full diff",
|
||||
"loadingDiff": "Loading diff…",
|
||||
"noChanges": "No changes to display",
|
||||
"noChangedFiles": "No changed files",
|
||||
"noChangesBody": "This pull request has no file changes.",
|
||||
"fileAdded": "Added",
|
||||
"fileRemoved": "Removed",
|
||||
"fileModified": "Modified",
|
||||
"fileRenamed": "Renamed",
|
||||
"fileCopied": "Copied",
|
||||
"fileChanged": "Changed",
|
||||
"reviews": "Reviews",
|
||||
"approve": "Approve",
|
||||
"requestChanges": "Request changes",
|
||||
"comment": "Comment",
|
||||
"merge": "Merge",
|
||||
"mergeSquash": "Squash",
|
||||
"mergeCreate": "Merge commit",
|
||||
"mergeConfirmTitle": "Merge pull request?",
|
||||
"mergeConfirmBody": "Choose how this pull request should be merged.",
|
||||
"mergeSuccessTitle": "Merged",
|
||||
"mergeSuccessBody": "The pull request was merged.",
|
||||
"notMergeable": "This pull request cannot be merged automatically.",
|
||||
"reviewStateApproved": "Approved",
|
||||
"reviewStateChanges": "Changes requested",
|
||||
"reviewStateComment": "Commented",
|
||||
"reviewStatePending": "Pending",
|
||||
"review": {
|
||||
"approve": "Approving this pull request.",
|
||||
"request_changes": "Requesting changes to this pull request.",
|
||||
"comment": "Leaving a review comment.",
|
||||
"body": "Review comment",
|
||||
"placeholder": "Write your review…",
|
||||
"submit": "Submit review"
|
||||
}
|
||||
},
|
||||
"comments": {
|
||||
"title": "Comments",
|
||||
"add": "Add a comment",
|
||||
"placeholder": "Leave a comment…",
|
||||
"submit": "Comment",
|
||||
"loading": "Loading comments…",
|
||||
"empty": "No comments yet",
|
||||
"emptyBody": "No content",
|
||||
"edited": "edited",
|
||||
"deleteTitle": "Delete comment?",
|
||||
"deleteBody": "This comment will be permanently deleted."
|
||||
},
|
||||
"checks": {
|
||||
"success": "Checks passed",
|
||||
"pending": "Checks pending",
|
||||
"failure": "Checks failed",
|
||||
"error": "Checks errored",
|
||||
"warning": "Checks warning",
|
||||
"skipped": "Checks skipped",
|
||||
"noStatus": "No checks",
|
||||
"count": "{{count}} checks",
|
||||
"unnamed": "check"
|
||||
},
|
||||
"inbox": {
|
||||
"title": "Inbox",
|
||||
|
||||
@@ -223,7 +223,25 @@
|
||||
"labels": "Labels",
|
||||
"milestone": "Mijlpaal",
|
||||
"noDescription": "Geen beschrijving opgegeven",
|
||||
"notFound": "Deze issue kon niet worden gevonden."
|
||||
"notFound": "Deze issue kon niet worden gevonden.",
|
||||
"reopen": "Heropenen",
|
||||
"close": "Sluiten",
|
||||
"compose": {
|
||||
"createTitle": "Nieuwe issue",
|
||||
"editTitle": "Issue bewerken",
|
||||
"title": "Titel",
|
||||
"titlePlaceholder": "Korte, beschrijvende titel",
|
||||
"titleRequired": "Een titel is verplicht.",
|
||||
"body": "Beschrijving",
|
||||
"bodyPlaceholder": "Beschrijf de issue…",
|
||||
"bodyHelp": "Markdown wordt ondersteund.",
|
||||
"assignees": "Toegewezen aan",
|
||||
"noLabels": "Geen labels beschikbaar",
|
||||
"noAssignees": "Geen medewerkers beschikbaar",
|
||||
"noMilestones": "Geen open mijlpalen",
|
||||
"create": "Issue aanmaken",
|
||||
"save": "Wijzigingen opslaan"
|
||||
}
|
||||
},
|
||||
"pulls": {
|
||||
"title": "Pull requests",
|
||||
@@ -244,7 +262,68 @@
|
||||
"reviewers": "Reviewers",
|
||||
"noDescription": "Geen beschrijving opgegeven",
|
||||
"changedFiles": "{{count}} bestanden gewijzigd",
|
||||
"notFound": "Deze pull request kon niet worden gevonden."
|
||||
"notFound": "Deze pull request kon niet worden gevonden.",
|
||||
"files": "Bestanden ({{count}})",
|
||||
"changedFilesTitle": "Gewijzigde bestanden",
|
||||
"diff": "Diff",
|
||||
"viewFullDiff": "Volledige diff bekijken",
|
||||
"loadingDiff": "Diff laden…",
|
||||
"noChanges": "Geen wijzigingen om te tonen",
|
||||
"noChangedFiles": "Geen gewijzigde bestanden",
|
||||
"noChangesBody": "Deze pull request heeft geen bestandswijzigingen.",
|
||||
"fileAdded": "Toegevoegd",
|
||||
"fileRemoved": "Verwijderd",
|
||||
"fileModified": "Gewijzigd",
|
||||
"fileRenamed": "Hernoemd",
|
||||
"fileCopied": "Gekopieerd",
|
||||
"fileChanged": "Gewijzigd",
|
||||
"reviews": "Reviews",
|
||||
"approve": "Goedkeuren",
|
||||
"requestChanges": "Wijzigingen aanvragen",
|
||||
"comment": "Reageren",
|
||||
"merge": "Mergen",
|
||||
"mergeSquash": "Squash",
|
||||
"mergeCreate": "Merge-commit",
|
||||
"mergeConfirmTitle": "Pull request mergen?",
|
||||
"mergeConfirmBody": "Kies hoe deze pull request moet worden gemerged.",
|
||||
"mergeSuccessTitle": "Gemerged",
|
||||
"mergeSuccessBody": "De pull request is gemerged.",
|
||||
"notMergeable": "Deze pull request kan niet automatisch worden gemerged.",
|
||||
"reviewStateApproved": "Goedgekeurd",
|
||||
"reviewStateChanges": "Wijzigingen gevraagd",
|
||||
"reviewStateComment": "Becommentarieerd",
|
||||
"reviewStatePending": "In behandeling",
|
||||
"review": {
|
||||
"approve": "Deze pull request goedkeuren.",
|
||||
"request_changes": "Wijzigingen aanvragen voor deze pull request.",
|
||||
"comment": "Een review-opmerking plaatsen.",
|
||||
"body": "Review-opmerking",
|
||||
"placeholder": "Schrijf je review…",
|
||||
"submit": "Review versturen"
|
||||
}
|
||||
},
|
||||
"comments": {
|
||||
"title": "Reacties",
|
||||
"add": "Reactie toevoegen",
|
||||
"placeholder": "Laat een reactie achter…",
|
||||
"submit": "Reageren",
|
||||
"loading": "Reacties laden…",
|
||||
"empty": "Nog geen reacties",
|
||||
"emptyBody": "Geen inhoud",
|
||||
"edited": "bewerkt",
|
||||
"deleteTitle": "Reactie verwijderen?",
|
||||
"deleteBody": "Deze reactie wordt permanent verwijderd."
|
||||
},
|
||||
"checks": {
|
||||
"success": "Checks geslaagd",
|
||||
"pending": "Checks in behandeling",
|
||||
"failure": "Checks mislukt",
|
||||
"error": "Checks met fout",
|
||||
"warning": "Checks met waarschuwing",
|
||||
"skipped": "Checks overgeslagen",
|
||||
"noStatus": "Geen checks",
|
||||
"count": "{{count}} checks",
|
||||
"unnamed": "check"
|
||||
},
|
||||
"inbox": {
|
||||
"title": "Inbox",
|
||||
|
||||
@@ -12,8 +12,12 @@ import { CommitDetailScreen } from '@/features/repository/screens/commit-detail-
|
||||
import { CommitsScreen } from '@/features/repository/screens/commits-screen';
|
||||
import { FileViewerScreen } from '@/features/repository/screens/file-viewer-screen';
|
||||
import { FilesScreen } from '@/features/repository/screens/files-screen';
|
||||
import { IssueComposeScreen } from '@/features/repository/screens/issue-compose-screen';
|
||||
import { IssueDetailScreen } from '@/features/repository/screens/issue-detail-screen';
|
||||
import { PullDetailScreen } from '@/features/repository/screens/pull-detail-screen';
|
||||
import { PullDiffScreen } from '@/features/repository/screens/pull-diff-screen';
|
||||
import { PullFilesScreen } from '@/features/repository/screens/pull-files-screen';
|
||||
import { PullReviewScreen } from '@/features/repository/screens/pull-review-screen';
|
||||
import { RepoIssuesScreen } from '@/features/repository/screens/repo-issues-screen';
|
||||
import { RepoOverviewScreen } from '@/features/repository/screens/repo-overview-screen';
|
||||
import { RepoPullsScreen } from '@/features/repository/screens/repo-pulls-screen';
|
||||
@@ -83,6 +87,13 @@ export function RepositoryNavigator() {
|
||||
component={IssueDetailScreen}
|
||||
options={({ route }) => ({ title: `#${route.params.index}` })}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="IssueCompose"
|
||||
component={IssueComposeScreen}
|
||||
options={({ route }) => ({
|
||||
title: route.params.index ? t('issues.compose.editTitle') : t('issues.compose.createTitle'),
|
||||
})}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="RepoPulls"
|
||||
component={RepoPullsScreen}
|
||||
@@ -93,6 +104,30 @@ export function RepositoryNavigator() {
|
||||
component={PullDetailScreen}
|
||||
options={({ route }) => ({ title: `#${route.params.index}` })}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="PullFiles"
|
||||
component={PullFilesScreen}
|
||||
options={{ title: t('pulls.changedFilesTitle') }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="PullDiff"
|
||||
component={PullDiffScreen}
|
||||
options={({ route }) => ({
|
||||
title: route.params.path ? lastSegment(route.params.path, t('pulls.diff')) : t('pulls.diff'),
|
||||
})}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="PullReview"
|
||||
component={PullReviewScreen}
|
||||
options={({ route }) => ({
|
||||
title:
|
||||
route.params.event === 'APPROVE'
|
||||
? t('pulls.approve')
|
||||
: route.params.event === 'REQUEST_CHANGES'
|
||||
? t('pulls.requestChanges')
|
||||
: t('pulls.comment'),
|
||||
})}
|
||||
/>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
import type { NavigatorScreenParams } from '@react-navigation/native';
|
||||
|
||||
import type { ReviewEvent } from '@/core/api/types';
|
||||
|
||||
export type AuthStackParamList = {
|
||||
Welcome: undefined;
|
||||
Connect: { baseUrl?: string } | undefined;
|
||||
@@ -48,8 +50,12 @@ export type RepositoryStackParamList = {
|
||||
Tags: { owner: string; name: string };
|
||||
RepoIssues: { owner: string; name: string };
|
||||
IssueDetail: { owner: string; name: string; index: number };
|
||||
IssueCompose: { owner: string; name: string; index?: number };
|
||||
RepoPulls: { owner: string; name: string };
|
||||
PullDetail: { owner: string; name: string; index: number };
|
||||
PullFiles: { owner: string; name: string; index: number };
|
||||
PullDiff: { owner: string; name: string; index: number; path?: string };
|
||||
PullReview: { owner: string; name: string; index: number; event: ReviewEvent };
|
||||
};
|
||||
|
||||
export type SettingsStackParamList = {
|
||||
|
||||
Reference in new issue
Block a user