Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d68bc4a

Browse filesBrowse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
feat: rename, deletion, and validation support
Closes #1599 Closes #1825 Closes #649 Closes #1847 Closes #1882 Co-authored-by: Akos Kitta <a.kitta@arduino.cc> Co-authored-by: per1234 <accounts@perglass.com> Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 4f07515 commit d68bc4a
Copy full SHA for d68bc4a

File tree

71 files changed

+2895
-864
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

71 files changed

+2895
-864
lines changed

‎.vscode/launch.json

Copy file name to clipboardExpand all lines: .vscode/launch.json
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
".",
1515
"--log-level=debug",
1616
"--hostname=localhost",
17-
"--no-cluster",
1817
"--app-project-path=${workspaceRoot}/electron-app",
1918
"--remote-debugging-port=9222",
2019
"--no-app-auto-install",
@@ -52,7 +51,6 @@
5251
".",
5352
"--log-level=debug",
5453
"--hostname=localhost",
55-
"--no-cluster",
5654
"--app-project-path=${workspaceRoot}/electron-app",
5755
"--remote-debugging-port=9222",
5856
"--no-app-auto-install",

‎arduino-ide-extension/package.json

Copy file name to clipboardExpand all lines: arduino-ide-extension/package.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@
6767
"auth0-js": "^9.14.0",
6868
"btoa": "^1.2.1",
6969
"classnames": "^2.3.1",
70+
"cross-fetch": "^3.1.5",
7071
"dateformat": "^3.0.3",
7172
"deepmerge": "2.0.1",
7273
"electron-updater": "^4.6.5",
7374
"fast-json-stable-stringify": "^2.1.0",
7475
"fast-safe-stringify": "^2.1.1",
76+
"filename-reserved-regex": "^2.0.0",
7577
"glob": "^7.1.6",
7678
"google-protobuf": "^3.20.1",
7779
"hash.js": "^1.1.7",

‎arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
SketchesService,
2424
SketchesServicePath,
2525
} from '../common/protocol/sketches-service';
26-
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
26+
import { SketchesServiceClientImpl } from './sketches-service-client-impl';
2727
import { CoreService, CoreServicePath } from '../common/protocol/core-service';
2828
import { BoardsListWidget } from './boards/boards-list-widget';
2929
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
@@ -344,6 +344,9 @@ import { DebugViewModel } from '@theia/debug/lib/browser/view/debug-view-model';
344344
import { DebugSessionWidget } from '@theia/debug/lib/browser/view/debug-session-widget';
345345
import { DebugConfigurationWidget } from '@theia/debug/lib/browser/view/debug-configuration-widget';
346346
import { ConfigServiceClient } from './config/config-service-client';
347+
import { ValidateSketch } from './contributions/validate-sketch';
348+
import { RenameCloudSketch } from './contributions/rename-cloud-sketch';
349+
import { CreateFeatures } from './create/create-features';
347350

