-
Notifications
You must be signed in to change notification settings - Fork 78
[FIX] Fix work items outer box #55
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
3 commits
Select commit
Hold shift + click to select a range
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
235 changes: 235 additions & 0 deletions
235
ui/src/components/project-issues/ProjectIssuesDisplayPanel.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,235 @@ | ||
| import { type ReactNode, useState } from 'react'; | ||
| import type { SavedViewGroupBy, SavedViewOrderBy } from '../../lib/projectSavedViewDisplay'; | ||
| import { | ||
| ALL_SAVED_VIEW_DISPLAY_PROPERTIES, | ||
| SAVED_VIEW_DISPLAY_PROPERTY_LABELS, | ||
| } from '../../lib/projectSavedViewDisplay'; | ||
| import type { ProjectIssuesDisplayState } from '../../lib/projectIssuesDisplay'; | ||
|
|
||
| const IconChevronDown = () => ( | ||
| <svg | ||
| width="12" | ||
| height="12" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| aria-hidden | ||
| > | ||
| <path d="m6 9 6 6 6-6" /> | ||
| </svg> | ||
| ); | ||
|
|
||
| const IconCheck = () => ( | ||
| <svg | ||
| width="12" | ||
| height="12" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2.5" | ||
| aria-hidden | ||
| > | ||
| <path d="M20 6 9 17l-5-5" /> | ||
| </svg> | ||
| ); | ||
|
|
||
| type SectionId = 'properties' | 'group' | 'order'; | ||
|
|
||
| const GROUP_OPTIONS: { value: SavedViewGroupBy; label: string }[] = [ | ||
| { value: 'states', label: 'States' }, | ||
| { value: 'priority', label: 'Priority' }, | ||
| { value: 'cycle', label: 'Cycle' }, | ||
| { value: 'module', label: 'Module' }, | ||
| { value: 'labels', label: 'Labels' }, | ||
| { value: 'assignees', label: 'Assignees' }, | ||
| { value: 'created_by', label: 'Created by' }, | ||
| { value: 'none', label: 'None' }, | ||
| ]; | ||
|
|
||
| const ORDER_OPTIONS: { value: SavedViewOrderBy; label: string }[] = [ | ||
| { value: 'manual', label: 'Manual' }, | ||
| { value: 'last_created', label: 'Last created' }, | ||
| { value: 'last_updated', label: 'Last updated' }, | ||
| { value: 'start_date', label: 'Start date' }, | ||
| { value: 'due_date', label: 'Due date' }, | ||
| { value: 'priority', label: 'Priority' }, | ||
| ]; | ||
|
|
||
| function CollapsibleSection(props: { | ||
| id: SectionId; | ||
| title: string; | ||
| expanded: boolean; | ||
| onToggle: (id: SectionId) => void; | ||
| children: ReactNode; | ||
| }) { | ||
| const { id, title, expanded, onToggle, children } = props; | ||
| return ( | ||
| <div className="border-b border-(--border-subtle) last:border-b-0"> | ||
| <button | ||
| type="button" | ||
| onClick={() => onToggle(id)} | ||
| className="flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-[11px] font-semibold tracking-wide text-(--txt-secondary)" | ||
| > | ||
| <span>{title}</span> | ||
| <span | ||
| className={`text-(--txt-icon-tertiary) transition-transform ${expanded ? 'rotate-180' : ''}`} | ||
| > | ||
| <IconChevronDown /> | ||
| </span> | ||
| </button> | ||
| {expanded ? <div className="px-2 pb-2">{children}</div> : null} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function RadioRow<T extends string>(props: { | ||
| selected: boolean; | ||
| value: T; | ||
| label: string; | ||
| onSelect: (v: T) => void; | ||
| }) { | ||
| const { selected, value, label, onSelect } = props; | ||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={() => onSelect(value)} | ||
| className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-(--txt-primary) hover:bg-(--bg-layer-1-hover) ${selected ? 'bg-(--bg-layer-1-hover)' : ''}`} | ||
| > | ||
| <span | ||
| className={`flex size-4 shrink-0 items-center justify-center rounded-full border-2 ${ | ||
| selected | ||
| ? 'border-(--brand-default) bg-(--brand-default) text-white' | ||
| : 'border-(--border-strong)' | ||
| }`} | ||
| > | ||
| {selected ? <IconCheck /> : null} | ||
| </span> | ||
| <span>{label}</span> | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| export interface ProjectIssuesDisplayPanelProps { | ||
| display: ProjectIssuesDisplayState; | ||
| setDisplay: React.Dispatch<React.SetStateAction<ProjectIssuesDisplayState>>; | ||
| } | ||
|
|
||
| export function ProjectIssuesDisplayPanel({ display, setDisplay }: ProjectIssuesDisplayPanelProps) { | ||
| const [sections, setSections] = useState<Record<SectionId, boolean>>({ | ||
| properties: true, | ||
| group: true, | ||
| order: true, | ||
| }); | ||
|
|
||
| const toggleSection = (id: SectionId) => { | ||
| setSections((s) => ({ ...s, [id]: !s[id] })); | ||
| }; | ||
|
|
||
| const toggleProperty = (id: (typeof ALL_SAVED_VIEW_DISPLAY_PROPERTIES)[number]) => { | ||
| setDisplay((prev) => { | ||
| const next = new Set(prev.displayProperties); | ||
| if (next.has(id)) next.delete(id); | ||
| else next.add(id); | ||
| return { ...prev, displayProperties: next }; | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="max-h-[min(70vh,560px)] overflow-y-auto py-1"> | ||
| <CollapsibleSection | ||
| id="properties" | ||
| title="Display properties" | ||
| expanded={sections.properties} | ||
| onToggle={toggleSection} | ||
| > | ||
| <div className="flex flex-wrap gap-1.5"> | ||
| {ALL_SAVED_VIEW_DISPLAY_PROPERTIES.map((prop) => { | ||
| const on = display.displayProperties.has(prop); | ||
| return ( | ||
| <button | ||
| key={prop} | ||
| type="button" | ||
| onClick={() => toggleProperty(prop)} | ||
| className={`rounded-md border px-2 py-1 text-[12px] font-medium transition-colors ${ | ||
| on | ||
| ? 'border-(--brand-default) bg-(--brand-default) text-white' | ||
| : 'border-(--border-subtle) bg-(--bg-layer-1) text-(--txt-secondary) hover:bg-(--bg-layer-1-hover)' | ||
| }`} | ||
| > | ||
| {SAVED_VIEW_DISPLAY_PROPERTY_LABELS[prop]} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
| </CollapsibleSection> | ||
|
|
||
| <CollapsibleSection | ||
| id="group" | ||
| title="Group by" | ||
| expanded={sections.group} | ||
| onToggle={toggleSection} | ||
| > | ||
| <div className="flex flex-col gap-0.5"> | ||
| {GROUP_OPTIONS.map((opt) => ( | ||
| <RadioRow | ||
| key={opt.value} | ||
| value={opt.value} | ||
| label={opt.label} | ||
| selected={display.groupBy === opt.value} | ||
| onSelect={(v) => setDisplay((p) => ({ ...p, groupBy: v }))} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </CollapsibleSection> | ||
|
|
||
| <CollapsibleSection | ||
| id="order" | ||
| title="Order by" | ||
| expanded={sections.order} | ||
| onToggle={toggleSection} | ||
| > | ||
| <div className="flex flex-col gap-0.5"> | ||
| {ORDER_OPTIONS.map((opt) => ( | ||
| <RadioRow | ||
| key={opt.value} | ||
| value={opt.value} | ||
| label={opt.label} | ||
| selected={display.orderBy === opt.value} | ||
| onSelect={(v) => setDisplay((p) => ({ ...p, orderBy: v }))} | ||
| /> | ||
| ))} | ||
| </div> | ||
| <div className="mx-2 my-2 border-t border-(--border-subtle)" /> | ||
| <label className="flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[13px] text-(--txt-primary) hover:bg-(--bg-layer-1-hover)"> | ||
| <input | ||
| type="checkbox" | ||
| className="size-3.5 rounded border-(--border-strong)" | ||
| checked={display.showSubWorkItems} | ||
| onChange={(e) => | ||
| setDisplay((p) => ({ | ||
| ...p, | ||
| showSubWorkItems: e.target.checked, | ||
| })) | ||
| } | ||
| /> | ||
| Show sub-work items | ||
| </label> | ||
| <label className="flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[13px] text-(--txt-primary) hover:bg-(--bg-layer-1-hover)"> | ||
| <input | ||
| type="checkbox" | ||
| className="size-3.5 rounded border-(--border-strong)" | ||
| checked={display.showEmptyGroups} | ||
| onChange={(e) => | ||
| setDisplay((p) => ({ | ||
| ...p, | ||
| showEmptyGroups: e.target.checked, | ||
| })) | ||
| } | ||
| /> | ||
| Show empty groups | ||
| </label> | ||
| </CollapsibleSection> | ||
| </div> | ||
| ); | ||
| } | ||
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.
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.
This file uses
React.Dispatch/React.SetStateActionbut doesn’t importReactas a type. In this repo’s TS setup, theReactnamespace won’t be in scope automatically, so the file won’t compile. Import the types directly fromreact(recommended) or add aimport type * as React from 'react'.