Browse Source

Plugin setting transform work in progress

Afshin Darian 6 years ago
parent
commit
4715d2539b

+ 4 - 0
packages/coreutils/src/plugin-schema.json

@@ -14,6 +14,10 @@
       "type": "string",
       "default": "Plugin"
     },
+    "jupyter.lab.setting-transform": {
+      "type": "boolean",
+      "default": false
+    },
     "jupyter.lab.shortcuts": {
       "items": { "$ref": "#/definitions/shortcut" },
       "type": "array",

+ 1 - 1
packages/coreutils/src/settingregistry.ts

@@ -828,7 +828,7 @@ export class SettingRegistry {
     }
 
     if (plugin.id in transformers) {
-      return Promise.resolve(transformers[plugin.id].apply(null, settings));
+      return Promise.resolve(transformers[plugin.id].call(null, settings));
     }
 
     // TODO: Implement timeout logic.

+ 2 - 18
packages/shortcuts-extension/schema/plugin.json

@@ -1,25 +1,9 @@
 {
   "jupyter.lab.setting-icon-class": "jp-LauncherIcon",
   "jupyter.lab.setting-icon-label": "Keyboard Shortcuts",
+  "jupyter.lab.setting-transform": true,
   "title": "Keyboard Shortcuts",
   "description": "Keyboard shortcut settings for JupyterLab.",
   "properties": {},
-  "oneOf": [{ "$ref": "#/definitions/shortcut" }],
-  "type": "object",
-  "definitions": {
-    "shortcut": {
-      "properties": {
-        "command": { "type": "string" },
-        "keys": {
-          "items": { "type": "string" },
-          "minItems": 1,
-          "type": "array"
-        },
-        "selector": { "type": "string" },
-        "title": { "type": "string" },
-        "category": { "type": "string" }
-      },
-      "type": "object"
-    }
-  }
+  "type": "object"
 }

+ 4 - 0
packages/shortcuts-extension/src/index.ts

@@ -138,6 +138,10 @@ namespace Private {
     return settings => {
       const plugin = registry.plugins.filter(p => p.id === settings.plugin)[0];
 
+      if (!plugin) {
+        return settings;
+      }
+
       return new ShortcutSettings({ plugin, registry });
     };
   }