mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Form Publishing
Summary: Adds initial implementation of form publishing, built upon WYSIWYS shares. A simple UI for publishing and unpublishing forms is included. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Subscribers: paulfitz, jarek Differential Revision: https://phab.getgrist.com/D4154
This commit is contained in:
@@ -268,6 +268,21 @@ type ISuggestion = string | [string, string, boolean];
|
||||
// Suggestion paired with an optional example value to show on the right
|
||||
export type ISuggestionWithValue = [ISuggestion, string | null];
|
||||
|
||||
/**
|
||||
* Share information from a Grist document.
|
||||
*/
|
||||
export interface ShareInfo {
|
||||
linkId: string;
|
||||
options: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share information from the Grist home database.
|
||||
*/
|
||||
export interface RemoteShareInfo {
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface ActiveDocAPI {
|
||||
/**
|
||||
* Closes a document, and unsubscribes from its userAction events.
|
||||
@@ -330,7 +345,7 @@ export interface ActiveDocAPI {
|
||||
* Returns a diff of changes that will be applied to the destination table from `transformRule`
|
||||
* if the data from `hiddenTableId` is imported with the specified `mergeOptions`.
|
||||
*/
|
||||
generateImportDiff(hiddenTableId: string, transformRule: TransformRule,
|
||||
generateImportDiff(hiddenTableId: string, transformRule: TransformRule,
|
||||
mergeOptions: MergeOptions): Promise<DocStateComparison>;
|
||||
|
||||
/**
|
||||
@@ -428,4 +443,6 @@ export interface ActiveDocAPI {
|
||||
* Get users that are worth proposing to "View As" for access control purposes.
|
||||
*/
|
||||
getUsersForViewAs(): Promise<PermissionDataWithExtraUsers>;
|
||||
|
||||
getShare(linkId: string): Promise<RemoteShareInfo>;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,30 @@ export interface UserAPI {
|
||||
/**
|
||||
* Creates publicly shared URL for a rendered form.
|
||||
*/
|
||||
formUrl(docId: string, vsId: number): string;
|
||||
formUrl(options: FormUrlOptions): string;
|
||||
}
|
||||
|
||||
interface FormUrlOptions {
|
||||
vsId: number;
|
||||
/**
|
||||
* The canonical URL or document ID.
|
||||
*
|
||||
* If set, the returned form URL will only be accessible by users with access to the
|
||||
* document. This is currently only used for the preview functionality in the widget,
|
||||
* where document access is a pre-requisite.
|
||||
*
|
||||
* Only one of `urlId` or `shareKey` should be set.
|
||||
*/
|
||||
urlId?: string;
|
||||
/**
|
||||
* The key of the Share granting access to the form.
|
||||
*
|
||||
* If set, the returned form URL will be accessible by anyone, so long as the form
|
||||
* is published.
|
||||
*
|
||||
* Only one of `urlId` or `shareKey` should be set.
|
||||
*/
|
||||
shareKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,8 +537,17 @@ export class UserAPIImpl extends BaseAPI implements UserAPI {
|
||||
super(_options);
|
||||
}
|
||||
|
||||
public formUrl(docId: string, vsId: number): string {
|
||||
return `${this._url}/api/docs/${docId}/forms/${vsId}`;
|
||||
public formUrl(options: FormUrlOptions): string {
|
||||
const {urlId, shareKey, vsId} = options;
|
||||
if (!urlId && !shareKey) {
|
||||
throw new Error('Invalid form URL: missing urlId or shareKey');
|
||||
}
|
||||
|
||||
if (urlId) {
|
||||
return `${this._url}/api/docs/${urlId}/forms/${vsId}`;
|
||||
} else {
|
||||
return `${this._url}/forms/${shareKey}/${vsId}`;
|
||||
}
|
||||
}
|
||||
|
||||
public forRemoved(): UserAPI {
|
||||
|
||||
Reference in New Issue
Block a user