From 36c4e8419a8a174b807a6f1af00266a9e69725b9 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 7 May 2024 17:33:01 +0100 Subject: [PATCH] Toggle V2 features warning via settings and diagnostics --- lang/ui.ca.json | 12 +++++ lang/ui.de.json | 12 +++++ lang/ui.en.json | 14 ++++- lang/ui.es-es.json | 12 +++++ lang/ui.fr.json | 12 +++++ lang/ui.ja.json | 12 +++++ lang/ui.ko.json | 12 +++++ lang/ui.lol.json | 20 ++++--- lang/ui.nl.json | 12 +++++ lang/ui.zh-cn.json | 12 +++++ lang/ui.zh-tw.json | 12 +++++ src/editor/EditorContainer.tsx | 8 ++- src/editor/codemirror/CodeMirror.tsx | 17 +++++- .../codemirror/language-server/diagnostics.ts | 16 ++++-- src/editor/codemirror/language-server/view.ts | 52 ++++++++++++++++--- src/editor/codemirror/themeExtensions.ts | 14 +++++ src/messages/ui.ca.json | 18 +++++++ src/messages/ui.de.json | 18 +++++++ src/messages/ui.en.json | 20 ++++++- src/messages/ui.es-es.json | 18 +++++++ src/messages/ui.fr.json | 20 ++++++- src/messages/ui.ja.json | 18 +++++++ src/messages/ui.ko.json | 18 +++++++ src/messages/ui.lol.json | 30 ++++++----- src/messages/ui.nl.json | 18 +++++++ src/messages/ui.zh-cn.json | 18 +++++++ src/messages/ui.zh-tw.json | 18 +++++++ src/settings/SettingsArea.tsx | 17 ++++++ src/settings/settings.tsx | 4 +- 29 files changed, 446 insertions(+), 38 deletions(-) diff --git a/lang/ui.ca.json b/lang/ui.ca.json index bca7bb52a..883b8e86a 100644 --- a/lang/ui.ca.json +++ b/lang/ui.ca.json @@ -742,6 +742,14 @@ "defaultMessage": "Canviar mòduls de tercers pot significar que no funcionin com s'havia previst.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Configuració", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "visita microbit.org (s'obre en una pestanya nova)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Un altre procés està connectat a aquest dispositiu.", "description": "Part of WebUSB error message" diff --git a/lang/ui.de.json b/lang/ui.de.json index 42bf46a69..d3650bc9b 100644 --- a/lang/ui.de.json +++ b/lang/ui.de.json @@ -742,6 +742,14 @@ "defaultMessage": "Wenn du Module von Drittanbietern änderst, kann es sein, dass sie nicht mehr wie vorgesehen funktionieren.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Einstellungen", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "besuche microbit.org (öffnet in neuen Tab)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Ein anderer Prozess ist mit diesem Gerät verbunden.", "description": "Part of WebUSB error message" diff --git a/lang/ui.en.json b/lang/ui.en.json index f12fc199a..c863be945 100644 --- a/lang/ui.en.json +++ b/lang/ui.en.json @@ -743,6 +743,14 @@ "defaultMessage": "Changing third-party modules may mean they don’t work as intended.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Settings", "description": "Settings text" @@ -1111,6 +1119,10 @@ "defaultMessage": "visit microbit.org (opens in a new tab)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Another process is connected to this device.", "description": "Part of WebUSB error message" @@ -1163,4 +1175,4 @@ "defaultMessage": "Zoom out", "description": "Text label for zoom out button" } -} +} \ No newline at end of file diff --git a/lang/ui.es-es.json b/lang/ui.es-es.json index aa0e6f85c..a0965c8d9 100644 --- a/lang/ui.es-es.json +++ b/lang/ui.es-es.json @@ -742,6 +742,14 @@ "defaultMessage": "Cambiar los módulos de terceros puede provocar que no funcionen como deberían.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Configuración", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "visitar microbit.org (abre en una nueva pestaña)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Otro proceso está conectado a este dispositivo.", "description": "Part of WebUSB error message" diff --git a/lang/ui.fr.json b/lang/ui.fr.json index 459567c90..186123602 100644 --- a/lang/ui.fr.json +++ b/lang/ui.fr.json @@ -742,6 +742,14 @@ "defaultMessage": "La modification de modules tiers peut empêcher leur bon fonctionnement.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Paramètres", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "visiter microbit.org (s’ouvre dans un nouvel onglet)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Un autre processus est connecté à cet appareil.", "description": "Part of WebUSB error message" diff --git a/lang/ui.ja.json b/lang/ui.ja.json index 00816c9ef..40299f50e 100644 --- a/lang/ui.ja.json +++ b/lang/ui.ja.json @@ -742,6 +742,14 @@ "defaultMessage": "サードパーティ製モジュールを変更すると、意図した通りに動作しない可能性があります。", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "設定", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "microbit.orgにアクセスします(新しいタブで開きます)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "別のプロセスがこのデバイスに接続されています。", "description": "Part of WebUSB error message" diff --git a/lang/ui.ko.json b/lang/ui.ko.json index 4f0fa7668..f1f783615 100644 --- a/lang/ui.ko.json +++ b/lang/ui.ko.json @@ -742,6 +742,14 @@ "defaultMessage": "서드파티 모듈을 변경하면 모듈이 의도대로 작동하지 않을 수 있습니다.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "설정", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "microbit.org 방문(새 탭에서 열기)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "다른 프로세스가 이 장치에 연결되어 있습니다.", "description": "Part of WebUSB error message" diff --git a/lang/ui.lol.json b/lang/ui.lol.json index 39c1fd99e..e22ef6e7d 100644 --- a/lang/ui.lol.json +++ b/lang/ui.lol.json @@ -742,6 +742,14 @@ "defaultMessage": "crwdns331722:0crwdne331722:0", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "crwdns331724:0crwdne331724:0", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "crwdns331784:0crwdne331784:0", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "crwdns331786:0crwdne331786:0", "description": "Part of WebUSB error message" @@ -1130,14 +1142,6 @@ "defaultMessage": "crwdns331794:0crwdne331794:0", "description": "Part of WebUSB error message" }, - "webusb-error-update-req-description": { - "defaultMessage": "crwdns331796:0crwdne331796:0", - "description": "WebUSB error telling user to update firmware" - }, - "webusb-error-update-req-title": { - "defaultMessage": "crwdns331798:0crwdne331798:0", - "description": "Error text telling user to update firmware" - }, "webusb-not-supported": { "defaultMessage": "crwdns331800:0crwdne331800:0", "description": "Explantion shown when user's browser doesn't support WebUSB" diff --git a/lang/ui.nl.json b/lang/ui.nl.json index b2ded615d..c7b1c834e 100644 --- a/lang/ui.nl.json +++ b/lang/ui.nl.json @@ -742,6 +742,14 @@ "defaultMessage": "Wijzigen van modules van derden kan betekenen dat ze niet werken zoals bedoeld.", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "Instellingen", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "bezoek microbit.org (opent in een nieuw tabblad)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "Een ander proces is verbonden met dit apparaat.", "description": "Part of WebUSB error message" diff --git a/lang/ui.zh-cn.json b/lang/ui.zh-cn.json index bf60c362a..f98a1a80a 100644 --- a/lang/ui.zh-cn.json +++ b/lang/ui.zh-cn.json @@ -742,6 +742,14 @@ "defaultMessage": "更改第三方模块可能意味着它们无法按预期工作。", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "设置", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "访问 microbit.org (在新标签页中打开)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "另一个进程已连接到此设备。", "description": "Part of WebUSB error message" diff --git a/lang/ui.zh-tw.json b/lang/ui.zh-tw.json index b25af3439..82f0d8964 100644 --- a/lang/ui.zh-tw.json +++ b/lang/ui.zh-tw.json @@ -742,6 +742,14 @@ "defaultMessage": "變更第三方模組,可能代表它們無法按預期運作。", "description": "Checkbox setting label" }, + "setting-warn-on-v2-only-features": { + "defaultMessage": "Show warnings about V2-only features", + "description": "Checkbox setting label" + }, + "setting-warn-on-v2-only-features-info": { + "defaultMessage": "Warnings are shown in the editor when a micro:bit V1 is connected", + "description": "Checkbox setting label" + }, "settings": { "defaultMessage": "設置", "description": "Settings text" @@ -1110,6 +1118,10 @@ "defaultMessage": "造訪 microbit.org (在新索引標籤中開啟)", "description": "alt text for logo link to .org" }, + "warn-on-v2-only-features-action": { + "defaultMessage": "Disable warnings about V2-only features", + "description": "Label for editor action" + }, "webusb-error-clear-connect-description-1": { "defaultMessage": "其他程序連線至此裝置。", "description": "Part of WebUSB error message" diff --git a/src/editor/EditorContainer.tsx b/src/editor/EditorContainer.tsx index 3e5ad643d..f3e1ef366 100644 --- a/src/editor/EditorContainer.tsx +++ b/src/editor/EditorContainer.tsx @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: MIT */ +import { useCallback } from "react"; import { useProjectFileText } from "../project/project-hooks"; import { useSettings } from "../settings/settings"; import { WorkbenchSelection } from "../workbench/use-selection"; @@ -18,7 +19,10 @@ interface EditorContainerProps { * and wires it to the currently open file. */ const EditorContainer = ({ selection }: EditorContainerProps) => { - const [settings] = useSettings(); + const [settings, setSettings] = useSettings(); + const disableV2OnlyFeaturesWarning = useCallback(() => { + setSettings({ ...settings, warnOnV2OnlyFeatures: false }); + }, [setSettings, settings]); // Note fileInfo is not updated for ordinary text edits. const [fileInfo, onFileChange] = useProjectFileText(selection.file); if (fileInfo === undefined) { @@ -36,6 +40,8 @@ const EditorContainer = ({ selection }: EditorContainerProps) => { fontSize={settings.fontSize} codeStructureOption={settings.codeStructureHighlight} parameterHelpOption={settings.parameterHelp} + warnOnV2OnlyFeatures={settings.warnOnV2OnlyFeatures} + disableV2OnlyFeaturesWarning={disableV2OnlyFeaturesWarning} /> ); }; diff --git a/src/editor/codemirror/CodeMirror.tsx b/src/editor/codemirror/CodeMirror.tsx index 6e770a6a6..05ec97999 100644 --- a/src/editor/codemirror/CodeMirror.tsx +++ b/src/editor/codemirror/CodeMirror.tsx @@ -51,6 +51,8 @@ interface CodeMirrorProps { fontSize: number; codeStructureOption: CodeStructureOption; parameterHelpOption: ParameterHelpOption; + warnOnV2OnlyFeatures: boolean; + disableV2OnlyFeaturesWarning: () => void; } /** @@ -69,6 +71,8 @@ const CodeMirror = ({ fontSize, codeStructureOption, parameterHelpOption, + warnOnV2OnlyFeatures, + disableV2OnlyFeaturesWarning, }: CodeMirrorProps) => { // Really simple model for now as we only have one editor at a time. const [, setActiveEditor] = useActiveEditorActionsState(); @@ -98,8 +102,9 @@ const CodeMirror = ({ fontSize, codeStructureOption, parameterHelpOption, + warnOnV2OnlyFeatures, }), - [fontSize, codeStructureOption, parameterHelpOption] + [fontSize, codeStructureOption, parameterHelpOption, warnOnV2OnlyFeatures] ); useEffect(() => { @@ -144,6 +149,10 @@ const CodeMirror = ({ signatureHelp: { automatic: parameterHelpOption === "automatic", }, + warnOnV2OnlyFeatures: options.warnOnV2OnlyFeatures, + }, + { + disableV2OnlyFeaturesWarning, } ) : [], @@ -176,6 +185,7 @@ const CodeMirror = ({ uri, apiReferenceMap, device, + disableV2OnlyFeaturesWarning, ]); useEffect(() => { // Do this separately as we don't want to destroy the view whenever options needed for initialization change. @@ -204,6 +214,10 @@ const CodeMirror = ({ signatureHelp: { automatic: parameterHelpOption === "automatic", }, + warnOnV2OnlyFeatures: options.warnOnV2OnlyFeatures, + }, + { + disableV2OnlyFeaturesWarning, } ) : [], @@ -221,6 +235,7 @@ const CodeMirror = ({ uri, apiReferenceMap, device, + disableV2OnlyFeaturesWarning, ]); const { location } = selection; diff --git a/src/editor/codemirror/language-server/diagnostics.ts b/src/editor/codemirror/language-server/diagnostics.ts index 8a5e47f04..2f3405807 100644 --- a/src/editor/codemirror/language-server/diagnostics.ts +++ b/src/editor/codemirror/language-server/diagnostics.ts @@ -5,7 +5,7 @@ */ import { Text } from "@codemirror/state"; import * as LSP from "vscode-languageserver-protocol"; -import { Diagnostic } from "../lint/lint"; +import { Action, Diagnostic } from "../lint/lint"; import { positionToOffset } from "./positions"; import { DeviceConnection } from "../../../device/device"; @@ -19,17 +19,21 @@ const severityMapping = { export const diagnosticsMapping = ( document: Text, lspDiagnostics: LSP.Diagnostic[], - device: DeviceConnection + device: DeviceConnection, + warnOnV2OnlyFeatures: boolean, + warnOnV2OnlyFeaturesAction: () => Action ): Diagnostic[] => lspDiagnostics .map(({ range, message, severity, tags, code }): Diagnostic | undefined => { - // Only show warnings for using V2 API features if a V1 board is connected. + // Only show warnings for using V2 API features if a V1 board is connected + // and warnOnV2OnlyFeatures setting is on. if ( code === "reportMicrobitV2ApiUse" && - device.getBoardVersion() !== "V1" + (!warnOnV2OnlyFeatures || device.getBoardVersion() !== "V1") ) { return undefined; } + let from = positionToOffset(document, range.start); let to = positionToOffset(document, range.end); // Skip if we can't map to the current document. @@ -41,6 +45,10 @@ export const diagnosticsMapping = ( severity: severityMapping[severity ?? LSP.DiagnosticSeverity.Warning], message, tags: tags ? tags.map(convertTag) : undefined, + actions: + code === "reportMicrobitV2ApiUse" + ? [warnOnV2OnlyFeaturesAction()] + : [], }; } return undefined; diff --git a/src/editor/codemirror/language-server/view.ts b/src/editor/codemirror/language-server/view.ts index 5227bc4dd..a500db581 100644 --- a/src/editor/codemirror/language-server/view.ts +++ b/src/editor/codemirror/language-server/view.ts @@ -10,7 +10,7 @@ import * as LSP from "vscode-languageserver-protocol"; import { ApiReferenceMap } from "../../../documentation/mapping/content"; import { LanguageServerClient } from "../../../language-server/client"; import { Logging } from "../../../logging/logging"; -import { setDiagnostics } from "../lint/lint"; +import { Action, setDiagnostics } from "../lint/lint"; import { autocompletion } from "./autocompletion"; import { BaseLanguageServerView, clientFacet, uriFacet } from "./common"; import { diagnosticsMapping } from "./diagnostics"; @@ -28,7 +28,9 @@ class LanguageServerView extends BaseLanguageServerView implements PluginValue { const diagnostics = diagnosticsMapping( this.view.state.doc, params.diagnostics, - this.device + this.device, + this.warnOnV2OnlyFeatures, + this.warnOnV2OnlyFeaturesAction ); this.view.dispatch(setDiagnostics(this.view.state, diagnostics)); } @@ -38,11 +40,28 @@ class LanguageServerView extends BaseLanguageServerView implements PluginValue { const diagnostics = diagnosticsMapping( this.view.state.doc, this.client.allDiagnostics(), - this.device + this.device, + this.warnOnV2OnlyFeatures, + this.warnOnV2OnlyFeaturesAction ); this.view.dispatch(setDiagnostics(this.view.state, diagnostics)); }; - constructor(view: EditorView, private device: DeviceConnection) { + private warnOnV2OnlyFeaturesAction = (): Action => { + return { + name: this.intl.formatMessage({ id: "warn-on-v2-only-features-action" }), + apply: () => { + this.disableV2OnlyFeaturesWarning(); + }, + }; + }; + + constructor( + view: EditorView, + private device: DeviceConnection, + private intl: IntlShape, + private warnOnV2OnlyFeatures: boolean, + private disableV2OnlyFeaturesWarning: () => void + ) { super(view); this.client.on("diagnostics", this.diagnosticsListener); @@ -55,7 +74,9 @@ class LanguageServerView extends BaseLanguageServerView implements PluginValue { const diagnostics = diagnosticsMapping( view.state.doc, this.client.currentDiagnostics(this.uri), - device + device, + warnOnV2OnlyFeatures, + this.warnOnV2OnlyFeaturesAction ); view.dispatch(setDiagnostics(view.state, diagnostics)); } @@ -75,7 +96,7 @@ class LanguageServerView extends BaseLanguageServerView implements PluginValue { destroy() { this.destroyed = true; this.client.removeListener("diagnostics", this.diagnosticsListener); - this.device.on(EVENT_STATUS, this.onDeviceStatusChanged); + this.device.removeListener(EVENT_STATUS, this.onDeviceStatusChanged); // We don't own the client/connection which might outlive us, just our notifications. } } @@ -84,6 +105,11 @@ interface Options { signatureHelp: { automatic: boolean; }; + warnOnV2OnlyFeatures: boolean; +} + +interface Actions { + disableV2OnlyFeaturesWarning: () => void; } /** @@ -102,12 +128,22 @@ export function languageServer( intl: IntlShape, logging: Logging, apiReferenceMap: ApiReferenceMap, - options: Options + options: Options, + actions: Actions ) { return [ uriFacet.of(uri), clientFacet.of(client), - ViewPlugin.define((view) => new LanguageServerView(view, device)), + ViewPlugin.define( + (view) => + new LanguageServerView( + view, + device, + intl, + options.warnOnV2OnlyFeatures, + actions.disableV2OnlyFeaturesWarning + ) + ), signatureHelp(intl, options.signatureHelp.automatic, apiReferenceMap), autocompletion(intl, logging, apiReferenceMap), ]; diff --git a/src/editor/codemirror/themeExtensions.ts b/src/editor/codemirror/themeExtensions.ts index aabb86627..8b1918cff 100644 --- a/src/editor/codemirror/themeExtensions.ts +++ b/src/editor/codemirror/themeExtensions.ts @@ -108,6 +108,20 @@ export const themeExtensions = (fontSize: string) => { // This used to be the default until https://github.com/codemirror/view/commit/a2d7f9111872fe61ffad8fd3ea371a7a41650da6 padding: "0 2px 0 4px", }, + ".cm-diagnosticAction": { + marginLeft: 0, + display: "block", + backgroundColor: "unset", + color: "var(--chakra-colors-brand-600)", + fontSize: "0.9em", + marginTop: "0.2em", + }, + ".cm-diagnosticAction:hover": { + textDecoration: "underline", + }, + "ul:focus [aria-selected] .cm-diagnosticAction": { + color: "var(--chakra-colors-gray-100)", + }, }); }; diff --git a/src/messages/ui.ca.json b/src/messages/ui.ca.json index a789f7519..f7e96d69f 100644 --- a/src/messages/ui.ca.json +++ b/src/messages/ui.ca.json @@ -1669,6 +1669,18 @@ "value": "Canviar mòduls de tercers pot significar que no funcionin com s'havia previst." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2387,6 +2399,12 @@ "value": "visita microbit.org (s'obre en una pestanya nova)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.de.json b/src/messages/ui.de.json index b4e57babe..df0ede71f 100644 --- a/src/messages/ui.de.json +++ b/src/messages/ui.de.json @@ -1743,6 +1743,18 @@ "value": "Wenn du Module von Drittanbietern änderst, kann es sein, dass sie nicht mehr wie vorgesehen funktionieren." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2469,6 +2481,12 @@ "value": "besuche microbit.org (öffnet in neuen Tab)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.en.json b/src/messages/ui.en.json index 0b5f4dff4..6ad55af7d 100644 --- a/src/messages/ui.en.json +++ b/src/messages/ui.en.json @@ -1703,6 +1703,18 @@ "value": "Changing third-party modules may mean they don’t work as intended." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2421,6 +2433,12 @@ "value": "visit microbit.org (opens in a new tab)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, @@ -2430,7 +2448,7 @@ "webusb-error-clear-connect-description-2": [ { "type": 0, - "value": "Close any other pages or tabs that may be using WebUSB (e.g. MakeCode, Python Editor), or unplug and replug the micro:bit before trying again." + "value": "Close any other tabs that may be using WebUSB (e.g. MakeCode, Python Editor), or unplug and replug the micro:bit before trying again." } ], "webusb-error-clear-connect-title": [ diff --git a/src/messages/ui.es-es.json b/src/messages/ui.es-es.json index 16521d834..81c431adc 100644 --- a/src/messages/ui.es-es.json +++ b/src/messages/ui.es-es.json @@ -1703,6 +1703,18 @@ "value": "Cambiar los módulos de terceros puede provocar que no funcionen como deberían." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2413,6 +2425,12 @@ "value": "visitar microbit.org (abre en una nueva pestaña)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.fr.json b/src/messages/ui.fr.json index c4ec989fe..f174d9469 100644 --- a/src/messages/ui.fr.json +++ b/src/messages/ui.fr.json @@ -1703,6 +1703,18 @@ "value": "La modification de modules tiers peut empêcher leur bon fonctionnement." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2413,6 +2425,12 @@ "value": "visiter microbit.org (s’ouvre dans un nouvel onglet)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, @@ -2491,4 +2509,4 @@ "value": "Zoom arrière" } ] -} \ No newline at end of file +} diff --git a/src/messages/ui.ja.json b/src/messages/ui.ja.json index 2835a439d..4b30cfa8b 100644 --- a/src/messages/ui.ja.json +++ b/src/messages/ui.ja.json @@ -1696,6 +1696,18 @@ "value": "サードパーティ製モジュールを変更すると、意図した通りに動作しない可能性があります。" } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2415,6 +2427,12 @@ "value": "microbit.orgにアクセスします(新しいタブで開きます)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.ko.json b/src/messages/ui.ko.json index 60055a44e..ed776b78e 100644 --- a/src/messages/ui.ko.json +++ b/src/messages/ui.ko.json @@ -1711,6 +1711,18 @@ "value": "서드파티 모듈을 변경하면 모듈이 의도대로 작동하지 않을 수 있습니다." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2409,6 +2421,12 @@ "value": "microbit.org 방문(새 탭에서 열기)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.lol.json b/src/messages/ui.lol.json index 154142bc7..bd12a3c0e 100644 --- a/src/messages/ui.lol.json +++ b/src/messages/ui.lol.json @@ -1331,6 +1331,18 @@ "value": "crwdns331722:0crwdne331722:0" } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -1979,6 +1991,12 @@ "value": "crwdns331784:0crwdne331784:0" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, @@ -2009,18 +2027,6 @@ "value": "crwdns331794:0crwdne331794:0" } ], - "webusb-error-update-req-description": [ - { - "type": 0, - "value": "crwdns331796:0crwdne331796:0" - } - ], - "webusb-error-update-req-title": [ - { - "type": 0, - "value": "crwdns331798:0crwdne331798:0" - } - ], "webusb-not-supported": [ { "type": 0, diff --git a/src/messages/ui.nl.json b/src/messages/ui.nl.json index b55ab54dd..fe7920baa 100644 --- a/src/messages/ui.nl.json +++ b/src/messages/ui.nl.json @@ -1726,6 +1726,18 @@ "value": "Wijzigen van modules van derden kan betekenen dat ze niet werken zoals bedoeld." } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2456,6 +2468,12 @@ "value": "bezoek microbit.org (opent in een nieuw tabblad)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.zh-cn.json b/src/messages/ui.zh-cn.json index 6c57d2d5a..43b5f8b6e 100644 --- a/src/messages/ui.zh-cn.json +++ b/src/messages/ui.zh-cn.json @@ -1696,6 +1696,18 @@ "value": "更改第三方模块可能意味着它们无法按预期工作。" } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2422,6 +2434,12 @@ "value": "访问 microbit.org (在新标签页中打开)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/messages/ui.zh-tw.json b/src/messages/ui.zh-tw.json index cf35b26e6..cef9e10e8 100644 --- a/src/messages/ui.zh-tw.json +++ b/src/messages/ui.zh-tw.json @@ -1703,6 +1703,18 @@ "value": "變更第三方模組,可能代表它們無法按預期運作。" } ], + "setting-warn-on-v2-only-features": [ + { + "type": 0, + "value": "Show warnings about V2-only features" + } + ], + "setting-warn-on-v2-only-features-info": [ + { + "type": 0, + "value": "Warnings are shown in the editor when a micro:bit V1 is connected" + } + ], "settings": [ { "type": 0, @@ -2421,6 +2433,12 @@ "value": "造訪 microbit.org (在新索引標籤中開啟)" } ], + "warn-on-v2-only-features-action": [ + { + "type": 0, + "value": "Disable warnings about V2-only features" + } + ], "webusb-error-clear-connect-description-1": [ { "type": 0, diff --git a/src/settings/SettingsArea.tsx b/src/settings/SettingsArea.tsx index 528d064d5..70db0ed5a 100644 --- a/src/settings/SettingsArea.tsx +++ b/src/settings/SettingsArea.tsx @@ -138,6 +138,23 @@ const SettingsArea = () => { + + { + setSettings({ + ...settings, + warnOnV2OnlyFeatures: event.currentTarget.checked, + }); + }} + > + + + + + + ); }; diff --git a/src/settings/settings.tsx b/src/settings/settings.tsx index b22c058a8..5cc858ac3 100644 --- a/src/settings/settings.tsx +++ b/src/settings/settings.tsx @@ -105,6 +105,7 @@ export const defaultSettings: Settings = { showPostSaveHelp: true, showMultipleFilesHelp: true, allowEditingThirdPartyModules: false, + warnOnV2OnlyFeatures: true, }; const inContextTranslationLangId = "lol"; @@ -161,9 +162,10 @@ export interface Settings { showTransferHexHelp: boolean; showPostSaveHelp: boolean; showMultipleFilesHelp: boolean; + warnOnV2OnlyFeatures: boolean; } -type SettingsContextValue = [Settings, (settings: Settings) => void]; +export type SettingsContextValue = [Settings, (settings: Settings) => void]; const SettingsContext = createContext( undefined