123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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; }
- 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; }
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['react', 'prop-types', 'ca-ui-toolkit', '../VisualItem', '../../../widgets/livewidget/nls/StringResources', '../../../lib/@waca/dashboard-common/dist/lib/@ba-ui-toolkit/ba-graphics/dist/icons-js/information_16'], function (React, PropTypes, UI_Toolkit, VisualItem, StringResources, Information_16) {
- var FlexLayout = UI_Toolkit.FlexLayout,
- FlexItem = UI_Toolkit.FlexItem,
- VSpacer = UI_Toolkit.VSpacer,
- HSpacer = UI_Toolkit.HSpacer,
- Flyout = UI_Toolkit.Flyout,
- Label = UI_Toolkit.Label;
- var PreviewVisualItem = function (_VisualItem) {
- _inherits(PreviewVisualItem, _VisualItem);
- function PreviewVisualItem(props) {
- _classCallCheck(this, PreviewVisualItem);
- var _this = _possibleConstructorReturn(this, _VisualItem.call(this, props));
- _this.state.sdkIsRunning = false;
- _this._initRenderContext(_this.state.sdkIsRunning);
- return _this;
- }
- PreviewVisualItem.prototype._initRenderContext = function _initRenderContext(sdkIsRunning) {
- var item = this.state.item;
- var _props = this.props,
- handlers = _props.handlers,
- iconsFeature = _props.iconsFeature;
- var isSchematicType = handlers.isSchematicType(item);
- var icon = void 0;
- if (isSchematicType) {
- icon = iconsFeature.getIcon('svgFile').id;
- } else {
- icon = iconsFeature.getIcon('codeFile').id;
- }
- this._renderContext = {
- icon: icon,
- description: isSchematicType ? item.label : StringResources.get('customVisTestVisualization'),
- isDisabled: isSchematicType ? false : sdkIsRunning ? false : true
- };
- };
- PreviewVisualItem.prototype._isSDKActive = function _isSDKActive() {
- return this.props.handlers.isSDKActive();
- };
- PreviewVisualItem.prototype.componentDidMount = function componentDidMount() {
- var _this2 = this;
- _VisualItem.prototype.componentDidMount.call(this);
- return this._isSDKActive().then(function (sdkIsRunning) {
- if (sdkIsRunning) {
- _this2._initRenderContext(true);
- _this2.setState({
- sdkIsRunning: true
- });
- _this2._attachCallbacksAndImages();
- }
- }).catch(function () {
- // swallow it... sdk is not running and that's fine
- });
- };
- PreviewVisualItem.prototype.componentWillUnmount = function componentWillUnmount() {
- _VisualItem.prototype.componentWillUnmount.call(this);
- };
- PreviewVisualItem.prototype._getVisualItemCssClasses = function _getVisualItemCssClasses() {
- return _VisualItem.prototype._getVisualItemCssClasses.call(this) + ' vis-custom-preview';
- };
- PreviewVisualItem.prototype._canRenderMenuOption = function _canRenderMenuOption() {
- return this._renderContext.isDisabled ? true : false;
- };
- PreviewVisualItem.prototype._getContextMenuContent = function _getContextMenuContent() {
- return React.createElement(
- Flyout,
- {
- theme: true,
- placement: 'bottomRight',
- showX: true,
- triggerNode: this.target,
- domNodeToAttachTo: document.body,
- onClose: this.onClose.bind(this),
- className: 'vis-preview-indicator-menu'
- },
- React.createElement(
- FlexLayout,
- {
- fullHeight: true,
- direction: 'row',
- justifyContent: 'flex-start'
- },
- React.createElement(
- FlexItem,
- null,
- React.createElement(HSpacer, { size: 2 })
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(
- FlexLayout,
- {
- fullHeight: true,
- direction: 'column',
- justifyContent: 'flex-start'
- },
- React.createElement(
- FlexItem,
- null,
- React.createElement(VSpacer, { size: 2 })
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(Label, {
- label: StringResources.get('extVisNoSDKConnection'),
- className: 'vis-preview-indicator-menu-title'
- })
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(VSpacer, { size: 2 })
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(Label, {
- label: StringResources.get('extVisNoSDKPreviewMsg'),
- className: 'vis-preview-indicator-menu-msg'
- })
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(VSpacer, { size: 2 })
- )
- )
- ),
- React.createElement(
- FlexItem,
- null,
- React.createElement(HSpacer, { size: 2 })
- )
- )
- );
- };
- return PreviewVisualItem;
- }(VisualItem);
- PreviewVisualItem.propTypes = {
- item: PropTypes.object.isRequired,
- handlers: PropTypes.shape({
- componentDidMountCallback: PropTypes.func.isRequired,
- componentWillUnmountCallback: PropTypes.func.isRequired,
- isSchematicType: PropTypes.func.isRequired,
- isSDKActive: PropTypes.func.isRequired
- }).isRequired,
- menuIcon: PropTypes.object
- };
- PreviewVisualItem.defaultProps = {
- menuIcon: Information_16
- };
- return PreviewVisualItem;
- });
- //# sourceMappingURL=PreviewVisualItem.js.map
|