grafana/public/app/features/playlist/PlaylistPageList.tsx
Uchechukwu Obasi eb2e1197e9
PlaylistPage: fix search input (#39226)
* 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>
2021-09-22 10:45:29 +01:00

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>
))}
</>
);
};