mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - The experimental Responsibilities dashboard (`outline_v2`) lists a
person's areas and responsibilities as a clean outline.
> - Today, operators cannot filter the Responsibilities outline by
whether a responsibility has routines, and rows do not show which agents
are assigned to those routines.
> - Operators need a quick visual signal of which responsibilities
already have agent-run routines and a fast way to focus on
responsibilities with or without routines.
> - This pull request adds `routineAgentIds` to `ResponsibilityRollup`,
adds the shared toolbar filter icon with "Has routines" and "No
routines" options (defaulting to either), and displays slightly
overlapping agent avatars on the right side of responsibility rows that
have assigned routines.
> - The benefit is faster scanning of routine coverage across
responsibilities without leaving the outline view.
## Linked Issues or Issue Description
**What existing behavior does this improve?**
The Responsibilities dashboard (`outline_v2` view at
`/<prefix>/responsibilities`) and the `ResponsibilityRollup` response
returned by `GET /api/companies/:companyId/responsibilities`.
**Subsystem affected**
Cross-cutting (multiple of the above)
**Current behavior**
The Responsibilities dashboard header shows only a search box, total
counts, and the New area button. Each responsibility row shows only its
bar sentence or title, with no visual indicator of which agents are
assigned to its routines and no filter to narrow by routine presence.
**Proposed behavior**
The header adds the shared toolbar Filter icon button beside the search
box, opening a popover with "Has routines" and "No routines" options
(both unchecked by default so either is shown) and a Clear action. Each
responsibility row with one or more non-archived routines assigned to
agents displays those agents' avatars slightly overlapping on the right
side of the row (up to 4 avatars with a `+N` overflow indicator and a
tooltip listing agent names).
**Reason and benefit**
Operators scanning their responsibilities need to see at a glance which
responsibilities already have agents running routines and quickly filter
to responsibilities that still need routines set up (or only those with
routines).
**Breaking changes**
Additive field `routineAgentIds: string[]` added to
`ResponsibilityRollup`. Existing callers ignore unknown fields.
## What Changed
- Added `routineAgentIds: string[]` to `ResponsibilityRollup` in
`packages/shared/src/types/responsibility.ts` and refreshed the pinned
hash in `tests/runner-e2e/source-sdk-public-inputs.json`.
- Updated `responsibilityService.computeRollups` and
`buildResponsibilityRollup` in `server/src/services/responsibilities.ts`
to select `routines.assigneeAgentId` (ordered deterministically by title
and id) and deduplicate non-null assignees across non-archived member
routines (direct and project-linked) with no extra queries.
- Added `OutlineV2RoutineFilter` and `filterOutlineV2Groups` in
`ui/src/lib/responsibility-outline-v2.ts`.
- Added the shared toolbar `Filter` icon popover ("Has routines" / "No
routines", default either) and live filtered counts to
`ui/src/pages/Responsibilities.tsx`.
- Updated `ui/src/components/responsibilities/DashboardOutlineV2.tsx` to
filter groups, unfold matching areas while filtered, show an empty-match
state with a Clear filter button, and render slightly overlapping
routine-agent avatars (`size={20}`, `-space-x-1.5`, capped at 4 with
`+N`) on the right side of each row that has routines with assigned
agents.
- Added unit, embedded-Postgres integration, jsdom UI, and Storybook
coverage (`server/src/__tests__/responsibilities-rollup.test.ts`,
`server/src/__tests__/responsibilities.test.ts`,
`ui/src/lib/responsibility-outline-v2.test.ts`,
`ui/src/components/responsibilities/DashboardOutlineV2.test.tsx`,
`ui/src/pages/Responsibilities.outline-v2.test.tsx`, and
`ui/storybook/stories/activity/responsibilities.stories.tsx`).
## Verification
- `pnpm --filter @paperclipai/shared build` — passed.
- `pnpm --filter @paperclipai/server typecheck` — passed (all 7 layers).
- `pnpm --filter @paperclipai/ui typecheck` — passed.
- `pnpm check:token-gates` — passed (all 4 gates clean).
- Focused Vitest suites (194 tests across 10 files) — passed:
- `server/src/__tests__/responsibilities-rollup.test.ts` (18/18)
- `server/src/__tests__/responsibilities.test.ts` (37/37, embedded
PostgreSQL)
- `server/src/__tests__/responsibility-summaries.test.ts`,
`responsibility-summary-generator.test.ts`,
`responsibility-tools.test.ts`
- `ui/src/lib/responsibilities.test.ts` (41/41),
`responsibility-views.test.ts` (35/35),
`responsibility-outline-v2.test.ts` (15/15)
- `ui/src/components/responsibilities/DashboardOutlineV2.test.tsx` (2/2)
- `ui/src/pages/Responsibilities.outline-v2.test.tsx` (1/1)
- Manually verified live Storybook preview (`Dashboard view: Outline v2,
routine avatars & filter`) in dark mode across default, "Has routines",
"No routines", and "Clear" states, confirming avatar overlap for 1, 2,
and 3 agents and empty states for rows without routines.
- Note: `pnpm verify` exited with code `2` because
`tests/runner-e2e/source-sdk-public-inputs.json` changed; CI supplies
the full broad suite.
## Risks
- Low risk. `routineAgentIds` is computed from the existing
`memberRoutines` query in `computeRollups` (adding one column selection
and deterministic ordering, no new queries or schema migrations).
## Model Used
- Google Gemini 4 Neon (High) via Antigravity with tool use and code
execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
391 lines
18 KiB
TypeScript
391 lines
18 KiB
TypeScript
import { useResolvedViewerId } from "@/hooks/useResolvedViewerId";
|
||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||
import { useQuery } from "@tanstack/react-query";
|
||
import type { ResponsibilityArea, ResponsibilityWithRollup } from "@paperclipai/shared";
|
||
import { Plus } from "lucide-react";
|
||
import { describeError } from "@/api/errors";
|
||
import { responsibilitiesApi } from "@/api/responsibilities";
|
||
import { FilterGroup, FilterRow, ToolbarFilterPopover } from "@/components/CollectionFilterOptions";
|
||
import { PageSkeleton } from "@/components/PageSkeleton";
|
||
import { QueryErrorState, QueryView, useQueryView } from "@/components/QueryView";
|
||
import { ToolbarSearch } from "@/components/ToolbarSearch";
|
||
import { AddResponsibilityDialog } from "@/components/responsibilities/AddResponsibilityDialog";
|
||
import { DashboardAgentStatus } from "@/components/responsibilities/DashboardAgentStatus";
|
||
import { DashboardAutomation } from "@/components/responsibilities/DashboardAutomation";
|
||
import { DashboardBoard } from "@/components/responsibilities/DashboardBoard";
|
||
import { DashboardChatComposer } from "@/components/responsibilities/DashboardChatComposer";
|
||
import { DashboardExceptions } from "@/components/responsibilities/DashboardExceptions";
|
||
import { DashboardOutline } from "@/components/responsibilities/DashboardOutline";
|
||
import { DashboardOutlineV2 } from "@/components/responsibilities/DashboardOutlineV2";
|
||
import { useAgentDirectory } from "@/components/responsibilities/AgentsWorking";
|
||
import { QuickAddResponsibilityDialog } from "@/components/responsibilities/QuickAddResponsibilityDialog";
|
||
import {
|
||
AddAreaDialog,
|
||
ArchiveAreaDialog,
|
||
RenameAreaDialog,
|
||
useRestoreArea,
|
||
} from "@/components/responsibilities/AreaDialogs";
|
||
import type { AreaActions } from "@/components/responsibilities/HomeSections";
|
||
import {
|
||
ResponsibilitiesHomeLayout,
|
||
type ResponsibilitiesHomeLayoutProps,
|
||
} from "@/components/responsibilities/ResponsibilitiesHomeLayout";
|
||
import {
|
||
ResponsibilityDelegateDialog,
|
||
type ResponsibilityDelegateTarget,
|
||
} from "@/components/responsibilities/ResponsibilityDelegateDialog";
|
||
import { usePageView } from "@/components/responsibilities/usePageView";
|
||
import { Button } from "@/components/ui/button";
|
||
import { useBreadcrumbs } from "@/context/BreadcrumbContext";
|
||
import { useCompany } from "@/context/CompanyContext";
|
||
import { useAgentlessOnboardingAutoOpen } from "@/hooks/useAgentlessOnboardingAutoOpen";
|
||
import { queryKeys } from "@/lib/queryKeys";
|
||
import {
|
||
delegationPrefillForReason,
|
||
onboardingProvenance,
|
||
type AttentionItem,
|
||
} from "@/lib/responsibilities";
|
||
import {
|
||
outlineV2Counts,
|
||
outlineV2CountsLabel,
|
||
outlineV2Groups,
|
||
outlineV2VisibleGroups,
|
||
type OutlineV2RoutineFilter,
|
||
} from "@/lib/responsibility-outline-v2";
|
||
import { DASHBOARD_DEFAULT_VIEW, DASHBOARD_VIEW_OPTIONS } from "@/lib/responsibility-views";
|
||
import { cn, formatShortDate } from "@/lib/utils";
|
||
|
||
type AreaRef = Pick<ResponsibilityArea, "id" | "title" | "status">;
|
||
|
||
interface NewTaskLaunch {
|
||
responsibility: ResponsibilityDelegateTarget;
|
||
defaultTitle: string;
|
||
projectId: string | null;
|
||
}
|
||
|
||
const EMPTY_AREAS: readonly AreaRef[] = [];
|
||
|
||
function ProvenanceLine({
|
||
responsibilities,
|
||
agentName,
|
||
}: {
|
||
responsibilities: readonly ResponsibilityWithRollup[];
|
||
agentName: (id: string) => string | undefined;
|
||
}) {
|
||
const provenance = useMemo(() => onboardingProvenance(responsibilities), [responsibilities]);
|
||
if (!provenance) return null;
|
||
const name = provenance.agentId ? agentName(provenance.agentId) : undefined;
|
||
return (
|
||
<p className="text-xs text-muted-foreground">
|
||
{name ? `Drafted by ${name} during onboarding.` : "Drafted during onboarding."}
|
||
{provenance.confirmedAt ? ` Confirmed by you on ${formatShortDate(provenance.confirmedAt)}.` : null}
|
||
</p>
|
||
);
|
||
}
|
||
|
||
/**
|
||
* The Responsibilities home, shown as "Dashboard" while the experimental flag
|
||
* is on. Loads the overview and agents, owns every dialog and mutation, and
|
||
* hands the loaded data to `ResponsibilitiesHomeLayout`.
|
||
*/
|
||
export function Responsibilities() {
|
||
const { selectedCompanyId } = useCompany();
|
||
const viewer = useResolvedViewerId();
|
||
if (viewer.error) return <QueryErrorState error={viewer.error} action="load your dashboard" onRetry={() => { void viewer.retry(); }} />;
|
||
if (!selectedCompanyId || !viewer.userId) return <PageSkeleton variant="dashboard" />;
|
||
return <OwnerDashboard key={JSON.stringify([selectedCompanyId, viewer.userId])} selectedCompanyId={selectedCompanyId} ownerUserId={viewer.userId} />;
|
||
}
|
||
|
||
function OwnerDashboard({ selectedCompanyId, ownerUserId }: { selectedCompanyId: string; ownerUserId: string }) {
|
||
const { setBreadcrumbs } = useBreadcrumbs();
|
||
const [includeLetGo, setIncludeLetGo] = useState(false);
|
||
const [adding, setAdding] = useState<{ areaId: string | null } | null>(null);
|
||
const [addingArea, setAddingArea] = useState(false);
|
||
const [keepEmptyAreas, setKeepEmptyAreas] = useState<ReadonlySet<string>>(() => new Set());
|
||
const [newTask, setNewTask] = useState<NewTaskLaunch | null>(null);
|
||
const [renaming, setRenaming] = useState<AreaRef | null>(null);
|
||
const [archiving, setArchiving] = useState<AreaRef | null>(null);
|
||
const restore = useRestoreArea();
|
||
// One dashboard, no switch between views; reviewing proposals visits the full layout.
|
||
const { view, visiting, visit, leave } = usePageView(DASHBOARD_VIEW_OPTIONS, DASHBOARD_DEFAULT_VIEW);
|
||
const [search, setSearch] = useState("");
|
||
const [routineFilter, setRoutineFilter] = useState<OutlineV2RoutineFilter>("all");
|
||
const clearRoutineFilter = useCallback(() => setRoutineFilter("all"), []);
|
||
const { agents, byId: agentsById, query: agentsQuery } = useAgentDirectory(selectedCompanyId);
|
||
const agentsView = useQueryView(agentsQuery);
|
||
// One clock per visit: day-level judgements, and a stable value keeps rows memoized.
|
||
const now = useMemo(() => new Date(), []);
|
||
|
||
// This page can be home, so it carries the same first-run offer as the classic dashboard.
|
||
useAgentlessOnboardingAutoOpen();
|
||
|
||
useEffect(() => {
|
||
setBreadcrumbs([{ label: "Dashboard" }]);
|
||
}, [setBreadcrumbs]);
|
||
|
||
const overviewQuery = useQuery({
|
||
queryKey: queryKeys.responsibilities.overview(selectedCompanyId ?? "__none__", { includeLetGo, ownerUserId }),
|
||
queryFn: () => responsibilitiesApi.overview(selectedCompanyId!, { includeLetGo, ownerUserId }),
|
||
enabled: !!selectedCompanyId,
|
||
});
|
||
const overview = overviewQuery.data;
|
||
const areasForNew = useMemo(
|
||
() => overview?.areas.filter((area) => area.status !== "archived") ?? EMPTY_AREAS,
|
||
[overview?.areas],
|
||
);
|
||
const ownedPerArea = useMemo(() => {
|
||
const counts = new Map<string, number>();
|
||
for (const item of overview?.responsibilities ?? []) if (item.areaId) counts.set(item.areaId, (counts.get(item.areaId) ?? 0) + 1);
|
||
return counts;
|
||
}, [overview?.responsibilities]);
|
||
|
||
const outlineGroups = useMemo(
|
||
() => (overview ? outlineV2Groups(overview.areas, overview.responsibilities, keepEmptyAreas) : null),
|
||
[overview, keepEmptyAreas],
|
||
);
|
||
const visibleOutlineGroups = useMemo(
|
||
() => (outlineGroups ? outlineV2VisibleGroups(outlineGroups, { search, routineFilter }) : null),
|
||
[outlineGroups, search, routineFilter],
|
||
);
|
||
// Outline v2's one line of numbers, beside its search and filter. Null on an empty dashboard.
|
||
const outlineCounts = useMemo(() => {
|
||
if (!overview || !outlineGroups || !visibleOutlineGroups) return null;
|
||
const total = outlineV2Counts(outlineGroups);
|
||
// The same rule as the view's empty state, which shows only the create module.
|
||
if (total.areas === 0 && total.responsibilities === 0 && overview.proposed.length === 0) return null;
|
||
return outlineV2Counts(visibleOutlineGroups);
|
||
}, [overview, outlineGroups, visibleOutlineGroups]);
|
||
|
||
const openAdd = useCallback((areaId: string | null) => setAdding({ areaId }), []);
|
||
const agentName = useCallback((id: string) => agentsById.get(id)?.name, [agentsById]);
|
||
const openNewTask = useCallback((responsibility: ResponsibilityWithRollup, item: AttentionItem) => {
|
||
const prefill = delegationPrefillForReason(item.text, responsibility.rollup.overdueProjects);
|
||
setNewTask({ responsibility: { id: responsibility.id, title: responsibility.title }, defaultTitle: prefill.title, projectId: prefill.projectId });
|
||
}, []);
|
||
const restoreArea = restore.mutate;
|
||
const areaActions = useMemo<AreaActions>(() => ({
|
||
onAddHere: (areaId) => openAdd(areaId),
|
||
onRename: setRenaming,
|
||
onArchive: setArchiving,
|
||
onRestore: (area) => restoreArea(area.id),
|
||
}), [openAdd, restoreArea]);
|
||
|
||
if (!selectedCompanyId) return null;
|
||
const isEmpty = overview !== undefined && overview.responsibilities.length === 0 && overview.proposed.length === 0;
|
||
|
||
return (
|
||
// The Board's four status columns get the wider page; Automation's rows span the whole content pane.
|
||
// At least as tall as the content pane, so the composer rests at its foot on a short page.
|
||
<div className={cn("mx-auto flex min-h-full w-full flex-col gap-8", view === "automation" ? "max-w-none" : view === "board" ? "max-w-7xl" : "max-w-5xl")}>
|
||
{/* An empty Outline v2 has nothing to search or count: no header, so no gap above the create module. */}
|
||
<header
|
||
className={cn(
|
||
"flex flex-wrap justify-between gap-4",
|
||
view === "outline_v2" ? "items-center" : "items-start",
|
||
view === "outline_v2" && !outlineCounts && "hidden",
|
||
)}
|
||
>
|
||
{view === "outline_v2" ? (
|
||
// The breadcrumb bar's heading already names the page: search, filter and the counts take the headline's place.
|
||
outlineCounts ? (
|
||
<div className="flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2">
|
||
<div className="design-page-toolbar gap-2">
|
||
<ToolbarSearch
|
||
query={search}
|
||
onQueryChange={setSearch}
|
||
label="Search your dashboard"
|
||
placeholder="Search"
|
||
inputType="search"
|
||
/>
|
||
<ToolbarFilterPopover
|
||
activeCount={routineFilter === "all" ? 0 : 1}
|
||
onClear={clearRoutineFilter}
|
||
label="Filter responsibilities"
|
||
contentLabel="Filter responsibilities"
|
||
align="start"
|
||
contentClassName="w-56"
|
||
triggerDataAttr="data-outline-v2-filter"
|
||
>
|
||
<div className="task-filters-grid">
|
||
<FilterGroup title="Routines" optionsKey="routines">
|
||
<FilterRow
|
||
label="Has routines"
|
||
checked={routineFilter === "has_routines"}
|
||
onToggle={() => setRoutineFilter((current) => (current === "has_routines" ? "all" : "has_routines"))}
|
||
/>
|
||
<FilterRow
|
||
label="No routines"
|
||
checked={routineFilter === "no_routines"}
|
||
onToggle={() => setRoutineFilter((current) => (current === "no_routines" ? "all" : "no_routines"))}
|
||
/>
|
||
</FilterGroup>
|
||
</div>
|
||
</ToolbarFilterPopover>
|
||
</div>
|
||
<p className="text-sm text-muted-foreground" data-dashboard-counts="">{outlineV2CountsLabel(outlineCounts)}</p>
|
||
</div>
|
||
) : null
|
||
) : (
|
||
<div className="flex min-w-0 flex-col gap-1">
|
||
<h1 className="text-2xl font-semibold text-foreground">Dashboard</h1>
|
||
{view === "full" ? (
|
||
<>
|
||
<p className="text-sm text-muted-foreground">What you own, whether each one is meeting its bar, and the work underneath.</p>
|
||
{overview ? <ProvenanceLine responsibilities={overview.responsibilities} agentName={agentName} /> : null}
|
||
</>
|
||
) : null}
|
||
</div>
|
||
)}
|
||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||
{visiting ? (
|
||
<Button variant="ghost" onClick={leave} data-dashboard-back="">
|
||
Back
|
||
</Button>
|
||
) : null}
|
||
{view === "outline_v2" ? (
|
||
// The page's one primary action, last in the row after search.
|
||
<Button onClick={() => setAddingArea(true)}>
|
||
<Plus aria-hidden="true" />
|
||
New area
|
||
</Button>
|
||
) : null}
|
||
{view === "full" || view === "board" ? (
|
||
<>
|
||
<Button variant="outline" onClick={() => setAddingArea(true)}>
|
||
<Plus aria-hidden="true" />
|
||
Add area
|
||
</Button>
|
||
{isEmpty ? null : (
|
||
<Button onClick={() => openAdd(null)}>
|
||
<Plus aria-hidden="true" />
|
||
Add responsibility
|
||
</Button>
|
||
)}
|
||
</>
|
||
) : null}
|
||
</div>
|
||
</header>
|
||
|
||
{restore.error ? (
|
||
<p role="alert" className="text-sm text-destructive">
|
||
Couldn’t restore the area. {describeError(restore.error).body}
|
||
</p>
|
||
) : null}
|
||
|
||
<QueryView
|
||
query={overviewQuery}
|
||
size="page"
|
||
action="load your responsibilities"
|
||
loading={<PageSkeleton variant="dashboard" />}
|
||
>
|
||
{(loaded) => {
|
||
const layoutProps: ResponsibilitiesHomeLayoutProps = {
|
||
companyId: selectedCompanyId,
|
||
overview: loaded,
|
||
agents,
|
||
agentsById,
|
||
now,
|
||
includeLetGo,
|
||
onToggleLetGo: () => setIncludeLetGo((value) => !value),
|
||
keepEmptyAreas,
|
||
onAddResponsibility: openAdd,
|
||
onNewTask: openNewTask,
|
||
areaActions,
|
||
};
|
||
if (view === "full") return <ResponsibilitiesHomeLayout {...layoutProps} />;
|
||
const viewProps = { ...layoutProps, onAddArea: () => setAddingArea(true), onReviewProposals: () => visit("full") };
|
||
if (view === "outline") return <DashboardOutline {...viewProps} />;
|
||
if (view === "outline_v2") {
|
||
return (
|
||
<DashboardOutlineV2
|
||
{...viewProps}
|
||
search={search}
|
||
routineFilter={routineFilter}
|
||
visibleGroups={visibleOutlineGroups ?? undefined}
|
||
onClearFilter={clearRoutineFilter}
|
||
/>
|
||
);
|
||
}
|
||
if (view === "board") return <DashboardBoard {...viewProps} />;
|
||
if (view === "automation") return <DashboardAutomation {...viewProps} />;
|
||
if (view === "agent_status") return <DashboardAgentStatus {...viewProps} />;
|
||
return <DashboardExceptions {...viewProps} />;
|
||
}}
|
||
</QueryView>
|
||
|
||
{/* Start a chat from any view: anchored to the foot of the content pane
|
||
like the chat and task composers. On a short page `mt-auto` rests it
|
||
there; on a long one it stays pinned while the page scrolls behind
|
||
it. Last in the page, so it never covers the last of the content.
|
||
The dock itself is see-through and lets clicks pass: no band fades
|
||
or clips the content beside and above the composer card. */}
|
||
<div
|
||
className="pointer-events-none sticky bottom-(--tc-composer-bottom) z-20 mt-auto pt-2 md:bottom-0"
|
||
data-dashboard-chat-dock=""
|
||
>
|
||
<div className="pointer-events-auto">
|
||
{agentsView.kind === "error" ? (
|
||
<div className="mb-2 rounded-lg border border-border bg-background px-4 py-3" data-dashboard-chat="error">
|
||
<QueryErrorState error={agentsView.error} size="inline" action="load your agents"
|
||
onRetry={agentsView.retry} retrying={agentsView.isFetching} />
|
||
</div>
|
||
) : null}
|
||
{/* Always mounted: it owns the draft, which a failed refresh must not discard. */}
|
||
<DashboardChatComposer companyId={selectedCompanyId} agents={agents} loaded={agentsQuery.data !== undefined} />
|
||
</div>
|
||
</div>
|
||
|
||
{/* Outline v2 adds a responsibility as one sentence; its bar is set up later on its page. */}
|
||
{view === "outline_v2" ? (
|
||
<QuickAddResponsibilityDialog
|
||
open={adding !== null}
|
||
onOpenChange={(open) => {
|
||
if (!open) setAdding(null);
|
||
}}
|
||
companyId={selectedCompanyId}
|
||
areas={areasForNew}
|
||
defaultAreaId={adding?.areaId ?? null}
|
||
/>
|
||
) : (
|
||
<AddResponsibilityDialog
|
||
open={adding !== null}
|
||
onOpenChange={(open) => {
|
||
if (!open) setAdding(null);
|
||
}}
|
||
companyId={selectedCompanyId}
|
||
areas={areasForNew}
|
||
defaultAreaId={adding?.areaId ?? null}
|
||
/>
|
||
)}
|
||
<AddAreaDialog
|
||
open={addingArea}
|
||
onOpenChange={setAddingArea}
|
||
companyId={selectedCompanyId}
|
||
onCreated={(area) => {
|
||
setKeepEmptyAreas((current) => new Set([...current, area.id]));
|
||
// With nothing on the page yet, the new area would not show: go straight to filling it.
|
||
if (isEmpty) openAdd(area.id);
|
||
}}
|
||
/>
|
||
{newTask ? (
|
||
<ResponsibilityDelegateDialog
|
||
open
|
||
onOpenChange={(open) => {
|
||
if (!open) setNewTask(null);
|
||
}}
|
||
companyId={selectedCompanyId}
|
||
responsibility={newTask.responsibility}
|
||
defaultTitle={newTask.defaultTitle}
|
||
projectId={newTask.projectId}
|
||
/>
|
||
) : null}
|
||
<RenameAreaDialog area={renaming} onOpenChange={(open) => { if (!open) setRenaming(null); }} />
|
||
<ArchiveAreaDialog
|
||
area={archiving}
|
||
ownedHere={archiving ? ownedPerArea.get(archiving.id) ?? 0 : 0}
|
||
onOpenChange={(open) => { if (!open) setArchiving(null); }}
|
||
/>
|
||
</div>
|
||
);
|
||
}
|