Skip to content

Commit c55b8c9

Browse files
committed
Remove the Quick Input sample
1 parent b9739d6 commit c55b8c9

File tree

1 file changed

+5
-136
lines changed

1 file changed

+5
-136
lines changed

integration/vscode/ada/src/multiStepInput.ts

Lines changed: 5 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
/**
7+
* This file is laregely based on the Quick Picker Sample project by Microsoft,
8+
* with some additions and fixes by AdaCore.
9+
*/
10+
611
import {
712
QuickPickItem,
813
window,
@@ -15,142 +20,6 @@ import {
1520
Uri,
1621
} from 'vscode';
1722

18-
/**
19-
* A multi-step input using window.createQuickPick() and window.createInputBox().
20-
*
21-
* This first part uses the helper class `MultiStepInput` that wraps the API for the multi-step case.
22-
*/
23-
export async function multiStepInput(context: ExtensionContext) {
24-
class MyButton implements QuickInputButton {
25-
constructor(
26-
public iconPath: { light: Uri; dark: Uri },
27-
public tooltip: string,
28-
) {}
29-
}
30-
31-
const createResourceGroupButton = new MyButton(
32-
{
33-
dark: Uri.file(context.asAbsolutePath('resources/dark/add.svg')),
34-
light: Uri.file(context.asAbsolutePath('resources/light/add.svg')),
35-
},
36-
'Create Resource Group',
37-
);
38-
39-
const resourceGroups: QuickPickItem[] = [
40-
'vscode-data-function',
41-
'vscode-appservice-microservices',
42-
'vscode-appservice-monitor',
43-
'vscode-appservice-preview',
44-
'vscode-appservice-prod',
45-
].map((label) => ({ label }));
46-
47-
interface State {
48-
title: string;
49-
step: number;
50-
totalSteps: number;
51-
resourceGroup: QuickPickItem | string;
52-
name: string;
53-
runtime: QuickPickItem;
54-
}
55-
56-
async function collectInputs() {
57-
const state = {} as Partial<State>;
58-
await MultiStepInput.run((input) => pickResourceGroup(input, state));
59-
return state as State;
60-
}
61-
62-
const title = 'Create Application Service';
63-
64-
async function pickResourceGroup(input: MultiStepInput, state: Partial<State>) {
65-
const pick = await input.showQuickPick({
66-
title,
67-
step: 1,
68-
totalSteps: 3,
69-
placeholder: 'Pick a resource group',
70-
items: resourceGroups,
71-
activeItem: typeof state.resourceGroup !== 'string' ? state.resourceGroup : undefined,
72-
buttons: [createResourceGroupButton],
73-
shouldResume: shouldResume,
74-
});
75-
if (pick instanceof MyButton) {
76-
return (input: MultiStepInput) => inputResourceGroupName(input, state);
77-
}
78-
state.resourceGroup = pick;
79-
return (input: MultiStepInput) => inputName(input, state);
80-
}
81-
82-
async function inputResourceGroupName(input: MultiStepInput, state: Partial<State>) {
83-
state.resourceGroup = await input.showInputBox({
84-
title,
85-
step: 2,
86-
totalSteps: 4,
87-
value: typeof state.resourceGroup === 'string' ? state.resourceGroup : '',
88-
prompt: 'Choose a unique name for the resource group',
89-
validate: validateNameIsUnique,
90-
shouldResume: shouldResume,
91-
});
92-
return (input: MultiStepInput) => inputName(input, state);
93-
}
94-
95-
async function inputName(input: MultiStepInput, state: Partial<State>) {
96-
const additionalSteps = typeof state.resourceGroup === 'string' ? 1 : 0;
97-
// TODO: Remember current value when navigating back.
98-
state.name = await input.showInputBox({
99-
title,
100-
step: 2 + additionalSteps,
101-
totalSteps: 3 + additionalSteps,
102-
value: state.name || '',
103-
prompt: 'Choose a unique name for the Application Service',
104-
validate: validateNameIsUnique,
105-
shouldResume: shouldResume,
106-
});
107-
return (input: MultiStepInput) => pickRuntime(input, state);
108-
}
109-
110-
async function pickRuntime(input: MultiStepInput, state: Partial<State>) {
111-
const additionalSteps = typeof state.resourceGroup === 'string' ? 1 : 0;
112-
const runtimes = await getAvailableRuntimes(
113-
state.resourceGroup!,
114-
undefined /* TODO: token */,
115-
);
116-
// TODO: Remember currently active item when navigating back.
117-
state.runtime = await input.showQuickPick({
118-
title,
119-
step: 3 + additionalSteps,
120-
totalSteps: 3 + additionalSteps,
121-
placeholder: 'Pick a runtime',
122-
items: runtimes,
123-
activeItem: state.runtime,
124-
shouldResume: shouldResume,
125-
});
126-
}
127-
128-
function shouldResume() {
129-
// Could show a notification with the option to resume.
130-
return new Promise<boolean>((resolve, reject) => {
131-
// noop
132-
});
133-
}
134-
135-
async function validateNameIsUnique(name: string) {
136-
// ...validate...
137-
await new Promise((resolve) => setTimeout(resolve, 1000));
138-
return name === 'vscode' ? 'Name not unique' : undefined;
139-
}
140-
141-
async function getAvailableRuntimes(
142-
resourceGroup: QuickPickItem | string,
143-
token?: CancellationToken,
144-
): Promise<QuickPickItem[]> {
145-
// ...retrieve...
146-
await new Promise((resolve) => setTimeout(resolve, 1000));
147-
return ['Node 8.9', 'Node 6.11', 'Node 4.5'].map((label) => ({ label }));
148-
}
149-
150-
const state = await collectInputs();
151-
window.showInformationMessage(`Creating Application Service '${state.name}'`);
152-
}
153-
15423
// -------------------------------------------------------
15524
// Helper code that wraps the API for the multi-step case.
15625
// -------------------------------------------------------

0 commit comments

Comments
 (0)