import { faDownLong } from '@fortawesome/free-solid-svg-icons/faDownLong';
import { faUpLong } from '@fortawesome/free-solid-svg-icons/faUpLong';
import { faThumbtack } from '@fortawesome/free-solid-svg-icons/faThumbtack';
import { SORTING, ACTIONS } from '../types';
export function getHeaderColumnsActions({
  isPinned,
  canSort,
  canPin,
  isPinDisabled,
  limitSorting,
  customActions,
  localizationText
}) {
  const sortActions = [];
  if (canSort) {
    if (limitSorting !== SORTING.ASC) {
      sortActions.push({
        key: SORTING.DESC,
        title: localizationText.sortDescendingText,
        testId: 'sort-desc',
        icon: faDownLong
      });
    }
    if (limitSorting !== SORTING.DESC) {
      sortActions.push({
        key: SORTING.ASC,
        title: localizationText.sortAscendingText,
        testId: 'sort-asc',
        icon: faUpLong
      });
    }
  }
  const pinAction = isPinned ? {
    key: ACTIONS.UNPIN,
    title: localizationText.unPinText,
    testId: 'unpin-column',
    icon: faThumbtack
  } : {
    key: ACTIONS.PIN,
    title: localizationText.pinText,
    testId: 'pin-column',
    icon: faThumbtack,
    disabled: isPinDisabled,
    tooltipText: isPinDisabled ? localizationText.disabledPinText : null
  };
  const pinActions = canPin ? [pinAction] : [];
  const defaultActions = [...pinActions, ...sortActions];
  const standardSection = defaultActions.length ? {
    key: 'standard-actions',
    subOptions: defaultActions
  } : null;
  const customSection = customActions.length ? {
    key: 'custom actions',
    subOptions: customActions
  } : null;
  return [standardSection, customSection].filter(item => !!item);
}