feat(filters): auto-expand used sections (#1278)

feat(web): auto-expand sections with data
This commit is contained in:
soup 2023-11-26 12:58:46 +01:00 committed by GitHub
parent e6b3d6117e
commit 4d13d08c87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 23 deletions

View file

@ -222,7 +222,7 @@ const externalFilterSchema = z.object({
webhook_expect_status: z.number().optional(), webhook_expect_status: z.number().optional(),
webhook_retry_status: z.string().optional(), webhook_retry_status: z.string().optional(),
webhook_retry_attempts: z.number().optional(), webhook_retry_attempts: z.number().optional(),
webhook_retry_delay_seconds: z.number().optional(), webhook_retry_delay_seconds: z.number().optional()
}).superRefine((value, ctx) => { }).superRefine((value, ctx) => {
if (!value.name) { if (!value.name) {
ctx.addIssue({ ctx.addIssue({

View file

@ -16,7 +16,7 @@ type ValueConsumer = {
const Releases = ({ values }: ValueConsumer) => ( const Releases = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen defaultOpen={values.use_regex || values.match_releases || values.except_releases}
title="Release Names" title="Release Names"
subtitle="Match only certain release names and/or ignore other release names." subtitle="Match only certain release names and/or ignore other release names."
> >
@ -92,9 +92,9 @@ const Releases = ({ values }: ValueConsumer) => (
</CollapsibleSection> </CollapsibleSection>
); );
const Groups = () => ( const Groups = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={values.match_release_groups || values.except_release_groups}
title="Groups" title="Groups"
subtitle="Match only certain groups and/or ignore other groups." subtitle="Match only certain groups and/or ignore other groups."
> >
@ -125,9 +125,9 @@ const Groups = () => (
</CollapsibleSection> </CollapsibleSection>
); );
const Categories = () => ( const Categories = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen defaultOpen={values.match_categories || values.except_categories}
title="Categories" title="Categories"
subtitle="Match or exclude categories (if announced)" subtitle="Match or exclude categories (if announced)"
> >
@ -158,9 +158,9 @@ const Categories = () => (
</CollapsibleSection> </CollapsibleSection>
); );
const Tags = () => ( const Tags = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={values.tags || values.except_tags}
title="Tags" title="Tags"
subtitle="Match or exclude tags (if announced)" subtitle="Match or exclude tags (if announced)"
> >
@ -221,9 +221,9 @@ const Tags = () => (
</CollapsibleSection> </CollapsibleSection>
); );
const Uploaders = () => ( const Uploaders = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={values.uploaders || values.except_uploaders}
title="Uploaders" title="Uploaders"
subtitle="Match or ignore uploaders (if announced)" subtitle="Match or ignore uploaders (if announced)"
> >
@ -255,9 +255,9 @@ const Uploaders = () => (
</CollapsibleSection> </CollapsibleSection>
); );
const Language = () => ( const Language = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={(values.match_language && values.match_language.length > 0) || (values.except_language && values.except_language.length > 0)}
title="Language" title="Language"
subtitle="Match or ignore languages (if announced)" subtitle="Match or ignore languages (if announced)"
> >
@ -276,9 +276,9 @@ const Language = () => (
</CollapsibleSection> </CollapsibleSection>
); );
const Origins = () => ( const Origins = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={(values.origins && values.origins.length > 0 || values.except_origins && values.except_origins.length > 0)}
title="Origins" title="Origins"
subtitle="Match Internals, Scene, P2P, etc. (if announced)" subtitle="Match Internals, Scene, P2P, etc. (if announced)"
> >
@ -299,7 +299,7 @@ const Origins = () => (
const Freeleech = ({ values }: ValueConsumer) => ( const Freeleech = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen defaultOpen={values.freeleech || values.freeleech_percent}
title="Freeleech" title="Freeleech"
subtitle="Match based off freeleech (if announced)" subtitle="Match based off freeleech (if announced)"
> >
@ -351,7 +351,7 @@ const Freeleech = ({ values }: ValueConsumer) => (
const FeedSpecific = ({ values }: ValueConsumer) => ( const FeedSpecific = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={values.use_regex_description || values.match_description || values.except_description}
title="RSS/Torznab/Newznab-specific" title="RSS/Torznab/Newznab-specific"
subtitle={ subtitle={
<>These options are <span className="font-bold">only</span> for Feeds such as RSS, Torznab and Newznab</> <>These options are <span className="font-bold">only</span> for Feeds such as RSS, Torznab and Newznab</>
@ -402,7 +402,7 @@ const FeedSpecific = ({ values }: ValueConsumer) => (
const RawReleaseTags = ({ values }: ValueConsumer) => ( const RawReleaseTags = ({ values }: ValueConsumer) => (
<CollapsibleSection <CollapsibleSection
defaultOpen={false} defaultOpen={values.use_regex_release_tags || values.match_release_tags || values.except_release_tags}
title="Raw Release Tags" title="Raw Release Tags"
subtitle={ subtitle={
<> <>
@ -445,13 +445,13 @@ const RawReleaseTags = ({ values }: ValueConsumer) => (
export const Advanced = ({ values }: { values: FormikValues; }) => ( export const Advanced = ({ values }: { values: FormikValues; }) => (
<div className="flex flex-col w-full gap-y-4 py-2 sm:-mx-1"> <div className="flex flex-col w-full gap-y-4 py-2 sm:-mx-1">
<Releases values={values} /> <Releases values={values} />
<Groups /> <Groups values={values} />
<Categories /> <Categories values={values} />
<Freeleech values={values} /> <Freeleech values={values} />
<Tags /> <Tags values={values}/>
<Uploaders /> <Uploaders values={values}/>
<Language /> <Language values={values}/>
<Origins /> <Origins values={values} />
<FeedSpecific values={values} /> <FeedSpecific values={values} />
<RawReleaseTags values={values} /> <RawReleaseTags values={values} />
</div> </div>