mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Adding import from google drive to the home screen
Summary: Importing from google drive from home screen (also for anonymous users) Test Plan: Browser tests Reviewers: dsagal, paulfitz Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2943
This commit is contained in:
@@ -9,6 +9,7 @@ import fetch, {Response as FetchResponse, RequestInit} from 'node-fetch';
|
||||
import {ApiError} from 'app/common/ApiError';
|
||||
import {getSlugIfNeeded, parseSubdomainStrictly} from 'app/common/gristUrls';
|
||||
import {removeTrailingSlash} from 'app/common/gutil';
|
||||
import {LocalPlugin} from "app/common/plugin";
|
||||
import {Document as APIDocument} from 'app/common/UserAPI';
|
||||
import {Document} from "app/gen-server/entity/Document";
|
||||
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||||
@@ -29,6 +30,7 @@ export interface AttachOptions {
|
||||
docWorkerMap: IDocWorkerMap|null;
|
||||
sendAppPage: (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => Promise<void>;
|
||||
dbManager: HomeDBManager;
|
||||
plugins: LocalPlugin[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,11 +151,11 @@ async function getWorker(docWorkerMap: IDocWorkerMap, assignmentId: string,
|
||||
}
|
||||
|
||||
export function attachAppEndpoint(options: AttachOptions): void {
|
||||
const {app, middleware, docMiddleware, docWorkerMap, forceLogin, sendAppPage, dbManager} = options;
|
||||
const {app, middleware, docMiddleware, docWorkerMap, forceLogin, sendAppPage, dbManager, plugins} = options;
|
||||
// Per-workspace URLs open the same old Home page, and it's up to the client to notice and
|
||||
// render the right workspace.
|
||||
app.get(['/', '/ws/:wsId', '/p/:page'], ...middleware, expressWrap(async (req, res) =>
|
||||
sendAppPage(req, res, {path: 'app.html', status: 200, config: {}, googleTagManager: 'anon'})));
|
||||
sendAppPage(req, res, {path: 'app.html', status: 200, config: {plugins}, googleTagManager: 'anon'})));
|
||||
|
||||
app.get('/api/worker/:assignmentId([^/]+)/?*', expressWrap(async (req, res) => {
|
||||
if (!trustOrigin(req, res)) { throw new Error('Unrecognized origin'); }
|
||||
@@ -180,7 +182,7 @@ export function attachAppEndpoint(options: AttachOptions): void {
|
||||
return next();
|
||||
}
|
||||
if (!docWorkerMap) {
|
||||
return await sendAppPage(req, res, {path: 'app.html', status: 200, config: {},
|
||||
return await sendAppPage(req, res, {path: 'app.html', status: 200, config: {plugins},
|
||||
googleTagManager: 'anon'});
|
||||
}
|
||||
const mreq = req as RequestWithLogin;
|
||||
@@ -255,6 +257,7 @@ export function attachAppEndpoint(options: AttachOptions): void {
|
||||
assignmentId: docId,
|
||||
getWorker: {[docId]: customizeDocWorkerUrl(docStatus.docWorker.publicUrl, req)},
|
||||
getDoc: {[docId]: pruneAPIResult(doc as unknown as APIDocument)},
|
||||
plugins
|
||||
}});
|
||||
});
|
||||
// The * is a wildcard in express 4, rather than a regex symbol.
|
||||
|
||||
@@ -327,7 +327,6 @@ export class DocManager extends EventEmitter {
|
||||
clientId: docSession.client.clientId,
|
||||
doc: metaTables,
|
||||
log: recentActions,
|
||||
plugins: activeDoc.docPluginManager.getPlugins(),
|
||||
recoveryMode: activeDoc.recoveryMode,
|
||||
userOverride: await activeDoc.getUserOverride(docSession),
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ export class DocPluginManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a promise which resolves with the list of plugins definitions.
|
||||
* Returns a list of plugins definitions.
|
||||
*/
|
||||
public getPlugins(): LocalPlugin[] {
|
||||
return this._localPlugins;
|
||||
|
||||
@@ -645,7 +645,7 @@ export class FlexServer implements GristServer {
|
||||
}
|
||||
}
|
||||
|
||||
public addLandingPages() {
|
||||
public async addLandingPages() {
|
||||
// TODO: check if isSingleUserMode() path can be removed from this method
|
||||
if (this._check('landing', 'map', isSingleUserMode() ? null : 'homedb')) { return; }
|
||||
this.addSessions();
|
||||
@@ -710,6 +710,7 @@ export class FlexServer implements GristServer {
|
||||
docWorkerMap: isSingleUserMode() ? null : this._docWorkerMap,
|
||||
sendAppPage: this._sendAppPage,
|
||||
dbManager: this.dbManager,
|
||||
plugins : (await this._addPluginManager()).getPlugins()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ export async function main(port: number, serverTypes: ServerType[],
|
||||
server.addDocApiForwarder();
|
||||
}
|
||||
server.addJsonSupport();
|
||||
server.addLandingPages();
|
||||
await server.addLandingPages();
|
||||
// todo: add support for home api to standalone app
|
||||
if (!includeApp) {
|
||||
server.addHomeApi();
|
||||
|
||||
Reference in New Issue
Block a user