mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
* remove some gf-form * couple more transformations * clean up Playlists * review comments * fix unit tests
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { DragDropContext, Droppable, DropResult } from 'react-beautiful-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>
|
|
);
|
|
};
|