mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
chore: auto-fix lint & formatting [skip ci]
This commit is contained in:
parent
a77ac8ad91
commit
df16dc94f7
17 changed files with 142 additions and 125 deletions
|
|
@ -5,10 +5,10 @@ import { FILTER_TYPES, FILTER_OPS } from "~/types";
|
|||
|
||||
defineOptions({ name: "FilterNodeEditor" });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ node: NodeForm; depth?: number; deletable?: boolean }>(),
|
||||
{ depth: 0, deletable: false },
|
||||
);
|
||||
const props = withDefaults(defineProps<{ node: NodeForm; depth?: number; deletable?: boolean }>(), {
|
||||
depth: 0,
|
||||
deletable: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{ (e: "remove"): void }>();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,13 @@ import { computed, reactive, ref, watch } from "vue";
|
|||
import type { Filter, FilterNode, NamedFragment, Route, RouteTarget, RouteTemplate } from "~/types";
|
||||
import { FRAGMENT_PRESETS, ROUTE_TEMPLATES } from "~/types";
|
||||
import type { NodeForm } from "~/composables/useFilterNode";
|
||||
import { blankLeafForm, blankNode, nodeToForm, nodeFormToRouteFilters, formToNode } from "~/composables/useFilterNode";
|
||||
import {
|
||||
blankLeafForm,
|
||||
blankNode,
|
||||
nodeToForm,
|
||||
nodeFormToRouteFilters,
|
||||
formToNode,
|
||||
} from "~/composables/useFilterNode";
|
||||
|
||||
interface TargetForm {
|
||||
platform: "discord" | "telegram";
|
||||
|
|
@ -392,11 +398,7 @@ watch(
|
|||
<section class="editor-section">
|
||||
<h3 class="editor-section-title">{{ t("routeEditor.testMatch") }}</h3>
|
||||
<div class="field">
|
||||
<input
|
||||
v-model="testEvent"
|
||||
class="input"
|
||||
:placeholder="t('routeEditor.testEvent')"
|
||||
/>
|
||||
<input v-model="testEvent" class="input" :placeholder="t('routeEditor.testEvent')" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<textarea
|
||||
|
|
@ -413,7 +415,11 @@ watch(
|
|||
</div>
|
||||
<div v-if="testResult" class="test-result" :class="{ ok: testResult.matched }">
|
||||
<span class="test-badge">
|
||||
{{ testResult.matched ? t("routeEditor.testMatched") : t("routeEditor.testNotMatched") }}
|
||||
{{
|
||||
testResult.matched
|
||||
? t("routeEditor.testMatched")
|
||||
: t("routeEditor.testNotMatched")
|
||||
}}
|
||||
</span>
|
||||
<span class="test-explanation">{{ testResult.explanation }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ function remove(index: number) {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap items-center gap-1 rounded-md border border-border bg-surface/60 px-2 py-1.5 focus-within:border-accent">
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-1 rounded-md border border-border bg-surface/60 px-2 py-1.5 focus-within:border-accent"
|
||||
>
|
||||
<span
|
||||
v-for="(v, i) in modelValue"
|
||||
:key="`${v}-${i}`"
|
||||
|
|
|
|||
|
|
@ -146,8 +146,7 @@ export function describeLeaf(f: Filter, t: (key: string) => string): string {
|
|||
const op = f.op ?? "eq";
|
||||
const match = f.match;
|
||||
const values = match === undefined ? [] : Array.isArray(match) ? match : [match];
|
||||
const value =
|
||||
values.map((v) => JSON.stringify(v)).join(` ${t("filterNode.or")} `) || "\u2205";
|
||||
const value = values.map((v) => JSON.stringify(v)).join(` ${t("filterNode.or")} `) || "\u2205";
|
||||
let base: string;
|
||||
if (f.type === "keyword") {
|
||||
base = `${label} ${t("filterNode.matches")} ${value}`;
|
||||
|
|
@ -169,9 +168,7 @@ export function describeNode(node: FilterNode, t: (key: string) => string): stri
|
|||
.join(` ${t("filterNode.and")} `);
|
||||
}
|
||||
if ("any" in node) {
|
||||
const parts = node.any
|
||||
.map((c) => describeNode(c, t))
|
||||
.filter((s) => s.length);
|
||||
const parts = node.any.map((c) => describeNode(c, t)).filter((s) => s.length);
|
||||
return parts.length ? `(${parts.join(` ${t("filterNode.or")} `)})` : "";
|
||||
}
|
||||
if ("not" in node) {
|
||||
|
|
|
|||
19
app/types.ts
19
app/types.ts
|
|
@ -1,11 +1,4 @@
|
|||
export type FilterType =
|
||||
| "event"
|
||||
| "repo"
|
||||
| "actor"
|
||||
| "action"
|
||||
| "branch"
|
||||
| "keyword"
|
||||
| "field";
|
||||
export type FilterType = "event" | "repo" | "actor" | "action" | "branch" | "keyword" | "field";
|
||||
|
||||
export type FilterOp =
|
||||
| "eq"
|
||||
|
|
@ -267,7 +260,15 @@ export const FRAGMENT_PRESETS: FragmentPreset[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export const FILTER_TYPES = ["event", "repo", "actor", "action", "branch", "keyword", "field"] as const;
|
||||
export const FILTER_TYPES = [
|
||||
"event",
|
||||
"repo",
|
||||
"actor",
|
||||
"action",
|
||||
"branch",
|
||||
"keyword",
|
||||
"field",
|
||||
] as const;
|
||||
|
||||
export const FILTER_OPS: FilterOp[] = [
|
||||
"eq",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue