-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[WEB-2226]chore: updated 'Issue states' settings ui #6338
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 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 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,64 +1,108 @@ | ||
"use client"; | ||
|
||
import { FC, useState } from "react"; | ||
import { FC, useState, useRef } from "react"; | ||
import { observer } from "mobx-react"; | ||
import { Plus } from "lucide-react"; | ||
import { ChevronDown, Plus } from "lucide-react"; | ||
import { IState, TStateGroups } from "@plane/types"; | ||
// components | ||
import { StateGroupIcon } from "@plane/ui"; | ||
import { cn } from "@plane/utils"; | ||
import { StateList, StateCreate } from "@/components/project-states"; | ||
// hooks | ||
import { useUserPermissions } from "@/hooks/store"; | ||
import { EUserPermissions, EUserPermissionsLevel } from "ee/constants/user-permissions"; | ||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; | ||
|
||
type TGroupItem = { | ||
workspaceSlug: string; | ||
projectId: string; | ||
groupKey: TStateGroups; | ||
groupsExpanded: Partial<TStateGroups>[]; | ||
handleGroupCollapse: (groupKey: TStateGroups) => void; | ||
handleExpand: (groupKey: TStateGroups) => void; | ||
groupedStates: Record<string, IState[]>; | ||
states: IState[]; | ||
}; | ||
|
||
export const GroupItem: FC<TGroupItem> = observer((props) => { | ||
const { workspaceSlug, projectId, groupKey, groupedStates, states } = props; | ||
const { | ||
workspaceSlug, | ||
projectId, | ||
groupKey, | ||
groupedStates, | ||
states, | ||
groupsExpanded, | ||
handleExpand, | ||
handleGroupCollapse, | ||
} = props; | ||
// store hooks | ||
const { allowPermissions } = useUserPermissions(); | ||
// state | ||
const [createState, setCreateState] = useState(false); | ||
|
||
// derived values | ||
const currentStateExpanded = groupsExpanded.includes(groupKey); | ||
// refs | ||
const dropElementRef = useRef<HTMLDivElement | null>(null); | ||
|
||
const isEditable = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT); | ||
|
||
return ( | ||
<div className="space-y-3"> | ||
<div className="flex justify-between items-center"> | ||
<div className="text-base font-medium text-custom-text-200 capitalize">{groupKey}</div> | ||
{isEditable && ( | ||
<div | ||
className="space-y-1 border border-custom-border-200 rounded bg-custom-background-90 transition-all p-2" | ||
ref={dropElementRef} | ||
> | ||
<div className="flex justify-between items-center gap-2"> | ||
<div | ||
className="w-full flex items-center cursor-pointer py-1" | ||
onClick={() => (!currentStateExpanded ? handleExpand(groupKey) : handleGroupCollapse(groupKey))} | ||
> | ||
<div | ||
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100" | ||
onClick={() => !createState && setCreateState(true)} | ||
className={cn( | ||
"flex-shrink-0 w-5 h-5 rounded flex justify-center items-center overflow-hidden transition-all", | ||
{ | ||
"rotate-0": currentStateExpanded, | ||
"-rotate-90": !currentStateExpanded, | ||
} | ||
)} | ||
> | ||
<Plus className="w-4 h-4" /> | ||
<ChevronDown className="w-4 h-4" /> | ||
</div> | ||
<div className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden"> | ||
<StateGroupIcon stateGroup={groupKey} height="16px" width="16px" /> | ||
</div> | ||
)} | ||
<div className="text-base font-medium text-custom-text-200 capitalize px-1">{groupKey}</div> | ||
</div> | ||
<div | ||
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100" | ||
onClick={() => !createState && setCreateState(true)} | ||
> | ||
<Plus className="w-4 h-4" /> | ||
</div> | ||
</div> | ||
|
||
{isEditable && createState && ( | ||
<StateCreate | ||
workspaceSlug={workspaceSlug} | ||
projectId={projectId} | ||
groupKey={groupKey} | ||
handleClose={() => setCreateState(false)} | ||
/> | ||
{groupedStates[groupKey].length > 0 && currentStateExpanded && ( | ||
<div id="group-droppable-container"> | ||
<StateList | ||
workspaceSlug={workspaceSlug} | ||
projectId={projectId} | ||
groupKey={groupKey} | ||
groupedStates={groupedStates} | ||
states={states} | ||
disabled={!isEditable} | ||
/> | ||
</div> | ||
)} | ||
|
||
<div id="group-droppable-container"> | ||
<StateList | ||
workspaceSlug={workspaceSlug} | ||
projectId={projectId} | ||
groupKey={groupKey} | ||
groupedStates={groupedStates} | ||
states={states} | ||
disabled={!isEditable} | ||
/> | ||
</div> | ||
{isEditable && createState && ( | ||
<div className=""> | ||
<StateCreate | ||
workspaceSlug={workspaceSlug} | ||
projectId={projectId} | ||
groupKey={groupKey} | ||
handleClose={() => setCreateState(false)} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}); |
This file contains 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 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 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
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.
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.
🛠️ Refactor suggestion
Add ARIA attributes for accessibility.
The expandable section should have proper ARIA attributes for better accessibility.
📝 Committable suggestion