gristlabs_grist-core/app/client/components
Paul Fitzpatrick 2a206dfcf8 (core) add initial support for special shares
Summary:
This gives a mechanism for controlling access control within a document that is distinct from (though implemented with the same machinery as) granular access rules.

It was hard to find a good way to insert this that didn't dissolve in a soup of complications, so here's what I went with:
 * When reading rules, if there are shares, extra rules are added.
 * If there are shares, all rules are made conditional on a "ShareRef" user property.
 * "ShareRef" is null when a doc is accessed in normal way, and the row id of a share when accessed via a share.

There's no UI for controlling shares (George is working on it for forms), but you can do it by editing a `_grist_Shares` table in a document. Suppose you make a fresh document with a single page/table/widget, then to create an empty share you can do:

```
gristDocPageModel.gristDoc.get().docData.sendAction(['AddRecord', '_grist_Shares', null, {linkId: 'xyz', options: '{"publish": true}'}])
```

If you look at the home db now there should be something in the `shares` table:

```
$ sqlite3 -table landing.db "select * from shares"
+----+------------------------+------------------------+--------------+---------+
| id |          key           |         doc_id         |   link_id    | options |
+----+------------------------+------------------------+--------------+---------+
| 1  | gSL4g38PsyautLHnjmXh2K | 4qYuace1xP2CTcPunFdtan | xyz | ...      |
+----+------------------------+------------------------+--------------+---------+
```

If you take the key from that (gSL4g38PsyautLHnjmXh2K in this case) and replace the document's urlId in its URL with `s.<key>` (in this case `s.gSL4g38PsyautLHnjmXh2K` then you can use the regular document landing page (it will be quite blank initially) or API endpoint via the share.

E.g. for me `http://localhost:8080/o/docs/s0gSL4g38PsyautLHnjmXh2K/share-inter-3` accesses the doc.

To actually share some material - useful commands:

```
gristDocPageModel.gristDoc.get().docData.getMetaTable('_grist_Views_section').getRecords()
gristDocPageModel.gristDoc.get().docData.sendAction(['UpdateRecord', '_grist_Views_section', 1, {shareOptions: '{"publish": true, "form": true}'}])
gristDocPageModel.gristDoc.get().docData.getMetaTable('_grist_Pages').getRecords()
gristDocPageModel.gristDoc.get().docData.sendAction(['UpdateRecord', '_grist_Pages', 1, {shareRef: 1}])
```

For a share to be effective, at least one page needs to have its shareRef set to the rowId of the share, and at least one widget on one of those pages needs to have its shareOptions set to {"publish": "true", "form": "true"} (meaning turn on sharing, and include form sharing), and the share itself needs {"publish": true} on its options.

I think special shares are kind of incompatible with public sharing, since by their nature (allowing access to all endpoints) they easily expose the docId, and changing that would be hard.

Test Plan: tests added

Reviewers: dsagal, georgegevoian

Reviewed By: dsagal, georgegevoian

Subscribers: jarek, dsagal

