(core) Exposing custom widgets on the UI

Summary:
Exposing custom widgets as a dropdown menu in custom section configuration panel.

Adding new environmental variable GRIST_WIDGET_LIST_URL that points to a
json file with an array of available widgets. When not present, custom widget menu is
hidden, exposing only Custom URL option.

Available widget list can be fetched from:
https://github.com/gristlabs/grist-widget/releases/download/latest/manifest.json

Test Plan: New tests, and updated old ones.

Reviewers: paulfitz, dsagal

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3127
This commit is contained in:
Jarosław Sadziński
2021-11-26 11:43:55 +01:00
parent be96db4689
commit 1425461cd8
16 changed files with 482 additions and 25 deletions

View File

@@ -52,7 +52,9 @@ export class CursorMonitor extends Disposable {
this.autoDispose(doc.cursorPosition.addListener(pos => {
// if current position is not restored yet, don't change it
if (!this._restored) { return; }
if (pos) { this._storePosition(pos); }
// store position only when we have valid rowId
// for some views (like CustomView) cursor position might not reflect actual row
if (pos && pos.rowId !== undefined) { this._storePosition(pos); }
}));
}

View File

@@ -771,20 +771,7 @@ ViewConfigTab.prototype._buildCustomTypeItems = function() {
}, {
// 2)
showObs: () => activeSection().customDef.mode() === "url",
buildDom: () => kd.scope(activeSection, ({customDef}) => dom('div',
kf.row(18, kf.text(customDef.url, {placeholder: "Full URL of webpage to show"}, dom.testId('ViewConfigTab_url'))),
kf.row(5, "Access", 13, dom(kf.select(customDef.access, ['none', 'read table', 'full']), dom.testId('ViewConfigTab_customView_access'))),
kf.helpRow('none: widget has no access to document.',
kd.style('text-align', 'left'),
kd.style('margin-top', '1.5rem')),
kf.helpRow('read table: widget can read the selected table.',
kd.style('text-align', 'left'),
kd.style('margin-top', '1.5rem')),
kf.helpRow('full: widget can read, modify, and copy the document.',
kd.style('text-align', 'left'),
kd.style('margin-top', '1.5rem'))
)),
// TODO: refactor this part, Custom Widget moved to separate file.
}, {
// 3)