@splunk/react-page 6.0.4 → 6.1.0
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 +7 -0
- package/cypress/plugins/index.js +11 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/index.js +20 -0
- package/cypress.json +10 -0
- package/lib/index.js +30 -21
- package/package.json +5 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
Change Log
|
|
2
2
|
============
|
|
3
3
|
|
|
4
|
+
6.1.0 - May 2, 2023
|
|
5
|
+
New Features:
|
|
6
|
+
* a new `options.loader` parameter has been added to `layout` to allow `requirejs` to be used instead of `scriptjs` (SUI-5341).
|
|
7
|
+
|
|
8
|
+
Bug Fixes:
|
|
9
|
+
* `layout` will no longer automatically fall back to `requirejs` if `scriptjs` fails to load, reversing the behavior introduced in 6.0.4 (SUI-5341).
|
|
10
|
+
|
|
4
11
|
6.0.4 - April 6, 2023
|
|
5
12
|
----------
|
|
6
13
|
* `layout` will now fall back to `requirejs` if `scriptjs` fails to load (SUI-5341).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ***********************************************
|
|
2
|
+
// This example commands.js shows you how to
|
|
3
|
+
// create various custom commands and overwrite
|
|
4
|
+
// existing commands.
|
|
5
|
+
//
|
|
6
|
+
// For more comprehensive examples of custom
|
|
7
|
+
// commands please read more here:
|
|
8
|
+
// https://on.cypress.io/custom-commands
|
|
9
|
+
// ***********************************************
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
// -- This is a parent command --
|
|
13
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// -- This is a child command --
|
|
17
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// -- This is a dual command --
|
|
21
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
// -- This will overwrite an existing command --
|
|
25
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/index.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands';
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
package/cypress.json
ADDED
package/lib/index.js
CHANGED
|
@@ -324,30 +324,33 @@ var DARK_LAYOUT = 'build/api/layout-dark.js';
|
|
|
324
324
|
* Loads the layout from the server, using requirejs if available on the window and scriptjs if not.
|
|
325
325
|
*
|
|
326
326
|
* @param {Function} callback - A callback invoked with the layout module once resolved.
|
|
327
|
+
* @param {object} [options]
|
|
328
|
+
* @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
|
|
327
329
|
* @private
|
|
328
330
|
*/
|
|
329
331
|
|
|
330
332
|
function getLayoutApi(theme, callback) {
|
|
333
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
334
|
+
_ref$loader = _ref.loader,
|
|
335
|
+
loader = _ref$loader === void 0 ? 'scriptjs' : _ref$loader;
|
|
336
|
+
|
|
331
337
|
var themedLayout = theme === 'dark' ? DARK_LAYOUT : LIGHT_LAYOUT;
|
|
332
338
|
var url = Object(url_["createStaticURL"])(themedLayout);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
339
|
+
|
|
340
|
+
if (loader === 'scriptjs') {
|
|
341
|
+
external_scriptjs_default()(url, function () {
|
|
336
342
|
// eslint-disable-next-line no-underscore-dangle
|
|
337
343
|
callback(window.__splunk_layout__);
|
|
344
|
+
});
|
|
345
|
+
} else if (loader === 'requirejs') {
|
|
346
|
+
if (window.requirejs) {
|
|
347
|
+
window.requirejs([url], callback);
|
|
338
348
|
} else {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (window.requirejs) {
|
|
342
|
-
window.requirejs([url], callback);
|
|
343
|
-
} else {
|
|
344
|
-
if (false) {} // callback with no arguments will trigger the error flow
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
callback();
|
|
348
|
-
}
|
|
349
|
+
throw new Error('Error in react-page: options.loader = "requirejs" was set but window.requirejs does not exist.');
|
|
349
350
|
}
|
|
350
|
-
}
|
|
351
|
+
} else {
|
|
352
|
+
throw new Error('Invalid options.loader configuration: must be "scriptjs" or "requirejs".');
|
|
353
|
+
}
|
|
351
354
|
}
|
|
352
355
|
/**
|
|
353
356
|
* Renders a React element into the Layout API.
|
|
@@ -366,18 +369,22 @@ function getLayoutApi(theme, callback) {
|
|
|
366
369
|
* to the edge of the page.
|
|
367
370
|
* @param {Boolean} [options.useGlobalLayerStack = true] - Wraps elements in @splunk/react-ui's LayerStackGlobalProvider.
|
|
368
371
|
* @param {String} [options.theme = 'light'] - Used to theme UI elements. Ex. "light" or "dark".
|
|
372
|
+
* @param {String} [options.loader = 'scriptjs'] - Configures the loader used for the loading the layout - available loaders are "scriptjs" and "requirejs".
|
|
373
|
+
* Change this only if the default loader does not work for your application.
|
|
369
374
|
*/
|
|
370
375
|
|
|
371
376
|
|
|
372
377
|
function layout(element) {
|
|
373
|
-
var
|
|
378
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
374
379
|
|
|
375
|
-
var
|
|
376
|
-
useGlobalLayerStack =
|
|
377
|
-
pageTitle =
|
|
378
|
-
|
|
379
|
-
theme =
|
|
380
|
-
|
|
380
|
+
var _ref2$useGlobalLayerS = _ref2.useGlobalLayerStack,
|
|
381
|
+
useGlobalLayerStack = _ref2$useGlobalLayerS === void 0 ? true : _ref2$useGlobalLayerS,
|
|
382
|
+
pageTitle = _ref2.pageTitle,
|
|
383
|
+
_ref2$theme = _ref2.theme,
|
|
384
|
+
theme = _ref2$theme === void 0 ? 'light' : _ref2$theme,
|
|
385
|
+
_ref2$loader = _ref2.loader,
|
|
386
|
+
loader = _ref2$loader === void 0 ? 'scriptjs' : _ref2$loader,
|
|
387
|
+
layoutAPIOptions = _objectWithoutProperties(_ref2, ["useGlobalLayerStack", "pageTitle", "theme", "loader"]);
|
|
381
388
|
|
|
382
389
|
if (pageTitle) {
|
|
383
390
|
document.title = pageTitle;
|
|
@@ -432,6 +439,8 @@ function layout(element) {
|
|
|
432
439
|
var wrappedElement = useGlobalLayerStack ? /*#__PURE__*/external_react_default.a.createElement(Layer_["LayerStackGlobalProvider"], null, /*#__PURE__*/external_react_default.a.createElement(SplunkThemeProvider_default.a, splunkTheme, element)) : /*#__PURE__*/external_react_default.a.createElement(SplunkThemeProvider_default.a, splunkTheme, element);
|
|
433
440
|
Object(external_react_dom_["render"])(wrappedElement, containerEl);
|
|
434
441
|
}, 30);
|
|
442
|
+
}, {
|
|
443
|
+
loader: loader
|
|
435
444
|
});
|
|
436
445
|
}
|
|
437
446
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splunk/react-page",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Load React components into the latest layout from Splunk Enterprise",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,18 +18,14 @@
|
|
|
18
18
|
"lint:ci": "yarn run eslint:ci && yarn run stylelint",
|
|
19
19
|
"start": "cross-env NODE_ENV=development webpack --watch",
|
|
20
20
|
"stylelint": "stylelint \"src/**/*.{js,jsx}\" --config stylelint.config.js",
|
|
21
|
-
"test:
|
|
22
|
-
"test:
|
|
23
|
-
"test:functional:ci": "yarn run test:functional:prepare && splunk-wdio-functional-test-runner functional.ci.conf.js",
|
|
24
|
-
"test:functional:cloud": "yarn run test:functional:prepare && splunk-wdio-functional-test-runner functional.cloud.conf.js",
|
|
25
|
-
"test:cypress": "echo TODO: SUI-3442",
|
|
26
|
-
"test:cypress:ci": "echo TODO: SUI-3442"
|
|
21
|
+
"test:cypress": "node src/tests/run-cypress-tests.js 8.0.3",
|
|
22
|
+
"test:cypress:ci": "node src/tests/run-cypress-tests.js"
|
|
27
23
|
},
|
|
28
24
|
"dependencies": {
|
|
29
25
|
"@splunk/react-ui": "^4.16.3",
|
|
30
|
-
"@splunk/splunk-utils": "^2.3.
|
|
26
|
+
"@splunk/splunk-utils": "^2.3.4",
|
|
31
27
|
"@splunk/themes": "^0.16.0",
|
|
32
|
-
"@splunk/ui-utils": "^1.
|
|
28
|
+
"@splunk/ui-utils": "^1.6.0",
|
|
33
29
|
"prop-types": "^15.6.2",
|
|
34
30
|
"scriptjs": "^2.5.8"
|
|
35
31
|
},
|
|
@@ -39,7 +35,6 @@
|
|
|
39
35
|
"@splunk/cicd-tools": "^0.5.0",
|
|
40
36
|
"@splunk/eslint-config": "^4.0.0",
|
|
41
37
|
"@splunk/stylelint-config": "^4.0.0",
|
|
42
|
-
"@splunk/wdio-functional-test-runner": "^10.1.0",
|
|
43
38
|
"@splunk/webpack-configs": "^6.0.0",
|
|
44
39
|
"babel-eslint": "^10.1.0",
|
|
45
40
|
"babel-loader": "^8.0.4",
|