feat(phase5): star/watch/fork, releases, wiki fallback, capability probe
- endpoints: is-starred (404→false), star/unstar, subscription watch/unwatch, fork, releases list/detail - hooks: useIsStarred/useToggleStar, useSubscription/useToggleWatch, useForkRepository, useReleases/useRelease - repo overview: star/watch/fork actions, Releases + Wiki entries (wiki via explicit browser fallback gated by capability probe) - screens: Releases list, Release detail with downloadable assets - core/capabilities: version parsing + per-capability minimum versions + tests - i18n (en/nl); README/ROADMAP/FEATURE_PARITY updated for phases 3-5
This commit is contained in:
1 parent
c9dd49446a
commit
5e8c9492b3
16 files changed
+769
-24
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Linking, StyleSheet, View } from 'react-native';
|
||||
import { Alert, Linking, StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
@@ -13,8 +13,17 @@ import { LabelChip } from '@/components/ui/label-chip';
|
||||
import { ListItem } from '@/components/ui/list-item';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { parseGiteaVersion, supports } from '@/core/capabilities';
|
||||
import { buildEditorUrl } from '@/core/utils/editor-url';
|
||||
import { useRepository, useRepositoryLanguages } from '@/features/repositories/queries';
|
||||
import {
|
||||
useForkRepository,
|
||||
useIsStarred,
|
||||
useRepository,
|
||||
useRepositoryLanguages,
|
||||
useSubscription,
|
||||
useToggleStar,
|
||||
useToggleWatch,
|
||||
} from '@/features/repositories/queries';
|
||||
import { decodeBase64, useReadme } from '@/features/repository/queries';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { useSettingsStore } from '@/features/settings/settings-store';
|
||||
@@ -38,6 +47,35 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
|
||||
const readmeRef = ref ?? repo?.default_branch;
|
||||
const readmeQuery = useReadme(owner, name, readmeRef);
|
||||
const languagesQuery = useRepositoryLanguages(owner, name);
|
||||
const isStarred = useIsStarred(owner, name);
|
||||
const toggleStar = useToggleStar(owner, name);
|
||||
const subscription = useSubscription(owner, name);
|
||||
const toggleWatch = useToggleWatch(owner, name);
|
||||
const forkRepo = useForkRepository(owner, name);
|
||||
|
||||
const version = parseGiteaVersion(instance?.version);
|
||||
const repoUrl = instance ? `${instance.baseUrl}/${owner}/${name}` : null;
|
||||
|
||||
const confirmFork = () => {
|
||||
Alert.alert(t('repo.forkTitle'), t('repo.forkBody', { name }), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
{
|
||||
text: t('repo.fork'),
|
||||
onPress: () =>
|
||||
forkRepo.mutate(
|
||||
{},
|
||||
{
|
||||
onSuccess: (forked) =>
|
||||
Alert.alert(
|
||||
t('repo.forkedTitle'),
|
||||
t('repo.forkedBody', { name: forked.full_name ?? name }),
|
||||
),
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
),
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
const languages = useMemo(() => {
|
||||
const entries = Object.entries(languagesQuery.data ?? {});
|
||||
@@ -127,6 +165,33 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<View style={styles.actionRow}>
|
||||
<Button
|
||||
label={isStarred.data ? t('repo.unstar') : t('repo.star')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft={isStarred.data ? 'star' : 'starOutline'}
|
||||
loading={toggleStar.isPending}
|
||||
onPress={() => toggleStar.mutate(isStarred.data ?? false)}
|
||||
/>
|
||||
<Button
|
||||
label={subscription.data?.subscribed ? t('repo.unwatch') : t('repo.watch')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="bell"
|
||||
loading={toggleWatch.isPending}
|
||||
onPress={() => toggleWatch.mutate(subscription.data?.subscribed ?? false)}
|
||||
/>
|
||||
<Button
|
||||
label={t('repo.fork')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="fork"
|
||||
loading={forkRepo.isPending}
|
||||
onPress={confirmFork}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Quick navigation */}
|
||||
@@ -155,6 +220,20 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
|
||||
title={t('repo.tags')}
|
||||
onPress={() => navigation.navigate('Tags', { owner, name })}
|
||||
/>
|
||||
{repo.has_releases !== false ? (
|
||||
<ListItem
|
||||
leadingIcon="download"
|
||||
title={t('releases.title')}
|
||||
onPress={() => navigation.navigate('Releases', { owner, name })}
|
||||
/>
|
||||
) : null}
|
||||
{repo.has_wiki && supports('wiki', version) && repoUrl ? (
|
||||
<ListItem
|
||||
leadingIcon="globe"
|
||||
title={t('repo.wiki')}
|
||||
onPress={() => void Linking.openURL(`${repoUrl}/wiki`).catch(() => undefined)}
|
||||
/>
|
||||
) : null}
|
||||
{repo.has_issues !== false ? (
|
||||
<ListItem
|
||||
leadingIcon="issue"
|
||||
@@ -299,6 +378,7 @@ const styles = StyleSheet.create({
|
||||
titleRow: { flexDirection: 'row', alignItems: 'baseline', flexWrap: 'wrap' },
|
||||
name: { flexShrink: 1 },
|
||||
badges: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm, alignItems: 'center' },
|
||||
actionRow: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
||||
section: { marginTop: spacing.xl, gap: spacing.sm },
|
||||
sectionTitle: { paddingHorizontal: spacing.lg },
|
||||
card: { marginHorizontal: spacing.lg },
|
||||
|
||||
Reference in new issue
Block a user