@atlaskit/rovo-agent-components
Version:
This package host public components related to rovo agents, the components here are needed for other public atlaskit packages
194 lines (193 loc) • 6.57 kB
JavaScript
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import "./index.compiled.css";
import { ax, ix } from "@compiled/react/runtime";
import React from 'react';
import { useIntl } from 'react-intl';
import Heading from '@atlaskit/heading';
import Link from '@atlaskit/link';
import { AtlassianIcon, RovoIcon } from '@atlaskit/logo';
import { fg } from '@atlaskit/platform-feature-flags';
import { Box, Inline, Stack } from '@atlaskit/primitives/compiled';
import Skeleton from '@atlaskit/skeleton';
import Tooltip from '@atlaskit/tooltip';
import { HiddenIcon } from '../../common/ui/hidden-icon';
import { StarIconButton } from '../../common/ui/star-icon-button';
import { isForgeAgentByCreatorType } from '../../common/utils/is-forge-agent';
import { messages } from './messages';
const styles = {
clickableItem: "_zulp1b66 _1e0c1txw _4cvr1h6o",
rovoIconWrapper: "_1e0c1txw",
name: "_1bah1yb4 _4cvr1y6m",
description: "_1mouze3t _1i4qfg65 _1nmz1hna",
headingWrapper: "_kqswh2mm",
hiddenIconWrapper: "_19pkv77o"
};
export const getAgentCreator = ({
creatorType,
authoringTeam,
userCreator,
forgeCreator
}) => {
if (creatorType === 'SYSTEM') {
return {
type: 'SYSTEM'
};
}
if (fg('rovo_agent_support_a2a_avatar') ? isForgeAgentByCreatorType(creatorType) : creatorType === 'FORGE' || creatorType === 'THIRD_PARTY' // THIRD_PARTY is deprecated in convo-ai, use FORGE instead
) {
return {
// @todo: remove cast in rovo_agent_support_a2a_avatar cleanup
type: fg('jira_improve_agent_profile_for_a2a') ? creatorType : 'FORGE',
name: forgeCreator !== null && forgeCreator !== void 0 ? forgeCreator : ''
};
}
if (creatorType === 'OOTB') {
return {
type: 'OOTB'
};
}
if (creatorType === 'CUSTOMER') {
if (authoringTeam) {
var _authoringTeam$profil;
return {
type: 'CUSTOMER',
name: authoringTeam.displayName,
profileLink: (_authoringTeam$profil = authoringTeam.profileLink) !== null && _authoringTeam$profil !== void 0 ? _authoringTeam$profil : ''
};
}
if (!(userCreator !== null && userCreator !== void 0 && userCreator.profileLink)) {
return undefined;
}
return {
type: 'CUSTOMER',
name: userCreator.name,
profileLink: userCreator.profileLink,
status: userCreator.status
};
}
return;
};
export const AgentProfileCreator = ({
creator,
onCreatorLinkClick,
isLoading
}) => {
const {
formatMessage
} = useIntl();
const getCreatorRender = () => {
if (isLoading) {
return formatMessage(messages.agentCreatedBy, {
creatorNameWithLink: /*#__PURE__*/React.createElement(Skeleton, {
testId: "agent-profile-creator-skeleton",
isShimmering: true,
height: 18,
width: 100
})
});
}
if (!creator) {
return null;
}
if (creator.type === 'SYSTEM' || creator.type === 'OOTB') {
return formatMessage(messages.agentCreatedBy, {
creatorNameWithLink: /*#__PURE__*/React.createElement(Inline, {
alignBlock: "center",
testId: "atlassian-icon"
}, /*#__PURE__*/React.createElement(AtlassianIcon, {
label: "",
size: "small",
appearance: "brand"
}), /*#__PURE__*/React.createElement(Box, null, "Atlassian"))
});
}
if (creator.type === 'CUSTOMER') {
return formatMessage(messages.agentCreatedBy, {
creatorNameWithLink: /*#__PURE__*/React.createElement(Link, {
href: creator.profileLink,
onClick: () => onCreatorLinkClick(),
target: "_blank"
}, creator.name, ' ', creator.status === 'inactive' && formatMessage(messages.agentDeactivated))
});
}
if (creator.type === 'REMOTE_A2A') {
return formatMessage(messages.remoteAgentCreatedBy, {
creatorNameWithLink: creator.name
});
}
// THIRD_PARTY is deprecated in convo-ai, use FORGE instead
if (creator.type === 'THIRD_PARTY' || creator.type === 'FORGE') {
return formatMessage(messages.agentCreatedBy, {
creatorNameWithLink: creator.name
});
}
return null;
};
const creatorRender = getCreatorRender();
if (fg('jira_improve_agent_profile_for_a2a')) {
const showRovoIcon = (creator === null || creator === void 0 ? void 0 : creator.type) !== 'REMOTE_A2A';
return creatorRender ? /*#__PURE__*/React.createElement(Box, {
xcss: styles.clickableItem
}, showRovoIcon ? /*#__PURE__*/React.createElement(Box, {
xcss: styles.rovoIconWrapper,
testId: "rovo-icon-wrapper",
"aria-hidden": "true"
}, /*#__PURE__*/React.createElement(RovoIcon, {
appearance: "brand",
size: "small"
})) : null, creatorRender) : null;
}
return creatorRender ? /*#__PURE__*/React.createElement(Box, {
xcss: styles.clickableItem
}, /*#__PURE__*/React.createElement(Box, {
xcss: styles.rovoIconWrapper,
testId: "rovo-icon-wrapper",
"aria-hidden": "true"
}, /*#__PURE__*/React.createElement(RovoIcon, {
appearance: "brand",
size: "small"
})), creatorRender) : null;
};
export const AgentProfileInfo = ({
agentName,
agentDescription,
creatorRender,
starCountRender,
headingRender,
isStarred,
isHidden,
onStarToggle,
showStarButton = true,
renderAdditionalContent
}) => {
const {
formatMessage
} = useIntl();
return /*#__PURE__*/React.createElement(Stack, {
space: "space.100"
}, /*#__PURE__*/React.createElement(Inline, {
xcss: styles.name,
space: "space.100",
alignBlock: "center"
}, /*#__PURE__*/React.createElement(Inline, {
space: "space.075",
xcss: styles.headingWrapper
}, /*#__PURE__*/React.createElement(Heading, {
as: "h2",
size: "medium"
}, agentName), headingRender, isHidden && /*#__PURE__*/React.createElement(Box, {
xcss: styles.hiddenIconWrapper
}, /*#__PURE__*/React.createElement(Tooltip, {
content: formatMessage(messages.hiddenTooltip),
position: "top"
}, /*#__PURE__*/React.createElement(HiddenIcon, {
label: formatMessage(messages.hiddenIcon)
})))), showStarButton && /*#__PURE__*/React.createElement(StarIconButton, {
isStarred: isStarred,
handleToggle: onStarToggle,
agentName: agentName
})), creatorRender, !!agentDescription && /*#__PURE__*/React.createElement(Box, {
xcss: styles.description,
as: "p"
}, agentDescription), starCountRender, !!renderAdditionalContent && fg('jira_browse_agents_modal') && renderAdditionalContent());
};