mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
c6fd79ac1f
Summary: WIP Test Plan: Existing tests. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D4196
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import {get as getBrowserGlobals} from 'app/client/lib/browserGlobals';
|
|
import {setupLocale} from 'app/client/lib/localization';
|
|
import {AppModel, TopAppModelImpl} from 'app/client/models/AppModel';
|
|
import {reportError, setUpErrorHandling} from 'app/client/models/errors';
|
|
import {buildSnackbarDom} from 'app/client/ui/NotifyUI';
|
|
import {addViewportTag} from 'app/client/ui/viewport';
|
|
import {attachCssRootVars, attachTheme} from 'app/client/ui2018/cssVars';
|
|
import {BaseAPI} from 'app/common/BaseAPI';
|
|
import {dom, DomContents} from 'grainjs';
|
|
|
|
const G = getBrowserGlobals('document', 'window');
|
|
|
|
/**
|
|
* Sets up the application model, error handling, and global styles, and replaces
|
|
* the DOM body with the result of calling `buildAppPage`.
|
|
*/
|
|
export function createAppPage(buildAppPage: (appModel: AppModel) => DomContents) {
|
|
setUpErrorHandling();
|
|
|
|
const topAppModel = TopAppModelImpl.create(null, {});
|
|
|
|
addViewportTag();
|
|
attachCssRootVars(topAppModel.productFlavor);
|
|
setupLocale().catch(reportError);
|
|
|
|
// Add globals needed by test utils.
|
|
G.window.gristApp = {
|
|
testNumPendingApiRequests: () => BaseAPI.numPendingRequests(),
|
|
};
|
|
dom.update(document.body, dom.maybeOwned(topAppModel.appObs, (owner, appModel) => {
|
|
owner.autoDispose(attachTheme(appModel.currentTheme));
|
|
|
|
return [
|
|
buildAppPage(appModel),
|
|
buildSnackbarDom(appModel.notifier, appModel),
|
|
];
|
|
}));
|
|
}
|