mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) control the distribution of attachment metadata
Summary: for users who don't automatically have deep rights to the document, provide them with attachment metadata only for rows they have access to. This is a little tricky to do efficiently. We provide attachment metadata when an individual table is fetched, rather than on initial document load, so we don't block that load on a full document scan. We provide attachment metadata to a client when we see that we are shipping rows mentioning particular attachments, without making any effort to keep track of the metadata they already have. Test Plan: updated tests Reviewers: dsagal, jarek Reviewed By: dsagal, jarek Differential Revision: https://phab.getgrist.com/D3722
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { AddRecord, BulkAddRecord, BulkRemoveRecord, BulkUpdateRecord,
|
||||
CellValue, DocAction, getTableId, RemoveRecord, ReplaceTableData,
|
||||
DocAction, getTableId, RemoveRecord, ReplaceTableData,
|
||||
TableDataAction, UpdateRecord } from "app/common/DocActions";
|
||||
import { getSetMapValue } from "app/common/gutil";
|
||||
|
||||
@@ -77,33 +77,3 @@ export function getRowIdsFromDocAction(docActions: RemoveRecord | BulkRemoveReco
|
||||
const ids = docActions[2];
|
||||
return (typeof ids === 'number') ? [ids] : ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tiny helper to get the col ids mentioned in a record-related DocAction as a list
|
||||
* (even if the action is not a bulk action). When the action touches the whole row,
|
||||
* it returns ["*"].
|
||||
*/
|
||||
export function getColIdsFromDocAction(docActions: RemoveRecord | BulkRemoveRecord | AddRecord |
|
||||
BulkAddRecord | UpdateRecord | BulkUpdateRecord | ReplaceTableData |
|
||||
TableDataAction) {
|
||||
if (docActions[3]) { return Object.keys(docActions[3]); }
|
||||
return ['*'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract column values for a particular column as CellValue[] from a
|
||||
* record-related DocAction. Undefined if absent.
|
||||
*/
|
||||
export function getColValuesFromDocAction(docAction: RemoveRecord | BulkRemoveRecord | AddRecord |
|
||||
BulkAddRecord | UpdateRecord | BulkUpdateRecord | ReplaceTableData |
|
||||
TableDataAction, colId: string): CellValue[]|undefined {
|
||||
const colValues = docAction[3];
|
||||
if (!colValues) { return undefined; }
|
||||
const cellValues = colValues[colId];
|
||||
if (!cellValues) { return undefined; }
|
||||
if (Array.isArray(docAction[2])) {
|
||||
return cellValues as CellValue[];
|
||||
} else {
|
||||
return [cellValues as CellValue];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user