feat: release asset upload, transfer, Actions secrets/variables/artifacts, admin, teams/projects, file search, reactions, attachments, package version delete
- client: multipart postForm; expo-document-picker + react-native-webview deps - release assets: upload (DocumentPicker) and delete; run artifacts list - repository transfer; Actions secrets + variables management screen - admin (users/orgs/repos) screen gated on is_admin - org teams, repo projects (read-only); find-file via recursive git tree - issue reactions toggle and attachments list; package version delete - endpoint tests (126 total)
This commit is contained in:
1 parent
b2b44bca73
commit
587bf732b5
31 files changed
+1919
-46
No files matched your search
@@ -0,0 +1,215 @@
|
||||
import { useState } from 'react';
|
||||
import { Alert, StyleSheet, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Field } from '@/components/ui/field';
|
||||
import { IconButton } from '@/components/ui/icon-button';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import {
|
||||
useCreateRepoVariable,
|
||||
useDeleteRepoSecret,
|
||||
useDeleteRepoVariable,
|
||||
usePutRepoSecret,
|
||||
useRepoSecrets,
|
||||
useRepoVariables,
|
||||
} from '@/features/repositories/settings-queries';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'ActionsSettings'>;
|
||||
|
||||
/** Repository Actions secrets and variables (secrets are write-only). */
|
||||
export function ActionsSettingsScreen({ route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name } = route.params;
|
||||
|
||||
const secrets = useRepoSecrets(owner, name);
|
||||
const variables = useRepoVariables(owner, name);
|
||||
const putSecret = usePutRepoSecret(owner, name);
|
||||
const deleteSecret = useDeleteRepoSecret(owner, name);
|
||||
const createVariable = useCreateRepoVariable(owner, name);
|
||||
const deleteVariable = useDeleteRepoVariable(owner, name);
|
||||
|
||||
const [secretName, setSecretName] = useState('');
|
||||
const [secretValue, setSecretValue] = useState('');
|
||||
const [varName, setVarName] = useState('');
|
||||
const [varValue, setVarValue] = useState('');
|
||||
|
||||
if (secrets.isPending || variables.isPending) return <LoadingView />;
|
||||
if (secrets.isError || variables.isError) {
|
||||
const error = secrets.error ?? variables.error;
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => {
|
||||
void secrets.refetch();
|
||||
void variables.refetch();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const secretItems = secrets.data ?? [];
|
||||
const variableItems = variables.data ?? [];
|
||||
|
||||
const addSecret = () => {
|
||||
if (secretName.trim().length === 0 || secretValue.length === 0) return;
|
||||
putSecret.mutate(
|
||||
{ key: secretName.trim(), value: secretValue },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setSecretName('');
|
||||
setSecretValue('');
|
||||
},
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const addVariable = () => {
|
||||
if (varName.trim().length === 0) return;
|
||||
createVariable.mutate(
|
||||
{ key: varName.trim(), value: varValue },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setVarName('');
|
||||
setVarValue('');
|
||||
},
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const confirmSecretDelete = (key: string) => {
|
||||
Alert.alert(t('repoSettings.deleteSecretTitle'), t('repoSettings.deleteSecretBody', { name: key }), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
{
|
||||
text: t('common.delete'),
|
||||
style: 'destructive',
|
||||
onPress: () =>
|
||||
deleteSecret.mutate(key, {
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
const confirmVariableDelete = (key: string) => {
|
||||
Alert.alert(t('repoSettings.deleteVariableTitle'), t('repoSettings.deleteVariableBody', { name: key }), [
|
||||
{ text: t('common.cancel'), style: 'cancel' },
|
||||
{
|
||||
text: t('common.delete'),
|
||||
style: 'destructive',
|
||||
onPress: () =>
|
||||
deleteVariable.mutate(key, {
|
||||
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<AppText variant="subheading">{t('repoSettings.secrets')}</AppText>
|
||||
<Card>
|
||||
<Field
|
||||
label={t('repoSettings.secretName')}
|
||||
value={secretName}
|
||||
onChangeText={setSecretName}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
<Field
|
||||
label={t('repoSettings.secretValue')}
|
||||
value={secretValue}
|
||||
onChangeText={setSecretValue}
|
||||
secureTextEntry
|
||||
autoCapitalize="none"
|
||||
/>
|
||||
<Button
|
||||
label={t('common.add')}
|
||||
onPress={addSecret}
|
||||
loading={putSecret.isPending}
|
||||
disabled={secretName.trim().length === 0 || secretValue.length === 0}
|
||||
fullWidth
|
||||
style={styles.spaced}
|
||||
/>
|
||||
</Card>
|
||||
{secretItems.map((secret) => (
|
||||
<Card key={secret.name}>
|
||||
<View style={styles.row}>
|
||||
<AppText variant="bodyMedium" style={styles.name} numberOfLines={1}>
|
||||
{secret.name}
|
||||
</AppText>
|
||||
<IconButton
|
||||
name="trash"
|
||||
onPress={() => confirmSecretDelete(secret.name ?? '')}
|
||||
accessibilityLabel={t('common.delete')}
|
||||
/>
|
||||
</View>
|
||||
</Card>
|
||||
))}
|
||||
|
||||
<AppText variant="subheading">{t('repoSettings.variables')}</AppText>
|
||||
<Card>
|
||||
<Field
|
||||
label={t('repoSettings.variableName')}
|
||||
value={varName}
|
||||
onChangeText={setVarName}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
<Field
|
||||
label={t('repoSettings.variableValue')}
|
||||
value={varValue}
|
||||
onChangeText={setVarValue}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
<Button
|
||||
label={t('common.add')}
|
||||
onPress={addVariable}
|
||||
loading={createVariable.isPending}
|
||||
disabled={varName.trim().length === 0}
|
||||
fullWidth
|
||||
style={styles.spaced}
|
||||
/>
|
||||
</Card>
|
||||
{variableItems.map((variable) => (
|
||||
<Card key={variable.name}>
|
||||
<View style={styles.row}>
|
||||
<View style={styles.name}>
|
||||
<AppText variant="bodyMedium" numberOfLines={1}>
|
||||
{variable.name}
|
||||
</AppText>
|
||||
{variable.data ? (
|
||||
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1}>
|
||||
{variable.data}
|
||||
</AppText>
|
||||
) : null}
|
||||
</View>
|
||||
<IconButton
|
||||
name="trash"
|
||||
onPress={() => confirmVariableDelete(variable.name ?? '')}
|
||||
accessibilityLabel={t('common.delete')}
|
||||
/>
|
||||
</View>
|
||||
</Card>
|
||||
))}
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
spaced: { marginTop: spacing.md },
|
||||
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
|
||||
name: { flex: 1 },
|
||||
});
|
||||
Reference in new issue
Block a user