UNPKG

@atlaskit/profilecard

Version:

A React component to display a card with user information.

56 lines 1.78 kB
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'; const GIVE_KUDOS_ACTION_ID = 'give-kudos'; export const TeamActions = ({ isKudosEnabled, otherActions, loading, ...props }) => { const { formatMessage } = useIntl(); const [isKudosOpen, setIsKudosOpen] = useState(false); const onKudosClick = useCallback(() => { setIsKudosOpen(true); }, []); const actions = []; let 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(...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: () => setIsKudosOpen(false), recipient: { type: KudosType.TEAM, recipientId: extractIdFromAri(kudosProps.teamId) }, analyticsSource: kudosProps.analyticsSource, teamCentralBaseUrl: kudosProps.teamCentralBaseUrl, cloudId: kudosProps.cloudId, addFlag: kudosProps.showKudosFlag }))); };