Skip to content

Commit 8afb35e

Browse files
committed
feat: add breadcrumbs to folder setting
1 parent c20c0ef commit 8afb35e

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src-web/components/FolderSettingsDialog.tsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import { createWorkspaceModel, foldersAtom, patchModel } from '@yaakapp-internal/models';
1+
import {
2+
createWorkspaceModel,
3+
foldersAtom,
4+
patchModel,
5+
workspacesAtom,
6+
} from '@yaakapp-internal/models';
27
import { useAtomValue } from 'jotai';
3-
import { useMemo, useState } from 'react';
8+
import { Fragment, useMemo, useState } from 'react';
49
import { useAuthTab } from '../hooks/useAuthTab';
510
import { useEnvironmentsBreakdown } from '../hooks/useEnvironmentsBreakdown';
611
import { useHeadersTab } from '../hooks/useHeadersTab';
712
import { useInheritedHeaders } from '../hooks/useInheritedHeaders';
13+
import { useParentFolders } from '../hooks/useParentFolders';
814
import { Button } from './core/Button';
915
import { CountBadge } from './core/CountBadge';
16+
import { Icon } from './core/Icon';
1017
import { Input } from './core/Input';
1118
import { Link } from './core/Link';
1219
import { VStack } from './core/Stacks';
@@ -36,7 +43,9 @@ export type FolderSettingsTab =
3643

3744
export function FolderSettingsDialog({ folderId, tab }: Props) {
3845
const folders = useAtomValue(foldersAtom);
46+
const workspaces = useAtomValue(workspacesAtom);
3947
const folder = folders.find((f) => f.id === folderId) ?? null;
48+
const parentFolders = useParentFolders(folder);
4049
const [activeTab, setActiveTab] = useState<string>(tab ?? TAB_GENERAL);
4150
const authTab = useAuthTab(TAB_AUTH, folder);
4251
const headersTab = useHeadersTab(TAB_HEADERS, folder);
@@ -47,6 +56,20 @@ export function FolderSettingsDialog({ folderId, tab }: Props) {
4756
);
4857
const numVars = (folderEnvironment?.variables ?? []).filter((v) => v.name).length;
4958

59+
const breadcrumbs = useMemo(() => {
60+
if (!folder) return [];
61+
62+
const workspace = workspaces.find((w) => w.id === folder.workspaceId);
63+
64+
const items = [];
65+
if (workspace) {
66+
items.push({ id: workspace.id, name: workspace.name });
67+
}
68+
items.push(...parentFolders.reverse().map((f) => ({ id: f.id, name: f.name })));
69+
70+
return items;
71+
}, [folder, parentFolders, workspaces]);
72+
5073
const tabs = useMemo<TabItem[]>(() => {
5174
if (folder == null) return [];
5275

@@ -82,6 +105,23 @@ export function FolderSettingsDialog({ folderId, tab }: Props) {
82105
</TabContent>
83106
<TabContent value={TAB_GENERAL} className="overflow-y-auto h-full px-4">
84107
<VStack space={3} className="pb-3 h-full">
108+
{breadcrumbs.length > 0 && (
109+
<div className="flex flex-col gap-1.5">
110+
<div className="text-xs font-medium text-text-subtle uppercase tracking-wide">
111+
Location
112+
</div>
113+
<div className="flex items-center gap-1.5 text-sm text-text-subtlest px-2 py-1.5 bg-surface rounded border border-border">
114+
{breadcrumbs.map((item, index) => (
115+
<Fragment key={item.id}>
116+
{index > 0 && <Icon icon="chevron_right" size="sm" className="opacity-50" />}
117+
<span className={index === breadcrumbs.length - 1 ? 'text-text-subtle' : ''}>
118+
{item.name}
119+
</span>
120+
</Fragment>
121+
))}
122+
</div>
123+
</div>
124+
)}
85125
<Input
86126
label="Folder Name"
87127
defaultValue={folder.name}

0 commit comments

Comments
 (0)