UNPKG

@atlaskit/profilecard

Version:

A React component to display a card with user information.

63 lines 2.38 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["isKudosEnabled", "otherActions", "loading"]; import React, { Suspense, useCallback, useState } from 'react'; import { useIntl } from 'react-intl-next'; import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos'; import { ButtonItem } from '@atlaskit/menu'; import { extractIdFromAri } from '../../../client/getTeamFromAGG'; import { messages } from './messages'; import { MoreActions } from './more-actions'; var GIVE_KUDOS_ACTION_ID = 'give-kudos'; export var TeamActions = function TeamActions(_ref) { var isKudosEnabled = _ref.isKudosEnabled, otherActions = _ref.otherActions, loading = _ref.loading, props = _objectWithoutProperties(_ref, _excluded); var _useIntl = useIntl(), formatMessage = _useIntl.formatMessage; var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), isKudosOpen = _useState2[0], setIsKudosOpen = _useState2[1]; var onKudosClick = useCallback(function () { setIsKudosOpen(true); }, []); var actions = []; var kudosProps = null; if (isKudosEnabled) { actions.push({ id: GIVE_KUDOS_ACTION_ID, item: /*#__PURE__*/React.createElement(ButtonItem, { onClick: onKudosClick }, formatMessage(messages.giveKudos)) }); kudosProps = props; } if (otherActions) { actions.push.apply(actions, _toConsumableArray(otherActions)); } if (actions.length === 0) { return null; } return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MoreActions, { actions: actions, loading: loading }), isKudosEnabled && kudosProps && /*#__PURE__*/React.createElement(Suspense, { fallback: null }, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, { isOpen: isKudosOpen, onClose: function onClose() { return setIsKudosOpen(false); }, recipient: { type: KudosType.TEAM, recipientId: extractIdFromAri(kudosProps.teamId) }, analyticsSource: kudosProps.analyticsSource, teamCentralBaseUrl: kudosProps.teamCentralBaseUrl, cloudId: kudosProps.cloudId, addFlag: kudosProps.showKudosFlag }))); };