2020-10-09 20:47:22 +00:00
|
|
|
/* global $, window */
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2021-09-04 07:04:52 +00:00
|
|
|
// This is the entry point into loading the whole of Grist frontend application. Some extensions
|
|
|
|
// attempt to load it more than once (e.g. "Lingvanex"). This leads to duplicated work and errors.
|
|
|
|
// At least some of such interference can be neutralized by simply ignoring repeated loads.
|
|
|
|
if (window._gristAppLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
window._gristAppLoaded = true;
|
|
|
|
|
2022-09-29 08:01:37 +00:00
|
|
|
const {setupLocale} = require('./lib/localization');
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
const {App} = require('./ui/App');
|
|
|
|
|
|
|
|
// Disable longStackTraces, which seem to be enabled in the browser by default.
|
|
|
|
var bluebird = require('bluebird');
|
|
|
|
bluebird.config({ longStackTraces: false });
|
|
|
|
|
|
|
|
// Set up integration between grainjs and knockout disposal.
|
|
|
|
const {setupKoDisposal} = require('grainjs');
|
|
|
|
const ko = require('knockout');
|
|
|
|
setupKoDisposal(ko);
|
|
|
|
|
|
|
|
$(function() {
|
2021-11-23 03:21:40 +00:00
|
|
|
// Manually disable the bfcache. We dispose some components in App.ts on unload, and
|
|
|
|
// leaving the cache on causes problems when the browser back/forward buttons are pressed.
|
|
|
|
// Some browsers automatically disable it when the 'beforeunload' or 'unload' events
|
|
|
|
// have listeners, but not all do (Safari).
|
|
|
|
window.onpageshow = function(event) {
|
|
|
|
if (event.persisted) { window.location.reload(); }
|
|
|
|
};
|
|
|
|
|
2022-09-29 08:01:37 +00:00
|
|
|
const localeSetup = setupLocale();
|
|
|
|
// By the time dom ready is fired, resource files should already be loaded, but
|
|
|
|
// if that is not the case, we will redirect to an error page by throwing an error.
|
|
|
|
localeSetup.then(() => {
|
|
|
|
window.gristApp = App.create(null);
|
|
|
|
}).catch(error => {
|
|
|
|
throw new Error(`Failed to load locale: ${error?.message || 'Unknown error'}`);
|
|
|
|
})
|
2020-10-02 15:10:00 +00:00
|
|
|
// Set from the login tests to stub and un-stub functions during execution.
|
|
|
|
window.loginTestSandbox = null;
|
|
|
|
|
|
|
|
// These modules are exposed for the sake of browser tests.
|
|
|
|
window.exposeModulesForTests = function() {
|
|
|
|
return (import('./exposeModulesForTests' /* webpackChunkName: "modulesForTests" */));
|
|
|
|
};
|
(core) Improve API Console and link from Document Settings.
Summary:
Changes to building and serving:
- Remove unpkg dependencies, add npm module for swagger-ui-dist instead.
- Move apiconsole JS logic into core/app/client/apiconsole.ts, and use TypeScript.
- Add symlinks to swagger in static/ and core/static/.
- Refactor loadScript, and add loadCssFile; use these to load swagger-ui resources.
Changes to console itself:
- Support docId, workspaceId, orgId URL parameters. When present, the matching
value in dropdowns is moved to the front and marked as "(Current)".
- Fix the ordering of example values, particularly for workspaces.
- Remove unwanted example values.
- Hide confusing "Authorize" button.
- Hide API keys, and rely consistently on cookies for executing API calls.
Integration into Grist:
- Added a button to Document Settings, just under document ID in "API".
- The button opens a separate page, passing in org, workspace, and doc info for the current doc.
Test Plan: Only tested manually, no automated tests yet.
Reviewers: jarek
Reviewed By: jarek
Differential Revision: https://phab.getgrist.com/D4173
2024-01-27 04:21:34 +00:00
|
|
|
window.exposedModules = {};
|
|
|
|
// Make it easy for tests to use loadScript() whether or not exposedModules has already loaded.
|
|
|
|
window.loadScript = (name) =>
|
|
|
|
window.exposeModulesForTests().then(() => window.exposedModules.loadScript.loadScript(name));
|
2020-10-02 15:10:00 +00:00
|
|
|
});
|