'use strict'; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Content Explorer *| (C) Copyright IBM Corp. 2016, 2020 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['../../../lib/@waca/baglass/js/baglass/app/plugins/Button'], function (BaseClass) { var WIDGET_CONTAINER_ID = 'com.ibm.bi.dashboard.widgets'; var CONTENT_CONTAINER_ID = 'com.ibm.bi.dashboard.contentTypes'; var CustomWidgetButton = BaseClass.extend({ init: function init(options) { CustomWidgetButton.inherited('init', this, arguments); var appController = options.glassContext.appController; this._determineVisibility(appController); }, _determineVisibility: function _determineVisibility(appController) { var _this = this; appController.findCollection(WIDGET_CONTAINER_ID).then(function (collection) { var customWidgets = collection.filter(function (widget) { return !widget.builtin; }); if (customWidgets.length > 0) { return true; } else { return appController.findCollection(CONTENT_CONTAINER_ID).then(function (contents) { return (contents || []).some(function (content) { return content.expose; }); }); } }).then(function (shouldRender) { if (shouldRender) { _this.show(); } else { // We have no custom widgets/contents so we never want this button to be shown. _this.hideForever = true; _this.hide(); } }); } }); return CustomWidgetButton; }); //# sourceMappingURL=CustomWidgetButton.js.map