Skip to content

Commit 15ac89c

Browse files
authored
Merge pull request #677 from dataelement/fix/sidebar-focus-truncation
fix: sidebar Focus list no longer truncates at 12 items without expand option
2 parents fc01993 + 757b88a commit 15ac89c

1 file changed

Lines changed: 60 additions & 7 deletions

File tree

frontend/src/pages/agent-detail/AgentDetailPage.tsx

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,10 @@ export default function AgentDetailPage() {
20632063
const [showAllFocus, setShowAllFocus] = useState(false);
20642064
const [showCompletedFocus, setShowCompletedFocus] = useState(false);
20652065
const [showAllReflections, setShowAllReflections] = useState(false);
2066+
// Sidebar Focus group expand states
2067+
const [showAllSideActive, setShowAllSideActive] = useState(false);
2068+
const [showAllSideSystem, setShowAllSideSystem] = useState(false);
2069+
const [showAllSideCompleted, setShowAllSideCompleted] = useState(false);
20662070
const [awareView, setAwareView] = useState<'list' | 'calendar'>('list');
20672071
const [awareCalendarMode, setAwareCalendarMode] = useState<'day' | 'week' | 'month'>('week');
20682072
const [awareCalendarDate, setAwareCalendarDate] = useState<Date>(() => new Date());
@@ -4448,12 +4452,42 @@ export default function AgentDetailPage() {
44484452
</div>
44494453
);
44504454
};
4451-
const renderFocusGroup = (title: string, items: FocusItem[]) => {
4455+
const SIDE_FOCUS_LIMIT = 12;
4456+
const renderFocusGroup = (
4457+
title: string,
4458+
items: FocusItem[],
4459+
showAll: boolean,
4460+
setShowAll: (val: boolean) => void,
4461+
) => {
44524462
if (items.length === 0) return null;
4463+
const hasMore = items.length > SIDE_FOCUS_LIMIT;
4464+
const visibleItems = showAll ? items : items.slice(0, SIDE_FOCUS_LIMIT);
44534465
return (
44544466
<div className="aware-side-focus-group">
4455-
<div className="aware-side-subtitle">{title}</div>
4456-
{items.slice(0, 12).map(renderFocusItem)}
4467+
<div className="aware-side-subtitle" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
4468+
<span>{title}</span>
4469+
{hasMore && (
4470+
<span style={{ fontSize: '11px', color: 'var(--text-tertiary)' }}>
4471+
{showAll ? '' : `${SIDE_FOCUS_LIMIT}/${items.length}`}
4472+
</span>
4473+
)}
4474+
</div>
4475+
{visibleItems.map(renderFocusItem)}
4476+
{hasMore && (
4477+
<button
4478+
type="button"
4479+
className="aware-side-collapse"
4480+
onClick={() => setShowAll(!showAll)}
4481+
style={{ marginTop: '4px', width: '100%', textAlign: 'center', borderTop: '1px dashed var(--border-subtle)', paddingTop: '6px' }}
4482+
>
4483+
<span>
4484+
{showAll
4485+
? (isZh ? '收起' : 'Show less')
4486+
: (isZh ? `显示更多 (+${items.length - SIDE_FOCUS_LIMIT})` : `Show more (+${items.length - SIDE_FOCUS_LIMIT})`)
4487+
}
4488+
</span>
4489+
</button>
4490+
)}
44574491
</div>
44584492
);
44594493
};
@@ -4612,19 +4646,38 @@ export default function AgentDetailPage() {
46124646
<div className="aware-side-empty">{t('agent.aware.focusEmpty')}</div>
46134647
) : (
46144648
<>
4615-
{renderFocusGroup(isZh ? '进行中' : 'In progress', activeFocusItems)}
4616-
{renderFocusGroup(isZh ? '系统 Focus' : 'System Focus', systemFocusItems)}
4649+
{renderFocusGroup(isZh ? '进行中' : 'In progress', activeFocusItems, showAllSideActive, setShowAllSideActive)}
4650+
{renderFocusGroup(isZh ? '系统 Focus' : 'System Focus', systemFocusItems, showAllSideSystem, setShowAllSideSystem)}
46174651
{completedFocusItems.length > 0 && (
46184652
<div className="aware-side-focus-group">
46194653
<button
46204654
type="button"
46214655
className="aware-side-collapse"
4622-
onClick={() => setShowCompletedFocus(!showCompletedFocus)}
4656+
onClick={() => { setShowCompletedFocus(!showCompletedFocus); setShowAllSideCompleted(false); }}
46234657
>
46244658
<span>{showCompletedFocus ? (isZh ? '收起已完成' : 'Hide completed') : (isZh ? `已完成 (${completedFocusItems.length})` : `Completed (${completedFocusItems.length})`)}</span>
46254659
<span className={`aware-side-chevron ${showCompletedFocus ? 'open' : ''}`}></span>
46264660
</button>
4627-
{showCompletedFocus && completedFocusItems.slice(0, 12).map(renderFocusItem)}
4661+
{showCompletedFocus && (
4662+
<>
4663+
{(showAllSideCompleted ? completedFocusItems : completedFocusItems.slice(0, SIDE_FOCUS_LIMIT)).map(renderFocusItem)}
4664+
{completedFocusItems.length > SIDE_FOCUS_LIMIT && (
4665+
<button
4666+
type="button"
4667+
className="aware-side-collapse"
4668+
onClick={() => setShowAllSideCompleted(!showAllSideCompleted)}
4669+
style={{ marginTop: '4px', width: '100%', textAlign: 'center', borderTop: '1px dashed var(--border-subtle)', paddingTop: '6px' }}
4670+
>
4671+
<span>
4672+
{showAllSideCompleted
4673+
? (isZh ? '收起' : 'Show less')
4674+
: (isZh ? `显示更多 (+${completedFocusItems.length - SIDE_FOCUS_LIMIT})` : `Show more (+${completedFocusItems.length - SIDE_FOCUS_LIMIT})`)
4675+
}
4676+
</span>
4677+
</button>
4678+
)}
4679+
</>
4680+
)}
46284681
</div>
46294682
)}
46304683
</>

0 commit comments

Comments
 (0)