feat(phase5): actions, repo settings, collaborators, webhooks, protections, orgs, packages, credentials, release management
- API: Actions (workflows/runs/jobs/logs getText), repo create/edit/delete, collaborators, webhooks, branch protections, orgs, packages, user keys/GPG keys/tokens, release create/edit/delete - hooks: features/actions, repositories/settings-queries, features/profile - screens: Actions + run detail (expandable job logs), RepoSettings, Collaborators, Webhooks, Protections, CreateRepo, Organizations, OrgRepos, Packages, Credentials, ReleaseCompose; releases list/detail management - navigation + i18n (en/nl) wired for all new screens
This commit is contained in:
1 parent
5e8c9492b3
commit
fa1ebc9184
30 files changed
+3001
-9
No files matched your search
@@ -0,0 +1,122 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, StyleSheet, Switch, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Field } from '@/components/ui/field';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { useCreateRepo } from '@/features/repositories/settings-queries';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoriesStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoriesStackParamList, 'CreateRepo'>;
|
||||
|
||||
/** Create a repository under the authenticated user. */
|
||||
export function CreateRepoScreen({ navigation }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const create = useCreateRepo();
|
||||
|
||||
const [name, setName] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [isPrivate, setIsPrivate] = useState(false);
|
||||
const [autoInit, setAutoInit] = useState(true);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
const nameError = submitted && name.trim().length === 0 ? t('createRepo.nameRequired') : undefined;
|
||||
|
||||
const submit = () => {
|
||||
setSubmitted(true);
|
||||
if (name.trim().length === 0) return;
|
||||
create.mutate(
|
||||
{
|
||||
name: name.trim(),
|
||||
description: description.trim() || undefined,
|
||||
private: isPrivate,
|
||||
auto_init: autoInit,
|
||||
},
|
||||
{
|
||||
onSuccess: () => navigation.goBack(),
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<Field
|
||||
label={t('createRepo.name')}
|
||||
value={name}
|
||||
onChangeText={setName}
|
||||
placeholder={t('createRepo.namePlaceholder')}
|
||||
showError={Boolean(nameError)}
|
||||
error={nameError}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
testID="repo-name"
|
||||
/>
|
||||
<Field
|
||||
label={t('repo.description')}
|
||||
value={description}
|
||||
onChangeText={setDescription}
|
||||
autoCapitalize="sentences"
|
||||
/>
|
||||
<Card>
|
||||
<View style={styles.switchRow}>
|
||||
<AppText variant="bodyMedium" style={styles.switchLabel}>
|
||||
{t('repositories.private')}
|
||||
</AppText>
|
||||
<Switch
|
||||
value={isPrivate}
|
||||
onValueChange={setIsPrivate}
|
||||
trackColor={{ true: colors.primary, false: colors.border }}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.switchRow}>
|
||||
<View style={styles.switchLabel}>
|
||||
<AppText variant="bodyMedium">{t('createRepo.autoInit')}</AppText>
|
||||
<AppText variant="caption" tone="tertiary">
|
||||
{t('createRepo.autoInitHelp')}
|
||||
</AppText>
|
||||
</View>
|
||||
<Switch
|
||||
value={autoInit}
|
||||
onValueChange={setAutoInit}
|
||||
trackColor={{ true: colors.primary, false: colors.border }}
|
||||
/>
|
||||
</View>
|
||||
</Card>
|
||||
|
||||
{create.isError ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{apiErrorMessage(create.error, t)}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
label={t('createRepo.submit')}
|
||||
onPress={submit}
|
||||
loading={create.isPending}
|
||||
disabled={name.trim().length === 0}
|
||||
fullWidth
|
||||
testID="repo-create-submit"
|
||||
/>
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
switchRow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
gap: spacing.md,
|
||||
marginTop: spacing.sm,
|
||||
},
|
||||
switchLabel: { flex: 1 },
|
||||
});
|
||||
Reference in new issue
Block a user