mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-27 10:00:50 +00:00
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import classNames from 'classnames';
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { DropdownMenuItemContent } from 'mastodon/components/dropdown_menu';
|
|
import type { MenuItem } from 'mastodon/models/dropdown_menu';
|
|
import {
|
|
isActionItem,
|
|
isExternalLinkItem,
|
|
} from 'mastodon/models/dropdown_menu';
|
|
|
|
export const ActionsModal: React.FC<{
|
|
actions: MenuItem[];
|
|
onClick: React.MouseEventHandler;
|
|
}> = ({ actions, onClick }) => (
|
|
<div className='modal-root__modal actions-modal'>
|
|
<ul>
|
|
{actions.map((option, i: number) => {
|
|
if (option === null) {
|
|
return <li key={`sep-${i}`} className='dropdown-menu__separator' />;
|
|
}
|
|
|
|
const { text, highlighted, disabled, dangerous } = option;
|
|
|
|
let element: React.ReactElement;
|
|
|
|
if (isActionItem(option)) {
|
|
element = (
|
|
<button onClick={onClick} data-index={i} disabled={disabled}>
|
|
<DropdownMenuItemContent item={option} />
|
|
</button>
|
|
);
|
|
} else if (isExternalLinkItem(option)) {
|
|
element = (
|
|
<a
|
|
href={option.href}
|
|
target={option.target ?? '_target'}
|
|
data-method={option.method}
|
|
rel='noopener'
|
|
onClick={onClick}
|
|
data-index={i}
|
|
>
|
|
<DropdownMenuItemContent item={option} />
|
|
</a>
|
|
);
|
|
} else {
|
|
element = (
|
|
<Link to={option.to} onClick={onClick} data-index={i}>
|
|
<DropdownMenuItemContent item={option} />
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<li
|
|
className={classNames('dropdown-menu__item', {
|
|
'dropdown-menu__item--dangerous': dangerous,
|
|
'dropdown-menu__item--highlighted': highlighted,
|
|
})}
|
|
key={`${text}-${i}`}
|
|
>
|
|
{element}
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</div>
|
|
);
|