Skip to content

Commit

Permalink
feat: add entry conditions for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Nov 10, 2024
1 parent febc678 commit 53810ba
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 310 deletions.
150 changes: 35 additions & 115 deletions apps/renderer/src/modules/settings/action-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,58 +211,49 @@ export function ActionCard({
}) {
const { t } = useTranslation("settings")

const EntryOptions = useMemo(() => {
const FeedOptions = useMemo(() => {
return [
{
name: t("actions.action_card.entry_options.all"),
value: "all",
name: t("actions.action_card.feed_options.subscription_view"),
value: "view",
type: "view",
},
{
name: t("actions.action_card.entry_options.title"),
name: t("actions.action_card.feed_options.feed_title"),
value: "title",
},
{
name: t("actions.action_card.entry_options.content"),
value: "content",
},
{
name: t("actions.action_card.entry_options.author"),
value: "author",
name: t("actions.action_card.feed_options.feed_category"),
value: "category",
},
{
name: t("actions.action_card.entry_options.url"),
value: "url",
name: t("actions.action_card.feed_options.site_url"),
value: "site_url",
},
{
name: t("actions.action_card.entry_options.order"),
value: "order",
type: "number",
name: t("actions.action_card.feed_options.feed_url"),
value: "feed_url",
},
]
}, [t])

const FeedOptions = useMemo(() => {
return [
{
name: t("actions.action_card.feed_options.view"),
value: "view",
type: "view",
name: t("actions.action_card.feed_options.entry_title"),
value: "entry_title",
},
{
name: t("actions.action_card.feed_options.title"),
value: "title",
name: t("actions.action_card.feed_options.entry_content"),
value: "entry_content",
},
{
name: t("actions.action_card.feed_options.category"),
value: "category",
name: t("actions.action_card.feed_options.entry_url"),
value: "entry_url",
},
{
name: t("actions.action_card.feed_options.site_url"),
value: "site_url",
name: t("actions.action_card.feed_options.entry_author"),
value: "entry_author",
},
{
name: t("actions.action_card.feed_options.feed_url"),
value: "feed_url",
name: t("actions.action_card.feed_options.entry_media_length"),
value: "entry_media_length",
type: "number",
},
]
}, [t])
Expand Down Expand Up @@ -527,6 +518,19 @@ export function ActionCard({
</div>
<Divider />

<div className="flex w-full items-center justify-between">
<span className="w-0 shrink grow truncate">{t("actions.action_card.block")}</span>
<Switch
disabled={disabled}
checked={data.result.block}
onCheckedChange={(checked) => {
data.result.block = checked
onChange(data)
}}
/>
</div>
<Divider />

<SettingCollapsible
title={t("actions.action_card.rewrite_rules")}
onOpenChange={(open) => {
Expand Down Expand Up @@ -609,90 +613,6 @@ export function ActionCard({
/>
</SettingCollapsible>
<Divider />
<SettingCollapsible
title={t("actions.action_card.block_rules")}
onOpenChange={(open) => {
if (open && (!data.result.blockRules || data.result.blockRules?.length === 0)) {
data.result.blockRules = [{}]
}
onChange(data)
}}
>
{data.result.blockRules && data.result.blockRules.length > 0 && (
<Table>
<FieldTableHeader />
<TableBody>
{data.result.blockRules.map((rule, index) => {
const change = (key: string, value: string | number) => {
data.result.blockRules![index][key] = value
onChange(data)
}
const type =
EntryOptions.find((option) => option.value === rule.field)?.type ||
"text"
return (
<TableRow key={index}>
<DeleteTableCell
disabled={disabled}
onClick={() => {
if (data.result.blockRules?.length === 1) {
delete data.result.blockRules
} else {
data.result.blockRules?.splice(index, 1)
}
onChange(data)
}}
/>
<TableCell size="sm">
<Select
disabled={disabled}
value={rule.field}
onValueChange={(value) => change("field", value)}
>
<CommonSelectTrigger />
<SelectContent>
{EntryOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.name}
</SelectItem>
))}
</SelectContent>
</Select>
</TableCell>
<OperationTableCell
disabled={disabled}
type={type}
value={rule.operator}
onValueChange={(value) => change("operator", value)}
/>
<TableCell size="sm">
<Input
disabled={disabled}
type={type}
value={rule.value}
className="h-8"
onChange={(e) => change("value", e.target.value)}
/>
</TableCell>
</TableRow>
)
})}
</TableBody>
</Table>
)}
<AddTableRow
disabled={disabled}
onClick={() => {
if (!data.result.blockRules) {
data.result.blockRules = []
}
data.result.blockRules!.push({})
onChange(data)
}}
/>
</SettingCollapsible>
<Divider />

<SettingCollapsible
title={t("actions.action_card.webhooks")}
onOpenChange={(open) => {
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-DZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "مرشحات مخصصة",
"actions.action_card.enable_readability": "تمكين الوضوح",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "رابط URL",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط التغذية",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "حقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "توليد ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-IQ.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "مرشحات مخصصة",
"actions.action_card.enable_readability": "تمكين الوضوح",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "رابط URL",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط التغذية",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "حقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "توليد ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-KW.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "مرشحات مخصصة",
"actions.action_card.enable_readability": "تمكين القراءة الواضحة",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "رابط",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط التغذية",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "الحقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "إنشاء ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-MA.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "فلاتر مخصصة",
"actions.action_card.enable_readability": "تشغيل القراية المريحة",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "رابط URL",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط التغذية",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "حقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "توليد ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-SA.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "مرشحات مخصصة",
"actions.action_card.enable_readability": "تمكين قابلية القراءة",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "الرابط",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط الخلاصة",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "الحقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "توليد ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/ar-TN.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "قواعد الحظر",
"actions.action_card.custom_filters": "مرشحات مخصصة",
"actions.action_card.enable_readability": "تمكين إمكانية القراءة",
"actions.action_card.entry_options.all": "الكل",
"actions.action_card.entry_options.author": "المؤلف",
"actions.action_card.entry_options.content": "المحتوى",
"actions.action_card.entry_options.order": "الترتيب",
"actions.action_card.entry_options.title": "العنوان",
"actions.action_card.entry_options.url": "الرابط",
"actions.action_card.feed_options.category": "الفئة",
"actions.action_card.feed_options.feed_url": "رابط التغذية",
"actions.action_card.feed_options.site_url": "رابط الموقع",
"actions.action_card.feed_options.title": "العنوان",
"actions.action_card.feed_options.view": "عرض",
"actions.action_card.field": "الحقل",
"actions.action_card.from": "من",
"actions.action_card.generate_summary": "توليد ملخص باستخدام الذكاء الاصطناعي",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "Blockregeln",
"actions.action_card.custom_filters": "Benutzerdefinierte Filter",
"actions.action_card.enable_readability": "Lesbarkeit aktivieren",
"actions.action_card.entry_options.all": "Alle",
"actions.action_card.entry_options.author": "Autor",
"actions.action_card.entry_options.content": "Inhalt",
"actions.action_card.entry_options.order": "Reihenfolge",
"actions.action_card.entry_options.title": "Titel",
"actions.action_card.entry_options.url": "URL",
"actions.action_card.feed_options.category": "Kategorie",
"actions.action_card.feed_options.feed_url": "Feed-URL",
"actions.action_card.feed_options.site_url": "Website-URL",
"actions.action_card.feed_options.title": "Titel",
"actions.action_card.feed_options.view": "Ansicht",
"actions.action_card.field": "Feld",
"actions.action_card.from": "Von",
"actions.action_card.generate_summary": "Zusammenfassung mit KI erstellen",
Expand Down
18 changes: 9 additions & 9 deletions locales/settings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
"actions.actionName": "Action {{number}}",
"actions.action_card.add": "Add",
"actions.action_card.all": "All",
"actions.action_card.block": "Block",
"actions.action_card.block_rules": "Block Rules",
"actions.action_card.custom_filters": "Custom filters",
"actions.action_card.enable_readability": "Enable readability",
"actions.action_card.entry_options.all": "All",
"actions.action_card.entry_options.author": "Author",
"actions.action_card.entry_options.content": "Content",
"actions.action_card.entry_options.order": "Order",
"actions.action_card.entry_options.title": "Title",
"actions.action_card.entry_options.url": "Url",
"actions.action_card.feed_options.category": "Category",
"actions.action_card.feed_options.entry_author": "Entry Author",
"actions.action_card.feed_options.entry_content": "Entry Content",
"actions.action_card.feed_options.entry_media_length": "Entry Media Length",
"actions.action_card.feed_options.entry_title": "Entry Title",
"actions.action_card.feed_options.entry_url": "Entry URL",
"actions.action_card.feed_options.feed_category": "Feed Category",
"actions.action_card.feed_options.feed_title": "Feed Title",
"actions.action_card.feed_options.feed_url": "Feed URL",
"actions.action_card.feed_options.site_url": "Site URL",
"actions.action_card.feed_options.title": "Title",
"actions.action_card.feed_options.view": "View",
"actions.action_card.feed_options.subscription_view": "Subscription View",
"actions.action_card.field": "Field",
"actions.action_card.from": "From",
"actions.action_card.generate_summary": "Generate summary using AI",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "Reglas de bloqueo",
"actions.action_card.custom_filters": "Filtros personalizados",
"actions.action_card.enable_readability": "Habilitar legibilidad",
"actions.action_card.entry_options.all": "Todos",
"actions.action_card.entry_options.author": "Autor",
"actions.action_card.entry_options.content": "Contenido",
"actions.action_card.entry_options.order": "Orden",
"actions.action_card.entry_options.title": "Título",
"actions.action_card.entry_options.url": "URL",
"actions.action_card.feed_options.category": "Categoría",
"actions.action_card.feed_options.feed_url": "URL del feed",
"actions.action_card.feed_options.site_url": "URL del sitio",
"actions.action_card.feed_options.title": "Título",
"actions.action_card.feed_options.view": "Vista",
"actions.action_card.field": "Campo",
"actions.action_card.from": "Desde",
"actions.action_card.generate_summary": "Generar resumen usando IA",
Expand Down
9 changes: 0 additions & 9 deletions locales/settings/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
"actions.action_card.block_rules": "Estosäännöt",
"actions.action_card.custom_filters": "Mukautetut suodattimet",
"actions.action_card.enable_readability": "Ota luettavuus käyttöön",
"actions.action_card.entry_options.all": "Kaikki",
"actions.action_card.entry_options.author": "Tekijä",
"actions.action_card.entry_options.content": "Sisältö",
"actions.action_card.entry_options.order": "Järjestys",
"actions.action_card.entry_options.title": "Otsikko",
"actions.action_card.entry_options.url": "URL",
"actions.action_card.feed_options.category": "Kategoria",
"actions.action_card.feed_options.feed_url": "Syötteen URL",
"actions.action_card.feed_options.site_url": "Sivuston URL",
"actions.action_card.feed_options.title": "Otsikko",
"actions.action_card.feed_options.view": "Näkymä",
"actions.action_card.field": "Kenttä",
"actions.action_card.from": "Lähde",
"actions.action_card.generate_summary": "Luo yhteenveto tekoälyn avulla",
Expand Down
Loading

0 comments on commit 53810ba

Please sign in to comment.