Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/components/src/components/archive/archive-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,20 @@ export function ArchivedSessionGroupSection({
);
}

export function ArchiveView() {
export type ArchiveViewProps = {
/**
* Suppresses the My Tasks / All Tasks scope control and pins the listing to
* the viewer's own archived sessions.
*
* A host whose workspace has exactly one member has nothing to switch
* between, so the control is a dropdown whose two entries list the same
* sessions. Defaults to `false`, which is the scope picker every cloud
* workspace has always had.
*/
hideTeamScope?: boolean;
};

export function ArchiveView({ hideTeamScope = false }: ArchiveViewProps = {}) {
const { t } = useTranslation();
const router = useRouter();
const isMobile = useIsMobile();
Expand All @@ -1010,7 +1023,11 @@ export function ArchiveView() {
const { restoreSession, deleteArchivedSession } = useSessionActions();
const openMobileDrawer = useSetAtom(setMobileDrawerOpenAtom);
const [deleteConfirmSession, setDeleteConfirmSession] = useState<SessionMeta | null>(null);
const [archiveScope, setArchiveScope] = useAtom(archiveScopeAtom);
const [storedArchiveScope, setArchiveScope] = useAtom(archiveScopeAtom);
// The stored scope is still written and still read back; it is only the
// ANSWER that is pinned, so turning the prop off restores the member's own
// last choice rather than a default.
const archiveScope = hideTeamScope ? 'my' : storedArchiveScope;
const [searchQuery, setSearchQuery] = useState('');
const [sortMode, setSortMode] = useState<ArchiveSortMode>('newest');
const [groupMode, setGroupMode] = useState<ArchiveGroupMode>('project');
Expand Down Expand Up @@ -1453,7 +1470,7 @@ export function ArchiveView() {
className="h-8 border-foreground/[0.10] bg-background pl-8 text-sm shadow-none dark:border-input-border dark:bg-input"
/>
</div>
{isMobile ? (
{isMobile && !hideTeamScope ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
Expand Down Expand Up @@ -1717,6 +1734,7 @@ export function ArchiveView() {
return (
<WebArchiveScreen
archiveScope={archiveScope}
hideTeamScope={hideTeamScope}
isMultiSelectMode={isMultiSelectMode}
selectedCount={selectedCount}
isBulkActionBusy={isBulkActionBusy}
Expand Down
11 changes: 11 additions & 0 deletions packages/components/src/components/archive/web-archive-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ type ArchiveScope = 'my' | 'team';

export type WebArchiveScreenProps = {
archiveScope: ArchiveScope;
/**
* Suppresses the My Tasks / All Tasks scope control in the header.
*
* A host whose workspace has one member has nothing to switch between. The
* Archive title keeps its place; only the dropdown beside it goes. Defaults to
* `false`, which is the header every cloud workspace has always had.
*/
hideTeamScope?: boolean;
isMultiSelectMode: boolean;
selectedCount: number;
isBulkActionBusy: boolean;
Expand All @@ -35,6 +43,7 @@ export type WebArchiveScreenProps = {

export function WebArchiveScreen({
archiveScope,
hideTeamScope = false,
isMultiSelectMode,
selectedCount,
isBulkActionBusy,
Expand Down Expand Up @@ -123,6 +132,7 @@ export function WebArchiveScreen({
<Archive className="h-4 w-4 text-muted-foreground" />
<h1 className="text-sm font-semibold">{t('archive.title', 'Archive')}</h1>
</div>
{hideTeamScope ? null : (
<div className="ml-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down Expand Up @@ -160,6 +170,7 @@ export function WebArchiveScreen({
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</>
)}
</header>
Expand Down