Skip to content

Commit fff23f9

Browse files
committed
add secondary create project menu
1 parent a349c65 commit fff23f9

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

src/common/pickers/managers.ts

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,57 @@ export async function pickCreator(creators: PythonProjectCreator[]): Promise<Pyt
131131
return creators[0];
132132
}
133133

134-
const items: (QuickPickItem & { c: PythonProjectCreator })[] = creators.map((c) => ({
135-
label: c.displayName ?? c.name,
136-
description: c.description,
137-
c: c,
138-
}));
134+
// First level menu
135+
const autoFindCreator = creators.find((c) => c.name === 'autoProjects');
136+
const existingProjectsCreator = creators.find((c) => c.name === 'existingProjects');
137+
const otherCreators = creators.filter((c) => c.name !== 'autoProjects' && c.name !== 'existingProjects');
138+
139+
const items: QuickPickItem[] = [
140+
{
141+
label: 'Auto Find',
142+
description: autoFindCreator?.description ?? 'Automatically find Python projects',
143+
},
144+
{
145+
label: 'Select Existing',
146+
description: existingProjectsCreator?.description ?? 'Select existing Python projects',
147+
},
148+
{
149+
label: 'Create New...',
150+
description: 'Create a new Python project from a template',
151+
},
152+
];
153+
139154
const selected = await showQuickPick(items, {
140155
placeHolder: Pickers.Managers.selectProjectCreator,
141156
ignoreFocusOut: true,
142157
});
143-
return (selected as { c: PythonProjectCreator })?.c;
158+
159+
if (!selected) {
160+
return undefined;
161+
}
162+
163+
// Return appropriate creator based on selection
164+
switch (selected.label) {
165+
case 'Auto Find':
166+
return autoFindCreator;
167+
case 'Select Existing':
168+
return existingProjectsCreator;
169+
case 'Create New...':
170+
// Show second level menu for other creators
171+
if (otherCreators.length === 0) {
172+
return undefined;
173+
}
174+
const newItems: (QuickPickItem & { c: PythonProjectCreator })[] = otherCreators.map((c) => ({
175+
label: c.displayName ?? c.name,
176+
description: c.description,
177+
c: c,
178+
}));
179+
const newSelected = await showQuickPick(newItems, {
180+
placeHolder: 'Select project type for new project',
181+
ignoreFocusOut: true,
182+
});
183+
return newSelected?.c;
184+
}
185+
186+
return undefined;
144187
}

src/features/creators/newPackageProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PythonProjectManager } from '../../internal.api';
55

66
export class NewPackageProject implements PythonProjectCreator {
77
public readonly name = 'newPackage';
8-
public readonly displayName = 'New Python Package';
8+
public readonly displayName = 'Python Package';
99
public readonly description = 'Create a new Python package project';
1010
public readonly tooltip = new MarkdownString('Create a new Python package with proper structure');
1111

src/features/creators/newScriptProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PythonProjectManager } from '../../internal.api';
44

55
export class NewScriptProject implements PythonProjectCreator {
66
public readonly name = 'newScript';
7-
public readonly displayName = 'New Python Script';
7+
public readonly displayName = 'Script';
88
public readonly description = 'Create a new Python script project';
99
public readonly tooltip = new MarkdownString('Create a new Python script with basic structure');
1010

0 commit comments

Comments
 (0)