Skip to content

Commit 824f71c

Browse files
committed
feat: show urlPattern option when needed
1 parent b213c12 commit 824f71c

File tree

4 files changed

+15
-34
lines changed

4 files changed

+15
-34
lines changed

memshell-java8/src/main/java/com/reajason/javaweb/memshell/springwebflux/injector/SpringWebFluxWebFilterInjector.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ public class SpringWebFluxWebFilterInjector {
2525
new SpringWebFluxWebFilterInjector();
2626
}
2727

28-
public String getUrlPattern() {
29-
return "{{urlPattern}}";
30-
}
31-
3228
public String getClassName() {
3329
return "{{className}}";
3430
}

memshell-java8/src/main/java/com/reajason/javaweb/memshell/springwebmvc/injector/SpringWebMvcInterceptorInjector.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ public class SpringWebMvcInterceptorInjector {
2020
new SpringWebMvcInterceptorInjector();
2121
}
2222

23-
public String getUrlPattern() {
24-
return "{{urlPattern}}";
25-
}
26-
2723
public String getClassName() {
2824
return "{{className}}";
2925
}

web/src/components/tips/url-pattern-tip.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

web/src/components/tools/urlpattern-field.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
import { UrlPatternTip } from "@/components/tips/url-pattern-tip.tsx";
21
import { FormField, FormItem, FormLabel } from "@/components/ui/form.tsx";
32
import { Input } from "@/components/ui/input.tsx";
3+
import { cn } from "@/lib/utils";
44
import { FormSchema } from "@/types/schema.ts";
55
import { FormProvider, UseFormReturn } from "react-hook-form";
66
import { useTranslation } from "react-i18next";
77

8+
function shouldHidden(shellType: string) {
9+
return (
10+
shellType.endsWith("Listener") ||
11+
shellType.endsWith("Valve") ||
12+
shellType.startsWith("Agent") ||
13+
shellType.endsWith("Interceptor") ||
14+
shellType.endsWith("NettyHandler") ||
15+
shellType.endsWith("WebFilter")
16+
);
17+
}
18+
819
export function UrlPatternFormField({ form }: Readonly<{ form: UseFormReturn<FormSchema> }>) {
920
const { t } = useTranslation();
21+
const shellType = form.watch("shellType");
1022
return (
1123
<FormProvider {...form}>
1224
<FormField
1325
control={form.control}
1426
name="urlPattern"
1527
render={({ field }) => (
16-
<FormItem className="gap-1">
17-
<FormLabel className="h-6 flex items-center gap-1">
18-
{t("mainConfig.urlPattern")} <UrlPatternTip />
19-
</FormLabel>
28+
<FormItem className={cn("gap-1", shouldHidden(shellType) ? "hidden" : "block")}>
29+
<FormLabel className="h-6 flex items-center gap-1">{t("mainConfig.urlPattern")}</FormLabel>
2030
<Input {...field} placeholder={t("placeholders.input")} className="h-8" />
2131
</FormItem>
2232
)}

0 commit comments

Comments
 (0)