Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make changes required for Desktop FS updates #1099

Merged
merged 22 commits into from
Sep 17, 2024
Merged

Conversation

SleepyLeslie
Copy link
Collaborator

@SleepyLeslie SleepyLeslie commented Jul 10, 2024

  • Implements required changes for Desktop user experience overhaul grist-desktop#42
  • Adds a --no-nodemon flag to yarn start that allows grist-desktop to use the script without running nodemon.
  • Updates use of deprecated TypeORM API.
  • Makes a new class MergedServer that does not run the server automatically on creation. This allows for modifying certain aspects of the MergedServer before running it.
  • Moves login system from ServerOptions to ICreate.

@SleepyLeslie SleepyLeslie force-pushed the sleepyleslie/nativefs branch 2 times, most recently from c0a0d09 to ab32eac Compare July 17, 2024 15:41
app/server/MergedServer.ts Show resolved Hide resolved
app/server/MergedServer.ts Show resolved Hide resolved
app/server/lib/FlexServer.ts Outdated Show resolved Hide resolved
app/server/lib/ICreate.ts Outdated Show resolved Hide resolved
test/gen-server/AuthCaching.ts Show resolved Hide resolved
@@ -24,6 +21,7 @@ import {Workspace} from 'app/common/UserAPI';
import {computed, dom, domComputed, DomElementArg, observable, Observable, styled} from 'grainjs';
import {createHelpTools, cssLeftPanel, cssScrollPane,
cssSectionHeader, cssTools} from 'app/client/ui/LeftPanelCommon';
import {createDocAndOpen, importDocAndOpen, importFromPluginAndOpen} from "app/client/ui/NewDocMethods";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use locally consistent quotes. Please do your best to put imports in alphabetical order, even if prev devs have left small muddles.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reordered all imports here manually.

I noticed that our eslint config has ignoreDeclarationSort: true, which effectively disables sort-imports checks across lines. Is that intentional?

@@ -1,6 +0,0 @@
import { getCoreLoginSystem } from "app/server/lib/coreLogins";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We will need to be careful when syncing SaaS, also grist-static, since they are still using logins.ts)

stubs/app/client/ui/HomeImports.ts Outdated Show resolved Hide resolved
import {ImportSourceElement} from 'app/client/lib/ImportSourceElement';
import {reportError} from 'app/client/models/AppModel';

export async function createDocAndOpen(home: HomeModel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding significant new code to stubs is undesirable, unless it is for grist-core and only grist-core, not desktop, not ee, not saas etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do have a doubt that maybe desktop is using some material from stubs? But if so ideally that material would go into core/ and be used from desktop ext and by stubs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Desktop is using version.ts from stubs. I just removed it. Now there is no core/stubs dependency.

Comment on lines +144 to +146
public hasComponent(serverType: ServerType) {
return this._serverTypes.includes(serverType);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces includeHome, includeDocs, includeStatic and includeApp.

externalStorage?: boolean;
}

export class MergedServer {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new class that holds all necessary information such that the MergedServer can be created and started as separate steps.

} else {
ms.flexServer.setServesPlugins(false);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code to handle options.loginSystem is removed because login system has been moved to ICreate. FlexServer will now deal with the login system.


export class MergedServer {

public static async create(port: number, serverTypes: ServerType[], options: ServerOptions = {}) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the constructor for MergedServer has to be async, I used this static function. It contains everything in the old main function up to server.start().

}


public async run() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the second part of the old main function.

The FlexServer is created in create(), but before calling run() it is not started. Between these two function calls, one can retrieve and modify certain FlexServer components.

// If set, documents saved to external storage such as s3 (default is to check environment variables,
// which get set in various ways in dev/test entry points)
externalStorage?: boolean;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loginSystem is removed because it is now specified via ICreate instead.

SleepyLeslie and others added 3 commits August 6, 2024 01:47
The testing hooks were registering before the _comm port had been
created.

This adjusts the startup order to allow the server to be initialised
before the testing hooks are registered.
getLoginSystem(): Promise<GristLoginSystem>;

// Used by Grist Desktop to override the getPath function.
decorateDocStorageManager? (original: IDocStorageManager): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned about having this here, with the intended purpose of overriding methods from inside an arbitrary interface. It feels like it's asking for unexpected trouble in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored this in #1180 to allow a new storage manager to be injected

@Spoffy Spoffy mentioned this pull request Aug 26, 2024
4 tasks
Comment on lines 99 to 100
// Expose the HomeModel for grist-desktop.
(window as any).gristHomeModel = pageModel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we can remove this by using window.gristApp instead.

Spoffy and others added 2 commits September 11, 2024 14:35
This replaces decorateDocStorageManager with new ICreate methods that allow the DocStorageManager implementation to overridden by other versions of Grist, allowing them to subclass or use a custom implementation.
Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all makes reasonable sense. I'd guess this will break SaaS and we'll need to scramble to fix it (loginSystem changes, storageManager creation changes, new stubs to define), but that is normal these days.

@Spoffy could you run this PR through the SaaS CI just to see what the damage is?

@@ -118,17 +119,18 @@ export async function main() {
log.info("== staticServer");
const staticPort = getPort("STATIC_PORT", 9001);
process.env.APP_STATIC_URL = `http://localhost:${staticPort}`;
await mergedServerMain(staticPort, ["static"]);
await MergedServer.create(staticPort, ["static"]).then((s) => s.run());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weak preference for spelling this out with an intermediate variable rather than using a then

@@ -12,6 +13,11 @@ import {IShell} from 'app/server/lib/IShell';
import {createSandbox, SpawnFn} from 'app/server/lib/NSandbox';
import {SqliteVariant} from 'app/server/lib/SqliteCommon';
import {ITelemetry} from 'app/server/lib/Telemetry';
import {IDocStorageManager} from './IDocStorageManager';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a near-universal convention of spelling out the paths as app/.... Not much reason for it, but grist-static does depend on it in some cases so it would be nice to keep.

@@ -17,6 +16,7 @@ import * as fse from 'fs-extra';
import {tmpdir} from 'os';
import * as path from 'path';
import * as tmp from 'tmp';
import {create} from "app/server/lib/create";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import ordering

# Conflicts:
#	.gitignore
#	app/client/ui/HomeLeftPane.ts
#	app/gen-server/lib/homedb/HomeDBManager.ts
#	app/server/lib/FlexServer.ts
Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some unresolved review comments, but all minor, and this version has been checked on SaaS and the fixes needed there are figured out. So going to merge. Thanks @SleepyLeslie @Spoffy.

@paulfitz paulfitz merged commit 02cfcee into main Sep 17, 2024
11 checks passed
@paulfitz paulfitz deleted the sleepyleslie/nativefs branch September 17, 2024 01:02
hexaltation pushed a commit to hexaltation/grist-core that referenced this pull request Sep 24, 2024
Make a set of changes required for Desktop FS improvements, see
gristlabs/grist-desktop#42

---------

Co-authored-by: Spoffy <[email protected]>
Co-authored-by: Spoffy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants