Skip to content

Commit ad2c0c8

Browse files
committed
feat: implement org-scoped app catalog with AppCatalogService and related hooks for improved app management
1 parent 66c7f7f commit ad2c0c8

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

apps/studio/src/components/ApiConsolePage.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useClient } from '@objectstack/client-react';
55
import { Badge } from '@/components/ui/badge';
66
import {
77
Globe, Play, Copy, Check, ChevronDown, ChevronRight, Clock,
8-
Loader2, Search, RefreshCw, Trash2, Plus, X,
8+
Loader2, Search, RefreshCw, Trash2, Plus, X, Server, FolderOpen,
99
} from 'lucide-react';
1010
import { useApiDiscovery, type EndpointDef, type HttpMethod } from '@/hooks/use-api-discovery';
1111
import {
@@ -65,7 +65,10 @@ let nextParamId = 1;
6565

6666
export function ApiConsolePage({ projectId }: { projectId?: string } = {}) {
6767
const client = useClient();
68-
const { groups, loading: discovering, refresh } = useApiDiscovery(projectId);
68+
// When a projectId is provided, allow toggling between project scope and system scope
69+
const [scopeMode, setScopeMode] = useState<'project' | 'system'>(projectId ? 'project' : 'system');
70+
const effectiveProjectId = projectId && scopeMode === 'project' ? projectId : undefined;
71+
const { groups, loading: discovering, refresh } = useApiDiscovery(effectiveProjectId);
6972

7073
const [searchQuery, setSearchQuery] = useState('');
7174
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());
@@ -246,6 +249,34 @@ export function ApiConsolePage({ projectId }: { projectId?: string } = {}) {
246249
<RefreshCw className={`h-3.5 w-3.5 ${discovering ? 'animate-spin' : ''}`} />
247250
</button>
248251
</div>
252+
253+
{/* Scope toggle — only shown when a project context is available */}
254+
{projectId && (
255+
<div className="flex items-center rounded-md border bg-muted/30 p-0.5 gap-0.5">
256+
<button
257+
onClick={() => setScopeMode('project')}
258+
className={`flex-1 flex items-center justify-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors ${
259+
scopeMode === 'project'
260+
? 'bg-background text-foreground shadow-sm'
261+
: 'text-muted-foreground hover:text-foreground'
262+
}`}
263+
>
264+
<FolderOpen className="h-3 w-3" />
265+
Project API
266+
</button>
267+
<button
268+
onClick={() => setScopeMode('system')}
269+
className={`flex-1 flex items-center justify-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors ${
270+
scopeMode === 'system'
271+
? 'bg-background text-foreground shadow-sm'
272+
: 'text-muted-foreground hover:text-foreground'
273+
}`}
274+
>
275+
<Server className="h-3 w-3" />
276+
System API
277+
</button>
278+
</div>
279+
)}
249280
<div className="relative">
250281
<Search className="absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
251282
<input

0 commit comments

Comments
 (0)