@splunk/react-page 6.0.3 → 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 CHANGED
@@ -1,6 +1,17 @@
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
+
11
+ 6.0.4 - April 6, 2023
12
+ ----------
13
+ * `layout` will now fall back to `requirejs` if `scriptjs` fails to load (SUI-5341).
14
+
4
15
  6.0.3 - December 6, 2022
5
16
  ----------
6
17
  * Optimizes bundle sizes of consumers by reducing footprint of "lodash" (SUI-5090).
@@ -0,0 +1,11 @@
1
+ /* eslint-env node */
2
+
3
+ module.exports = (on, config) => {
4
+ on('before:browser:launch', (browser = {}, launchOptions) => {
5
+ if (browser.name === 'chrome') {
6
+ launchOptions.args.push('--disable-gpu');
7
+ }
8
+ });
9
+
10
+ return config;
11
+ };
@@ -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
@@ -0,0 +1,10 @@
1
+ {
2
+ "baseUrl": "http://localhost:8000",
3
+ "env": {},
4
+ "defaultCommandTimeout": 1000,
5
+ "fixturesFolder": false,
6
+ "integrationFolder": "src/tests",
7
+ "testFiles": "**.spec.js",
8
+ "video": false,
9
+ "videoUploadOnPasses": false
10
+ }
package/lib/index.js CHANGED
@@ -324,16 +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
- external_scriptjs_default()(url, function () {
334
- // eslint-disable-next-line no-underscore-dangle
335
- callback(window.__splunk_layout__);
336
- });
339
+
340
+ if (loader === 'scriptjs') {
341
+ external_scriptjs_default()(url, function () {
342
+ // eslint-disable-next-line no-underscore-dangle
343
+ callback(window.__splunk_layout__);
344
+ });
345
+ } else if (loader === 'requirejs') {
346
+ if (window.requirejs) {
347
+ window.requirejs([url], callback);
348
+ } else {
349
+ throw new Error('Error in react-page: options.loader = "requirejs" was set but window.requirejs does not exist.');
350
+ }
351
+ } else {
352
+ throw new Error('Invalid options.loader configuration: must be "scriptjs" or "requirejs".');
353
+ }
337
354
  }
338
355
  /**
339
356
  * Renders a React element into the Layout API.
@@ -352,18 +369,22 @@ function getLayoutApi(theme, callback) {
352
369
  * to the edge of the page.
353
370
  * @param {Boolean} [options.useGlobalLayerStack = true] - Wraps elements in @splunk/react-ui's LayerStackGlobalProvider.
354
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.
355
374
  */
356
375
 
357
376
 
358
377
  function layout(element) {
359
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
378
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
360
379
 
361
- var _ref$useGlobalLayerSt = _ref.useGlobalLayerStack,
362
- useGlobalLayerStack = _ref$useGlobalLayerSt === void 0 ? true : _ref$useGlobalLayerSt,
363
- pageTitle = _ref.pageTitle,
364
- _ref$theme = _ref.theme,
365
- theme = _ref$theme === void 0 ? 'light' : _ref$theme,
366
- layoutAPIOptions = _objectWithoutProperties(_ref, ["useGlobalLayerStack", "pageTitle", "theme"]);
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"]);
367
388
 
368
389
  if (pageTitle) {
369
390
  document.title = pageTitle;
@@ -418,6 +439,8 @@ function layout(element) {
418
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);
419
440
  Object(external_react_dom_["render"])(wrappedElement, containerEl);
420
441
  }, 30);
442
+ }, {
443
+ loader: loader
421
444
  });
422
445
  }
423
446
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/react-page",
3
- "version": "6.0.3",
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:functional:prepare": "node src/tests/helpers/prepare_environment.js 8.0.3",
22
- "test:functional": "yarn run test:functional:prepare && splunk-wdio-functional-test-runner functional.local.conf.js",
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
- "@splunk/react-ui": "^4.15.0",
30
- "@splunk/splunk-utils": "^2.2.4",
31
- "@splunk/themes": "^0.13.1",
32
- "@splunk/ui-utils": "^1.5.2",
25
+ "@splunk/react-ui": "^4.16.3",
26
+ "@splunk/splunk-utils": "^2.3.4",
27
+ "@splunk/themes": "^0.16.0",
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",