Skip to content

Commit 5f68eb8

Browse files
committed
chore: Review-Kommentare umgesetzt (#453)
1 parent d9308f8 commit 5f68eb8

File tree

7 files changed

+101
-103
lines changed

7 files changed

+101
-103
lines changed

cypress/e2e/code-editor.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe("Code Editor Page Tests", () => {
1919
it("[CodeEditor] opens reset dialog", () => {
2020
cy.visit("/codeeditor");
2121
cy.get('img[alt="Sensebox ESP"]').click();
22-
cy.get("button").contains(/Reset code|Code zurücksetzen/).click();
23-
cy.get("button").contains(/Reset|Zurücksetzen/).should("exist");
22+
cy.get("button").contains("Reset code").click();
23+
cy.get("button").contains("Zurücksetzen").should("exist");
2424
});
2525

2626
it("[CodeEditor] fetches libraries", () => {

src/components/Blockly/BlocklyWindow.jsx

Lines changed: 69 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class BlocklyWindow extends Component {
2626

2727
// Hilfsfunktion für die Block-Validierung
2828
validateArduinoFunctionBlock = (workspace, newBlock) => {
29-
const existingBlocks = workspace.getAllBlocks()
30-
.filter(block => block.type === 'arduino_functions');
31-
29+
const existingBlocks = workspace
30+
.getAllBlocks()
31+
.filter((block) => block.type === "arduino_functions");
32+
3233
if (existingBlocks.length > 0) {
3334
if (newBlock) {
3435
const oldBlock = existingBlocks[0];
@@ -43,17 +44,18 @@ class BlocklyWindow extends Component {
4344

4445
// Backpack Event-Handler
4546
handleBackpackDragStart = (block) => {
46-
if (block.type === 'arduino_functions') {
47+
if (block.type === "arduino_functions") {
4748
this.backpackBlockPosition = block.getRelativeToSurfaceXY();
4849
}
4950
};
5051

5152
handleBackpackDragEnd = (block) => {
52-
if (block.type === 'arduino_functions') {
53+
if (block.type === "arduino_functions") {
5354
const workspace = Blockly.getMainWorkspace();
54-
const existingBlocks = workspace.getAllBlocks()
55-
.filter(b => b.type === 'arduino_functions');
56-
55+
const existingBlocks = workspace
56+
.getAllBlocks()
57+
.filter((b) => b.type === "arduino_functions");
58+
5759
if (existingBlocks.length > 1) {
5860
existingBlocks[0].dispose();
5961
block.moveTo(this.backpackBlockPosition);
@@ -62,7 +64,7 @@ class BlocklyWindow extends Component {
6264
};
6365

6466
handleBackpackDrop = (block) => {
65-
if (block.type === 'arduino_functions') {
67+
if (block.type === "arduino_functions") {
6668
const workspace = Blockly.getMainWorkspace();
6769
this.validateArduinoFunctionBlock(workspace, block);
6870
}
@@ -71,44 +73,44 @@ class BlocklyWindow extends Component {
7173
// Aktualisiere die Backpack-UI
7274
updateBackpackUI = () => {
7375
if (!this.backpack) return;
74-
76+
7577
try {
76-
const backpackElement = document.querySelector('.blocklyBackpack');
78+
const backpackElement = document.querySelector(".blocklyBackpack");
7779
if (backpackElement) {
78-
backpackElement.setAttribute('title', Blockly.Msg['EMPTY_BACKPACK']);
80+
backpackElement.setAttribute("title", Blockly.Msg["EMPTY_BACKPACK"]);
7981
}
80-
82+
8183
if (this.backpack) {
8284
this.backpack.options.contextMenu = {
8385
emptyBackpack: true,
8486
removeFromBackpack: true,
8587
copyToBackpack: true,
8688
copyAllToBackpack: true,
8789
pasteAllToBackpack: true,
88-
disablePreconditionChecks: false
90+
disablePreconditionChecks: false,
8991
};
9092
}
91-
92-
if (process.env.NODE_ENV === 'development') {
93-
console.log('Backpack UI updated');
93+
94+
if (process.env.NODE_ENV === "development") {
95+
console.log("Backpack UI updated");
9496
}
9597
} catch (error) {
96-
if (process.env.NODE_ENV === 'development') {
97-
console.error('Error updating Backpack UI:', error);
98+
if (process.env.NODE_ENV === "development") {
99+
console.error("Error updating Backpack UI:", error);
98100
}
99101
}
100102
};
101103

102104
// Initialisiere den Backpack
103105
initializeBackpack = (workspace) => {
104106
if (this.backpackInitialized) {
105-
if (process.env.NODE_ENV === 'development') {
106-
console.log('Backpack already initialized, updating translations only');
107+
if (process.env.NODE_ENV === "development") {
108+
console.log("Backpack already initialized, updating translations only");
107109
}
108110
this.updateBackpackUI();
109111
return;
110112
}
111-
113+
112114
const backpackOptions = {
113115
allowEmptyBackpackOpen: true,
114116
useFilledBackpackImage: true,
@@ -119,45 +121,49 @@ class BlocklyWindow extends Component {
119121
copyToBackpack: true,
120122
copyAllToBackpack: true,
121123
pasteAllToBackpack: true,
122-
disablePreconditionChecks: false
123-
}
124+
disablePreconditionChecks: false,
125+
},
124126
};
125-
127+
126128
this.backpack = new Backpack(workspace, backpackOptions);
127-
129+
128130
this.backpack.onDragStart = (block) => {
129-
if (block.type === 'arduino_functions') {
131+
if (block.type === "arduino_functions") {
130132
return false;
131133
}
132134
return true;
133135
};
134-
136+
135137
const originalCopyToBackpack = this.backpack.copyToBackpack;
136138
this.backpack.copyToBackpack = (block) => {
137-
if (block.type === 'arduino_functions') {
139+
if (block.type === "arduino_functions") {
138140
return;
139141
}
140142
return originalCopyToBackpack.call(this.backpack, block);
141143
};
142-
144+
143145
const originalCopyAllToBackpack = this.backpack.copyAllToBackpack;
144146
this.backpack.copyAllToBackpack = (blocks) => {
145-
const filteredBlocks = blocks.filter(block => block.type !== 'arduino_functions');
147+
const filteredBlocks = blocks.filter(
148+
(block) => block.type !== "arduino_functions",
149+
);
146150
return originalCopyAllToBackpack.call(this.backpack, filteredBlocks);
147151
};
148-
152+
149153
const originalPasteAllFromBackpack = this.backpack.pasteAllFromBackpack;
150154
this.backpack.pasteAllFromBackpack = (blocks) => {
151-
const filteredBlocks = blocks.filter(block => block.type !== 'arduino_functions');
155+
const filteredBlocks = blocks.filter(
156+
(block) => block.type !== "arduino_functions",
157+
);
152158
return originalPasteAllFromBackpack.call(this.backpack, filteredBlocks);
153159
};
154-
160+
155161
this.backpack.init();
156162
this.backpackInitialized = true;
157-
if (process.env.NODE_ENV === 'development') {
158-
console.log('Backpack initialized');
163+
if (process.env.NODE_ENV === "development") {
164+
console.log("Backpack initialized");
159165
}
160-
166+
161167
this.updateBackpackUI();
162168
};
163169

@@ -166,32 +172,35 @@ class BlocklyWindow extends Component {
166172
this.props.onChangeWorkspace({});
167173
this.props.clearStats();
168174
workspace.addChangeListener(Blockly.Events.disableOrphans);
169-
175+
170176
workspace.addChangeListener((event) => {
171177
this.props.onChangeWorkspace(event);
172178

173179
try {
174-
if (event.type === Blockly.Events.BLOCK_CREATE ||
175-
event.type === Blockly.Events.BLOCK_PASTE ||
176-
event.type === Blockly.Events.BACKPACK_DRAG) {
177-
180+
if (
181+
event.type === Blockly.Events.BLOCK_CREATE ||
182+
event.type === Blockly.Events.BLOCK_PASTE ||
183+
event.type === Blockly.Events.BACKPACK_DRAG
184+
) {
178185
const allBlocks = workspace.getAllBlocks();
179-
const arduinoFunctionBlocks = allBlocks.filter(block => block.type === 'arduino_functions');
180-
186+
const arduinoFunctionBlocks = allBlocks.filter(
187+
(block) => block.type === "arduino_functions",
188+
);
189+
181190
if (arduinoFunctionBlocks.length > 1) {
182191
const firstBlock = arduinoFunctionBlocks[0];
183192
const position = firstBlock.getRelativeToSurfaceXY();
184-
185-
arduinoFunctionBlocks.slice(1).forEach(block => {
193+
194+
arduinoFunctionBlocks.slice(1).forEach((block) => {
186195
block.dispose();
187196
});
188-
197+
189198
firstBlock.moveTo(position);
190199
}
191200
}
192201
} catch (error) {
193-
if (process.env.NODE_ENV === 'development') {
194-
console.error('Error validating blocks:', error);
202+
if (process.env.NODE_ENV === "development") {
203+
console.error("Error validating blocks:", error);
195204
}
196205
}
197206
});
@@ -225,20 +234,25 @@ class BlocklyWindow extends Component {
225234
if (!xml) xml = initialXml;
226235
Blockly.Xml.domToWorkspace(Blockly.utils.xml.textToDom(xml), workspace);
227236
}
228-
237+
229238
if (prevProps.language !== this.props.language) {
230-
if (process.env.NODE_ENV === 'development') {
231-
console.log('Language changed from', prevProps.language, 'to', this.props.language);
239+
if (process.env.NODE_ENV === "development") {
240+
console.log(
241+
"Language changed from",
242+
prevProps.language,
243+
"to",
244+
this.props.language,
245+
);
232246
}
233-
247+
234248
this.updateBackpackUI();
235-
249+
236250
xml = localStorage.getItem("autoSaveXML");
237251
if (!xml) xml = initialXml;
238252
xmlDom = Blockly.utils.xml.textToDom(xml);
239253
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
240254
}
241-
255+
242256
Blockly.svgResize(workspace);
243257
}
244258

src/components/Blockly/blocks/procedures.js

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,22 @@ Blockly.Blocks["arduino_functions"] = {
3030
this.setHelpUrl("https://arduino.cc/en/Reference/Loop");
3131
this.contextMenu = false;
3232
this.data = board;
33-
34-
35-
this.isBackpackable = function() {
36-
return false;
37-
};
3833

39-
this.onDragStart = function() {
40-
return false;
41-
};
42-
43-
this.isDeletable = function() {
44-
return false;
45-
};
46-
47-
this.isDuplicatable = function() {
48-
return false;
49-
};
50-
51-
this.isCopyable = function() {
52-
return false;
53-
};
54-
55-
this.isPasteable = function() {
56-
return false;
57-
};
58-
59-
this.isMovable = function() {
60-
return false;
61-
};
62-
63-
this.isEditable = function() {
64-
return false;
65-
};
34+
this.isBackpackable = false;
35+
36+
this.onDragStart = false;
37+
38+
this.isDeletable = false;
39+
40+
this.isDuplicatable = false;
41+
42+
this.isCopyable = false;
43+
44+
this.isPasteable = false;
45+
46+
this.isMovable = false;
47+
48+
this.isEditable = false;
6649
},
6750
/** @return {!boolean} True if the block instance is in the workspace. */
6851
getArduinoLoopsInstance: function () {
@@ -943,9 +926,7 @@ Blockly.Blocks["procedures_callnoreturn"] = {
943926
if (quarkId in this.quarkConnections_) {
944927
const connection = this.quarkConnections_[quarkId];
945928
try {
946-
if (connection &&
947-
!connection.reconnect(this, "ARG" + i)
948-
) {
929+
if (connection && !connection.reconnect(this, "ARG" + i)) {
949930
// Block no longer exists or has been attached elsewhere.
950931
delete this.quarkConnections_[quarkId];
951932
}

src/components/Blockly/msg/de/translations.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,4 @@ export const TRANSLATIONS = {
264264
senseBox_watertemperature: "Wassertemperatur",
265265
senseBox_watertemperature_tooltip:
266266
"Das Wasserthermometer gibt Temperatur in Grad Celsius aus. Schließe den Sensor an einen der 6 Anschlüsse des One-Wire Adapters an und schließe dann den One-Wire Adapter an einen der 3 digital/analog Ports der senseBox an und wähle den Port im Block aus. Wenn du nur ein Thermometer am One-Wire Adapter angeschlossen hast, dann belasse den Index bei 0. Jedes weitere angeschlossene Thermometer kann entsprechend mit einem um 1 erhöhten Index angesprochen werden. Es kommt dabei nicht darauf an, an welchem Anschluss des Adapters die Thermometer angeschlossen werden.",
267-
EMPTY_BACKPACK: "Rucksack leeren",
268-
REMOVE_FROM_BACKPACK: "Aus Rucksack entfernen",
269-
COPY_TO_BACKPACK: "In Rucksack kopieren",
270-
COPY_ALL_TO_BACKPACK: "Alle Blöcke in Rucksack kopieren",
271-
PASTE_ALL_FROM_BACKPACK: "Alle Blöcke aus Rucksack einfügen",
272267
};
273-

src/components/Blockly/msg/de/ui.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,11 @@ export const UI = {
401401
goToApp_text:
402402
"Der Code wurde erfolgreich kompiliert! Klicke den unteren Button um zur senseBox:connect App zu gelangen und die Übertragung des Sketches fertigzustellen!",
403403
goToApp_title: "Over-The-Air Übertragung",
404+
405+
// Backpack translations
406+
EMPTY_BACKPACK: "Rucksack leeren",
407+
REMOVE_FROM_BACKPACK: "Entfernen aus Rucksack",
408+
COPY_TO_BACKPACK: "Kopieren in Rucksack",
409+
COPY_ALL_TO_BACKPACK: "Alle Blöcke in Rucksack kopieren",
410+
PASTE_ALL_FROM_BACKPACK: "Alle Blöcke aus Rucksack einfügen",
404411
};

src/components/Blockly/msg/en/translations.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,4 @@ export const TRANSLATIONS = {
244244
senseBox_watertemperature: "Water Temperature",
245245
senseBox_watertemperature_tooltip:
246246
"The water thermometer outputs temperature in degrees Celsius. Connect the sensor to one of the 6 ports of the One-Wire adapter and then connect the One-Wire adapter to one of the 3 digital/analog ports of the senseBox and select the port in the block. If you only have one thermometer connected to the One-Wire adapter, then leave the index at 0. Each additional connected thermometer can be addressed with an index increased by 1. It does not matter at which port of the adapter the thermometers are connected.",
247-
EMPTY_BACKPACK: "Empty Backpack",
248-
REMOVE_FROM_BACKPACK: "Remove from Backpack",
249-
COPY_TO_BACKPACK: "Copy to Backpack",
250-
COPY_ALL_TO_BACKPACK: "Copy All to Backpack",
251-
PASTE_ALL_FROM_BACKPACK: "Paste All from Backpack",
252247
};

src/components/Blockly/msg/en/ui.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,11 @@ export const UI = {
395395
goToApp_text:
396396
"The code has been compiled successfully. Start with the transfer by clicking on the button below, redirecting you to the senseBox:connect App ! ",
397397
goToApp_title: "Over-The-Air Transfer",
398+
399+
// Backpack translations
400+
EMPTY_BACKPACK: "Empty Backpack",
401+
REMOVE_FROM_BACKPACK: "Remove from Backpack",
402+
COPY_TO_BACKPACK: "Copy to Backpack",
403+
COPY_ALL_TO_BACKPACK: "Copy All to Backpack",
404+
PASTE_ALL_FROM_BACKPACK: "Paste All from Backpack",
398405
};

0 commit comments

Comments
 (0)