AP1.8a: Portfolio-Rang im Cockpit mit Reorder und Next-Action-Sortierung.
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 2m21s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 21s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 2m21s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 21s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d7aefed0de
commit
a19c6abd26
16 files changed
+426
-34
No files matched your search
@@ -1,20 +1,27 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { listInitiatives } from '../api/initiatives.js'
|
||||
import { reorderPortfolio } from '../api/workspace.js'
|
||||
import { StatusBadge } from '../components/StatusBadge.jsx'
|
||||
import { PriorityBadge } from '../components/PriorityBadge.jsx'
|
||||
import { EmptyState } from '../components/EmptyState.jsx'
|
||||
import { ErrorState } from '../components/ErrorState.jsx'
|
||||
import { LoadingState } from '../components/LoadingState.jsx'
|
||||
import { ReorderControls } from '../components/ReorderControls.jsx'
|
||||
import { scopedPath } from '../utils/routes.js'
|
||||
import { formatPortfolioRank, sortByPortfolioRank } from '../utils/portfolioRank.js'
|
||||
import { WidgetCard } from '../components/WidgetCard.jsx'
|
||||
import { ArchetypeBadge } from '../components/ArchetypeBadge.jsx'
|
||||
import { useEntityArchetypes } from '../hooks/useEntityArchetypes.js'
|
||||
import { useCapabilities } from '../hooks/useCapabilities.js'
|
||||
|
||||
export function InitiativePortfolioWidget() {
|
||||
const { initiativeArchetypes } = useEntityArchetypes()
|
||||
const { hasCapability } = useCapabilities()
|
||||
const canManage = hasCapability('kairo.initiative.manage')
|
||||
const [initiatives, setInitiatives] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
@@ -34,13 +41,42 @@ export function InitiativePortfolioWidget() {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
const sortedInitiatives = useMemo(() => sortByPortfolioRank(initiatives), [initiatives])
|
||||
|
||||
async function handleMove(itemId, direction) {
|
||||
const sorted = sortByPortfolioRank(initiatives)
|
||||
const fromIndex = sorted.findIndex((item) => item.id === itemId)
|
||||
if (fromIndex < 0) return
|
||||
const toIndex = direction === 'up' ? fromIndex - 1 : fromIndex + 1
|
||||
if (toIndex < 0 || toIndex >= sorted.length) return
|
||||
|
||||
const next = [...sorted]
|
||||
const [moved] = next.splice(fromIndex, 1)
|
||||
next.splice(toIndex, 0, moved)
|
||||
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
try {
|
||||
const updated = await reorderPortfolio(next.map((item) => item.id))
|
||||
setInitiatives(Array.isArray(updated) ? updated : next)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<WidgetCard
|
||||
title="Portfolio — alle Vorhaben"
|
||||
subtitle="Querschnitt über deine Initiativen. Klick öffnet die Steuerungs-Übersicht."
|
||||
subtitle={
|
||||
canManage
|
||||
? 'Nach Portfolio-Priorität sortiert — ↑↓ setzt die Aufmerksamkeits-Reihenfolge.'
|
||||
: 'Querschnitt über deine Initiativen. Klick öffnet die Steuerungs-Übersicht.'
|
||||
}
|
||||
className="widget-card--span-full"
|
||||
actions={
|
||||
<button type="button" className="btn btn-ghost" onClick={load} disabled={loading}>
|
||||
<button type="button" className="btn btn-ghost" onClick={load} disabled={loading || busy}>
|
||||
Aktualisieren
|
||||
</button>
|
||||
}
|
||||
@@ -52,26 +88,48 @@ export function InitiativePortfolioWidget() {
|
||||
)}
|
||||
{!loading && !error && initiatives.length > 0 && (
|
||||
<div className="initiative-portfolio-grid">
|
||||
{initiatives.map((item) => (
|
||||
<Link
|
||||
key={item.id}
|
||||
to={scopedPath('/control/status', { initiativeId: item.id })}
|
||||
className="initiative-portfolio-card card"
|
||||
>
|
||||
<h3 className="initiative-portfolio-card-title">{item.title}</h3>
|
||||
{item.goal && (
|
||||
<p className="initiative-portfolio-card-goal muted">{item.goal}</p>
|
||||
)}
|
||||
<div className="initiative-portfolio-card-badges">
|
||||
<ArchetypeBadge
|
||||
archetypeKey={item.archetype_key}
|
||||
archetypes={initiativeArchetypes}
|
||||
/>
|
||||
<StatusBadge kind="initiative" status={item.status} />
|
||||
<PriorityBadge priority={item.priority} />
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
{sortedInitiatives.map((item, index) => {
|
||||
const rankLabel = formatPortfolioRank(item.portfolio_rank ?? index)
|
||||
return (
|
||||
<article key={item.id} className="initiative-portfolio-card card">
|
||||
{canManage && (
|
||||
<div className="initiative-portfolio-card__reorder">
|
||||
<ReorderControls
|
||||
itemId={item.id}
|
||||
canMoveUp={index > 0}
|
||||
canMoveDown={index < sortedInitiatives.length - 1}
|
||||
onMove={(direction) => handleMove(item.id, direction)}
|
||||
busy={busy}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Link
|
||||
to={scopedPath('/control/status', { initiativeId: item.id })}
|
||||
className="initiative-portfolio-card__link"
|
||||
>
|
||||
<div className="initiative-portfolio-card__head">
|
||||
{rankLabel && (
|
||||
<span className="initiative-portfolio-card__rank" title="Portfolio-Priorität">
|
||||
{rankLabel}
|
||||
</span>
|
||||
)}
|
||||
<h3 className="initiative-portfolio-card-title">{item.title}</h3>
|
||||
</div>
|
||||
{item.goal && (
|
||||
<p className="initiative-portfolio-card-goal muted">{item.goal}</p>
|
||||
)}
|
||||
<div className="initiative-portfolio-card-badges">
|
||||
<ArchetypeBadge
|
||||
archetypeKey={item.archetype_key}
|
||||
archetypes={initiativeArchetypes}
|
||||
/>
|
||||
<StatusBadge kind="initiative" status={item.status} />
|
||||
<PriorityBadge priority={item.priority} />
|
||||
</div>
|
||||
</Link>
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</WidgetCard>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ErrorState } from '../components/ErrorState.jsx'
|
||||
import { LoadingState } from '../components/LoadingState.jsx'
|
||||
import { WidgetCard } from '../components/WidgetCard.jsx'
|
||||
import { actionPath, scopedPath } from '../utils/routes.js'
|
||||
import { formatPortfolioRank } from '../utils/portfolioRank.js'
|
||||
|
||||
function NextActionList({ items, initiativeId, showInitiativeLink = true }) {
|
||||
if (items.length === 0) {
|
||||
@@ -43,6 +44,11 @@ function NextActionList({ items, initiativeId, showInitiativeLink = true }) {
|
||||
>
|
||||
<div className="list-item-main">
|
||||
<span className="next-action-rank">{index + 1}</span>
|
||||
{item.portfolio_rank != null && (
|
||||
<span className="next-action-portfolio-rank muted" title="Portfolio-Priorität">
|
||||
{formatPortfolioRank(item.portfolio_rank)}
|
||||
</span>
|
||||
)}
|
||||
<span className="badge status-badge status-active next-action-kind">
|
||||
{NEXT_ACTION_KIND_LABELS[item.kind] || item.kind}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user