mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
const Promise = require('bluebird');
|
||||
const G = require('./browserGlobals').get('document');
|
||||
|
||||
/**
|
||||
* Load dynamically an external JS script from the given URL. Returns a promise that is
|
||||
* resolved when the script is loaded.
|
||||
*/
|
||||
function loadScript(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let script = G.document.createElement("script");
|
||||
script.type = "text/javascript";
|
||||
script.onload = resolve;
|
||||
script.onerror = reject;
|
||||
script.src = url;
|
||||
G.document.getElementsByTagName("head")[0].appendChild(script);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = loadScript;
|
||||
23
app/client/lib/loadScript.ts
Normal file
23
app/client/lib/loadScript.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {dom} from 'grainjs';
|
||||
|
||||
/**
|
||||
* Load dynamically an external JS script from the given URL. Returns a promise that is
|
||||
* resolved when the script is loaded.
|
||||
*/
|
||||
export function loadScript(url: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const script = dom("script", {type: "text/javascript", src: url, crossorigin: "anonymous"});
|
||||
document.head.appendChild(Object.assign(script, {onload: resolve, onerror: reject}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load dynamically an external CSS file from the given URL. Returns a promise that is
|
||||
* resolved when the file is loaded.
|
||||
*/
|
||||
export function loadCssFile(url: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const link = dom("link", {rel: "stylesheet", href: url});
|
||||
document.head.appendChild(Object.assign(link, {onload: resolve, onerror: reject}));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user