-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Conversation
06eb1c2
to
140eb4f
Compare
c0a0d09
to
ab32eac
Compare
ab32eac
to
9f60f25
Compare
a8ef6a8
to
3505b30
Compare
3505b30
to
9de01df
Compare
app/client/ui/HomeLeftPane.ts
Outdated
@@ -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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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/NewDocMethods.ts
Outdated
import {ImportSourceElement} from 'app/client/lib/ImportSourceElement'; | ||
import {reportError} from 'app/client/models/AppModel'; | ||
|
||
export async function createDocAndOpen(home: HomeModel) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
public hasComponent(serverType: ServerType) { | ||
return this._serverTypes.includes(serverType); | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); | ||
} | ||
|
There was a problem hiding this comment.
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 = {}) { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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.
89089b0
to
9950120
Compare
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.
app/server/lib/ICreate.ts
Outdated
getLoginSystem(): Promise<GristLoginSystem>; | ||
|
||
// Used by Grist Desktop to override the getPath function. | ||
decorateDocStorageManager? (original: IDocStorageManager): void; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
app/client/ui/AppUI.ts
Outdated
// Expose the HomeModel for grist-desktop. | ||
(window as any).gristHomeModel = pageModel; |
There was a problem hiding this comment.
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.
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.
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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
01e3fc5
to
947170d
Compare
There was a problem hiding this 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.
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]>
--no-nodemon
flag toyarn start
that allows grist-desktop to use the script without running nodemon.MergedServer
that does not run the server automatically on creation. This allows for modifying certain aspects of the MergedServer before running it.ServerOptions
toICreate
.