2022-09-05 22:40:01 -05:00
import React , { useState } from 'react' ;
2022-04-22 08:33:13 -05:00
2022-09-13 10:18:50 -05:00
import { NavModelItem } from '@grafana/data' ;
2021-03-23 01:45:04 -05:00
import { locationService } from '@grafana/runtime' ;
2022-07-06 10:00:56 -05:00
import { Page } from 'app/core/components/Page/Page' ;
2022-04-22 08:33:13 -05:00
2021-03-23 01:45:04 -05:00
import { PlaylistForm } from './PlaylistForm' ;
2022-09-05 22:40:01 -05:00
import { createPlaylist , getDefaultPlaylist } from './api' ;
2021-03-23 01:45:04 -05:00
import { Playlist } from './types' ;
2022-07-20 10:26:52 -05:00
export const PlaylistNewPage = ( ) = > {
2022-09-05 22:40:01 -05:00
const [ playlist ] = useState < Playlist > ( getDefaultPlaylist ( ) ) ;
2021-03-23 01:45:04 -05:00
const onSubmit = async ( playlist : Playlist ) = > {
await createPlaylist ( playlist ) ;
locationService . push ( '/playlists' ) ;
} ;
2022-09-13 10:18:50 -05:00
const pageNav : NavModelItem = {
text : 'New playlist' ,
subTitle :
'A playlist rotates through a pre-selected list of dashboards. A playlist can be a great way to build situational awareness, or just show off your metrics to your team or visitors.' ,
} ;
2021-03-23 01:45:04 -05:00
return (
2022-09-13 10:18:50 -05:00
< Page navId = "dashboards/playlists" pageNav = { pageNav } >
2022-09-05 22:40:01 -05:00
< Page.Contents >
2021-03-23 01:45:04 -05:00
< PlaylistForm onSubmit = { onSubmit } playlist = { playlist } / >
< / Page.Contents >
< / Page >
) ;
} ;
2022-07-20 10:26:52 -05:00
export default PlaylistNewPage ;