Differential Revision: https://phab.getgrist.com/D4144
2024-01-04 05:57:38 -05:00
..
Forms (core) Forms feature 2023-12-20 13:23:12 +01:00
AceEditor.css (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
AceEditor.js (core) Implement AI Assistant UI V2 2023-07-13 10:30:35 -04:00
AceEditorCompletions.ts (core) Implement AI Assistant UI V2 2023-07-13 10:30:35 -04:00
ActionLog.css (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
ActionLog.ts (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
Banner.ts (core) Add AI assistant usage banners 2023-08-30 16:00:04 -04:00
Base.js (core) move client code to core 2020-10-02 13:24:21 -04:00
BaseView2.ts (core) Allow adding rows to widgets filtered by a link using a formula column 2023-12-18 20:28:41 +02:00
BaseView.js (core) Allow adding rows to widgets filtered by a link using a formula column 2023-12-18 20:28:41 +02:00
BehavioralPromptsManager.ts (core) Show tooltips in other Grist flavors 2023-10-31 23:56:27 -04:00
buildViewSectionDom.ts (core) Enable Record Cards 2023-11-21 16:49:41 -05:00
CellPosition.ts (core) Cursor in custom widgets 2023-08-29 09:19:52 +02:00
CellSelector.ts (core) Fixing bug with hiding multiple columns 2023-12-08 10:20:43 +01:00
ChartView.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ChartView.ts i18n: userManager translation + some forgotten translations (#557) 2023-07-16 12:52:13 -04:00
ClientScope.ts (core) move client code to core 2020-10-02 13:24:21 -04:00
Clipboard.css (core) move client code to core 2020-10-02 13:24:21 -04:00
Clipboard.js (core) Add cut, copy, and paste to context menu 2023-05-10 00:48:15 -04:00
CodeEditorPanel.css (core) Improve dark mode 2023-04-12 01:58:48 -04:00
CodeEditorPanel.ts Remove prefix from translations keys 2023-01-03 16:01:45 +01:00
ColumnFilters.css (core) Context menu for cards. 2021-06-29 15:29:56 +02:00
ColumnTransform.ts (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
Comm.ts (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
commandList.ts (core) Remove empty keyboard shortcut for command that shouldn't have one 2023-12-20 10:51:14 -05:00
commands.css (core) move client code to core 2020-10-02 13:24:21 -04:00
commands.ts (core) Floating formula editor 2023-06-02 17:59:22 +02:00
CopySelection.ts (core) Cursor in custom widgets 2023-08-29 09:19:52 +02:00
Cursor.ts Bidirectional Linking (#622) 2023-09-25 18:48:18 -04:00
CursorMonitor.ts (core) Cursor in custom widgets 2023-08-29 09:19:52 +02:00
CustomCalendarView.ts (core) support for bundling custom widgets with the Grist app 2023-10-27 17:00:10 -04:00
CustomView.css (core) Fix CustomView css to take full height of widget on all browsers including Safari 2020-10-06 13:18:50 -04:00
CustomView.ts fix shadowed variable in CustomView (#743) 2023-11-13 10:56:01 -05:00
DataTables.ts (core) Make Raw Data page more responsive 2023-12-19 19:15:28 -05:00
DetailView.css (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
DetailView.js (core) Enable Record Cards 2023-11-21 16:49:41 -05:00
DocComm.ts (core) Billing for formula assistant 2023-07-10 13:24:08 +02:00
DocConfigTab.js (core) move client code to core 2020-10-02 13:24:21 -04:00
DocumentUsage.ts (core) Add AI assistant usage banners 2023-08-30 16:00:04 -04:00
Drafts.ts Change translation keys for components directory 2023-01-03 15:49:26 +01:00
duplicatePage.ts (core) Polish tutorial popups 2023-04-20 12:20:03 -04:00
EditorMonitor.ts (core) Fix problem with localStorage in some cross-origin embed situations 2022-11-30 23:52:50 -05:00
EmbedForm.css (core) move client code to core 2020-10-02 13:24:21 -04:00
FieldConfigTab.css (core) move client code to core 2020-10-02 13:24:21 -04:00
FormulaTransform.ts (core) TypeTransform race condition fix 2023-08-02 17:11:34 +02:00
GridView.css (core) Allow scrolling the grid horizontally while column-shadow is under the cursor 2023-09-26 20:42:10 -04:00
GridView.js (core) Add shortcut for opening Record Card 2023-12-08 11:32:45 -05:00
GristDoc.css (core) move client code to core 2020-10-02 13:24:21 -04:00
GristDoc.ts (core) Forms feature 2023-12-20 13:23:12 +01:00
GristWSConnection.ts (core) Manage memory used for websocket responses to reduce the risk of server crashes. 2023-08-07 11:28:31 -04:00
Importer.ts (core) Adding testId to the widget iframe once it receives the ready message 2023-08-30 21:28:06 +02:00
Layout.css (core) Expanding widgets 2023-01-19 09:46:59 +01:00
Layout.ts (core) Avoiding the view layout's rebuild, when nothing has changed. 2023-09-18 09:47:50 +02:00
LayoutEditor.css (core) move client code to core 2020-10-02 13:24:21 -04:00
LayoutEditor.ts (core) Minimazing widgets 2023-03-02 11:22:49 +01:00
LayoutTray.ts (core) Adjust the style of the 'attic' to have more of a toolbar feel, flush to the top, and taking up less space 2023-06-30 08:22:26 -04:00
LinkingState.ts (core) Fix selecting new row in chain of filter links 2023-12-05 16:56:13 +02:00
Login.css (core) move client code to core 2020-10-02 13:24:21 -04:00
modals.ts (core) Fix blurry tooltips 2023-09-22 03:51:58 -04:00
ParseOptions.ts (core) Improve encoding detection for csv imports, and make encoding an editable option. 2023-08-24 09:50:52 -04:00
PluginScreen.ts (core) Import redesign 2023-08-04 14:59:55 +02:00
Printing.css (core) Improve printing of tables, fix printing of charts, add a browser test. 2020-10-12 16:04:18 -04:00
Printing.ts (core) Improve dark mode 2023-04-12 01:58:48 -04:00
RawDataPage.ts (core) Record Cards 2023-11-19 20:12:37 -05:00
RecordCardPopup.ts (core) Enable Record Cards 2023-11-21 16:49:41 -05:00
RecordLayout.css (core) Add behavioral and coaching call popups 2022-12-20 09:49:41 -05:00
RecordLayout.js (core) Record Cards 2023-11-19 20:12:37 -05:00
RecordLayoutEditor.js (core) Minimazing widgets 2023-03-02 11:22:49 +01:00
RefSelect.ts (core) Record Cards 2023-11-19 20:12:37 -05:00
SearchBar.css (core) move client code to core 2020-10-02 13:24:21 -04:00
SelectionSummary.ts (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
TypeConversion.ts (core) Guessing column widget options when transforming from 2023-10-30 13:36:39 +01:00
TypeTransform.ts (core) Guessing column widget options when transforming from 2023-10-30 13:36:39 +01:00
UndoStack.ts (core) Cursor in custom widgets 2023-08-29 09:19:52 +02:00
UnsavedChanges.ts (core) support ?embed=true and &style=light for a clean embed experience 2020-08-14 13:34:38 -04:00
ValidationPanel.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ValidationPanel.js Remove prefix from translations keys 2023-01-03 16:01:45 +01:00
ViewAsBanner.ts (core) Adds dots menu to access rules page item 2023-01-12 09:40:45 +01:00
viewCommon.css (core) Polish new Add Column menu 2023-10-17 15:39:53 -04:00
viewCommon.js (core) Skip saving column resizes in read-only mode 2021-12-07 14:37:25 -08:00
ViewConfigTab.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ViewConfigTab.js (core) Record Cards 2023-11-19 20:12:37 -05:00
ViewLayout.css (core) Polish dark mode and remove beta tag 2023-09-21 13:14:48 -04:00
ViewLayout.ts (core) Forms feature 2023-12-20 13:23:12 +01:00
ViewLinker.css (core) move client code to core 2020-10-02 13:24:21 -04:00
ViewPane.ts (core) Implementing row conditional formatting 2022-08-09 20:11:36 +02:00
WidgetFrame.ts (core) Don't throw error in onRecord(s) for insufficient access for includeColumns 2023-12-30 10:16:40 +02:00