SdkShowError.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2021
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['jquery', 'react', 'react-dom', 'ca-ui-toolkit', 'prop-types', 'jquery', '../../lib/@waca/dashboard-common/dist/lib/@ba-ui-toolkit/ba-graphics/dist/illustrations-js/disconnect_64', '../../lib/@waca/dashboard-common/dist/lib/@ba-ui-toolkit/ba-graphics/dist/illustrations-js/unknown-warning_128'], function (_, React, ReactDOM, UI_Toolkit, PropTypes, $, disconnect, permission) {
  11. var Container = UI_Toolkit.Container,
  12. FlexLayout = UI_Toolkit.FlexLayout,
  13. FlexItem = UI_Toolkit.FlexItem,
  14. VSpacer = UI_Toolkit.VSpacer,
  15. SVGIcon = UI_Toolkit.SVGIcon,
  16. Label = UI_Toolkit.Label;
  17. var Component = React.Component;
  18. var ExtensibleErrorComponent = function (_Component) {
  19. _inherits(ExtensibleErrorComponent, _Component);
  20. function ExtensibleErrorComponent() {
  21. _classCallCheck(this, ExtensibleErrorComponent);
  22. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  23. args[_key] = arguments[_key];
  24. }
  25. return _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args)));
  26. }
  27. ExtensibleErrorComponent.prototype.render = function render() {
  28. return React.createElement(
  29. Container,
  30. { className: 'vis-sdk-error-container' },
  31. React.createElement(
  32. FlexLayout,
  33. { fullHeight: true, direction: 'column', 'flex-wrap': 'wrap', justifyContent: 'center', alignItems: 'center' },
  34. React.createElement(
  35. FlexItem,
  36. null,
  37. React.createElement(SVGIcon, { iconId: this.props.context.default.id, height: 128, width: 128 })
  38. ),
  39. React.createElement(VSpacer, { size: 3 }),
  40. React.createElement(
  41. FlexLayout,
  42. { fullHeight: true, direction: 'column', 'flex-wrap': 'wrap', justifyContent: 'center' },
  43. React.createElement(
  44. FlexItem,
  45. null,
  46. React.createElement(Label, { className: 'vis-sdk-error-header', label: this.props.title })
  47. )
  48. ),
  49. React.createElement(VSpacer, null),
  50. React.createElement(
  51. FlexLayout,
  52. { fullHeight: true, direction: 'column', 'flex-wrap': 'wrap', justifyContent: 'center' },
  53. React.createElement(
  54. FlexItem,
  55. null,
  56. React.createElement(Label, { className: 'vis-sdk-error-msgContent', label: this.props.msgContent })
  57. )
  58. ),
  59. React.createElement(VSpacer, null)
  60. )
  61. );
  62. };
  63. return ExtensibleErrorComponent;
  64. }(Component);
  65. ExtensibleErrorComponent.propTypes = {
  66. title: PropTypes.object.isRequired,
  67. msgContent: PropTypes.object.isRequired,
  68. context: PropTypes.object.isRequired
  69. };
  70. return function () {
  71. function SdkShowError(el, title, msgContent, context) {
  72. _classCallCheck(this, SdkShowError);
  73. this.title = title;
  74. this.msgContent = msgContent;
  75. this.el = el;
  76. this.context = context === 'disconnect' ? disconnect : permission;
  77. }
  78. SdkShowError.prototype.showError = function showError() {
  79. this.$errorContainerWrapper = $('<div class="vis-sdk-error-container-wrapper errorContainer"></div>');
  80. this.el.append(this.$errorContainerWrapper[0]);
  81. ReactDOM.render(React.createElement(ExtensibleErrorComponent, { title: this.title, msgContent: this.msgContent, context: this.context }), this.$errorContainerWrapper[0]);
  82. };
  83. SdkShowError.prototype.destroy = function destroy() {
  84. if (this.$errorContainerWrapper) {
  85. ReactDOM.unmountComponentAtNode(this.$errorContainerWrapper[0]);
  86. }
  87. };
  88. return SdkShowError;
  89. }();
  90. });
  91. //# sourceMappingURL=SdkShowError.js.map