-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[WEB-5099] improvement: enhance rich filters with new components and configurations #7916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6ff3f05
feat: enhance rich filters with new components and configurations
prateekshourya29 1dc9f80
Merge branch 'preview' of github.com:makeplane/plane into improvement…
prateekshourya29 a17cf68
Refactor rich filters component structure and enhance filter item fun…
prateekshourya29 b0d81a3
[WEB-5111] feat: add 'created_at' and 'updated_at' filters to work it…
prateekshourya29 d49d994
fix: merge conflicts resolved
prateekshourya29 00af965
fix: build
prateekshourya29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
apps/web/ce/components/rich-filters/filter-value-input/root.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
import { observer } from "mobx-react"; | ||
// plane imports | ||
import { TFilterValue, TFilterProperty } from "@plane/types"; | ||
// local imports | ||
import { TFilterValueInputProps } from "@/components/rich-filters/shared"; | ||
|
||
export const AdditionalFilterValueInput = observer( | ||
<P extends TFilterProperty, V extends TFilterValue>(_props: TFilterValueInputProps<P, V>) => ( | ||
// Fallback | ||
<div className="h-full flex items-center px-4 text-xs text-custom-text-400 transition-opacity duration-200 cursor-not-allowed"> | ||
Filter type not supported | ||
</div> | ||
) | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
apps/web/core/components/rich-filters/add-filters/button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from "react"; | ||
import { observer } from "mobx-react"; | ||
import { ListFilter } from "lucide-react"; | ||
// plane imports | ||
import { IFilterInstance } from "@plane/shared-state"; | ||
import { LOGICAL_OPERATOR, TExternalFilter, TFilterProperty, TSupportedOperators } from "@plane/types"; | ||
import { cn, getButtonStyling, TButtonVariant } from "@plane/ui"; | ||
// local imports | ||
import { AddFilterDropdown } from "./dropdown"; | ||
|
||
export type TAddFilterButtonProps<P extends TFilterProperty, E extends TExternalFilter> = { | ||
buttonConfig?: { | ||
label: string | null; | ||
variant?: TButtonVariant; | ||
className?: string; | ||
defaultOpen?: boolean; | ||
iconConfig?: { | ||
shouldShowIcon: boolean; | ||
iconComponent?: React.ElementType; | ||
}; | ||
isDisabled?: boolean; | ||
}; | ||
filter: IFilterInstance<P, E>; | ||
onFilterSelect?: (id: string) => void; | ||
}; | ||
|
||
export const AddFilterButton = observer( | ||
<P extends TFilterProperty, E extends TExternalFilter>(props: TAddFilterButtonProps<P, E>) => { | ||
const { filter, buttonConfig, onFilterSelect } = props; | ||
const { | ||
variant = "link-neutral", | ||
className, | ||
label, | ||
iconConfig = { shouldShowIcon: true }, | ||
isDisabled = false, | ||
} = buttonConfig || {}; | ||
// derived values | ||
const FilterIcon = iconConfig.iconComponent || ListFilter; | ||
|
||
const handleFilterSelect = (property: P, operator: TSupportedOperators, isNegation: boolean) => { | ||
filter.addCondition( | ||
LOGICAL_OPERATOR.AND, | ||
{ | ||
property, | ||
operator, | ||
value: undefined, | ||
}, | ||
isNegation | ||
); | ||
onFilterSelect?.(property); | ||
}; | ||
|
||
if (isDisabled) return null; | ||
return ( | ||
<AddFilterDropdown | ||
{...props} | ||
buttonConfig={{ | ||
...buttonConfig, | ||
className: cn(getButtonStyling(variant, "sm"), "py-[5px]", className), | ||
}} | ||
handleFilterSelect={handleFilterSelect} | ||
customButton={ | ||
<div className="flex items-center gap-1"> | ||
{iconConfig.shouldShowIcon && <FilterIcon className="size-4 text-custom-text-200" />} | ||
{label} | ||
</div> | ||
} | ||
/> | ||
); | ||
} | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/web/core/components/rich-filters/filter-item/close-button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { observer } from "mobx-react"; | ||
import { X } from "lucide-react"; | ||
// plane imports | ||
import { IFilterInstance } from "@plane/shared-state"; | ||
import { TExternalFilter, TFilterProperty } from "@plane/types"; | ||
|
||
interface FilterItemCloseButtonProps<P extends TFilterProperty, E extends TExternalFilter> { | ||
conditionId: string; | ||
filter: IFilterInstance<P, E>; | ||
} | ||
|
||
export const FilterItemCloseButton = observer( | ||
<P extends TFilterProperty, E extends TExternalFilter>(props: FilterItemCloseButtonProps<P, E>) => { | ||
const { conditionId, filter } = props; | ||
|
||
const handleRemoveFilter = () => { | ||
filter.removeCondition(conditionId); | ||
}; | ||
|
||
return ( | ||
<button | ||
onClick={handleRemoveFilter} | ||
className="px-1.5 text-custom-text-400 hover:text-custom-text-300 focus:outline-none hover:bg-custom-background-90" | ||
type="button" | ||
aria-label="Remove filter" | ||
> | ||
<X className="size-3.5" /> | ||
</button> | ||
); | ||
} | ||
); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.