-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-1882] chore: optimised issue activity and updated the popover component in issue detail and peek overview #5208
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| "use client"; | ||
|
|
||
| import { FC } from "react"; | ||
| // components | ||
| import { ActivityFilter } from "@/components/issues"; | ||
| // plane web constants | ||
| import { TActivityFilters, ACTIVITY_FILTER_TYPE_OPTIONS, TActivityFilterOption } from "@/plane-web/constants/issues"; | ||
|
|
||
| export type TActivityFilterRoot = { | ||
| selectedFilters: TActivityFilters[]; | ||
| toggleFilter: (filter: TActivityFilters) => void; | ||
| }; | ||
|
|
||
| export const ActivityFilterRoot: FC<TActivityFilterRoot> = (props) => { | ||
| const { selectedFilters, toggleFilter } = props; | ||
|
|
||
| const filters: TActivityFilterOption[] = Object.entries(ACTIVITY_FILTER_TYPE_OPTIONS).map(([key, value]) => { | ||
| const filterKey = key as TActivityFilters; | ||
| return { | ||
| key: filterKey, | ||
| label: value.label, | ||
| isSelected: selectedFilters.includes(filterKey), | ||
| onClick: () => toggleFilter(filterKey), | ||
| }; | ||
| }); | ||
|
|
||
| return <ActivityFilter selectedFilters={selectedFilters} filterOptions={filters} />; | ||
| }; |
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 |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export * from "./root"; | ||
| export * from "./worklog-create-button"; | ||
|
|
||
| export * from "./filter-root"; |
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
116 changes: 45 additions & 71 deletions
116
web/core/components/issues/issue-detail/issue-activity/activity-filter.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 |
|---|---|---|
| @@ -1,85 +1,59 @@ | ||
| import React, { FC, Fragment } from "react"; | ||
| import React, { FC } from "react"; | ||
| import { observer } from "mobx-react"; | ||
| import { Check, ListFilter } from "lucide-react"; | ||
| import { Popover, Transition } from "@headlessui/react"; | ||
| // ui | ||
| import { Button } from "@plane/ui"; | ||
| import { Button, PopoverMenu } from "@plane/ui"; | ||
| // helper | ||
| import { cn } from "@/helpers/common.helper"; | ||
| // constants | ||
| import { TActivityFilters, ACTIVITY_FILTER_TYPE_OPTIONS } from "@/plane-web/constants/issues"; | ||
| import { TActivityFilterOption, TActivityFilters } from "@/plane-web/constants/issues"; | ||
|
|
||
| type Props = { | ||
| type TActivityFilter = { | ||
| selectedFilters: TActivityFilters[]; | ||
| toggleFilter: (filter: TActivityFilters) => void; | ||
| filterOptions: TActivityFilterOption[]; | ||
| }; | ||
|
|
||
| export const ActivityFilter: FC<Props> = observer((props) => { | ||
| const { selectedFilters, toggleFilter } = props; | ||
| return ( | ||
| <Popover as="div" className="relative"> | ||
| {({ open }) => ( | ||
| <> | ||
| <Popover.Button as={React.Fragment}> | ||
| <Button | ||
| variant="neutral-primary" | ||
| size="sm" | ||
| prependIcon={<ListFilter className="h-3 w-3" />} | ||
| className="relative" | ||
| > | ||
| <span className={`${open ? "text-custom-text-100" : "text-custom-text-200"}`}>Filters</span> | ||
| </Button> | ||
| </Popover.Button> | ||
| export const ActivityFilter: FC<TActivityFilter> = observer((props) => { | ||
| const { selectedFilters = [], filterOptions } = props; | ||
|
|
||
| <Transition | ||
| as={Fragment} | ||
| enter="transition ease-out duration-200" | ||
| enterFrom="opacity-0 translate-y-1" | ||
| enterTo="opacity-100 translate-y-0" | ||
| leave="transition ease-in duration-150" | ||
| leaveFrom="opacity-100 translate-y-0" | ||
| leaveTo="opacity-0 translate-y-1" | ||
| return ( | ||
| <PopoverMenu | ||
| buttonClassName="outline-none" | ||
| button={ | ||
| <Button | ||
| variant="neutral-primary" | ||
| size="sm" | ||
| prependIcon={<ListFilter className="h-3 w-3" />} | ||
| className="relative" | ||
| > | ||
| <span className="text-custom-text-200">Filters</span> | ||
| </Button> | ||
| } | ||
| panelClassName="p-2 rounded-md border border-custom-border-200 bg-custom-background-100" | ||
| data={filterOptions} | ||
| keyExtractor={(item) => item.key} | ||
| render={(item) => ( | ||
| <div | ||
| key={item.key} | ||
| className="flex items-center gap-2 text-sm cursor-pointer px-2 p-1 transition-all hover:bg-custom-background-80 rounded-sm" | ||
| onClick={item.onClick} | ||
| > | ||
| <div | ||
| className={cn( | ||
| "flex-shrink-0 w-3 h-3 flex justify-center items-center rounded-sm transition-all bg-custom-background-90", | ||
| { | ||
| "bg-custom-primary text-white": item.isSelected, | ||
| "bg-custom-background-80 text-custom-text-400": item.isSelected && selectedFilters.length === 1, | ||
| "bg-custom-background-90": !item.isSelected, | ||
| } | ||
| )} | ||
| > | ||
| <Popover.Panel className="absolute mt-2 right-0 z-10 min-w-40"> | ||
| <div className="p-2 rounded-md border border-custom-border-200 bg-custom-background-100"> | ||
| {Object.keys(ACTIVITY_FILTER_TYPE_OPTIONS).map((key) => { | ||
| const filterKey = key as TActivityFilters; | ||
| const filter = ACTIVITY_FILTER_TYPE_OPTIONS[filterKey]; | ||
| const isSelected = selectedFilters.includes(filterKey); | ||
| return ( | ||
| <div | ||
| key={filterKey} | ||
| className="flex items-center gap-2 text-sm cursor-pointer px-2 p-1 transition-all hover:bg-custom-background-80 rounded-sm" | ||
| onClick={() => toggleFilter(filterKey)} | ||
| > | ||
| <div | ||
| className={cn( | ||
| "flex-shrink-0 w-3 h-3 flex justify-center items-center rounded-sm transition-all bg-custom-background-90", | ||
| { | ||
| "bg-custom-primary text-white": isSelected, | ||
| "bg-custom-background-80 text-custom-text-400": isSelected && selectedFilters.length === 1, | ||
| "bg-custom-background-90": !isSelected, | ||
| } | ||
| )} | ||
| > | ||
| {isSelected && <Check className="h-2.5 w-2.5" />} | ||
| </div> | ||
| <div | ||
| className={cn( | ||
| "whitespace-nowrap", | ||
| isSelected ? "text-custom-text-100" : "text-custom-text-200" | ||
| )} | ||
| > | ||
| {filter.label} | ||
| </div> | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| </Popover.Panel> | ||
| </Transition> | ||
| </> | ||
| {item.isSelected && <Check className="h-2.5 w-2.5" />} | ||
| </div> | ||
| <div className={cn("whitespace-nowrap", item.isSelected ? "text-custom-text-100" : "text-custom-text-200")}> | ||
| {item.label} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </Popover> | ||
| /> | ||
| ); | ||
| }); | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "ce/components/issues/worklog/activity/filter-root"; |
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 |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export * from "./root"; | ||
| export * from "./worklog-create-button"; | ||
|
|
||
| export * from "./filter-root"; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Consider adding tests for the new component structure.
The
ActivityFiltercomponent has been refactored to usePopoverMenu, improving modularity and maintainability. The rendering logic is now more streamlined.Do you want me to generate the unit testing code or open a GitHub issue to track this task?