@theia/getting-started 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -37
- package/lib/browser/getting-started-widget.d.ts.map +1 -1
- package/lib/browser/getting-started-widget.js +8 -14
- package/lib/browser/getting-started-widget.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/getting-started-contribution.ts +126 -126
- package/src/browser/getting-started-frontend-module.ts +33 -33
- package/src/browser/getting-started-preferences.ts +69 -69
- package/src/browser/getting-started-widget.tsx +625 -628
- package/src/browser/style/index.css +129 -129
- package/src/package.spec.ts +28 -28
|
@@ -1,628 +1,625 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { codicon, CommonCommands, Key, KeyCode, LabelProvider, Message, PreferenceService, ReactWidget } from '@theia/core/lib/browser';
|
|
18
|
-
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
19
|
-
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
20
|
-
import { CommandRegistry, environment, isOSX, Path } from '@theia/core/lib/common';
|
|
21
|
-
import { ApplicationInfo, ApplicationServer } from '@theia/core/lib/common/application-protocol';
|
|
22
|
-
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
23
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
24
|
-
import URI from '@theia/core/lib/common/uri';
|
|
25
|
-
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
26
|
-
import * as React from '@theia/core/shared/react';
|
|
27
|
-
import { KeymapsCommands } from '@theia/keymaps/lib/browser';
|
|
28
|
-
import { WorkspaceCommands, WorkspaceService } from '@theia/workspace/lib/browser';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Default implementation of the `GettingStartedWidget`.
|
|
32
|
-
* The widget is displayed when there are currently no workspaces present.
|
|
33
|
-
* Some of the features displayed include:
|
|
34
|
-
* - `open` commands.
|
|
35
|
-
* - `recently used workspaces`.
|
|
36
|
-
* - `settings` commands.
|
|
37
|
-
* - `help` commands.
|
|
38
|
-
* - helpful links.
|
|
39
|
-
*/
|
|
40
|
-
@injectable()
|
|
41
|
-
export class GettingStartedWidget extends ReactWidget {
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The widget `id`.
|
|
45
|
-
*/
|
|
46
|
-
static readonly ID = 'getting.started.widget';
|
|
47
|
-
/**
|
|
48
|
-
* The widget `label` which is used for display purposes.
|
|
49
|
-
*/
|
|
50
|
-
static readonly LABEL = nls.localizeByDefault('Welcome');
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The `ApplicationInfo` for the application if available.
|
|
54
|
-
* Used in order to obtain the version number of the application.
|
|
55
|
-
*/
|
|
56
|
-
protected applicationInfo: ApplicationInfo | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* The application name which is used for display purposes.
|
|
59
|
-
*/
|
|
60
|
-
protected applicationName = FrontendApplicationConfigProvider.get().applicationName;
|
|
61
|
-
|
|
62
|
-
protected home: string | undefined;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The recently used workspaces limit.
|
|
66
|
-
* Used in order to limit the number of recently used workspaces to display.
|
|
67
|
-
*/
|
|
68
|
-
protected recentLimit = 5;
|
|
69
|
-
/**
|
|
70
|
-
* The list of recently used workspaces.
|
|
71
|
-
*/
|
|
72
|
-
protected recentWorkspaces: string[] = [];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Indicates whether the "ai-core" extension is available.
|
|
76
|
-
*/
|
|
77
|
-
protected aiIsIncluded: boolean;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Collection of useful links to display for end users.
|
|
81
|
-
*/
|
|
82
|
-
protected readonly documentationUrl = 'https://www.theia-ide.org/docs/';
|
|
83
|
-
protected readonly compatibilityUrl = 'https://eclipse-theia.github.io/vscode-theia-comparator/status.html';
|
|
84
|
-
protected readonly extensionUrl = 'https://www.theia-ide.org/docs/authoring_extensions';
|
|
85
|
-
protected readonly pluginUrl = 'https://www.theia-ide.org/docs/authoring_plugins';
|
|
86
|
-
protected readonly theiaAIDocUrl = 'https://theia-ide.org/docs/user_ai/';
|
|
87
|
-
protected readonly ghProjectUrl = 'https://github.com/eclipse-theia/theia/issues/new/choose';
|
|
88
|
-
|
|
89
|
-
@inject(ApplicationServer)
|
|
90
|
-
protected readonly appServer: ApplicationServer;
|
|
91
|
-
|
|
92
|
-
@inject(CommandRegistry)
|
|
93
|
-
protected readonly commandRegistry: CommandRegistry;
|
|
94
|
-
|
|
95
|
-
@inject(EnvVariablesServer)
|
|
96
|
-
protected readonly environments: EnvVariablesServer;
|
|
97
|
-
|
|
98
|
-
@inject(LabelProvider)
|
|
99
|
-
protected readonly labelProvider: LabelProvider;
|
|
100
|
-
|
|
101
|
-
@inject(WindowService)
|
|
102
|
-
protected readonly windowService: WindowService;
|
|
103
|
-
|
|
104
|
-
@inject(WorkspaceService)
|
|
105
|
-
protected readonly workspaceService: WorkspaceService;
|
|
106
|
-
|
|
107
|
-
@inject(PreferenceService)
|
|
108
|
-
protected readonly preferenceService: PreferenceService;
|
|
109
|
-
|
|
110
|
-
@postConstruct()
|
|
111
|
-
protected init(): void {
|
|
112
|
-
this.doInit();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
protected async doInit(): Promise<void> {
|
|
116
|
-
this.id = GettingStartedWidget.ID;
|
|
117
|
-
this.title.label = GettingStartedWidget.LABEL;
|
|
118
|
-
this.title.caption = GettingStartedWidget.LABEL;
|
|
119
|
-
this.title.closable = true;
|
|
120
|
-
|
|
121
|
-
this.applicationInfo = await this.appServer.getApplicationInfo();
|
|
122
|
-
this.recentWorkspaces = await this.workspaceService.recentWorkspaces();
|
|
123
|
-
this.home = new URI(await this.environments.getHomeDirUri()).path.toString();
|
|
124
|
-
|
|
125
|
-
const extensions = await this.appServer.getExtensionsInfos();
|
|
126
|
-
this.aiIsIncluded = extensions.find(ext => ext.name === '@theia/ai-core') !== undefined;
|
|
127
|
-
this.update();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
protected override onActivateRequest(msg: Message): void {
|
|
131
|
-
super.onActivateRequest(msg);
|
|
132
|
-
const elArr = this.node.getElementsByTagName('a');
|
|
133
|
-
if (elArr && elArr.length > 0) {
|
|
134
|
-
(elArr[0] as HTMLElement).focus();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Render the content of the widget.
|
|
140
|
-
*/
|
|
141
|
-
protected render(): React.ReactNode {
|
|
142
|
-
return <div className='gs-container'>
|
|
143
|
-
<div className='gs-content-container'>
|
|
144
|
-
{this.aiIsIncluded &&
|
|
145
|
-
<div className='gs-float shadow-pulse'>
|
|
146
|
-
{this.renderAIBanner()}
|
|
147
|
-
</div>
|
|
148
|
-
}
|
|
149
|
-
{this.renderHeader()}
|
|
150
|
-
<hr className='gs-hr' />
|
|
151
|
-
<div className='flex-grid'>
|
|
152
|
-
<div className='col'>
|
|
153
|
-
{this.renderStart()}
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
<div className='flex-grid'>
|
|
157
|
-
<div className='col'>
|
|
158
|
-
{this.renderRecentWorkspaces()}
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
<div className='flex-grid'>
|
|
162
|
-
<div className='col'>
|
|
163
|
-
{this.renderSettings()}
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
<div className='flex-grid'>
|
|
167
|
-
<div className='col'>
|
|
168
|
-
{this.renderHelp()}
|
|
169
|
-
</div>
|
|
170
|
-
</div>
|
|
171
|
-
<div className='flex-grid'>
|
|
172
|
-
<div className='col'>
|
|
173
|
-
{this.renderVersion()}
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
<div className='gs-preference-container'>
|
|
178
|
-
{this.renderPreferences()}
|
|
179
|
-
</div>
|
|
180
|
-
</div>;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Render the widget header.
|
|
185
|
-
* Renders the title `{applicationName} Getting Started`.
|
|
186
|
-
*/
|
|
187
|
-
protected renderHeader(): React.ReactNode {
|
|
188
|
-
return <div className='gs-header'>
|
|
189
|
-
<h1>{this.applicationName}<span className='gs-sub-header'>{' ' + GettingStartedWidget.LABEL}</span></h1>
|
|
190
|
-
</div>;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Render the `Start` section.
|
|
195
|
-
* Displays a collection of "start-to-work" related commands like `open` commands and some other.
|
|
196
|
-
*/
|
|
197
|
-
protected renderStart(): React.ReactNode {
|
|
198
|
-
const requireSingleOpen = isOSX || !environment.electron.is();
|
|
199
|
-
|
|
200
|
-
const createFile = <div className='gs-action-container'>
|
|
201
|
-
<a
|
|
202
|
-
role={'button'}
|
|
203
|
-
tabIndex={0}
|
|
204
|
-
onClick={this.doCreateFile}
|
|
205
|
-
onKeyDown={this.doCreateFileEnter}>
|
|
206
|
-
{CommonCommands.NEW_UNTITLED_FILE.label ?? nls.localizeByDefault('New File...')}
|
|
207
|
-
</a>
|
|
208
|
-
</div>;
|
|
209
|
-
|
|
210
|
-
const open = requireSingleOpen && <div className='gs-action-container'>
|
|
211
|
-
<a
|
|
212
|
-
role={'button'}
|
|
213
|
-
tabIndex={0}
|
|
214
|
-
onClick={this.doOpen}
|
|
215
|
-
onKeyDown={this.doOpenEnter}>
|
|
216
|
-
{nls.localizeByDefault('Open')}
|
|
217
|
-
</a>
|
|
218
|
-
</div>;
|
|
219
|
-
|
|
220
|
-
const openFile = !requireSingleOpen && <div className='gs-action-container'>
|
|
221
|
-
<a
|
|
222
|
-
role={'button'}
|
|
223
|
-
tabIndex={0}
|
|
224
|
-
onClick={this.doOpenFile}
|
|
225
|
-
onKeyDown={this.doOpenFileEnter}>
|
|
226
|
-
{nls.localizeByDefault('Open File')}
|
|
227
|
-
</a>
|
|
228
|
-
</div>;
|
|
229
|
-
|
|
230
|
-
const openFolder = !requireSingleOpen && <div className='gs-action-container'>
|
|
231
|
-
<a
|
|
232
|
-
role={'button'}
|
|
233
|
-
tabIndex={0}
|
|
234
|
-
onClick={this.doOpenFolder}
|
|
235
|
-
onKeyDown={this.doOpenFolderEnter}>
|
|
236
|
-
{nls.localizeByDefault('Open Folder')}
|
|
237
|
-
</a>
|
|
238
|
-
</div>;
|
|
239
|
-
|
|
240
|
-
const openWorkspace = (
|
|
241
|
-
<a
|
|
242
|
-
role={'button'}
|
|
243
|
-
tabIndex={0}
|
|
244
|
-
onClick={this.doOpenWorkspace}
|
|
245
|
-
onKeyDown={this.doOpenWorkspaceEnter}>
|
|
246
|
-
{nls.localizeByDefault('Open Workspace')}
|
|
247
|
-
</a>
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
return <div className='gs-section'>
|
|
251
|
-
<h3 className='gs-section-header'><i className={codicon('folder-opened')}></i>{nls.localizeByDefault('Start')}</h3>
|
|
252
|
-
{createFile}
|
|
253
|
-
{open}
|
|
254
|
-
{openFile}
|
|
255
|
-
{openFolder}
|
|
256
|
-
{openWorkspace}
|
|
257
|
-
</div>;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Render the recently used workspaces section.
|
|
262
|
-
*/
|
|
263
|
-
protected renderRecentWorkspaces(): React.ReactNode {
|
|
264
|
-
const items = this.recentWorkspaces;
|
|
265
|
-
const paths = this.buildPaths(items);
|
|
266
|
-
const content = paths.slice(0, this.recentLimit).map((item, index) =>
|
|
267
|
-
<div className='gs-action-container' key={index}>
|
|
268
|
-
<a
|
|
269
|
-
role={'button'}
|
|
270
|
-
tabIndex={0}
|
|
271
|
-
onClick={() => this.open(new URI(items[index]))}
|
|
272
|
-
onKeyDown={(e: React.KeyboardEvent) => this.openEnter(e, new URI(items[index]))}>
|
|
273
|
-
{new URI(items[index]).path.base}
|
|
274
|
-
</a>
|
|
275
|
-
<span className='gs-action-details'>
|
|
276
|
-
{item}
|
|
277
|
-
</span>
|
|
278
|
-
</div>
|
|
279
|
-
);
|
|
280
|
-
// If the recently used workspaces list exceeds the limit, display `More...` which triggers the recently used workspaces quick-open menu upon selection.
|
|
281
|
-
const more = paths.length > this.recentLimit && <div className='gs-action-container'>
|
|
282
|
-
<a
|
|
283
|
-
role={'button'}
|
|
284
|
-
tabIndex={0}
|
|
285
|
-
onClick={this.doOpenRecentWorkspace}
|
|
286
|
-
onKeyDown={this.doOpenRecentWorkspaceEnter}>
|
|
287
|
-
{nls.localizeByDefault('More...')}
|
|
288
|
-
</a>
|
|
289
|
-
</div>;
|
|
290
|
-
return <div className='gs-section'>
|
|
291
|
-
<h3 className='gs-section-header'>
|
|
292
|
-
<i className={codicon('history')}></i>{nls.localizeByDefault('Recent')}
|
|
293
|
-
</h3>
|
|
294
|
-
{items.length > 0 ? content : <p className='gs-no-recent'>
|
|
295
|
-
{nls.localizeByDefault('You have no recent folders,') + ' '}
|
|
296
|
-
<a
|
|
297
|
-
role={'button'}
|
|
298
|
-
tabIndex={0}
|
|
299
|
-
onClick={this.doOpenFolder}
|
|
300
|
-
onKeyDown={this.doOpenFolderEnter}>
|
|
301
|
-
{nls.localizeByDefault('open a folder')}
|
|
302
|
-
</a>
|
|
303
|
-
{' ' + nls.localizeByDefault('to start.')}
|
|
304
|
-
</p>}
|
|
305
|
-
{more}
|
|
306
|
-
</div>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Render the settings section.
|
|
311
|
-
* Generally used to display useful links.
|
|
312
|
-
*/
|
|
313
|
-
protected renderSettings(): React.ReactNode {
|
|
314
|
-
return <div className='gs-section'>
|
|
315
|
-
<h3 className='gs-section-header'>
|
|
316
|
-
<i className={codicon('settings-gear')}></i>
|
|
317
|
-
{nls.localizeByDefault('Settings')}
|
|
318
|
-
</h3>
|
|
319
|
-
<div className='gs-action-container'>
|
|
320
|
-
<a
|
|
321
|
-
role={'button'}
|
|
322
|
-
tabIndex={0}
|
|
323
|
-
onClick={this.doOpenPreferences}
|
|
324
|
-
onKeyDown={this.doOpenPreferencesEnter}>
|
|
325
|
-
{nls.localizeByDefault('Open Settings')}
|
|
326
|
-
</a>
|
|
327
|
-
</div>
|
|
328
|
-
<div className='gs-action-container'>
|
|
329
|
-
<a
|
|
330
|
-
role={'button'}
|
|
331
|
-
tabIndex={0}
|
|
332
|
-
onClick={this.doOpenKeyboardShortcuts}
|
|
333
|
-
onKeyDown={this.doOpenKeyboardShortcutsEnter}>
|
|
334
|
-
{nls.localizeByDefault('Open Keyboard Shortcuts')}
|
|
335
|
-
</a>
|
|
336
|
-
</div>
|
|
337
|
-
</div>;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Render the help section.
|
|
342
|
-
*/
|
|
343
|
-
protected renderHelp(): React.ReactNode {
|
|
344
|
-
return <div className='gs-section'>
|
|
345
|
-
<h3 className='gs-section-header'>
|
|
346
|
-
<i className={codicon('question')}></i>
|
|
347
|
-
{nls.localizeByDefault('Help')}
|
|
348
|
-
</h3>
|
|
349
|
-
<div className='gs-action-container'>
|
|
350
|
-
<a
|
|
351
|
-
role={'button'}
|
|
352
|
-
tabIndex={0}
|
|
353
|
-
onClick={() => this.doOpenExternalLink(this.documentationUrl)}
|
|
354
|
-
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.documentationUrl)}>
|
|
355
|
-
{nls.localizeByDefault('Documentation')}
|
|
356
|
-
</a>
|
|
357
|
-
</div>
|
|
358
|
-
<div className='gs-action-container'>
|
|
359
|
-
<a
|
|
360
|
-
role={'button'}
|
|
361
|
-
tabIndex={0}
|
|
362
|
-
onClick={() => this.doOpenExternalLink(this.compatibilityUrl)}
|
|
363
|
-
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.compatibilityUrl)}>
|
|
364
|
-
{nls.localize('theia/getting-started/apiComparator', '{0} API Compatibility', 'VS Code')}
|
|
365
|
-
</a>
|
|
366
|
-
</div>
|
|
367
|
-
<div className='gs-action-container'>
|
|
368
|
-
<a
|
|
369
|
-
role={'button'}
|
|
370
|
-
tabIndex={0}
|
|
371
|
-
onClick={() => this.doOpenExternalLink(this.extensionUrl)}
|
|
372
|
-
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.extensionUrl)}>
|
|
373
|
-
{nls.localize('theia/getting-started/newExtension', 'Building a New Extension')}
|
|
374
|
-
</a>
|
|
375
|
-
</div>
|
|
376
|
-
<div className='gs-action-container'>
|
|
377
|
-
<a
|
|
378
|
-
role={'button'}
|
|
379
|
-
tabIndex={0}
|
|
380
|
-
onClick={() => this.doOpenExternalLink(this.pluginUrl)}
|
|
381
|
-
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.pluginUrl)}>
|
|
382
|
-
{nls.localize('theia/getting-started/newPlugin', 'Building a New Plugin')}
|
|
383
|
-
</a>
|
|
384
|
-
</div>
|
|
385
|
-
</div>;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Render the version section.
|
|
390
|
-
*/
|
|
391
|
-
protected renderVersion(): React.ReactNode {
|
|
392
|
-
return <div className='gs-section'>
|
|
393
|
-
<div className='gs-action-container'>
|
|
394
|
-
<p className='gs-sub-header' >
|
|
395
|
-
{this.applicationInfo ? nls.localizeByDefault('Version: {0}', this.applicationInfo.version) : ''}
|
|
396
|
-
</p>
|
|
397
|
-
</div>
|
|
398
|
-
</div>;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
protected renderPreferences(): React.ReactNode {
|
|
402
|
-
return <WelcomePreferences preferenceService={this.preferenceService}></WelcomePreferences>;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
protected renderAIBanner(): React.ReactNode {
|
|
406
|
-
return <div className='gs-container gs-experimental-container'>
|
|
407
|
-
<div className='flex-grid'>
|
|
408
|
-
<div className='col'>
|
|
409
|
-
<h3 className='gs-section-header'> 🚀 Theia
|
|
410
|
-
<br />
|
|
411
|
-
<div className='gs-action-container'>
|
|
412
|
-
Theia IDE now contains
|
|
413
|
-
<br />
|
|
414
|
-
<br />
|
|
415
|
-
Please note that these features are disabled by default, ensuring that users can opt-in at their discretion
|
|
416
|
-
For those who choose to enable
|
|
417
|
-
requests to the language models (LLMs) you provide access to
|
|
418
|
-
<br />
|
|
419
|
-
For more details, please visit
|
|
420
|
-
<a
|
|
421
|
-
role={'button'}
|
|
422
|
-
tabIndex={0}
|
|
423
|
-
onClick={() => this.doOpenExternalLink(this.theiaAIDocUrl)}
|
|
424
|
-
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.theiaAIDocUrl)}>
|
|
425
|
-
{'
|
|
426
|
-
</a>.
|
|
427
|
-
<br />
|
|
428
|
-
<br />
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
{
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
props.preferenceService.
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
</div>
|
|
627
|
-
);
|
|
628
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { codicon, CommonCommands, Key, KeyCode, LabelProvider, Message, PreferenceService, ReactWidget } from '@theia/core/lib/browser';
|
|
18
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
19
|
+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
20
|
+
import { CommandRegistry, environment, isOSX, Path } from '@theia/core/lib/common';
|
|
21
|
+
import { ApplicationInfo, ApplicationServer } from '@theia/core/lib/common/application-protocol';
|
|
22
|
+
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
23
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
24
|
+
import URI from '@theia/core/lib/common/uri';
|
|
25
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
26
|
+
import * as React from '@theia/core/shared/react';
|
|
27
|
+
import { KeymapsCommands } from '@theia/keymaps/lib/browser';
|
|
28
|
+
import { WorkspaceCommands, WorkspaceService } from '@theia/workspace/lib/browser';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Default implementation of the `GettingStartedWidget`.
|
|
32
|
+
* The widget is displayed when there are currently no workspaces present.
|
|
33
|
+
* Some of the features displayed include:
|
|
34
|
+
* - `open` commands.
|
|
35
|
+
* - `recently used workspaces`.
|
|
36
|
+
* - `settings` commands.
|
|
37
|
+
* - `help` commands.
|
|
38
|
+
* - helpful links.
|
|
39
|
+
*/
|
|
40
|
+
@injectable()
|
|
41
|
+
export class GettingStartedWidget extends ReactWidget {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The widget `id`.
|
|
45
|
+
*/
|
|
46
|
+
static readonly ID = 'getting.started.widget';
|
|
47
|
+
/**
|
|
48
|
+
* The widget `label` which is used for display purposes.
|
|
49
|
+
*/
|
|
50
|
+
static readonly LABEL = nls.localizeByDefault('Welcome');
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The `ApplicationInfo` for the application if available.
|
|
54
|
+
* Used in order to obtain the version number of the application.
|
|
55
|
+
*/
|
|
56
|
+
protected applicationInfo: ApplicationInfo | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The application name which is used for display purposes.
|
|
59
|
+
*/
|
|
60
|
+
protected applicationName = FrontendApplicationConfigProvider.get().applicationName;
|
|
61
|
+
|
|
62
|
+
protected home: string | undefined;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The recently used workspaces limit.
|
|
66
|
+
* Used in order to limit the number of recently used workspaces to display.
|
|
67
|
+
*/
|
|
68
|
+
protected recentLimit = 5;
|
|
69
|
+
/**
|
|
70
|
+
* The list of recently used workspaces.
|
|
71
|
+
*/
|
|
72
|
+
protected recentWorkspaces: string[] = [];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Indicates whether the "ai-core" extension is available.
|
|
76
|
+
*/
|
|
77
|
+
protected aiIsIncluded: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Collection of useful links to display for end users.
|
|
81
|
+
*/
|
|
82
|
+
protected readonly documentationUrl = 'https://www.theia-ide.org/docs/';
|
|
83
|
+
protected readonly compatibilityUrl = 'https://eclipse-theia.github.io/vscode-theia-comparator/status.html';
|
|
84
|
+
protected readonly extensionUrl = 'https://www.theia-ide.org/docs/authoring_extensions';
|
|
85
|
+
protected readonly pluginUrl = 'https://www.theia-ide.org/docs/authoring_plugins';
|
|
86
|
+
protected readonly theiaAIDocUrl = 'https://theia-ide.org/docs/user_ai/';
|
|
87
|
+
protected readonly ghProjectUrl = 'https://github.com/eclipse-theia/theia/issues/new/choose';
|
|
88
|
+
|
|
89
|
+
@inject(ApplicationServer)
|
|
90
|
+
protected readonly appServer: ApplicationServer;
|
|
91
|
+
|
|
92
|
+
@inject(CommandRegistry)
|
|
93
|
+
protected readonly commandRegistry: CommandRegistry;
|
|
94
|
+
|
|
95
|
+
@inject(EnvVariablesServer)
|
|
96
|
+
protected readonly environments: EnvVariablesServer;
|
|
97
|
+
|
|
98
|
+
@inject(LabelProvider)
|
|
99
|
+
protected readonly labelProvider: LabelProvider;
|
|
100
|
+
|
|
101
|
+
@inject(WindowService)
|
|
102
|
+
protected readonly windowService: WindowService;
|
|
103
|
+
|
|
104
|
+
@inject(WorkspaceService)
|
|
105
|
+
protected readonly workspaceService: WorkspaceService;
|
|
106
|
+
|
|
107
|
+
@inject(PreferenceService)
|
|
108
|
+
protected readonly preferenceService: PreferenceService;
|
|
109
|
+
|
|
110
|
+
@postConstruct()
|
|
111
|
+
protected init(): void {
|
|
112
|
+
this.doInit();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
protected async doInit(): Promise<void> {
|
|
116
|
+
this.id = GettingStartedWidget.ID;
|
|
117
|
+
this.title.label = GettingStartedWidget.LABEL;
|
|
118
|
+
this.title.caption = GettingStartedWidget.LABEL;
|
|
119
|
+
this.title.closable = true;
|
|
120
|
+
|
|
121
|
+
this.applicationInfo = await this.appServer.getApplicationInfo();
|
|
122
|
+
this.recentWorkspaces = await this.workspaceService.recentWorkspaces();
|
|
123
|
+
this.home = new URI(await this.environments.getHomeDirUri()).path.toString();
|
|
124
|
+
|
|
125
|
+
const extensions = await this.appServer.getExtensionsInfos();
|
|
126
|
+
this.aiIsIncluded = extensions.find(ext => ext.name === '@theia/ai-core') !== undefined;
|
|
127
|
+
this.update();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
protected override onActivateRequest(msg: Message): void {
|
|
131
|
+
super.onActivateRequest(msg);
|
|
132
|
+
const elArr = this.node.getElementsByTagName('a');
|
|
133
|
+
if (elArr && elArr.length > 0) {
|
|
134
|
+
(elArr[0] as HTMLElement).focus();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Render the content of the widget.
|
|
140
|
+
*/
|
|
141
|
+
protected render(): React.ReactNode {
|
|
142
|
+
return <div className='gs-container'>
|
|
143
|
+
<div className='gs-content-container'>
|
|
144
|
+
{this.aiIsIncluded &&
|
|
145
|
+
<div className='gs-float shadow-pulse'>
|
|
146
|
+
{this.renderAIBanner()}
|
|
147
|
+
</div>
|
|
148
|
+
}
|
|
149
|
+
{this.renderHeader()}
|
|
150
|
+
<hr className='gs-hr' />
|
|
151
|
+
<div className='flex-grid'>
|
|
152
|
+
<div className='col'>
|
|
153
|
+
{this.renderStart()}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
<div className='flex-grid'>
|
|
157
|
+
<div className='col'>
|
|
158
|
+
{this.renderRecentWorkspaces()}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<div className='flex-grid'>
|
|
162
|
+
<div className='col'>
|
|
163
|
+
{this.renderSettings()}
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
<div className='flex-grid'>
|
|
167
|
+
<div className='col'>
|
|
168
|
+
{this.renderHelp()}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
<div className='flex-grid'>
|
|
172
|
+
<div className='col'>
|
|
173
|
+
{this.renderVersion()}
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
<div className='gs-preference-container'>
|
|
178
|
+
{this.renderPreferences()}
|
|
179
|
+
</div>
|
|
180
|
+
</div>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Render the widget header.
|
|
185
|
+
* Renders the title `{applicationName} Getting Started`.
|
|
186
|
+
*/
|
|
187
|
+
protected renderHeader(): React.ReactNode {
|
|
188
|
+
return <div className='gs-header'>
|
|
189
|
+
<h1>{this.applicationName}<span className='gs-sub-header'>{' ' + GettingStartedWidget.LABEL}</span></h1>
|
|
190
|
+
</div>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Render the `Start` section.
|
|
195
|
+
* Displays a collection of "start-to-work" related commands like `open` commands and some other.
|
|
196
|
+
*/
|
|
197
|
+
protected renderStart(): React.ReactNode {
|
|
198
|
+
const requireSingleOpen = isOSX || !environment.electron.is();
|
|
199
|
+
|
|
200
|
+
const createFile = <div className='gs-action-container'>
|
|
201
|
+
<a
|
|
202
|
+
role={'button'}
|
|
203
|
+
tabIndex={0}
|
|
204
|
+
onClick={this.doCreateFile}
|
|
205
|
+
onKeyDown={this.doCreateFileEnter}>
|
|
206
|
+
{CommonCommands.NEW_UNTITLED_FILE.label ?? nls.localizeByDefault('New File...')}
|
|
207
|
+
</a>
|
|
208
|
+
</div>;
|
|
209
|
+
|
|
210
|
+
const open = requireSingleOpen && <div className='gs-action-container'>
|
|
211
|
+
<a
|
|
212
|
+
role={'button'}
|
|
213
|
+
tabIndex={0}
|
|
214
|
+
onClick={this.doOpen}
|
|
215
|
+
onKeyDown={this.doOpenEnter}>
|
|
216
|
+
{nls.localizeByDefault('Open')}
|
|
217
|
+
</a>
|
|
218
|
+
</div>;
|
|
219
|
+
|
|
220
|
+
const openFile = !requireSingleOpen && <div className='gs-action-container'>
|
|
221
|
+
<a
|
|
222
|
+
role={'button'}
|
|
223
|
+
tabIndex={0}
|
|
224
|
+
onClick={this.doOpenFile}
|
|
225
|
+
onKeyDown={this.doOpenFileEnter}>
|
|
226
|
+
{nls.localizeByDefault('Open File')}
|
|
227
|
+
</a>
|
|
228
|
+
</div>;
|
|
229
|
+
|
|
230
|
+
const openFolder = !requireSingleOpen && <div className='gs-action-container'>
|
|
231
|
+
<a
|
|
232
|
+
role={'button'}
|
|
233
|
+
tabIndex={0}
|
|
234
|
+
onClick={this.doOpenFolder}
|
|
235
|
+
onKeyDown={this.doOpenFolderEnter}>
|
|
236
|
+
{nls.localizeByDefault('Open Folder')}
|
|
237
|
+
</a>
|
|
238
|
+
</div>;
|
|
239
|
+
|
|
240
|
+
const openWorkspace = (
|
|
241
|
+
<a
|
|
242
|
+
role={'button'}
|
|
243
|
+
tabIndex={0}
|
|
244
|
+
onClick={this.doOpenWorkspace}
|
|
245
|
+
onKeyDown={this.doOpenWorkspaceEnter}>
|
|
246
|
+
{nls.localizeByDefault('Open Workspace')}
|
|
247
|
+
</a>
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
return <div className='gs-section'>
|
|
251
|
+
<h3 className='gs-section-header'><i className={codicon('folder-opened')}></i>{nls.localizeByDefault('Start')}</h3>
|
|
252
|
+
{createFile}
|
|
253
|
+
{open}
|
|
254
|
+
{openFile}
|
|
255
|
+
{openFolder}
|
|
256
|
+
{openWorkspace}
|
|
257
|
+
</div>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Render the recently used workspaces section.
|
|
262
|
+
*/
|
|
263
|
+
protected renderRecentWorkspaces(): React.ReactNode {
|
|
264
|
+
const items = this.recentWorkspaces;
|
|
265
|
+
const paths = this.buildPaths(items);
|
|
266
|
+
const content = paths.slice(0, this.recentLimit).map((item, index) =>
|
|
267
|
+
<div className='gs-action-container' key={index}>
|
|
268
|
+
<a
|
|
269
|
+
role={'button'}
|
|
270
|
+
tabIndex={0}
|
|
271
|
+
onClick={() => this.open(new URI(items[index]))}
|
|
272
|
+
onKeyDown={(e: React.KeyboardEvent) => this.openEnter(e, new URI(items[index]))}>
|
|
273
|
+
{new URI(items[index]).path.base}
|
|
274
|
+
</a>
|
|
275
|
+
<span className='gs-action-details'>
|
|
276
|
+
{item}
|
|
277
|
+
</span>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
// If the recently used workspaces list exceeds the limit, display `More...` which triggers the recently used workspaces quick-open menu upon selection.
|
|
281
|
+
const more = paths.length > this.recentLimit && <div className='gs-action-container'>
|
|
282
|
+
<a
|
|
283
|
+
role={'button'}
|
|
284
|
+
tabIndex={0}
|
|
285
|
+
onClick={this.doOpenRecentWorkspace}
|
|
286
|
+
onKeyDown={this.doOpenRecentWorkspaceEnter}>
|
|
287
|
+
{nls.localizeByDefault('More...')}
|
|
288
|
+
</a>
|
|
289
|
+
</div>;
|
|
290
|
+
return <div className='gs-section'>
|
|
291
|
+
<h3 className='gs-section-header'>
|
|
292
|
+
<i className={codicon('history')}></i>{nls.localizeByDefault('Recent')}
|
|
293
|
+
</h3>
|
|
294
|
+
{items.length > 0 ? content : <p className='gs-no-recent'>
|
|
295
|
+
{nls.localizeByDefault('You have no recent folders,') + ' '}
|
|
296
|
+
<a
|
|
297
|
+
role={'button'}
|
|
298
|
+
tabIndex={0}
|
|
299
|
+
onClick={this.doOpenFolder}
|
|
300
|
+
onKeyDown={this.doOpenFolderEnter}>
|
|
301
|
+
{nls.localizeByDefault('open a folder')}
|
|
302
|
+
</a>
|
|
303
|
+
{' ' + nls.localizeByDefault('to start.')}
|
|
304
|
+
</p>}
|
|
305
|
+
{more}
|
|
306
|
+
</div>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Render the settings section.
|
|
311
|
+
* Generally used to display useful links.
|
|
312
|
+
*/
|
|
313
|
+
protected renderSettings(): React.ReactNode {
|
|
314
|
+
return <div className='gs-section'>
|
|
315
|
+
<h3 className='gs-section-header'>
|
|
316
|
+
<i className={codicon('settings-gear')}></i>
|
|
317
|
+
{nls.localizeByDefault('Settings')}
|
|
318
|
+
</h3>
|
|
319
|
+
<div className='gs-action-container'>
|
|
320
|
+
<a
|
|
321
|
+
role={'button'}
|
|
322
|
+
tabIndex={0}
|
|
323
|
+
onClick={this.doOpenPreferences}
|
|
324
|
+
onKeyDown={this.doOpenPreferencesEnter}>
|
|
325
|
+
{nls.localizeByDefault('Open Settings')}
|
|
326
|
+
</a>
|
|
327
|
+
</div>
|
|
328
|
+
<div className='gs-action-container'>
|
|
329
|
+
<a
|
|
330
|
+
role={'button'}
|
|
331
|
+
tabIndex={0}
|
|
332
|
+
onClick={this.doOpenKeyboardShortcuts}
|
|
333
|
+
onKeyDown={this.doOpenKeyboardShortcutsEnter}>
|
|
334
|
+
{nls.localizeByDefault('Open Keyboard Shortcuts')}
|
|
335
|
+
</a>
|
|
336
|
+
</div>
|
|
337
|
+
</div>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Render the help section.
|
|
342
|
+
*/
|
|
343
|
+
protected renderHelp(): React.ReactNode {
|
|
344
|
+
return <div className='gs-section'>
|
|
345
|
+
<h3 className='gs-section-header'>
|
|
346
|
+
<i className={codicon('question')}></i>
|
|
347
|
+
{nls.localizeByDefault('Help')}
|
|
348
|
+
</h3>
|
|
349
|
+
<div className='gs-action-container'>
|
|
350
|
+
<a
|
|
351
|
+
role={'button'}
|
|
352
|
+
tabIndex={0}
|
|
353
|
+
onClick={() => this.doOpenExternalLink(this.documentationUrl)}
|
|
354
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.documentationUrl)}>
|
|
355
|
+
{nls.localizeByDefault('Documentation')}
|
|
356
|
+
</a>
|
|
357
|
+
</div>
|
|
358
|
+
<div className='gs-action-container'>
|
|
359
|
+
<a
|
|
360
|
+
role={'button'}
|
|
361
|
+
tabIndex={0}
|
|
362
|
+
onClick={() => this.doOpenExternalLink(this.compatibilityUrl)}
|
|
363
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.compatibilityUrl)}>
|
|
364
|
+
{nls.localize('theia/getting-started/apiComparator', '{0} API Compatibility', 'VS Code')}
|
|
365
|
+
</a>
|
|
366
|
+
</div>
|
|
367
|
+
<div className='gs-action-container'>
|
|
368
|
+
<a
|
|
369
|
+
role={'button'}
|
|
370
|
+
tabIndex={0}
|
|
371
|
+
onClick={() => this.doOpenExternalLink(this.extensionUrl)}
|
|
372
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.extensionUrl)}>
|
|
373
|
+
{nls.localize('theia/getting-started/newExtension', 'Building a New Extension')}
|
|
374
|
+
</a>
|
|
375
|
+
</div>
|
|
376
|
+
<div className='gs-action-container'>
|
|
377
|
+
<a
|
|
378
|
+
role={'button'}
|
|
379
|
+
tabIndex={0}
|
|
380
|
+
onClick={() => this.doOpenExternalLink(this.pluginUrl)}
|
|
381
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.pluginUrl)}>
|
|
382
|
+
{nls.localize('theia/getting-started/newPlugin', 'Building a New Plugin')}
|
|
383
|
+
</a>
|
|
384
|
+
</div>
|
|
385
|
+
</div>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Render the version section.
|
|
390
|
+
*/
|
|
391
|
+
protected renderVersion(): React.ReactNode {
|
|
392
|
+
return <div className='gs-section'>
|
|
393
|
+
<div className='gs-action-container'>
|
|
394
|
+
<p className='gs-sub-header' >
|
|
395
|
+
{this.applicationInfo ? nls.localizeByDefault('Version: {0}', this.applicationInfo.version) : ''}
|
|
396
|
+
</p>
|
|
397
|
+
</div>
|
|
398
|
+
</div>;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
protected renderPreferences(): React.ReactNode {
|
|
402
|
+
return <WelcomePreferences preferenceService={this.preferenceService}></WelcomePreferences>;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
protected renderAIBanner(): React.ReactNode {
|
|
406
|
+
return <div className='gs-container gs-experimental-container'>
|
|
407
|
+
<div className='flex-grid'>
|
|
408
|
+
<div className='col'>
|
|
409
|
+
<h3 className='gs-section-header'> 🚀 AI Support in the Theia IDE is available! [Experimental] ✨</h3>
|
|
410
|
+
<br />
|
|
411
|
+
<div className='gs-action-container'>
|
|
412
|
+
Theia IDE now contains experimental AI support, which offers early access to cutting-edge AI capabilities within your IDE.
|
|
413
|
+
<br />
|
|
414
|
+
<br />
|
|
415
|
+
Please note that these features are disabled by default, ensuring that users can opt-in at their discretion.
|
|
416
|
+
For those who choose to enable AI support, it is important to be aware that these experimental features may generate continuous
|
|
417
|
+
requests to the language models (LLMs) you provide access to. This might incur costs that you need to monitor closely.
|
|
418
|
+
<br />
|
|
419
|
+
For more details, please visit
|
|
420
|
+
<a
|
|
421
|
+
role={'button'}
|
|
422
|
+
tabIndex={0}
|
|
423
|
+
onClick={() => this.doOpenExternalLink(this.theiaAIDocUrl)}
|
|
424
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.theiaAIDocUrl)}>
|
|
425
|
+
{'the documentation'}
|
|
426
|
+
</a>.
|
|
427
|
+
<br />
|
|
428
|
+
<br />
|
|
429
|
+
🚧 Please note that this feature is currently in development and may undergo frequent changes.
|
|
430
|
+
We welcome your feedback, contributions, and sponsorship! To support the ongoing development of the AI capabilities please visit the
|
|
431
|
+
<a
|
|
432
|
+
role={'button'}
|
|
433
|
+
tabIndex={0}
|
|
434
|
+
onClick={() => this.doOpenExternalLink(this.ghProjectUrl)}
|
|
435
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenExternalLinkEnter(e, this.ghProjectUrl)}>
|
|
436
|
+
{'Github Project'}
|
|
437
|
+
</a>.
|
|
438
|
+
Thank you for being part of our community!
|
|
439
|
+
</div>
|
|
440
|
+
<br />
|
|
441
|
+
<div className='gs-action-container'>
|
|
442
|
+
<a
|
|
443
|
+
role={'button'}
|
|
444
|
+
style={{ fontSize: 'var(--theia-ui-font-size2)' }}
|
|
445
|
+
tabIndex={0}
|
|
446
|
+
onClick={() => this.doOpenAIChatView()}
|
|
447
|
+
onKeyDown={(e: React.KeyboardEvent) => this.doOpenAIChatViewEnter(e)}>
|
|
448
|
+
{'Open the AI Chat View now to learn how to start! ✨'}
|
|
449
|
+
</a>
|
|
450
|
+
</div>
|
|
451
|
+
<br />
|
|
452
|
+
<br />
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
</div>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
protected doOpenAIChatView = () => this.commandRegistry.executeCommand('aiChat:toggle');
|
|
459
|
+
protected doOpenAIChatViewEnter = (e: React.KeyboardEvent) => {
|
|
460
|
+
if (this.isEnterKey(e)) {
|
|
461
|
+
this.doOpenAIChatView();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Build the list of workspace paths.
|
|
467
|
+
* @param workspaces {string[]} the list of workspaces.
|
|
468
|
+
* @returns {string[]} the list of workspace paths.
|
|
469
|
+
*/
|
|
470
|
+
protected buildPaths(workspaces: string[]): string[] {
|
|
471
|
+
const paths: string[] = [];
|
|
472
|
+
workspaces.forEach(workspace => {
|
|
473
|
+
const uri = new URI(workspace);
|
|
474
|
+
const pathLabel = this.labelProvider.getLongName(uri);
|
|
475
|
+
const path = this.home ? Path.tildify(pathLabel, this.home) : pathLabel;
|
|
476
|
+
paths.push(path);
|
|
477
|
+
});
|
|
478
|
+
return paths;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Trigger the create file command.
|
|
483
|
+
*/
|
|
484
|
+
protected doCreateFile = () => this.commandRegistry.executeCommand(CommonCommands.NEW_UNTITLED_FILE.id);
|
|
485
|
+
protected doCreateFileEnter = (e: React.KeyboardEvent) => {
|
|
486
|
+
if (this.isEnterKey(e)) {
|
|
487
|
+
this.doCreateFile();
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Trigger the open command.
|
|
493
|
+
*/
|
|
494
|
+
protected doOpen = () => this.commandRegistry.executeCommand(WorkspaceCommands.OPEN.id);
|
|
495
|
+
protected doOpenEnter = (e: React.KeyboardEvent) => {
|
|
496
|
+
if (this.isEnterKey(e)) {
|
|
497
|
+
this.doOpen();
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Trigger the open file command.
|
|
503
|
+
*/
|
|
504
|
+
protected doOpenFile = () => this.commandRegistry.executeCommand(WorkspaceCommands.OPEN_FILE.id);
|
|
505
|
+
protected doOpenFileEnter = (e: React.KeyboardEvent) => {
|
|
506
|
+
if (this.isEnterKey(e)) {
|
|
507
|
+
this.doOpenFile();
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Trigger the open folder command.
|
|
513
|
+
*/
|
|
514
|
+
protected doOpenFolder = () => this.commandRegistry.executeCommand(WorkspaceCommands.OPEN_FOLDER.id);
|
|
515
|
+
protected doOpenFolderEnter = (e: React.KeyboardEvent) => {
|
|
516
|
+
if (this.isEnterKey(e)) {
|
|
517
|
+
this.doOpenFolder();
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Trigger the open workspace command.
|
|
523
|
+
*/
|
|
524
|
+
protected doOpenWorkspace = () => this.commandRegistry.executeCommand(WorkspaceCommands.OPEN_WORKSPACE.id);
|
|
525
|
+
protected doOpenWorkspaceEnter = (e: React.KeyboardEvent) => {
|
|
526
|
+
if (this.isEnterKey(e)) {
|
|
527
|
+
this.doOpenWorkspace();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Trigger the open recent workspace command.
|
|
533
|
+
*/
|
|
534
|
+
protected doOpenRecentWorkspace = () => this.commandRegistry.executeCommand(WorkspaceCommands.OPEN_RECENT_WORKSPACE.id);
|
|
535
|
+
protected doOpenRecentWorkspaceEnter = (e: React.KeyboardEvent) => {
|
|
536
|
+
if (this.isEnterKey(e)) {
|
|
537
|
+
this.doOpenRecentWorkspace();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Trigger the open preferences command.
|
|
543
|
+
* Used to open the preferences widget.
|
|
544
|
+
*/
|
|
545
|
+
protected doOpenPreferences = () => this.commandRegistry.executeCommand(CommonCommands.OPEN_PREFERENCES.id);
|
|
546
|
+
protected doOpenPreferencesEnter = (e: React.KeyboardEvent) => {
|
|
547
|
+
if (this.isEnterKey(e)) {
|
|
548
|
+
this.doOpenPreferences();
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Trigger the open keyboard shortcuts command.
|
|
554
|
+
* Used to open the keyboard shortcuts widget.
|
|
555
|
+
*/
|
|
556
|
+
protected doOpenKeyboardShortcuts = () => this.commandRegistry.executeCommand(KeymapsCommands.OPEN_KEYMAPS.id);
|
|
557
|
+
protected doOpenKeyboardShortcutsEnter = (e: React.KeyboardEvent) => {
|
|
558
|
+
if (this.isEnterKey(e)) {
|
|
559
|
+
this.doOpenKeyboardShortcuts();
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Open a workspace given its uri.
|
|
565
|
+
* @param uri {URI} the workspace uri.
|
|
566
|
+
*/
|
|
567
|
+
protected open = (uri: URI) => this.workspaceService.open(uri);
|
|
568
|
+
protected openEnter = (e: React.KeyboardEvent, uri: URI) => {
|
|
569
|
+
if (this.isEnterKey(e)) {
|
|
570
|
+
this.open(uri);
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Open a link in an external window.
|
|
576
|
+
* @param url the link.
|
|
577
|
+
*/
|
|
578
|
+
protected doOpenExternalLink = (url: string) => this.windowService.openNewWindow(url, { external: true });
|
|
579
|
+
protected doOpenExternalLinkEnter = (e: React.KeyboardEvent, url: string) => {
|
|
580
|
+
if (this.isEnterKey(e)) {
|
|
581
|
+
this.doOpenExternalLink(url);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
protected isEnterKey(e: React.KeyboardEvent): boolean {
|
|
586
|
+
return Key.ENTER.keyCode === KeyCode.createKeyCode(e.nativeEvent).key?.keyCode;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
export interface PreferencesProps {
|
|
591
|
+
preferenceService: PreferenceService;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function WelcomePreferences(props: PreferencesProps): JSX.Element {
|
|
595
|
+
const [startupEditor, setStartupEditor] = React.useState<string>(
|
|
596
|
+
props.preferenceService.get('workbench.startupEditor', 'welcomePage')
|
|
597
|
+
);
|
|
598
|
+
React.useEffect(() => {
|
|
599
|
+
const prefListener = props.preferenceService.onPreferenceChanged(change => {
|
|
600
|
+
if (change.preferenceName === 'workbench.startupEditor') {
|
|
601
|
+
const prefValue = change.newValue;
|
|
602
|
+
setStartupEditor(prefValue);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
return () => prefListener.dispose();
|
|
606
|
+
}, [props.preferenceService]);
|
|
607
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
608
|
+
const newValue = e.target.checked ? 'welcomePage' : 'none';
|
|
609
|
+
props.preferenceService.updateValue('workbench.startupEditor', newValue);
|
|
610
|
+
};
|
|
611
|
+
return (
|
|
612
|
+
<div className='gs-preference'>
|
|
613
|
+
<input
|
|
614
|
+
type="checkbox"
|
|
615
|
+
className="theia-input"
|
|
616
|
+
id="startupEditor"
|
|
617
|
+
onChange={handleChange}
|
|
618
|
+
checked={startupEditor === 'welcomePage' || startupEditor === 'welcomePageInEmptyWorkbench'}
|
|
619
|
+
/>
|
|
620
|
+
<label htmlFor="startupEditor">
|
|
621
|
+
{nls.localizeByDefault('Show welcome page on startup')}
|
|
622
|
+
</label>
|
|
623
|
+
</div>
|
|
624
|
+
);
|
|
625
|
+
}
|