@orfeas126/box-ui-elements
Version:
Box UI Elements
1,057 lines (940 loc) • 76.1 kB
JavaScript
/*!
* Box UI Element
*
* Copyright 2019 Box, Inc. All rights reserved.
*
* This product includes software developed by Box, Inc. ("Box")
* (http://www.box.com)
*
* ALL BOX SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL BOX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* See the Box license for the specific language governing permissions
* and limitations under the license.
*/
"use strict";
(globalThis["webpackChunk_orfeas126_box_ui_elements"] = globalThis["webpackChunk_orfeas126_box_ui_elements"] || []).push([["content-open-with"],{
/***/ "./src/elements/content-open-with/BoxToolsInstallMessage.js":
/*!******************************************************************!*\
!*** ./src/elements/content-open-with/BoxToolsInstallMessage.js ***!
\******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/* harmony import */ var _BoxToolsInstallMessage_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BoxToolsInstallMessage.scss */ "./src/elements/content-open-with/BoxToolsInstallMessage.scss");
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
*
* @file Custom message to install Box Tools inside of Open With.
* @author Box
*/
const DEFAULT_BOX_TOOLS_INSTALLATION_URL = 'https://cloud.box.com/v/installboxtools';
const DEFAULT_BOX_TOOLS_NAME = 'Box Tools';
const BoxToolsInstallMessage = ({
boxToolsName = DEFAULT_BOX_TOOLS_NAME,
boxToolsInstallUrl = DEFAULT_BOX_TOOLS_INSTALLATION_URL
}) => {
const onLinkClick = () => {
// Manually open the URL since disabled menu items are blocked from clickable actions by default
window.open(boxToolsInstallUrl);
};
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_3__["default"], _extends({}, _common_messages__WEBPACK_IMPORTED_MODULE_1__["default"].boxToolsInstallMessage, {
values: {
boxTools:
/*#__PURE__*/
// eslint-disable-next-line jsx-a11y/anchor-is-valid
react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", {
href: "#",
onClick: onLinkClick,
rel: "noopener noreferrer"
}, boxToolsName)
}
}));
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxToolsInstallMessage);
/***/ }),
/***/ "./src/elements/content-open-with/ContentOpenWith.js":
/*!***********************************************************!*\
!*** ./src/elements/content-open-with/ContentOpenWith.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ContentOpenWithComponent: () => (/* binding */ ContentOpenWith),
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash/uniqueId */ "./node_modules/lodash/uniqueId.js");
/* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var lodash_noop__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash/noop */ "./node_modules/lodash/noop.js");
/* harmony import */ var lodash_noop__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash_noop__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! query-string */ "./node_modules/query-string/index.js");
/* harmony import */ var _common_Internationalize__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/Internationalize */ "./src/elements/common/Internationalize.js");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/* harmony import */ var _common_error_boundary__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../common/error-boundary */ "./src/elements/common/error-boundary/index.js");
/* harmony import */ var _api__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../api */ "./src/api/index.js");
/* harmony import */ var _IntegrationPortalContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./IntegrationPortalContainer */ "./src/elements/content-open-with/IntegrationPortalContainer.js");
/* harmony import */ var _OpenWithDropdownMenu__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./OpenWithDropdownMenu */ "./src/elements/content-open-with/OpenWithDropdownMenu.js");
/* harmony import */ var _BoxToolsInstallMessage__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./BoxToolsInstallMessage */ "./src/elements/content-open-with/BoxToolsInstallMessage.js");
/* harmony import */ var _OpenWithButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./OpenWithButton */ "./src/elements/content-open-with/OpenWithButton.js");
/* harmony import */ var _OpenWithFallbackButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./OpenWithFallbackButton */ "./src/elements/content-open-with/OpenWithFallbackButton.js");
/* harmony import */ var _ExecuteForm__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ExecuteForm */ "./src/elements/content-open-with/ExecuteForm.js");
/* harmony import */ var _common_base_scss__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../common/base.scss */ "./src/elements/common/base.scss");
/* harmony import */ var _ContentOpenWith_scss__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ContentOpenWith.scss */ "./src/elements/content-open-with/ContentOpenWith.scss");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../constants */ "./src/constants.js");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
*
* @file Open With Component
* @author Box
*/
const UNSUPPORTED_INVOCATION_METHOD_TYPE = 'Integration invocation using this HTTP method type is not supported';
const BLACKLISTED_ERROR_MESSAGE_KEY = 'boxToolsBlacklistedError';
const BOX_TOOLS_INSTALL_ERROR_MESSAGE_KEY = 'boxToolsInstallErrorMessage';
const GENERIC_EXECUTE_MESSAGE_KEY = 'executeIntegrationOpenWithErrorHeader';
const AUTH_CODE = 'auth_code';
class ContentOpenWith extends react__WEBPACK_IMPORTED_MODULE_0__.PureComponent {
/**
* [constructor]
*
* @private
* @return {ContentOpenWith}
*/
constructor(props) {
super(props);
_defineProperty(this, "initialState", {
isDropdownOpen: false,
integrations: null,
isLoading: true,
fetchError: null,
executePostData: null,
shouldRenderErrorIntegrationPortal: false,
shouldRenderLoadingIntegrationPortal: false
});
/**
* Fetch app integrations info needed to render.
*
* @param {OpenWithIntegrations} integrations - The available Open With integrations
* @return {void}
*/
_defineProperty(this, "fetchOpenWithSuccessHandler", async integrations => {
const {
boxToolsName,
boxToolsInstallUrl
} = this.props;
const boxEditIntegration = integrations.find(({
appIntegrationId
}) => this.isBoxEditIntegration(appIntegrationId));
if (boxEditIntegration && !boxEditIntegration.isDisabled) {
try {
const {
extension
} = await this.getIntegrationFileExtension();
boxEditIntegration.extension = extension;
// If Box Edit is present and enabled, we need to set its ability to locally open the given file
// No-op if these checks are successful
await this.isBoxEditAvailable();
await this.canOpenExtensionWithBoxEdit(boxEditIntegration);
} catch (error) {
const errorMessageObject = _common_messages__WEBPACK_IMPORTED_MODULE_6__["default"][error.message] || _common_messages__WEBPACK_IMPORTED_MODULE_6__["default"][GENERIC_EXECUTE_MESSAGE_KEY];
let formattedErrorMessage = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react_intl__WEBPACK_IMPORTED_MODULE_18__["default"], errorMessageObject);
if (error.message === BOX_TOOLS_INSTALL_ERROR_MESSAGE_KEY) {
formattedErrorMessage = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_BoxToolsInstallMessage__WEBPACK_IMPORTED_MODULE_11__["default"], {
boxToolsInstallUrl: boxToolsInstallUrl,
boxToolsName: boxToolsName
});
}
boxEditIntegration.disabledReasons.push(formattedErrorMessage);
boxEditIntegration.isDisabled = true;
}
}
this.setState({
integrations,
isLoading: false
});
});
/**
* Fetches the file extension of the current file.
*
* @return {Promise}
*/
_defineProperty(this, "getIntegrationFileExtension", () => {
const {
fileId
} = this.props;
return new Promise((resolve, reject) => {
this.api.getFileAPI().getFileExtension(fileId, resolve, () => reject(new Error(GENERIC_EXECUTE_MESSAGE_KEY)));
});
});
/**
* Uses Box Edit to check if Box Tools is installed and reachable
*
* @return {Promise}
*/
_defineProperty(this, "isBoxEditAvailable", () => {
return this.api.getBoxEditAPI().checkBoxEditAvailability().catch(() => {
throw new Error(BOX_TOOLS_INSTALL_ERROR_MESSAGE_KEY);
});
});
/**
* Uses Box Edit to check if Box Tools can open a given file type
*
* @param {String} extension - A file extension
* @return {Promise}
*/
_defineProperty(this, "canOpenExtensionWithBoxEdit", ({
extension = ''
}) => {
return this.api.getBoxEditAPI().getAppForExtension(extension).catch(() => {
throw new Error(BLACKLISTED_ERROR_MESSAGE_KEY);
});
});
/**
* Handles a fetch error for the open_with_integrations and app_integrations endpoints
*
* @param {Error} error - An axios fetch error
* @return {void}
*/
_defineProperty(this, "fetchErrorHandler", (error, code) => {
this.props.onError(error, code, {
error
});
this.setState({
fetchError: error,
isLoading: false
});
});
/**
* Click handler when an integration is clicked
*
* @private
* @param {string} appIntegrationId - An app integration ID
* @param {string} displayName - The integration's display name
* @return {void}
*/
_defineProperty(this, "onIntegrationClick", ({
appIntegrationId,
displayName
}) => {
const {
fileId
} = this.props;
const isBoxEditIntegration = this.isBoxEditIntegration(appIntegrationId);
this.api.getAppIntegrationsAPI(false).execute(appIntegrationId, fileId, this.executeIntegrationSuccessHandler.bind(this, appIntegrationId), isBoxEditIntegration ? this.executeBoxEditErrorHandler : this.executeIntegrationErrorHandler);
if (isBoxEditIntegration) {
// No window management is required when using Box Edit.
return;
}
// These window features will open the new window directly on top of the current window at the same
const windowFeatures = `left=${window.screenX},top=${window.screenY},height=${window.outerHeight},width=${window.innerWidth},toolbar=0`;
// window.open() is immediately invoked to avoid popup-blockers
// The name is included to be the target of a form if the integration is a POST integration.
// A uniqueid is used to force the browser to open a new tab every time, while still allowing
// a form to reference a given tab.
this.integrationWindow = this.window.open('', `${lodash_uniqueId__WEBPACK_IMPORTED_MODULE_2___default()(appIntegrationId)}`, windowFeatures);
this.integrationWindow.document.title = displayName;
this.integrationWindow.onunload = this.cleanupIntegrationWindow;
this.setState({
shouldRenderLoadingIntegrationPortal: true,
shouldRenderErrorIntegrationPortal: false
});
});
/**
* cleans up the portal UI when a tab is closed so that we can remount the component later.
*
* @private
* @return {void}
*/
_defineProperty(this, "cleanupIntegrationWindow", () => {
this.setState({
shouldRenderLoadingIntegrationPortal: false,
shouldRenderErrorIntegrationPortal: false
});
});
/**
* Opens the integration in a new tab based on the API data
*
* @private
* @param {string} integrationId - The integration that was executed
* @param {ExecuteAPI} executeData - API response on how to open an executed integration
* @return {void}
*/
_defineProperty(this, "executeIntegrationSuccessHandler", (integrationId, executeData) => {
if (this.isBoxEditIntegration(integrationId)) {
this.executeBoxEditSuccessHandler(integrationId, executeData);
} else {
this.executeOnlineIntegrationSuccessHandler(executeData);
}
this.onExecute(integrationId);
});
/**
* Opens the file via a Partner Integration
*
* @private
* @param {ExecuteAPI} executeData - API response on how to open an executed integration
* @return {void}
*/
_defineProperty(this, "executeOnlineIntegrationSuccessHandler", executeData => {
const {
method,
url
} = executeData;
switch (method) {
case _constants__WEBPACK_IMPORTED_MODULE_17__.HTTP_POST:
this.setState({
executePostData: executeData
});
break;
case _constants__WEBPACK_IMPORTED_MODULE_17__.HTTP_GET:
if (!this.integrationWindow) {
return;
}
// Prevents abuse of window.opener
// see here for more details: https://mathiasbynens.github.io/rel-noopener/
this.integrationWindow.location = url;
this.integrationWindow.opener = null;
break;
default:
this.executeIntegrationErrorHandler(Error(UNSUPPORTED_INVOCATION_METHOD_TYPE), _constants__WEBPACK_IMPORTED_MODULE_17__.ERROR_CODE_EXECUTE_INTEGRATION);
}
this.integrationWindow = null;
});
/**
* Opens the file via Box Edit
*
* @private
* @param {string} url - Integration execution URL
* @return {void}
*/
_defineProperty(this, "executeBoxEditSuccessHandler", (integrationId, {
url
}) => {
const {
fileId,
token,
onError
} = this.props;
const queryParams = query_string__WEBPACK_IMPORTED_MODULE_4__.parse(url);
const authCode = queryParams[AUTH_CODE];
const isFileScoped = this.isBoxEditSFCIntegration(integrationId);
this.api.getBoxEditAPI().openFile(fileId, {
data: {
auth_code: authCode,
token,
token_scope: isFileScoped ? _constants__WEBPACK_IMPORTED_MODULE_17__.TYPE_FILE : _constants__WEBPACK_IMPORTED_MODULE_17__.TYPE_FOLDER
}
}).catch(error => {
onError(error, _constants__WEBPACK_IMPORTED_MODULE_17__.ERROR_CODE_EXECUTE_INTEGRATION, {
error
});
});
});
/**
* Clears state after a form has been submitted
*
* @private
* @return {void}
*/
_defineProperty(this, "onExecuteFormSubmit", () => {
this.setState({
executePostData: null
});
});
/**
* Handles execution related errors
*
* @private
* @param {Error} error - Error object
* @return {void}
*/
_defineProperty(this, "executeIntegrationErrorHandler", (error, code) => {
this.props.onError(error, code, {
error
});
// eslint-disable-next-line no-console
console.error(error);
this.setState({
shouldRenderLoadingIntegrationPortal: false,
shouldRenderErrorIntegrationPortal: true
});
});
/**
* Handles Box Edit execution related errors
*
* @private
* @param {Error} error - Error object
* @return {void}
*/
_defineProperty(this, "executeBoxEditErrorHandler", error => {
this.props.onError(error);
// eslint-disable-next-line no-console
console.error(error);
});
const {
token: _token,
apiHost,
clientName,
language,
requestInterceptor,
responseInterceptor
} = props;
this.id = lodash_uniqueId__WEBPACK_IMPORTED_MODULE_2___default()('bcow_');
this.api = new _api__WEBPACK_IMPORTED_MODULE_8__["default"]({
apiHost,
clientName,
language,
requestInterceptor,
responseInterceptor,
token: _token
});
// Clone initial state to allow for state reset on new files
this.state = _objectSpread({}, this.initialState);
}
/**
* Destroys api instances with caches
*
* @private
* @return {void}
*/
clearCache() {
this.api.destroy(true);
}
/**
* Cleanup
*
* @private
* @inheritdoc
* @return {void}
*/
componentWillUnmount() {
// Don't destroy the cache while unmounting
this.api.destroy(false);
}
/**
*
* @private
* @inheritdoc
* @return {void}
*/
componentDidMount() {
const {
fileId
} = this.props;
if (!fileId) {
return;
}
this.window = window;
this.fetchOpenWithData();
}
/**
* After component updates, re-fetch Open With data if appropriate.
*
* @return {void}
*/
componentDidUpdate(prevProps) {
const {
fileId: currentFileId
} = this.props;
const {
fileId: previousFileId
} = prevProps;
if (!currentFileId) {
return;
}
if (currentFileId !== previousFileId) {
this.setState(_objectSpread({}, this.initialState));
this.fetchOpenWithData();
}
}
/**
* Checks if a given integration is a Box Edit integration.
*
* @param {string} [integrationId] - The integration ID
* @return {boolean}
*/
isBoxEditIntegration(integrationId) {
return integrationId === _constants__WEBPACK_IMPORTED_MODULE_17__.BOX_EDIT_INTEGRATION_ID || this.isBoxEditSFCIntegration(integrationId);
}
/**
* Checks if a given integration is a Box Edit integration.
*
* @param {string} [integrationId] - The integration ID
* @return {boolean}
*/
isBoxEditSFCIntegration(integrationId) {
return integrationId === _constants__WEBPACK_IMPORTED_MODULE_17__.BOX_EDIT_SFC_INTEGRATION_ID;
}
/**
* Fetches Open With data.
*
* @return {void}
*/
fetchOpenWithData() {
const {
fileId
} = this.props;
this.api.getOpenWithAPI(false).getOpenWithIntegrations(fileId, this.fetchOpenWithSuccessHandler, this.fetchErrorHandler);
}
/**
* Calls the onExecute prop
*
* @private
* @param {string} integrationID - The integration that was executed
* @return {void}
*/
onExecute(integrationID) {
this.props.onExecute(integrationID);
this.setState({
shouldRenderLoadingIntegrationPortal: false
});
}
/**
* Gets a display integration, if available, for the Open With button
*
* @private
* @return {?Integration}
*/
getDisplayIntegration() {
const {
integrations
} = this.state;
// We only consider an integration a display integration if is the only integration in our state
return Array.isArray(integrations) && integrations.length === 1 ? integrations[0] : null;
}
/**
* Render the Open With element
*
* @private
* @inheritdoc
* @return {Element}
*/
render() {
const {
language,
messages: intlMessages,
dropdownAlignment
} = this.props;
const {
fetchError,
isLoading,
integrations,
executePostData,
shouldRenderLoadingIntegrationPortal,
shouldRenderErrorIntegrationPortal
} = this.state;
const className = classnames__WEBPACK_IMPORTED_MODULE_1___default()('be bcow', this.props.className);
const displayIntegration = this.getDisplayIntegration();
const numIntegrations = integrations ? integrations.length : 0;
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_common_Internationalize__WEBPACK_IMPORTED_MODULE_5__["default"], {
language: language,
messages: intlMessages
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
className: className,
"data-testid": "bcow-content",
id: this.id
}, numIntegrations <= 1 ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_OpenWithButton__WEBPACK_IMPORTED_MODULE_12__["default"], {
displayIntegration: displayIntegration,
error: fetchError,
isLoading: isLoading,
onClick: this.onIntegrationClick
}) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_OpenWithDropdownMenu__WEBPACK_IMPORTED_MODULE_10__["default"], {
dropdownAlignment: dropdownAlignment,
integrations: integrations,
onClick: this.onIntegrationClick
}), (shouldRenderLoadingIntegrationPortal || shouldRenderErrorIntegrationPortal) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_IntegrationPortalContainer__WEBPACK_IMPORTED_MODULE_9__["default"], {
hasError: shouldRenderErrorIntegrationPortal,
integrationWindow: this.integrationWindow
}), executePostData && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_ExecuteForm__WEBPACK_IMPORTED_MODULE_14__["default"], {
executePostData: executePostData,
id: this.id,
onSubmit: this.onExecuteFormSubmit,
windowName: this.integrationWindow && this.integrationWindow.name
})));
}
}
_defineProperty(ContentOpenWith, "defaultProps", {
apiHost: _constants__WEBPACK_IMPORTED_MODULE_17__.DEFAULT_HOSTNAME_API,
className: '',
clientName: _constants__WEBPACK_IMPORTED_MODULE_17__.CLIENT_NAME_OPEN_WITH,
onExecute: (lodash_noop__WEBPACK_IMPORTED_MODULE_3___default()),
onError: (lodash_noop__WEBPACK_IMPORTED_MODULE_3___default())
});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_common_error_boundary__WEBPACK_IMPORTED_MODULE_7__.withErrorBoundary)(_constants__WEBPACK_IMPORTED_MODULE_17__.ORIGIN_OPEN_WITH, _OpenWithFallbackButton__WEBPACK_IMPORTED_MODULE_13__["default"])(ContentOpenWith));
/***/ }),
/***/ "./src/elements/content-open-with/ExecuteForm.js":
/*!*******************************************************!*\
!*** ./src/elements/content-open-with/ExecuteForm.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../constants */ "./src/constants.js");
/**
*
* @file Form to invoke an integration via POST
* @author Box
*/
class ExecuteForm extends react__WEBPACK_IMPORTED_MODULE_0__.PureComponent {
constructor(props) {
super(props);
this.ref = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createRef();
}
componentDidMount() {
const {
onSubmit
} = this.props;
this.ref.current.submit();
onSubmit();
}
render() {
const {
executePostData: {
url,
params
},
id,
windowName
} = this.props;
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("form", {
ref: this.ref,
action: url,
id: `bcow-execute-form-${id}`,
method: _constants__WEBPACK_IMPORTED_MODULE_1__.HTTP_POST,
rel: "noreferrer noopener",
target: windowName || '_blank'
}, params && params.map(({
key,
value
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
key: key,
name: key,
type: "hidden",
value: value
})));
}
}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ExecuteForm);
/***/ }),
/***/ "./src/elements/content-open-with/IconFileMap.js":
/*!*******************************************************!*\
!*** ./src/elements/content-open-with/IconFileMap.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _icons_google_docs_IconGoogleDocs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../icons/google-docs/IconGoogleDocs */ "./src/icons/google-docs/IconGoogleDocs.tsx");
/* harmony import */ var _icons_google_docs_IconGoogleSheets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../icons/google-docs/IconGoogleSheets */ "./src/icons/google-docs/IconGoogleSheets.tsx");
/* harmony import */ var _icons_google_docs_IconGoogleSlides__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../icons/google-docs/IconGoogleSlides */ "./src/icons/google-docs/IconGoogleSlides.tsx");
/* harmony import */ var _icons_file_icon_FileIcon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../icons/file-icon/FileIcon */ "./src/icons/file-icon/FileIcon.tsx");
/**
*
* @file Maintains a mapping of integration names to icons.
* @author Box
*/
const ICON_FILE_MAP = {
'Google Docs': _icons_google_docs_IconGoogleDocs__WEBPACK_IMPORTED_MODULE_1__["default"],
'Google Docs (beta)': _icons_google_docs_IconGoogleDocs__WEBPACK_IMPORTED_MODULE_1__["default"],
'Google Sheets': _icons_google_docs_IconGoogleSheets__WEBPACK_IMPORTED_MODULE_2__["default"],
'Google Sheets (beta)': _icons_google_docs_IconGoogleSheets__WEBPACK_IMPORTED_MODULE_2__["default"],
'Google Slides': _icons_google_docs_IconGoogleSlides__WEBPACK_IMPORTED_MODULE_3__["default"],
'Google Slides (beta)': _icons_google_docs_IconGoogleSlides__WEBPACK_IMPORTED_MODULE_3__["default"]
};
function getIcon(iconName) {
return ICON_FILE_MAP[iconName] || _icons_file_icon_FileIcon__WEBPACK_IMPORTED_MODULE_4__["default"];
}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getIcon);
/***/ }),
/***/ "./src/elements/content-open-with/IntegrationPortal.js":
/*!*************************************************************!*\
!*** ./src/elements/content-open-with/IntegrationPortal.js ***!
\*************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ copyStyles: () => (/* binding */ copyStyles),
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-dom */ "react-dom");
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_0__);
/**
*
* @file Allows react to render a component in an arbitrary DOM node, in this case in a new window.
* @author Box
*/
/**
* Copies stylesheets to the new window.
*
* @private
* @param {HTMLDocument} documentElement - an HTML document
* @param {Window} integrationWindow - a browser window
* @return {void}
*/
function copyStyles(documentElement, integrationWindow) {
// The new window will have no CSS, so we copy all style sheets as a safe way
// of ensuring required styles are present
Array.from(documentElement.styleSheets).forEach(styleSheet => {
if (!styleSheet.href) {
return;
}
const copiedStyleSheet = integrationWindow.document.createElement('link');
copiedStyleSheet.rel = 'stylesheet';
copiedStyleSheet.href = styleSheet.href;
integrationWindow.document.head.appendChild(copiedStyleSheet);
});
// Reset margin and padding in our new window
integrationWindow.document.body.style.margin = 0;
integrationWindow.document.body.style.padding = 0;
}
const IntegrationPortal = ({
integrationWindow,
children
}) => {
const containerElement = integrationWindow.document.createElement('div');
copyStyles(document, integrationWindow);
integrationWindow.document.body.appendChild(containerElement);
return /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_0__.createPortal)(children, containerElement);
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (IntegrationPortal);
/***/ }),
/***/ "./src/elements/content-open-with/IntegrationPortalContainer.js":
/*!**********************************************************************!*\
!*** ./src/elements/content-open-with/IntegrationPortalContainer.js ***!
\**********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var _components_error_mask_ErrorMask__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/error-mask/ErrorMask */ "./src/components/error-mask/ErrorMask.tsx");
/* harmony import */ var _components_loading_indicator_LoadingIndicator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/loading-indicator/LoadingIndicator */ "./src/components/loading-indicator/LoadingIndicator.tsx");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/* harmony import */ var _IntegrationPortal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./IntegrationPortal */ "./src/elements/content-open-with/IntegrationPortal.js");
/**
*
* @file integration portal container
* @author Box
*/
const IntegrationPortalContainer = ({
hasError,
integrationWindow
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_IntegrationPortal__WEBPACK_IMPORTED_MODULE_4__["default"], {
integrationWindow: integrationWindow
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", {
className: "be bcow bcow-portal-container"
}, hasError ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_error_mask_ErrorMask__WEBPACK_IMPORTED_MODULE_1__["default"], {
errorHeader: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_5__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_3__["default"].executeIntegrationOpenWithErrorHeader),
errorSubHeader: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_5__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_3__["default"].executeIntegrationOpenWithErrorSubHeader)
}) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_loading_indicator_LoadingIndicator__WEBPACK_IMPORTED_MODULE_2__["default"], {
className: "bcow-portal-loading-indicator",
size: "large"
})));
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (IntegrationPortalContainer);
/***/ }),
/***/ "./src/elements/content-open-with/MultipleIntegrationsOpenWithButton.js":
/*!******************************************************************************!*\
!*** ./src/elements/content-open-with/MultipleIntegrationsOpenWithButton.js ***!
\******************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var _components_dropdown_menu_MenuToggle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/dropdown-menu/MenuToggle */ "./src/components/dropdown-menu/MenuToggle.js");
/* harmony import */ var _icons_general_IconOpenWith__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../icons/general/IconOpenWith */ "./src/icons/general/IconOpenWith.tsx");
/* harmony import */ var _components_button_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../components/button/Button */ "./src/components/button/Button.tsx");
/* harmony import */ var _common_Tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/Tooltip */ "./src/elements/common/Tooltip.js");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/* harmony import */ var _OpenWithButtonContents__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./OpenWithButtonContents */ "./src/elements/content-open-with/OpenWithButtonContents.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../constants */ "./src/constants.js");
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
*
* @file Open With button when multiple integrations are present
* @author Box
*/
const MultipleIntegrationsOpenWithButton = buttonProps => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_common_Tooltip__WEBPACK_IMPORTED_MODULE_4__["default"], {
position: "middle-left",
text: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_8__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_5__["default"].defaultOpenWithDescription)
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_button_Button__WEBPACK_IMPORTED_MODULE_3__["default"], _extends({
"data-testid": "multipleintegrationsbutton"
}, buttonProps), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_dropdown_menu_MenuToggle__WEBPACK_IMPORTED_MODULE_1__["default"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_OpenWithButtonContents__WEBPACK_IMPORTED_MODULE_6__["default"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_icons_general_IconOpenWith__WEBPACK_IMPORTED_MODULE_2__["default"], {
className: _constants__WEBPACK_IMPORTED_MODULE_7__.CLASS_INTEGRATION_ICON,
dimension: _constants__WEBPACK_IMPORTED_MODULE_7__.OPEN_WITH_BUTTON_ICON_SIZE,
height: _constants__WEBPACK_IMPORTED_MODULE_7__.OPEN_WITH_BUTTON_ICON_SIZE,
width: _constants__WEBPACK_IMPORTED_MODULE_7__.OPEN_WITH_BUTTON_ICON_SIZE
})))));
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MultipleIntegrationsOpenWithButton);
/***/ }),
/***/ "./src/elements/content-open-with/OpenWithButton.js":
/*!**********************************************************!*\
!*** ./src/elements/content-open-with/OpenWithButton.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
/* harmony export */ getTooltip: () => (/* binding */ getTooltip)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var lodash_noop__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/noop */ "./node_modules/lodash/noop.js");
/* harmony import */ var lodash_noop__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_noop__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _components_button_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/button/Button */ "./src/components/button/Button.tsx");
/* harmony import */ var _icons_general_IconOpenWith__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../icons/general/IconOpenWith */ "./src/icons/general/IconOpenWith.tsx");
/* harmony import */ var _common_Tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/Tooltip */ "./src/elements/common/Tooltip.js");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/* harmony import */ var _OpenWithButtonContents__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./OpenWithButtonContents */ "./src/elements/content-open-with/OpenWithButtonContents.js");
/* harmony import */ var _openWithUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./openWithUtils */ "./src/elements/content-open-with/openWithUtils.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../constants */ "./src/constants.js");
/* harmony import */ var _IconFileMap__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./IconFileMap */ "./src/elements/content-open-with/IconFileMap.js");
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
*
* @file Open With button
* @author Box
*/
/**
* Gets the tooltip text for the ContentOpenWith button
*
* @private
* @return {?(string | Element)} the tooltip message
*/
const getTooltip = (displayDescription, isLoading, error, disabledReasons = []) => {
if (isLoading) {
return null;
}
let message = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_10__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_5__["default"].emptyOpenWithDescription);
if (disabledReasons.length > 0) {
[message] = disabledReasons;
} else if (error) {
message = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_10__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_5__["default"].errorOpenWithDescription);
} else if (displayDescription) {
message = displayDescription;
}
return message;
};
const OpenWithButton = ({
error,
onClick = (lodash_noop__WEBPACK_IMPORTED_MODULE_1___default()),
displayIntegration,
isLoading
}) => {
const {
displayName,
isDisabled: isDisplayIntegrationDisabled,
extension,
disabledReasons,
displayDescription
} = displayIntegration || {};
const isDisabled = !!isDisplayIntegrationDisabled || !displayName;
const Icon = displayName ? (0,_IconFileMap__WEBPACK_IMPORTED_MODULE_9__["default"])(displayName) : _icons_general_IconOpenWith__WEBPACK_IMPORTED_MODULE_3__["default"];
const tooltipDisplayProps = _openWithUtils__WEBPACK_IMPORTED_MODULE_7__["default"].isDisabledBecauseBoxToolsIsNotInstalled(displayIntegration) ? {
isShown: true,
showCloseButton: true
} : {};
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_common_Tooltip__WEBPACK_IMPORTED_MODULE_4__["default"], _extends({
className: "bcow-tooltip",
position: "bottom-center",
text: getTooltip(displayDescription, isLoading, error, disabledReasons)
}, tooltipDisplayProps), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_button_Button__WEBPACK_IMPORTED_MODULE_2__["default"], {
"data-testid": "singleintegrationbutton",
isDisabled: isDisabled,
onClick: () => displayIntegration ? onClick(displayIntegration) : (lodash_noop__WEBPACK_IMPORTED_MODULE_1___default())
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_OpenWithButtonContents__WEBPACK_IMPORTED_MODULE_6__["default"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Icon, {
className: _constants__WEBPACK_IMPORTED_MODULE_8__.CLASS_INTEGRATION_ICON,
dimension: _constants__WEBPACK_IMPORTED_MODULE_8__.OPEN_WITH_BUTTON_ICON_SIZE,
extension: extension,
height: _constants__WEBPACK_IMPORTED_MODULE_8__.OPEN_WITH_BUTTON_ICON_SIZE,
width: _constants__WEBPACK_IMPORTED_MODULE_8__.OPEN_WITH_BUTTON_ICON_SIZE
}))));
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (OpenWithButton);
/***/ }),
/***/ "./src/elements/content-open-with/OpenWithButtonContents.js":
/*!******************************************************************!*\
!*** ./src/elements/content-open-with/OpenWithButtonContents.js ***!
\******************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-intl */ "./node_modules/react-intl/lib/src/components/message.js");
/* harmony import */ var _common_messages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/messages */ "./src/elements/common/messages.js");
/**
*
* @file Open With button contents
* @author Box
*/
const OpenWithButtonContents = ({
children
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, children, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", {
className: "bcow-btn-header-text"
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_intl__WEBPACK_IMPORTED_MODULE_2__["default"], _common_messages__WEBPACK_IMPORTED_MODULE_1__["default"].open)));
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (OpenWithButtonContents);
/***/ }),
/***/ "./src/elements/content-open-with/OpenWithDropdownMenu.js":
/*!****************************************************************!*\
!*** ./src/elements/content-open-with/OpenWithDropdownMenu.js ***!
\****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _components_dropdown_menu_DropdownMenu__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../components/dropdown-menu/DropdownMenu */ "./src/components/dropdown-menu/DropdownMenu.js");
/* harmony import */ var _components_menu_Menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/menu/Menu */ "./src/components/menu/Menu.tsx");
/* harmony import */ var _OpenWithDropdownMenuItem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./OpenWithDropdownMenuItem */ "./src/elements/content-open-with/OpenWithDropdownMenuItem.js");
/* harmony import */ var _MultipleIntegrationsOpenWithButton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./MultipleIntegrationsOpenWithButton */ "./src/elements/content-open-with/MultipleIntegrationsOpenWithButton.js");
/**
*
* @file Open With dropdown menu
* @author Box
*/
const RIGHT_ALIGNMENT = 'right';
const OpenWithDropdownMenu = ({
dropdownAlignment = RIGHT_ALIGNMENT,
integrations,
onClick
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_dropdown_menu_DropdownMenu__WEBPACK_IMPO