import { Dropdown, Icon, Menu, Tooltip } from '@8base/boost';
import cx from 'classnames';
import React, { useCallback } from 'react';
import ActionButton from './ActionButton';
import css from './file-actions.module.css';
// -- TYPES
interface IAction {
title: string;
onClick: (dropdownOpts: { closeDropdown: () => void }) => void;
}
interface IFileActionsProps {
moreActions?: IAction[];
isSquared?: boolean;
isOwner?: boolean;
downloadUrl?: string | null;
}
// -- MAIN
function FileActions({
moreActions,
downloadUrl,
isSquared,
isOwner,
}: IFileActionsProps) {
const cnAction = cx(
isSquared
? css['squared-action']
: isOwner
? css['owner-action']
: css['foreign-action'],
);
// TODO: it's not good practice to stop propagation. May be we should refactor it
const onClickAction = useCallback(e => {
e.stopPropagation();
}, []);
return (
<>
{moreActions && moreActions.length > 0 && (
{(dropdownOpts: any) => (
)}
)}
{downloadUrl && (
)}
>
);
}
export default FileActions;