@looker/extension-utils 0.1.20-alpha.1650 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/lib/APIErrorDisplay/APIErrorContent.js +0 -15
- package/lib/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDetails.js +0 -5
- package/lib/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDialog.js +0 -7
- package/lib/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDisplay.js +0 -7
- package/lib/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDocLink.js +0 -8
- package/lib/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/APIErrorDisplay/index.js +0 -5
- package/lib/APIErrorDisplay/index.js.map +1 -1
- package/lib/APIErrorDisplay/utils.js +1 -10
- package/lib/APIErrorDisplay/utils.js.map +1 -1
- package/lib/ExtMarkdown.js +0 -8
- package/lib/ExtMarkdown.js.map +1 -1
- package/lib/OAuthScene.js +0 -14
- package/lib/OAuthScene.js.map +1 -1
- package/lib/adaptorUtils.js +1 -17
- package/lib/adaptorUtils.js.map +1 -1
- package/lib/authUtils.js +5 -23
- package/lib/authUtils.js.map +1 -1
- package/lib/browserAdaptor.js +4 -26
- package/lib/browserAdaptor.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorContent.js +25 -20
- package/lib/esm/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js +21 -13
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js +18 -10
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js +15 -7
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js +15 -9
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/esm/APIErrorDisplay/index.js +39 -3
- package/lib/esm/APIErrorDisplay/index.js.map +1 -1
- package/lib/esm/APIErrorDisplay/utils.js +10 -7
- package/lib/esm/APIErrorDisplay/utils.js.map +1 -1
- package/lib/esm/ExtMarkdown.js +14 -8
- package/lib/esm/ExtMarkdown.js.map +1 -1
- package/lib/esm/OAuthScene.js +23 -20
- package/lib/esm/OAuthScene.js.map +1 -1
- package/lib/esm/adaptorUtils.js +22 -10
- package/lib/esm/adaptorUtils.js.map +1 -1
- package/lib/esm/authUtils.js +14 -22
- package/lib/esm/authUtils.js.map +1 -1
- package/lib/esm/browserAdaptor.js +15 -24
- package/lib/esm/browserAdaptor.js.map +1 -1
- package/lib/esm/extensionAdaptor.js +15 -26
- package/lib/esm/extensionAdaptor.js.map +1 -1
- package/lib/esm/index.js +82 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/extensionAdaptor.js +4 -28
- package/lib/extensionAdaptor.js.map +1 -1
- package/lib/index.js +0 -14
- package/lib/index.js.map +1 -1
- package/package.json +8 -9
package/lib/authUtils.js
CHANGED
|
@@ -4,51 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OAuthConfigProvider = void 0;
|
|
7
|
-
|
|
8
7
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
13
|
class OAuthConfigProvider extends _sdkRtl.ApiSettings {
|
|
17
14
|
constructor(settings, configKey) {
|
|
18
15
|
super(settings);
|
|
19
16
|
this.configKey = configKey;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
getStorage(key) {
|
|
23
19
|
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
24
20
|
var value = sessionStorage.getItem(key);
|
|
25
|
-
|
|
26
21
|
if (value) {
|
|
27
22
|
return {
|
|
28
23
|
location: 'session',
|
|
29
24
|
value
|
|
30
25
|
};
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
value = localStorage.getItem(key);
|
|
34
|
-
|
|
35
28
|
if (value) {
|
|
36
29
|
return {
|
|
37
30
|
location: 'local',
|
|
38
31
|
value
|
|
39
32
|
};
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
return {
|
|
43
35
|
location: 'session',
|
|
44
36
|
value: defaultValue
|
|
45
37
|
};
|
|
46
38
|
}
|
|
47
|
-
|
|
48
39
|
isConfigured() {
|
|
49
40
|
return true;
|
|
50
41
|
}
|
|
51
|
-
|
|
52
42
|
getStoredConfig() {
|
|
53
43
|
var storage = this.getStorage(this.configKey);
|
|
54
44
|
var config = {
|
|
@@ -57,22 +47,17 @@ class OAuthConfigProvider extends _sdkRtl.ApiSettings {
|
|
|
57
47
|
client_id: '',
|
|
58
48
|
redirect_uri: ''
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
if (storage.value) {
|
|
62
51
|
config = JSON.parse(storage.value);
|
|
63
52
|
}
|
|
64
|
-
|
|
65
53
|
return config;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
authIsConfigured() {
|
|
69
56
|
var config = this.getStoredConfig();
|
|
70
57
|
return config.base_url !== '' && config.looker_url !== '';
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
readConfig(_section) {
|
|
74
60
|
var config = this.getStoredConfig();
|
|
75
|
-
|
|
76
61
|
if (!this.authIsConfigured()) {
|
|
77
62
|
var url = new URL(this.base_url);
|
|
78
63
|
var authServer = "".concat(url.protocol, "//").concat(url.hostname);
|
|
@@ -83,7 +68,6 @@ class OAuthConfigProvider extends _sdkRtl.ApiSettings {
|
|
|
83
68
|
redirect_uri: "".concat(window.location.origin, "/oauth")
|
|
84
69
|
};
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
var {
|
|
88
72
|
base_url,
|
|
89
73
|
looker_url,
|
|
@@ -98,8 +82,6 @@ class OAuthConfigProvider extends _sdkRtl.ApiSettings {
|
|
|
98
82
|
redirect_uri
|
|
99
83
|
});
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
}
|
|
103
|
-
|
|
104
86
|
exports.OAuthConfigProvider = OAuthConfigProvider;
|
|
105
87
|
//# sourceMappingURL=authUtils.js.map
|
package/lib/authUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"authUtils.js","names":["OAuthConfigProvider","ApiSettings","constructor","settings","configKey","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","client_id","redirect_uri","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","protocol","hostname","window","origin"],"sources":["../src/authUtils.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n constructor(\n settings: Partial<IApiSettings>,\n private readonly configKey: string\n ) {\n super(settings)\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = {\n base_url: '',\n looker_url: '',\n client_id: '',\n redirect_uri: '',\n }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n client_id: 'looker.api-explorer',\n redirect_uri: `${window.location.origin}/oauth`,\n }\n }\n\n const { base_url, looker_url, client_id, redirect_uri } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id,\n redirect_uri,\n },\n }\n }\n}\n"],"mappings":";;;;;;AA0BA;AAA6C;AAAA;AAAA;AAAA;AAAA;AAetC,MAAMA,mBAAmB,SAASC,mBAAW,CAAC;EACnDC,WAAW,CACTC,QAA+B,EACdC,SAAiB,EAClC;IACA,KAAK,CAACD,QAAQ,CAAC;IAAA,KAFEC,SAAiB,GAAjBA,SAAiB;EAGpC;EAEQC,UAAU,CAACC,GAAW,EAAoC;IAAA,IAAlCC,YAAY,uEAAG,EAAE;IAC/C,IAAIC,KAAK,GAAGC,cAAc,CAACC,OAAO,CAACJ,GAAG,CAAC;IACvC,IAAIE,KAAK,EAAE;MACT,OAAO;QACLG,QAAQ,EAAE,SAAS;QACnBH;MACF,CAAC;IACH;IACAA,KAAK,GAAGI,YAAY,CAACF,OAAO,CAACJ,GAAG,CAAC;IACjC,IAAIE,KAAK,EAAE;MACT,OAAO;QACLG,QAAQ,EAAE,OAAO;QACjBH;MACF,CAAC;IACH;IACA,OAAO;MACLG,QAAQ,EAAE,SAAS;MACnBH,KAAK,EAAED;IACT,CAAC;EACH;EAEAM,YAAY,GAAY;IAEtB,OAAO,IAAI;EACb;EAEAC,eAAe,GAAG;IAChB,IAAMC,OAAO,GAAG,IAAI,CAACV,UAAU,CAAC,IAAI,CAACD,SAAS,CAAC;IAC/C,IAAIY,MAAM,GAAG;MACXC,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,EAAE;MACdC,SAAS,EAAE,EAAE;MACbC,YAAY,EAAE;IAChB,CAAC;IACD,IAAIL,OAAO,CAACP,KAAK,EAAE;MACjBQ,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACP,OAAO,CAACP,KAAK,CAAC;IACpC;IACA,OAAOQ,MAAM;EACf;EAEAO,gBAAgB,GAAY;IAC1B,IAAMP,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;IACrC,OAAOE,MAAM,CAACC,QAAQ,KAAK,EAAE,IAAID,MAAM,CAACE,UAAU,KAAK,EAAE;EAC3D;EAEAM,UAAU,CAACC,QAAiB,EAAe;IAEzC,IAAIT,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;IACnC,IAAI,CAAC,IAAI,CAACS,gBAAgB,EAAE,EAAE;MAE5B,IAAMG,GAAG,GAAG,IAAIC,GAAG,CAAC,IAAI,CAACV,QAAQ,CAAC;MAClC,IAAMW,UAAU,aAAMF,GAAG,CAACG,QAAQ,eAAKH,GAAG,CAACI,QAAQ,CAAE;MACrDd,MAAM,GAAG;QACPC,QAAQ,EAAE,IAAI,CAACA,QAAQ;QACvBC,UAAU,YAAKU,UAAU,UAAO;QAChCT,SAAS,EAAE,qBAAqB;QAChCC,YAAY,YAAKW,MAAM,CAACpB,QAAQ,CAACqB,MAAM;MACzC,CAAC;IACH;IAEA,IAAM;MAAEf,QAAQ;MAAEC,UAAU;MAAEC,SAAS;MAAEC;IAAa,CAAC,GAAGJ,MAAM;IAEhE,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,uCACK,KAAK,CAACO,UAAU,CAACC,QAAQ,CAAC,GAC1B;MACDR,QAAQ;MACRC,UAAU;MACVC,SAAS;MACTC;IACF,CAAC;EAEL;AACF;AAAC"}
|
package/lib/browserAdaptor.js
CHANGED
|
@@ -3,91 +3,69 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.BrowserAuthAdaptor = exports.BrowserAdaptor = void 0;
|
|
8
7
|
var _adaptorUtils = require("./adaptorUtils");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
-
|
|
14
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
15
|
-
|
|
16
13
|
class BrowserAuthAdaptor {
|
|
17
14
|
constructor(sdk) {
|
|
18
15
|
this.sdk = sdk;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
login() {
|
|
22
18
|
var _this = this;
|
|
23
|
-
|
|
24
19
|
return _asyncToGenerator(function* () {
|
|
25
20
|
var token;
|
|
26
21
|
var settings = _this.sdk.authSession.settings;
|
|
27
|
-
|
|
28
22
|
if (settings.authIsConfigured()) {
|
|
29
23
|
token = yield _this.sdk.authSession.login();
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
return !!token;
|
|
33
26
|
})();
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
exports.BrowserAuthAdaptor = BrowserAuthAdaptor;
|
|
39
|
-
|
|
40
30
|
class BrowserAdaptor extends BrowserAuthAdaptor {
|
|
41
31
|
constructor(sdk) {
|
|
42
32
|
super(sdk);
|
|
43
|
-
|
|
44
33
|
_defineProperty(this, "_themeOverrides", void 0);
|
|
45
|
-
|
|
46
34
|
var {
|
|
47
35
|
hostname
|
|
48
36
|
} = location;
|
|
49
37
|
this._themeOverrides = (0, _adaptorUtils.getThemeOverrides)((0, _adaptorUtils.hostedInternally)(hostname));
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
copyToClipboard() {
|
|
53
40
|
return _asyncToGenerator(function* () {
|
|
54
41
|
yield navigator.clipboard.writeText(location.href);
|
|
55
42
|
})();
|
|
56
43
|
}
|
|
57
|
-
|
|
58
44
|
isExtension() {
|
|
59
45
|
return false;
|
|
60
46
|
}
|
|
61
|
-
|
|
62
47
|
localStorageGetItem(key) {
|
|
63
48
|
return _asyncToGenerator(function* () {
|
|
64
49
|
return localStorage.getItem(key);
|
|
65
50
|
})();
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
localStorageSetItem(key, value) {
|
|
69
53
|
return _asyncToGenerator(function* () {
|
|
70
54
|
yield localStorage.setItem(key, value);
|
|
71
55
|
})();
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
localStorageRemoveItem(key) {
|
|
75
58
|
return _asyncToGenerator(function* () {
|
|
76
59
|
yield localStorage.removeItem(key);
|
|
77
60
|
})();
|
|
78
61
|
}
|
|
79
|
-
|
|
80
62
|
themeOverrides() {
|
|
81
63
|
return this._themeOverrides;
|
|
82
64
|
}
|
|
83
|
-
|
|
84
65
|
openBrowserWindow(url, target) {
|
|
85
66
|
window.open(url, target);
|
|
86
67
|
}
|
|
87
|
-
|
|
88
68
|
logError(_error, _componentStack) {}
|
|
89
|
-
|
|
90
69
|
}
|
|
91
|
-
|
|
92
70
|
exports.BrowserAdaptor = BrowserAdaptor;
|
|
93
71
|
//# sourceMappingURL=browserAdaptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"browserAdaptor.js","names":["BrowserAuthAdaptor","constructor","sdk","login","token","settings","authSession","authIsConfigured","BrowserAdaptor","hostname","location","_themeOverrides","getThemeOverrides","hostedInternally","copyToClipboard","navigator","clipboard","writeText","href","isExtension","localStorageGetItem","key","localStorage","getItem","localStorageSetItem","value","setItem","localStorageRemoveItem","removeItem","themeOverrides","openBrowserWindow","url","target","window","open","logError","_error","_componentStack"],"sources":["../src/browserAdaptor.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IAuthAdaptor,\n IEnvironmentAdaptor,\n ThemeOverrides,\n} from './adaptorUtils'\nimport { getThemeOverrides, hostedInternally } from './adaptorUtils'\nimport type { OAuthConfigProvider } from './authUtils'\n\nexport class BrowserAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n let token\n const settings = this.sdk.authSession.settings as OAuthConfigProvider\n if (settings.authIsConfigured()) {\n token = await this.sdk.authSession.login()\n }\n return !!token\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when not running in an extension\n */\nexport class BrowserAdaptor\n extends BrowserAuthAdaptor\n implements IEnvironmentAdaptor\n{\n private _themeOverrides: ThemeOverrides\n\n constructor(sdk: IAPIMethods) {\n super(sdk)\n const { hostname } = location\n this._themeOverrides = getThemeOverrides(hostedInternally(hostname))\n }\n\n async copyToClipboard() {\n await navigator.clipboard.writeText(location.href)\n }\n\n isExtension() {\n return false\n }\n\n async localStorageGetItem(key: string) {\n return localStorage.getItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await localStorage.setItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await localStorage.removeItem(key)\n }\n\n themeOverrides() {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n window.open(url, target)\n }\n\n logError(_error: Error, _componentStack: string): void {\n // noop - error logging for standalone applications TBD\n }\n}\n"],"mappings":";;;;;;AAgCA;AAAoE;AAAA;AAAA;AAAA;AAAA;AAG7D,MAAMA,kBAAkB,CAAyB;EACtDC,WAAW,CAAiBC,GAAgB,EAAE;IAAA,KAAlBA,GAAgB,GAAhBA,GAAgB;EAAG;EAEzCC,KAAK,GAAG;IAAA;IAAA;MACZ,IAAIC,KAAK;MACT,IAAMC,QAAQ,GAAG,KAAI,CAACH,GAAG,CAACI,WAAW,CAACD,QAA+B;MACrE,IAAIA,QAAQ,CAACE,gBAAgB,EAAE,EAAE;QAC/BH,KAAK,SAAS,KAAI,CAACF,GAAG,CAACI,WAAW,CAACH,KAAK,EAAE;MAC5C;MACA,OAAO,CAAC,CAACC,KAAK;IAAA;EAChB;AACF;AAAC;AAKM,MAAMI,cAAc,SACjBR,kBAAkB,CAE5B;EAGEC,WAAW,CAACC,GAAgB,EAAE;IAC5B,KAAK,CAACA,GAAG,CAAC;IAAA;IACV,IAAM;MAAEO;IAAS,CAAC,GAAGC,QAAQ;IAC7B,IAAI,CAACC,eAAe,GAAG,IAAAC,+BAAiB,EAAC,IAAAC,8BAAgB,EAACJ,QAAQ,CAAC,CAAC;EACtE;EAEMK,eAAe,GAAG;IAAA;MACtB,MAAMC,SAAS,CAACC,SAAS,CAACC,SAAS,CAACP,QAAQ,CAACQ,IAAI,CAAC;IAAA;EACpD;EAEAC,WAAW,GAAG;IACZ,OAAO,KAAK;EACd;EAEMC,mBAAmB,CAACC,GAAW,EAAE;IAAA;MACrC,OAAOC,YAAY,CAACC,OAAO,CAACF,GAAG,CAAC;IAAA;EAClC;EAEMG,mBAAmB,CAACH,GAAW,EAAEI,KAAa,EAAE;IAAA;MACpD,MAAMH,YAAY,CAACI,OAAO,CAACL,GAAG,EAAEI,KAAK,CAAC;IAAA;EACxC;EAEME,sBAAsB,CAACN,GAAW,EAAE;IAAA;MACxC,MAAMC,YAAY,CAACM,UAAU,CAACP,GAAG,CAAC;IAAA;EACpC;EAEAQ,cAAc,GAAG;IACf,OAAO,IAAI,CAAClB,eAAe;EAC7B;EAEAmB,iBAAiB,CAACC,GAAW,EAAEC,MAAe,EAAE;IAC9CC,MAAM,CAACC,IAAI,CAACH,GAAG,EAAEC,MAAM,CAAC;EAC1B;EAEAG,QAAQ,CAACC,MAAa,EAAEC,eAAuB,EAAQ,CAEvD;AACF;AAAC"}
|
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APIErrorContent = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _sdkRtl = require("@looker/sdk-rtl");
|
|
9
|
+
var _adaptorUtils = require("../adaptorUtils");
|
|
10
|
+
var _ExtMarkdown = require("../ExtMarkdown");
|
|
11
|
+
var _APIErrorDetails = require("./APIErrorDetails");
|
|
12
|
+
var _APIErrorDocLink = require("./APIErrorDocLink");
|
|
13
|
+
var _utils = require("./utils");
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
3
17
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
|
-
import { ErrorDoc } from '@looker/sdk-rtl';
|
|
7
|
-
import { getEnvAdaptor } from '../adaptorUtils';
|
|
8
|
-
import { ExtMarkdown } from '../ExtMarkdown';
|
|
9
|
-
import { APIErrorDetails } from './APIErrorDetails';
|
|
10
|
-
import { APIErrorDocLink } from './APIErrorDocLink';
|
|
11
|
-
import { apiErrorDisplayFetch } from './utils';
|
|
12
|
-
export var APIErrorContent = _ref => {
|
|
18
|
+
var APIErrorContent = _ref => {
|
|
13
19
|
var _error$documentation_;
|
|
14
|
-
|
|
15
20
|
var {
|
|
16
21
|
error,
|
|
17
22
|
showDoc
|
|
18
23
|
} = _ref;
|
|
19
|
-
var [doc, setDoc] = useState('');
|
|
20
|
-
var getDoc = useCallback(function () {
|
|
24
|
+
var [doc, setDoc] = (0, _react.useState)('');
|
|
25
|
+
var getDoc = (0, _react.useCallback)(function () {
|
|
21
26
|
var _ref2 = _asyncToGenerator(function* (docUrl) {
|
|
22
|
-
var adaptor = getEnvAdaptor();
|
|
23
|
-
var errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch);
|
|
27
|
+
var adaptor = (0, _adaptorUtils.getEnvAdaptor)();
|
|
28
|
+
var errDoc = new _sdkRtl.ErrorDoc(adaptor.sdk, _utils.apiErrorDisplayFetch);
|
|
24
29
|
setDoc(yield errDoc.content(docUrl));
|
|
25
30
|
});
|
|
26
|
-
|
|
27
31
|
return function (_x) {
|
|
28
32
|
return _ref2.apply(this, arguments);
|
|
29
33
|
};
|
|
30
34
|
}(), [error]);
|
|
31
|
-
useEffect(() => {
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
32
36
|
if (showDoc && error && error.documentation_url) {
|
|
33
37
|
getDoc(error.documentation_url);
|
|
34
38
|
}
|
|
35
39
|
}, [error, showDoc]);
|
|
36
|
-
return
|
|
40
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_APIErrorDetails.APIErrorDetails, {
|
|
37
41
|
error: error
|
|
38
|
-
}), !showDoc &&
|
|
42
|
+
}), !showDoc && _react.default.createElement(_APIErrorDocLink.APIErrorDocLink, {
|
|
39
43
|
docUrl: (_error$documentation_ = error.documentation_url) !== null && _error$documentation_ !== void 0 ? _error$documentation_ : ''
|
|
40
|
-
}), showDoc && doc &&
|
|
44
|
+
}), showDoc && doc && _react.default.createElement(_ExtMarkdown.ExtMarkdown, {
|
|
41
45
|
source: doc
|
|
42
46
|
}));
|
|
43
47
|
};
|
|
48
|
+
exports.APIErrorContent = APIErrorContent;
|
|
44
49
|
//# sourceMappingURL=APIErrorContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"APIErrorContent.js","names":["APIErrorContent","error","showDoc","doc","setDoc","useState","getDoc","useCallback","docUrl","adaptor","getEnvAdaptor","errDoc","ErrorDoc","sdk","apiErrorDisplayFetch","content","useEffect","documentation_url"],"sources":["../../../src/APIErrorDisplay/APIErrorContent.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { ErrorDoc } from '@looker/sdk-rtl'\nimport { getEnvAdaptor } from '../adaptorUtils'\nimport { ExtMarkdown } from '../ExtMarkdown'\nimport { APIErrorDetails } from './APIErrorDetails'\nimport { APIErrorDocLink } from './APIErrorDocLink'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { apiErrorDisplayFetch } from './utils'\n\n/**\n * Shows available content of an API Error response\n * @param error to display\n * @param showDoc true to retrieve the corresponding error markdown\n */\nexport const APIErrorContent = ({ error, showDoc }: APIErrorDisplayProps) => {\n const [doc, setDoc] = useState<string>('')\n const getDoc = useCallback(\n async (docUrl: string) => {\n const adaptor = getEnvAdaptor()\n const errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch)\n setDoc(await errDoc.content(docUrl))\n },\n [error]\n )\n\n useEffect(() => {\n if (showDoc && error && error.documentation_url) {\n getDoc(error.documentation_url)\n }\n }, [error, showDoc])\n\n return (\n <>\n <APIErrorDetails error={error} />\n {!showDoc && <APIErrorDocLink docUrl={error.documentation_url ?? ''} />}\n {showDoc && doc && <ExtMarkdown source={doc} />}\n </>\n )\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AACA;AACA;AACA;AAEA;AAA8C;AAAA;AAAA;AAAA;AAOvC,IAAMA,eAAe,GAAG,QAA8C;EAAA;EAAA,IAA7C;IAAEC,KAAK;IAAEC;EAA8B,CAAC;EACtE,IAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAG,IAAAC,eAAQ,EAAS,EAAE,CAAC;EAC1C,IAAMC,MAAM,GAAG,IAAAC,kBAAW;IAAA,8BACxB,WAAOC,MAAc,EAAK;MACxB,IAAMC,OAAO,GAAG,IAAAC,2BAAa,GAAE;MAC/B,IAAMC,MAAM,GAAG,IAAIC,gBAAQ,CAACH,OAAO,CAACI,GAAG,EAAEC,2BAAoB,CAAC;MAC9DV,MAAM,OAAOO,MAAM,CAACI,OAAO,CAACP,MAAM,CAAC,CAAC;IACtC,CAAC;IAAA;MAAA;IAAA;EAAA,KACD,CAACP,KAAK,CAAC,CACR;EAED,IAAAe,gBAAS,EAAC,MAAM;IACd,IAAId,OAAO,IAAID,KAAK,IAAIA,KAAK,CAACgB,iBAAiB,EAAE;MAC/CX,MAAM,CAACL,KAAK,CAACgB,iBAAiB,CAAC;IACjC;EACF,CAAC,EAAE,CAAChB,KAAK,EAAEC,OAAO,CAAC,CAAC;EAEpB,OACE,4DACE,6BAAC,gCAAe;IAAC,KAAK,EAAED;EAAM,EAAG,EAChC,CAACC,OAAO,IAAI,6BAAC,gCAAe;IAAC,MAAM,2BAAED,KAAK,CAACgB,iBAAiB,yEAAI;EAAG,EAAG,EACtEf,OAAO,IAAIC,GAAG,IAAI,6BAAC,wBAAW;IAAC,MAAM,EAAEA;EAAI,EAAG,CAC9C;AAEP,CAAC;AAAA"}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APIErrorDetails = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _components = require("@looker/components");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var APIErrorDetails = _ref => {
|
|
4
11
|
var {
|
|
5
12
|
error
|
|
6
13
|
} = _ref;
|
|
7
|
-
if (!(error !== null && error !== void 0 && error.errors)) return
|
|
8
|
-
return
|
|
14
|
+
if (!(error !== null && error !== void 0 && error.errors)) return _react.default.createElement(_react.default.Fragment, null);
|
|
15
|
+
return _react.default.createElement(_components.Table, null, _react.default.createElement(_components.TableHead, null, _react.default.createElement(_components.TableRow, null, _react.default.createElement(_components.TableHeaderCell, {
|
|
9
16
|
p: "xsmall"
|
|
10
|
-
}, "Field"),
|
|
17
|
+
}, "Field"), _react.default.createElement(_components.TableHeaderCell, {
|
|
11
18
|
p: "xsmall"
|
|
12
|
-
}, "Code"),
|
|
19
|
+
}, "Code"), _react.default.createElement(_components.TableHeaderCell, {
|
|
13
20
|
p: "xsmall"
|
|
14
|
-
}, "Message"))),
|
|
21
|
+
}, "Message"))), _react.default.createElement(_components.TableBody, null, error.errors.map((_ref2, index) => {
|
|
15
22
|
var {
|
|
16
23
|
field,
|
|
17
24
|
code,
|
|
18
25
|
message
|
|
19
26
|
} = _ref2;
|
|
20
|
-
return
|
|
27
|
+
return _react.default.createElement(_components.TableRow, {
|
|
21
28
|
key: "".concat(field).concat(index)
|
|
22
|
-
},
|
|
29
|
+
}, _react.default.createElement(_components.TableDataCell, {
|
|
23
30
|
p: "xsmall"
|
|
24
|
-
}, field),
|
|
31
|
+
}, field), _react.default.createElement(_components.TableDataCell, {
|
|
25
32
|
p: "xsmall"
|
|
26
|
-
}, code),
|
|
33
|
+
}, code), _react.default.createElement(_components.TableDataCell, {
|
|
27
34
|
p: "xsmall"
|
|
28
|
-
},
|
|
35
|
+
}, _react.default.createElement(_components.Span, null, message)));
|
|
29
36
|
})));
|
|
30
37
|
};
|
|
38
|
+
exports.APIErrorDetails = APIErrorDetails;
|
|
31
39
|
//# sourceMappingURL=APIErrorDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"APIErrorDetails.js","names":["APIErrorDetails","error","errors","map","index","field","code","message"],"sources":["../../../src/APIErrorDisplay/APIErrorDetails.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { LookerSDKError } from '@looker/sdk-rtl'\nimport React from 'react'\nimport {\n Span,\n Table,\n TableBody,\n TableDataCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from '@looker/components'\n\ninterface APIErrorDetailsProps {\n error: LookerSDKError\n}\n\n/**\n * Shows the detailed API errors table\n *\n * Because documentation_url is currently identical with the main documentation_url\n * it is not included in the table\n *\n * @param error to display\n */\nexport const APIErrorDetails = ({ error }: APIErrorDetailsProps) => {\n if (!error?.errors) return <></>\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableHeaderCell p=\"xsmall\">Field</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Code</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Message</TableHeaderCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {error.errors.map(({ field, code, message }, index) => (\n <TableRow key={`${field}${index}`}>\n <TableDataCell p=\"xsmall\">{field}</TableDataCell>\n <TableDataCell p=\"xsmall\">{code}</TableDataCell>\n <TableDataCell p=\"xsmall\">\n <Span>{message}</Span>\n </TableDataCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n )\n}\n"],"mappings":";;;;;;AA2BA;AACA;AAQ2B;AAcpB,IAAMA,eAAe,GAAG,QAAqC;EAAA,IAApC;IAAEC;EAA4B,CAAC;EAC7D,IAAI,EAACA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEC,MAAM,GAAE,OAAO,2DAAK;EAEhC,OACE,6BAAC,iBAAK,QACJ,6BAAC,qBAAS,QACR,6BAAC,oBAAQ,QACP,6BAAC,2BAAe;IAAC,CAAC,EAAC;EAAQ,GAAC,OAAK,CAAkB,EACnD,6BAAC,2BAAe;IAAC,CAAC,EAAC;EAAQ,GAAC,MAAI,CAAkB,EAClD,6BAAC,2BAAe;IAAC,CAAC,EAAC;EAAQ,GAAC,SAAO,CAAkB,CAC5C,CACD,EACZ,6BAAC,qBAAS,QACPD,KAAK,CAACC,MAAM,CAACC,GAAG,CAAC,QAA2BC,KAAK;IAAA,IAA/B;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAQ,CAAC;IAAA,OACzC,6BAAC,oBAAQ;MAAC,GAAG,YAAKF,KAAK,SAAGD,KAAK;IAAG,GAChC,6BAAC,yBAAa;MAAC,CAAC,EAAC;IAAQ,GAAEC,KAAK,CAAiB,EACjD,6BAAC,yBAAa;MAAC,CAAC,EAAC;IAAQ,GAAEC,IAAI,CAAiB,EAChD,6BAAC,yBAAa;MAAC,CAAC,EAAC;IAAQ,GACvB,6BAAC,gBAAI,QAAEC,OAAO,CAAQ,CACR,CACP;EAAA,CACZ,CAAC,CACQ,CACN;AAEZ,CAAC;AAAA"}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APIErrorDialog = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _components = require("@looker/components");
|
|
9
|
+
var _APIErrorContent = require("./APIErrorContent");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
var APIErrorDialog = _ref => {
|
|
6
13
|
var {
|
|
7
14
|
error,
|
|
8
15
|
isOpen,
|
|
9
16
|
setOpen,
|
|
10
17
|
showDoc = false
|
|
11
18
|
} = _ref;
|
|
12
|
-
return
|
|
19
|
+
return _react.default.createElement(_components.Dialog, {
|
|
13
20
|
isOpen: isOpen,
|
|
14
|
-
content:
|
|
15
|
-
header: errorHeading(error),
|
|
16
|
-
footer:
|
|
21
|
+
content: _react.default.createElement(_components.DialogLayout, {
|
|
22
|
+
header: (0, _utils.errorHeading)(error),
|
|
23
|
+
footer: _react.default.createElement(_components.Button, {
|
|
17
24
|
size: "xsmall",
|
|
18
25
|
onClick: () => setOpen && setOpen(false)
|
|
19
26
|
}, "OK")
|
|
20
|
-
},
|
|
27
|
+
}, _react.default.createElement(_APIErrorContent.APIErrorContent, {
|
|
21
28
|
error: error,
|
|
22
29
|
showDoc: showDoc
|
|
23
30
|
}))
|
|
24
31
|
});
|
|
25
32
|
};
|
|
33
|
+
exports.APIErrorDialog = APIErrorDialog;
|
|
26
34
|
//# sourceMappingURL=APIErrorDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"APIErrorDialog.js","names":["APIErrorDialog","error","isOpen","setOpen","showDoc","errorHeading"],"sources":["../../../src/APIErrorDisplay/APIErrorDialog.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport { Button, Dialog, DialogLayout } from '@looker/components'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\ninterface APIErrorDialogProps extends APIErrorDisplayProps {\n /** toggle for dialog being open */\n isOpen: boolean\n /** callback for toggling the dialog display */\n setOpen: (open: boolean) => void\n}\n\nexport const APIErrorDialog = ({\n error,\n isOpen,\n setOpen,\n showDoc = false,\n}: APIErrorDialogProps) => (\n <Dialog\n isOpen={isOpen}\n content={\n <DialogLayout\n header={errorHeading(error)}\n footer={\n <Button size=\"xsmall\" onClick={() => setOpen && setOpen(false)}>\n OK\n </Button>\n }\n >\n <APIErrorContent error={error} showDoc={showDoc} />\n </DialogLayout>\n }\n />\n)\n"],"mappings":";;;;;;AA0BA;AACA;AAEA;AACA;AAAsC;AAS/B,IAAMA,cAAc,GAAG;EAAA,IAAC;IAC7BC,KAAK;IACLC,MAAM;IACNC,OAAO;IACPC,OAAO,GAAG;EACS,CAAC;EAAA,OACpB,6BAAC,kBAAM;IACL,MAAM,EAAEF,MAAO;IACf,OAAO,EACL,6BAAC,wBAAY;MACX,MAAM,EAAE,IAAAG,mBAAY,EAACJ,KAAK,CAAE;MAC5B,MAAM,EACJ,6BAAC,kBAAM;QAAC,IAAI,EAAC,QAAQ;QAAC,OAAO,EAAE,MAAME,OAAO,IAAIA,OAAO,CAAC,KAAK;MAAE,GAAC,IAEhE;IACD,GAED,6BAAC,gCAAe;MAAC,KAAK,EAAEF,KAAM;MAAC,OAAO,EAAEG;IAAQ,EAAG;EAEtD,EACD;AAAA,CACH;AAAA"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APIErrorDisplay = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _components = require("@looker/components");
|
|
9
|
+
var _APIErrorContent = require("./APIErrorContent");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
var APIErrorDisplay = _ref => {
|
|
6
13
|
var {
|
|
7
14
|
error,
|
|
8
15
|
showDoc = false
|
|
9
16
|
} = _ref;
|
|
10
|
-
return
|
|
17
|
+
return _react.default.createElement(_react.default.Fragment, null, error && _react.default.createElement(_components.SpaceVertical, null, _react.default.createElement(_components.Heading, {
|
|
11
18
|
type: "h2"
|
|
12
|
-
}, errorHeading(error)),
|
|
19
|
+
}, (0, _utils.errorHeading)(error)), _react.default.createElement(_APIErrorContent.APIErrorContent, {
|
|
13
20
|
error: error,
|
|
14
21
|
showDoc: showDoc
|
|
15
22
|
})));
|
|
16
23
|
};
|
|
24
|
+
exports.APIErrorDisplay = APIErrorDisplay;
|
|
17
25
|
//# sourceMappingURL=APIErrorDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"APIErrorDisplay.js","names":["APIErrorDisplay","error","showDoc","errorHeading"],"sources":["../../../src/APIErrorDisplay/APIErrorDisplay.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport type { LookerSDKError } from '@looker/sdk-rtl'\nimport { Heading, SpaceVertical } from '@looker/components'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\nexport interface APIErrorDisplayProps {\n /** Populated SDK error information, which may contain detailed errors */\n error: LookerSDKError\n /** true to retrieve the markdown error document from the CDN and display it instead of a link */\n showDoc?: boolean\n}\n\n/**\n * Show API error information in the parent React component\n * @param error to display\n * @param showDoc true to fetch the error document markdown. false for a clickable link\n */\nexport const APIErrorDisplay = ({\n error,\n showDoc = false,\n}: APIErrorDisplayProps) => {\n return (\n <>\n {error && (\n <SpaceVertical>\n <Heading type=\"h2\">{errorHeading(error)}</Heading>\n <APIErrorContent error={error} showDoc={showDoc} />\n </SpaceVertical>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AA0BA;AAEA;AACA;AACA;AAAsC;AAc/B,IAAMA,eAAe,GAAG,QAGH;EAAA,IAHI;IAC9BC,KAAK;IACLC,OAAO,GAAG;EACU,CAAC;EACrB,OACE,4DACGD,KAAK,IACJ,6BAAC,yBAAa,QACZ,6BAAC,mBAAO;IAAC,IAAI,EAAC;EAAI,GAAE,IAAAE,mBAAY,EAACF,KAAK,CAAC,CAAW,EAClD,6BAAC,gCAAe;IAAC,KAAK,EAAEA,KAAM;IAAC,OAAO,EAAEC;EAAQ,EAAG,CAEtD,CACA;AAEP,CAAC;AAAA"}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APIErrorDocLink = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _components = require("@looker/components");
|
|
9
|
+
var _adaptorUtils = require("../adaptorUtils");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
var APIErrorDocLink = _ref => {
|
|
5
12
|
var {
|
|
6
13
|
docUrl
|
|
7
14
|
} = _ref;
|
|
8
|
-
|
|
9
15
|
var onClick = e => {
|
|
10
16
|
e.preventDefault();
|
|
11
|
-
var adaptor = getEnvAdaptor();
|
|
17
|
+
var adaptor = (0, _adaptorUtils.getEnvAdaptor)();
|
|
12
18
|
adaptor.openBrowserWindow(e.currentTarget.href);
|
|
13
19
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return React.createElement(Link, {
|
|
20
|
+
if (!docUrl) return _react.default.createElement(_react.default.Fragment, null);
|
|
21
|
+
return _react.default.createElement(_components.Link, {
|
|
17
22
|
href: docUrl,
|
|
18
23
|
key: docUrl,
|
|
19
24
|
onClick: onClick
|
|
20
25
|
}, "More information");
|
|
21
26
|
};
|
|
27
|
+
exports.APIErrorDocLink = APIErrorDocLink;
|
|
22
28
|
//# sourceMappingURL=APIErrorDocLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"APIErrorDocLink.js","names":["APIErrorDocLink","docUrl","onClick","e","preventDefault","adaptor","getEnvAdaptor","openBrowserWindow","currentTarget","href"],"sources":["../../../src/APIErrorDisplay/APIErrorDocLink.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport React from 'react'\nimport { Link } from '@looker/components'\nimport { getEnvAdaptor } from '../adaptorUtils'\n\ninterface APIErrorDocLinkProps {\n docUrl?: string\n}\n\nexport const APIErrorDocLink = ({ docUrl }: APIErrorDocLinkProps) => {\n const onClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault()\n const adaptor = getEnvAdaptor()\n adaptor.openBrowserWindow(e.currentTarget.href)\n }\n\n if (!docUrl) return <></>\n return (\n <Link href={docUrl} key={docUrl} onClick={onClick}>\n More information\n </Link>\n )\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAA+C;AAMxC,IAAMA,eAAe,GAAG,QAAsC;EAAA,IAArC;IAAEC;EAA6B,CAAC;EAC9D,IAAMC,OAAO,GAAIC,CAAsC,IAAK;IAC1DA,CAAC,CAACC,cAAc,EAAE;IAClB,IAAMC,OAAO,GAAG,IAAAC,2BAAa,GAAE;IAC/BD,OAAO,CAACE,iBAAiB,CAACJ,CAAC,CAACK,aAAa,CAACC,IAAI,CAAC;EACjD,CAAC;EAED,IAAI,CAACR,MAAM,EAAE,OAAO,2DAAK;EACzB,OACE,6BAAC,gBAAI;IAAC,IAAI,EAAEA,MAAO;IAAC,GAAG,EAAEA,MAAO;IAAC,OAAO,EAAEC;EAAQ,GAAC,kBAEnD,CAAO;AAEX,CAAC;AAAA"}
|