🐛 fix(rules): Change rule type from 'auto' to 'default' and update
This commit is contained in:
@@ -159,7 +159,7 @@ export default function ImportYamlRules({ onImportSuccess }: ImportYamlRulesProp
|
||||
enable: false,
|
||||
tags: [],
|
||||
icon: '',
|
||||
type: 'auto',
|
||||
type: 'default',
|
||||
default: isDefault,
|
||||
});
|
||||
setImportProgress(i + 1);
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function Page() {
|
||||
enable: false,
|
||||
tags: values.tags || [],
|
||||
icon: values.icon || '',
|
||||
type: values.type || 'auto',
|
||||
type: values.type || 'default',
|
||||
default: false,
|
||||
});
|
||||
toast.success(t('createSuccess'));
|
||||
@@ -117,39 +117,41 @@ export default function Page() {
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'icon',
|
||||
header: t('appIcon'),
|
||||
cell: ({ row }) =>
|
||||
row.getValue('icon') ? (
|
||||
<Image
|
||||
src={row.getValue('icon')}
|
||||
alt={row.getValue('name')}
|
||||
className='h-8 w-8 rounded-md'
|
||||
width={32}
|
||||
height={32}
|
||||
/>
|
||||
) : (
|
||||
<div className='bg-muted flex h-8 w-8 items-center justify-center rounded-md'>
|
||||
{row.original.name?.slice(0, 2)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: t('name'),
|
||||
},
|
||||
{
|
||||
accessorKey: 'type',
|
||||
header: t('type'),
|
||||
cell: ({ row }) => {
|
||||
const type = row.original.type;
|
||||
if (type === 'auto') return t('auto');
|
||||
if (type === 'ban') return t('ban');
|
||||
return type || '--';
|
||||
const type = row.original.type || 'default';
|
||||
if (type === 'default') {
|
||||
return <Badge variant='default'>{t('default')}</Badge>;
|
||||
}
|
||||
if (type === 'reject') {
|
||||
return <Badge variant='destructive'>{t('reject')}</Badge>;
|
||||
}
|
||||
if (type === 'direct') {
|
||||
return <Badge variant='secondary'>{t('direct')}</Badge>;
|
||||
}
|
||||
return <Badge variant='default'>{t('default')}</Badge>;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: t('name'),
|
||||
cell: ({ row }) => (
|
||||
<div className='flex items-center gap-2'>
|
||||
{row.original.icon && (
|
||||
<Image
|
||||
src={row.original.icon}
|
||||
alt={row.original.name}
|
||||
className='h-6 w-6 rounded-md'
|
||||
width={24}
|
||||
height={24}
|
||||
/>
|
||||
)}
|
||||
<span>{row.original.name}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'tags',
|
||||
header: t('tags'),
|
||||
|
||||
@@ -43,7 +43,7 @@ const formSchema = z.object({
|
||||
tags: z.array(z.string()).default([]),
|
||||
rules: z.string().default(''),
|
||||
icon: z.string().default(''),
|
||||
type: z.string().default('auto'),
|
||||
type: z.string().default('default'),
|
||||
});
|
||||
|
||||
interface RuleFormProps<T> {
|
||||
@@ -172,8 +172,9 @@ export default function RuleForm<T extends Record<string, any>>({
|
||||
<SelectValue placeholder={t('selectType')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='auto'>{t('auto')}</SelectItem>
|
||||
<SelectItem value='ban'>{t('ban')}</SelectItem>
|
||||
<SelectItem value='default'>{t('default')}</SelectItem>
|
||||
<SelectItem value='reject'>{t('reject')}</SelectItem>
|
||||
<SelectItem value='direct'>{t('direct')}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
Reference in New Issue
Block a user