348351
export default new ContainerModule((bind, unbind, isBound, rebind) => {
349352
// Commands and toolbar items
@@ -729,6 +732,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
729732
Contribution.configure(bind, UpdateIndexes);
730733
Contribution.configure(bind, InterfaceScale);
731734
Contribution.configure(bind, NewCloudSketch);
735+
Contribution.configure(bind, ValidateSketch);
736+
Contribution.configure(bind, RenameCloudSketch);
732737

733738
bindContributionProvider(bind, StartupTaskProvider);
734739
bind(StartupTaskProvider).toService(BoardsServiceProvider); // to reuse the boards config in another window
@@ -889,6 +894,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
889894
);
890895
bind(CreateApi).toSelf().inSingletonScope();
891896
bind(SketchCache).toSelf().inSingletonScope();
897+
bind(CreateFeatures).toSelf().inSingletonScope();
898+
bind(FrontendApplicationContribution).toService(CreateFeatures);
892899

893900
bind(ShareSketchDialog).toSelf().inSingletonScope();
894901
bind(AuthenticationClientService).toSelf().inSingletonScope();

‎arduino-ide-extension/src/browser/config/config-service-client.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/config/config-service-client.ts
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ConfigServiceClient implements FrontendApplicationContribution {
3838
@postConstruct()
3939
protected init(): void {
4040
this.appStateService.reachedState('ready').then(async () => {
41-
const config = await this.fetchConfig();
41+
const config = await this.delegate.getConfiguration();
4242
this.use(config);
4343
});
4444
}
@@ -59,10 +59,6 @@ export class ConfigServiceClient implements FrontendApplicationContribution {
5959
return this.didChangeDataDirUriEmitter.event;
6060
}
6161

62-
async fetchConfig(): Promise<ConfigState> {
63-
return this.delegate.getConfiguration();
64-
}
65-
6662
/**
6763
* CLI config related error messages if any.
6864
*/

‎arduino-ide-extension/src/browser/contributions/add-file.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/add-file.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from './contribution';
1212
import { FileDialogService } from '@theia/filesystem/lib/browser';
1313
import { nls } from '@theia/core/lib/common';
14-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
14+
import { CurrentSketch } from '../sketches-service-client-impl';
1515

1616
@injectable()
1717
export class AddFile extends SketchContribution {

‎arduino-ide-extension/src/browser/contributions/archive-sketch.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/archive-sketch.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
MenuModelRegistry,
1010
} from './contribution';
1111
import { nls } from '@theia/core/lib/common';
12-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
12+
import { CurrentSketch } from '../sketches-service-client-impl';
1313

1414
@injectable()
1515
export class ArchiveSketch extends SketchContribution {
@@ -56,7 +56,7 @@ export class ArchiveSketch extends SketchContribution {
5656
if (!destinationUri) {
5757
return;
5858
}
59-
await this.sketchService.archive(sketch, destinationUri.toString());
59+
await this.sketchesService.archive(sketch, destinationUri.toString());
6060
this.messageService.info(
6161
nls.localize(
6262
'arduino/sketch/createdArchive',

‎arduino-ide-extension/src/browser/contributions/close.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/close.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
URI,
2121
} from './contribution';
2222
import { Dialog } from '@theia/core/lib/browser/dialogs';
23-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
23+
import { CurrentSketch } from '../sketches-service-client-impl';
2424
import { SaveAsSketch } from './save-as-sketch';
2525

2626
/**
@@ -185,7 +185,7 @@ export class Close extends SketchContribution {
185185
private async isCurrentSketchTemp(): Promise<false | Sketch> {
186186
const currentSketch = await this.sketchServiceClient.currentSketch();
187187
if (CurrentSketch.isValid(currentSketch)) {
188-
const isTemp = await this.sketchService.isTemp(currentSketch);
188+
const isTemp = await this.sketchesService.isTemp(currentSketch);
189189
if (isTemp) {
190190
return currentSketch;
191191
}
+121Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { CompositeTreeNode } from '@theia/core/lib/browser/tree';
2+
import { nls } from '@theia/core/lib/common/nls';
3+
import { inject, injectable } from '@theia/core/shared/inversify';
4+
import { CreateApi } from '../create/create-api';
5+
import { CreateFeatures } from '../create/create-features';
6+
import { CreateUri } from '../create/create-uri';
7+
import { Create, isNotFound } from '../create/typings';
8+
import { CloudSketchbookTree } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree';
9+
import { CloudSketchbookTreeModel } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree-model';
10+
import { CloudSketchbookTreeWidget } from '../widgets/cloud-sketchbook/cloud-sketchbook-tree-widget';
11+
import { SketchbookWidget } from '../widgets/sketchbook/sketchbook-widget';
12+
import { SketchbookWidgetContribution } from '../widgets/sketchbook/sketchbook-widget-contribution';
13+
import { SketchContribution } from './contribution';
14+
15+
export function sketchAlreadyExists(input: string): string {
16+
return nls.localize(
17+
'arduino/cloudSketch/alreadyExists',
18+
"Cloud sketch '{0}' already exists.",
19+
input
20+
);
21+
}
22+
export function sketchNotFound(input: string): string {
23+
return nls.localize(
24+
'arduino/cloudSketch/notFound',
25+
"Could not pull the cloud sketch '{0}'. It does not exist.",
26+
input
27+
);
28+
}
29+
export const synchronizingSketchbook = nls.localize(
30+
'arduino/cloudSketch/synchronizingSketchbook',
31+
'Synchronizing sketchbook...'
32+
);
33+
export function pullingSketch(input: string): string {
34+
return nls.localize(
35+
'arduino/cloudSketch/pulling',
36+
"Synchronizing sketchbook, pulling '{0}'...",
37+
input
38+
);
39+
}
40+
export function pushingSketch(input: string): string {
41+
return nls.localize(
42+
'arduino/cloudSketch/pushing',
43+
"Synchronizing sketchbook, pushing '{0}'...",
44+
input
45+
);
46+
}
47+
48+
@injectable()
49+
export abstract class CloudSketchContribution extends SketchContribution {
50+
@inject(SketchbookWidgetContribution)
51+
private readonly widgetContribution: SketchbookWidgetContribution;
52+
@inject(CreateApi)
53+
protected readonly createApi: CreateApi;
54+
@inject(CreateFeatures)
55+
protected readonly createFeatures: CreateFeatures;
56+
57+
protected async treeModel(): Promise<
58+
(CloudSketchbookTreeModel & { root: CompositeTreeNode }) | undefined
59+
> {
60+
const { enabled, session } = this.createFeatures;
61+
if (enabled && session) {
62+
const widget = await this.widgetContribution.widget;
63+
const treeModel = this.treeModelFrom(widget);
64+
if (treeModel) {
65+
const root = treeModel.root;
66+
if (CompositeTreeNode.is(root)) {
67+
return treeModel as CloudSketchbookTreeModel & {
68+
root: CompositeTreeNode;
69+
};
70+
}
71+
}
72+
}
73+
return undefined;
74+
}
75+
76+
protected async pull(
77+
sketch: Create.Sketch
78+
): Promise<CloudSketchbookTree.CloudSketchDirNode | undefined> {
79+
const treeModel = await this.treeModel();
80+
if (!treeModel) {
81+
return undefined;
82+
}
83+
const id = CreateUri.toUri(sketch).path.toString();
84+
const node = treeModel.getNode(id);
85+
if (!node) {
86+
throw new Error(
87+
`Could not find cloud sketchbook tree node with ID: ${id}.`
88+
);
89+
}
90+
if (!CloudSketchbookTree.CloudSketchDirNode.is(node)) {
91+
throw new Error(
92+
`Cloud sketchbook tree node expected to represent a directory but it did not. Tree node ID: ${id}.`
93+
);
94+
}
95+
try {
96+
await treeModel.sketchbookTree().pull({ node });
97+
return node;
98+
} catch (err) {
99+
if (isNotFound(err)) {
100+
await treeModel.refresh();
101+
this.messageService.error(sketchNotFound(sketch.name));
102+
return undefined;
103+
}
104+
throw err;
105+
}
106+
}
107+
108+
private treeModelFrom(
109+
widget: SketchbookWidget
110+
): CloudSketchbookTreeModel | undefined {
111+
for (const treeWidget of widget.getTreeWidgets()) {
112+
if (treeWidget instanceof CloudSketchbookTreeWidget) {
113+
const model = treeWidget.model;
114+
if (model instanceof CloudSketchbookTreeModel) {
115+
return model;
116+
}
117+
}
118+
}
119+
return undefined;
120+
}
121+
}

‎arduino-ide-extension/src/browser/contributions/contribution.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/contribution.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { SettingsService } from '../dialogs/settings/settings';
4141
import {
4242
CurrentSketch,
4343
SketchesServiceClientImpl,
44-
} from '../../common/protocol/sketches-service-client-impl';
44+
} from '../sketches-service-client-impl';
4545
import {
4646
SketchesService,
4747
FileSystemExt,
@@ -147,7 +147,7 @@ export abstract class SketchContribution extends Contribution {
147147
protected readonly configService: ConfigServiceClient;
148148

149149
@inject(SketchesService)
150-
protected readonly sketchService: SketchesService;
150+
protected readonly sketchesService: SketchesService;
151151

152152
@inject(OpenerService)
153153
protected readonly openerService: OpenerService;

‎arduino-ide-extension/src/browser/contributions/debug.ts

Copy file name to clipboardExpand all lines: arduino-ide-extension/src/browser/contributions/debug.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
TabBarToolbarRegistry,
1919
} from './contribution';
2020
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
21-
import { CurrentSketch } from '../../common/protocol/sketches-service-client-impl';
21+
import { CurrentSketch } from '../sketches-service-client-impl';
2222
import { ArduinoMenus } from '../menu/arduino-menus';
2323

2424
const COMPILE_FOR_DEBUG_KEY = 'arduino-compile-for-debug';
@@ -187,7 +187,7 @@ export class Debug extends SketchContribution {
187187
if (!CurrentSketch.isValid(sketch)) {
188188
return;
189189
}
190-
const ideTempFolderUri = await this.sketchService.getIdeTempFolderUri(
190+
const ideTempFolderUri = await this.sketchesService.getIdeTempFolderUri(
191191
sketch
192192
);
193193
const [cliPath, sketchPath, configPath] = await Promise.all([
@@ -246,7 +246,7 @@ export class Debug extends SketchContribution {
246246
): Promise<boolean> {
247247
if (err instanceof Error) {
248248
try {
249-
const tempBuildPaths = await this.sketchService.tempBuildPath(sketch);
249+
const tempBuildPaths = await this.sketchesService.tempBuildPath(sketch);
250250
return tempBuildPaths.some((tempBuildPath) =>
251251
err.message.includes(tempBuildPath)
252252
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.