Source: api/sharing/ShareInterface.js

/**
 * Licensed Materials - Property of IBM
 * IBM Cognos Products: Collaboration
 * (C) Copyright IBM Corp. 2018, 2019
 *
 * US Government Users Restricted Rights - Use, duplication or disclosure
 * restricted by GSA ADP Schedule Contract with IBM Corp.
 */

define([], function () {
	'use strict';

	/**
	 * This class provides a means to declare a share and embed controller.
	 * It plays the role of an interface, consumer can implement it.
	 * e.g.
	 * @example
	 * {
	 *   "id": "com.ibm.bi.dashboard.shareAndEmbed",
	 *   "collectionItems": [{
	 *     "containerId": "com.ibm.bi.glass.common.sharedResources",
	 *     "id": "dashboard",
	 *     "label": "Share & Embed",
	 *     "types": ["exploration"],
	 *     "perspectives": ["dashboard"],
	 *     "actionController": "dashboard/glass/controllers/ShareActionHandler"
	 *   }]
	 * }
	 * @public
	 * @interface ShareInterface
	 */

	var ShareInterface = function () {

		/**
		 * Called when the custom button/menu item is Clicked/Tapped
		 *
		 * @memberof ShareInterface
		 * @public
		 * @param {Object} context
		 * @returns {Object} urlMap object containing an object like:
		 * @example
		 * {
		 *   "perspective": "dashboard",
		 *   "objRef": "i047E166063164D5DA85C8872A4574513",
		 *   "action":"view",
		 *   "mode":"dashboard"
		 * }
		 */
		this.execute = function (context) {
			void (context);
		};

		/**
		 * Called to decide if the Sharing entry should be shown or not.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {Object} context 
		 * @returns {Boolean} true/false
		 */
		this.isVisible = function (context) {
			void (context);
		};

		/**
		 * Returns an array of DOM elements to be capture for a screenshot.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} context
		 * @return {Promise} An array of objects like: <code>[{"el":domNode,"label":"text"}]</code>
		 */
		this.getShareableItems = function (context) {
			void (context);
		};

		/**
		 * Returns information about the current asset.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} context
		 * @return {Promise} An object like: <code>[{"type":"dashboard","title":"Dashboard Name","subTitle":"Dashboard Tab 1","owner":"Sam Carter","saved":true}]</code>
		 */
		this.getShareableInfo = function (context) {
			void (context);
		};

		/**
		 * Tells the controller that the Share panel is about to be shown.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} options
		 * @param {object} options.glassContext
		 * @param {object} options.slideout
		 * @return {Promise}
		 */
		this.enterShareState = function (options) {
			void (options);
		};

		/**
		 * Tells the controller that the Share panel is about to be closed.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} options
		 * @param {object} options.glassContext
		 * @param {object} options.slideout
		 * @return {Promise}
		 */
		this.leaveShareState = function (options) {
			void (options);
		};

		/**
		 * Asks the controller if it supports exporting to PDF. If this method
		 * is not implemented, the default response will be `false`.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} options
		 * @param {object} options.glassContext
		 * @return {Boolean}
		 */
		this.canExportToPDF = function (options) {
			void (options);
		};

		/**
		 * Tells the controller to generate a PDF file. This will only be called
		 * if the canExportToPDF function returns true.
		 * 
		 * @memberof ShareInterface
		 * @public
		 * @param {object} options
		 * @param {object} options.glassContext
		 * @param {object} pageSize an object representing the size of the page
		 * @param {object} printFilters print filters
		 * @return {Promise}
		 */
		this.exportToPDF = function (options, pageSize, printFilters) {
			void (options, pageSize, printFilters);
		};

		/**
		* Asks the action controller for its instrumentation data. The `action` will
		* be set as `shared` by collaboration when invoking the instrumentation's
		* track() method.
		*
		* @memberof ShareInterface
		* @public
		* @param {object} options
		* @param {object} options.glassContext
		* @return {object} instrumentation object data
		* @example
		* {
		*   "objectId": "some_id",
		*   "objectType": "type",
		*   "details": {
		*    ...
		*   }
		* }
		*/
		this.getInstrumentation = function (options) {
			void (options);
		};
	};

	return ShareInterface;
});