)
}
// Unfortunately, you'll notice below, that I needed to use the array index,
// against react best practices (https://reactjs.org/docs/lists-and-keys.html)
// This is because the menu items have no unique identifier.
export const SecondaryActions = ({
secondaryActions,
secondaryOverflowMenuItems,
reversed = false,
}: Props): JSX.Element | null => {
const { formatMessage } = useIntl()
if (!secondaryActions && !secondaryOverflowMenuItems) return null
const menuLabel = formatMessage({
id: 'kzTitleBlock.overflowMenuLabel',
defaultMessage: 'Menu',
description: 'Label for the dropdown menu which displays additional action items',
})
const menuAriaLabel = formatMessage({
id: 'kzTitleBlock.overflowMenuAriaLabel',
defaultMessage: 'Opens overflow menu',
description: 'Aria Label for the dropdown menu which displays additional action items',
})
const combinedMenuLabel = formatMessage({
id: 'kzTitleBlock.combinedOverflowMenuLabel',
defaultMessage: 'Open combined secondary and overflow menu',
description:
'Label for the dropdown menu which displays additional action items and secondary actions',
})
const secondaryActionsAsToolbarItems = secondaryActions
? secondaryActions.map((action, i) => {
if ('menuItems' in action) {
return {
key: `titleblock_secondary_action_${i}`,
node: (
),
}
} else {
if ('onClick' in action && 'href' in action) {
// eslint-disable-next-line no-console
console.warn(
'\u001b[33m \nTITLE BLOCK WARNING:\nSecondary actions only support ' +
'either an href or an onClick, not both simultaneously.\n',
)
}
return {
key: `${i}`,
node: (