grafana/public/app/features/playlist/PlaylistTable.tsx
Ashley Harrison b321dc7280
Chore: Migrate from react-beautiful-dnd to @hello-pangea/dnd (#90328)
* migrate from react-beautiful-dnd to @hello-pangea/dnd

* revert comment
2024-07-12 10:23:29 +01:00

39 lines
1.1 KiB
TypeScript

import { DragDropContext, Droppable, DropResult } from '@hello-pangea/dnd';
import { FieldSet } from '@grafana/ui';
import { t } from 'app/core/internationalization';
import { PlaylistTableRows } from './PlaylistTableRows';
import { PlaylistItem } from './types';
interface Props {
items: PlaylistItem[];
deleteItem: (idx: number) => void;
moveItem: (src: number, dst: number) => void;
}
export const PlaylistTable = ({ items, deleteItem, moveItem }: Props) => {
const onDragEnd = (d: DropResult) => {
if (d.destination) {
moveItem(d.source.index, d.destination?.index);
}
};
return (
<FieldSet label={t('playlist-edit.form.table-heading', 'Dashboards')}>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="playlist-list" direction="vertical">
{(provided) => {
return (
<div ref={provided.innerRef} {...provided.droppableProps}>
<PlaylistTableRows items={items} onDelete={deleteItem} />
{provided.placeholder}
</div>
);
}}
</Droppable>
</DragDropContext>
</FieldSet>
);
};