Skip to content

Commit 65057ab

Browse files
committed
Fix graph selection UI when no graphs are available
- Hide select graph button in GraphSelector component when graphHierarchy is empty - Update Workspace page to conditionally show select graph button based on availableGraphs - Change messaging from 'No Graph Selected' to 'No Graphs Available' when appropriate - Ensure TypeScript type safety for currentGraph null checks Resolves issue where users saw misleading 'Select Graph' options with no graphs present.
1 parent b0fb9ae commit 65057ab

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

packages/web/src/components/GraphSelector.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export function GraphSelector() {
9696
}
9797
};
9898

99-
if (!currentGraph || graphHierarchy.length === 0) {
99+
// Show no graphs available if we have no available graphs at all
100+
if (graphHierarchy.length === 0 || !currentGraph) {
100101
return (
101102
<div className="p-3">
102103
<div className="text-center text-gray-400">

packages/web/src/pages/Workspace.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function Workspace() {
1515
const [showCreateGraphModal, setShowCreateGraphModal] = useState(false);
1616
const [showGraphSelectionModal, setShowGraphSelectionModal] = useState(false);
1717
const [viewMode, setViewMode] = useState<'graph' | 'dashboard' | 'table' | 'cards' | 'kanban' | 'gantt' | 'calendar' | 'activity'>('graph');
18-
const { currentGraph } = useGraph();
18+
const { currentGraph, availableGraphs } = useGraph();
1919
const { currentTeam, currentUser } = useAuth();
2020

2121
// Get real-time counts for header display
@@ -255,31 +255,38 @@ export function Workspace() {
255255
</h1>
256256

257257
<h2 className="text-lg font-medium text-green-300 mb-4">
258-
No Graph Selected
258+
{availableGraphs.length > 0 ? 'No Graph Selected' : 'No Graphs Available'}
259259
</h2>
260260

261261
<p className="text-gray-300 mb-8 leading-relaxed">
262-
Ready to organize your work? Choose an existing graph or create a new one to get started.
262+
{availableGraphs.length > 0
263+
? 'Ready to organize your work? Choose an existing graph or create a new one to get started.'
264+
: 'Get started by creating your first graph to organize your work.'
265+
}
263266
</p>
264267

265268
{/* Action Buttons */}
266269
<div className="space-y-3 mb-8">
267-
<button
268-
onClick={() => setShowGraphSelectionModal(true)}
269-
className="w-full px-6 py-3 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition-all duration-200 font-medium flex items-center justify-center shadow-lg hover:shadow-xl transform hover:-translate-y-0.5"
270-
>
271-
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
272-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"/>
273-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 5a2 2 0 012-2h4a2 2 0 012 2v3H8V5z"/>
274-
</svg>
275-
Select Graph
276-
</button>
270+
{availableGraphs.length > 0 && (
271+
<>
272+
<button
273+
onClick={() => setShowGraphSelectionModal(true)}
274+
className="w-full px-6 py-3 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition-all duration-200 font-medium flex items-center justify-center shadow-lg hover:shadow-xl transform hover:-translate-y-0.5"
275+
>
276+
<svg className="h-4 w-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
277+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"/>
278+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 5a2 2 0 012-2h4a2 2 0 012 2v3H8V5z"/>
279+
</svg>
280+
Select Graph
281+
</button>
277282

278-
<div className="flex items-center">
279-
<div className="flex-1 border-t border-gray-600"></div>
280-
<span className="px-4 text-gray-400 text-xs font-medium bg-gray-900">OR</span>
281-
<div className="flex-1 border-t border-gray-600"></div>
282-
</div>
283+
<div className="flex items-center">
284+
<div className="flex-1 border-t border-gray-600"></div>
285+
<span className="px-4 text-gray-400 text-xs font-medium bg-gray-900">OR</span>
286+
<div className="flex-1 border-t border-gray-600"></div>
287+
</div>
288+
</>
289+
)}
283290

284291
<button
285292
onClick={() => setShowCreateGraphModal(true)}

0 commit comments

Comments
 (0)