2021-09-29 13:57:55 +00:00
|
|
|
import {MinimalActionGroup} from 'app/common/ActionGroup';
|
2020-07-21 13:20:51 +00:00
|
|
|
import {TableDataAction} from 'app/common/DocActions';
|
2021-01-15 21:56:58 +00:00
|
|
|
import {Role} from 'app/common/roles';
|
2020-07-21 13:20:51 +00:00
|
|
|
import {StringUnion} from 'app/common/StringUnion';
|
2022-04-21 17:57:33 +00:00
|
|
|
import {DataLimitStatus, RowCount} from 'app/common/Usage';
|
2021-01-15 21:56:58 +00:00
|
|
|
import {FullUser} from 'app/common/UserAPI';
|
2020-07-21 13:20:51 +00:00
|
|
|
|
|
|
|
// Possible flavors of items in a list of documents.
|
|
|
|
export type DocEntryTag = ''|'sample'|'invite'|'shared';
|
|
|
|
|
|
|
|
export const OpenDocMode = StringUnion(
|
|
|
|
'default', // open doc with user's maximal access level
|
2020-08-14 16:40:39 +00:00
|
|
|
'view', // open doc limited to view access (if user has at least that level of access)
|
|
|
|
'fork', // as for 'view', but suggest a fork on any attempt to edit - the client will
|
|
|
|
// enable the editing UI experience and trigger a fork on any edit.
|
2020-07-21 13:20:51 +00:00
|
|
|
);
|
|
|
|
export type OpenDocMode = typeof OpenDocMode.type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an entry in the DocList.
|
|
|
|
*/
|
|
|
|
export interface DocEntry {
|
|
|
|
docId?: string; // Set for shared docs and invites
|
|
|
|
name: string;
|
|
|
|
mtime?: Date;
|
|
|
|
size?: number;
|
|
|
|
tag: DocEntryTag;
|
|
|
|
senderName?: string;
|
|
|
|
senderEmail?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DocCreationInfo {
|
|
|
|
id: string;
|
|
|
|
title: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This documents the members of the structure returned when a local
|
|
|
|
* grist document is opened.
|
|
|
|
*/
|
|
|
|
export interface OpenLocalDocResult {
|
|
|
|
docFD: number;
|
|
|
|
clientId: string; // the docFD is meaningful only in the context of this session
|
|
|
|
doc: {[tableId: string]: TableDataAction};
|
2021-09-29 13:57:55 +00:00
|
|
|
log: MinimalActionGroup[];
|
2022-04-21 17:57:33 +00:00
|
|
|
rowCount: RowCount;
|
2020-12-14 17:42:09 +00:00
|
|
|
recoveryMode?: boolean;
|
2021-01-15 21:56:58 +00:00
|
|
|
userOverride?: UserOverride;
|
(core) Grace period and delete-only mode when exceeding row limit
Summary:
Builds upon https://phab.getgrist.com/D3328
- Add HomeDB column `Document.gracePeriodStart`
- When the row count moves above the limit, set it to the current date. When it moves below, set it to null.
- Add DataLimitStatus type indicating if the document is approaching the limit, is in a grace period, or is in delete only mode if the grace period started at least 14 days ago. Compute it in ActiveDoc and send it to client when opening.
- Only allow certain user actions when in delete-only mode.
Follow-up tasks related to this diff:
- When DataLimitStatus in the client is non-empty, show a banner to the appropriate users.
- Only send DataLimitStatus to users with the appropriate access. There's no risk landing this now since real users will only see null until free team sites are released.
- Update DataLimitStatus immediately in the client when it changes, e.g. when user actions are applied or the product is changed. Right now it's only sent when the document loads.
- Update row limit, grace period start, and data limit status in ActiveDoc when the product changes, i.e. the user upgrades/downgrades.
- Account for data size when computing data limit status, not just row counts.
See also the tasks mentioned in https://phab.getgrist.com/D3331
Test Plan: Extended FreeTeam nbrowser test, testing the 4 statuses.
Reviewers: georgegevoian
Reviewed By: georgegevoian
Differential Revision: https://phab.getgrist.com/D3331
2022-03-24 12:05:51 +00:00
|
|
|
dataLimitStatus?: DataLimitStatus;
|
2021-01-15 21:56:58 +00:00
|
|
|
}
|
|
|
|
|
2021-04-26 21:54:09 +00:00
|
|
|
export interface UserOverride {
|
2021-01-15 21:56:58 +00:00
|
|
|
user: FullUser|null;
|
|
|
|
access: Role|null;
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface DocListAPI {
|
|
|
|
/**
|
|
|
|
* Returns a all known Grist documents and document invites to show in the doc list.
|
|
|
|
*/
|
|
|
|
getDocList(): Promise<{docs: DocEntry[], docInvites: DocEntry[]}>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new document, fetches it, and adds a table to it. Returns its name.
|
|
|
|
*/
|
|
|
|
createNewDoc(): Promise<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes a copy of the given sample doc. Returns the name of the new document.
|
|
|
|
*/
|
|
|
|
importSampleDoc(sampleDocName: string): Promise<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes an upload, containing possibly multiple files, to create a single new document, and
|
|
|
|
* returns the new document's name.
|
|
|
|
*/
|
|
|
|
importDoc(uploadId: number): Promise<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a Grist document. Returns the name of the deleted document. If `deletePermanently` is
|
|
|
|
* true, the doc is deleted permanently rather than just moved to the trash.
|
|
|
|
*/
|
|
|
|
deleteDoc(docName: string, deletePermanently: boolean): Promise<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renames a document.
|
|
|
|
*/
|
|
|
|
renameDoc(oldName: string, newName: string): Promise<void>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a document, loads it, subscribes to its userAction events, and returns its metadata.
|
|
|
|
*/
|
2020-12-09 13:57:35 +00:00
|
|
|
openDoc(userDocName: string, openMode?: OpenDocMode,
|
|
|
|
linkParameters?: Record<string, string>): Promise<OpenLocalDocResult>;
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|