mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* PlaylistPage: removes search due to no wildcard support * PlaylistPage: adds back search input and wildcard search support * makes banner to appear only when playlist does not exist * Chore: small refactor * Chore: some code refactoring to make it readable * fixes focus leaving input when query is cleared * adds styling to the emptyQueryList banner * extracts emptyQueryListBanner component to a separate file * adds debounce to search * use new theme for styling * Chore: some nit fix * fixes empty list banner showing for a second before the full list is loaded * Fix: removes search when playlist is empty Co-authored-by: Ash <ashharrison90@gmail.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { PlaylistDTO } from './types';
|
|
import { Button, Card, LinkButton } from '@grafana/ui';
|
|
import { contextSrv } from 'app/core/services/context_srv';
|
|
|
|
interface Props {
|
|
setStartPlaylist: (playlistItem: PlaylistDTO) => void;
|
|
setPlaylistToDelete: (playlistItem: PlaylistDTO) => void;
|
|
playlists: PlaylistDTO[] | undefined;
|
|
}
|
|
|
|
export const PlaylistPageList = ({ playlists, setStartPlaylist, setPlaylistToDelete }: Props) => {
|
|
return (
|
|
<>
|
|
{playlists!.map((playlist: PlaylistDTO) => (
|
|
<Card heading={playlist.name} key={playlist.id.toString()}>
|
|
<Card.Actions>
|
|
<Button variant="secondary" icon="play" onClick={() => setStartPlaylist(playlist)}>
|
|
Start playlist
|
|
</Button>
|
|
{contextSrv.isEditor && (
|
|
<>
|
|
<LinkButton key="edit" variant="secondary" href={`/playlists/edit/${playlist.id}`} icon="cog">
|
|
Edit playlist
|
|
</LinkButton>
|
|
<Button
|
|
disabled={false}
|
|
onClick={() => setPlaylistToDelete({ id: playlist.id, name: playlist.name })}
|
|
icon="trash-alt"
|
|
variant="destructive"
|
|
>
|
|
Delete playlist
|
|
</Button>
|
|
</>
|
|
)}
|
|
</Card.Actions>
|
|
</Card>
|
|
))}
|
|
</>
|
|
);
|
|
};
|