'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Notebook *| (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(['../../../../lib/@waca/dashboard-common/dist/ui/interaction/Utils', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI', '../../../../app/util/ErrorUtils', '../../../../app/nls/StringResources'], function (Utils, APIFactory, ContentActionsProviderAPI, ErrorUtils, stringResources) { // NOTE: DashboardWidget in jupyter-client relies on getAPI() for the hooks: // - this.selectedWidget.allowReconfigure() // - this.selectedWidget.editConfig() var EditNotebookAction = function () { function EditNotebookAction(_ref) { var features = _ref.features; _classCallCheck(this, EditNotebookAction); this._dashboard = features.API; features.ContentActions.registerProvider('editNotebook', this.getAPI()); this._dashboardState = features.DashboardState; this._icons = features.Icons; } EditNotebookAction.prototype.getAPI = function getAPI() { if (!this._api) { this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]); } return this._api; }; EditNotebookAction.prototype.destroy = function destroy() { this._dashboard = null; this._dashboardState = null; this._api = null; }; EditNotebookAction.prototype._isAvailable = function _isAvailable(idList) { var canAuthor = idList.length === 1 && this._dashboardState.getUiState().authoring === true && ErrorUtils.hasCapability(this._dashboard, 'canAuthorDashboard'); if (canAuthor) { this._selectedWidget = this._dashboard.getCanvas().getWidget(idList[0]); return this._selectedWidget && typeof this._selectedWidget.allowReconfigure === 'function' && this._selectedWidget.allowReconfigure(); } return false; }; EditNotebookAction.prototype.getContentActionList = function getContentActionList(idList) { if (this._isAvailable(idList)) { return [{ name: 'editNotebook', label: stringResources.get('editNotebook'), icon: this._icons.getIcon('edit').id, type: 'Button', actions: { apply: this.triggerEdit.bind(this) } }]; } else { return []; } }; EditNotebookAction.prototype.triggerEdit = function triggerEdit() /* event */{ this._selectedWidget.editConfig(); }; return EditNotebookAction; }(); return EditNotebookAction; }); //# sourceMappingURL=EditNotebookAction.js.map