2021-03-23 01:45:04 -05:00
|
|
|
import React, { FC } from 'react';
|
|
|
|
import { connect, MapStateToProps } from 'react-redux';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-03-23 01:45:04 -05:00
|
|
|
import { NavModel } from '@grafana/data';
|
|
|
|
import { locationService } from '@grafana/runtime';
|
2021-04-28 09:05:00 -05:00
|
|
|
import { useStyles2 } from '@grafana/ui';
|
2021-03-23 01:45:04 -05:00
|
|
|
import Page from 'app/core/components/Page/Page';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
2021-03-23 01:45:04 -05:00
|
|
|
import { StoreState } from 'app/types';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-03-23 01:45:04 -05:00
|
|
|
import { GrafanaRouteComponentProps } from '../../core/navigation/types';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-03-23 01:45:04 -05:00
|
|
|
import { PlaylistForm } from './PlaylistForm';
|
|
|
|
import { createPlaylist } from './api';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { getPlaylistStyles } from './styles';
|
2021-03-23 01:45:04 -05:00
|
|
|
import { Playlist } from './types';
|
|
|
|
import { usePlaylist } from './usePlaylist';
|
|
|
|
|
|
|
|
interface ConnectedProps {
|
|
|
|
navModel: NavModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Props extends ConnectedProps, GrafanaRouteComponentProps {}
|
|
|
|
|
|
|
|
export const PlaylistNewPage: FC<Props> = ({ navModel }) => {
|
2021-04-28 09:05:00 -05:00
|
|
|
const styles = useStyles2(getPlaylistStyles);
|
2021-03-23 01:45:04 -05:00
|
|
|
const { playlist, loading } = usePlaylist();
|
|
|
|
const onSubmit = async (playlist: Playlist) => {
|
|
|
|
await createPlaylist(playlist);
|
|
|
|
locationService.push('/playlists');
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Page navModel={navModel}>
|
|
|
|
<Page.Contents isLoading={loading}>
|
|
|
|
<h3 className={styles.subHeading}>New Playlist</h3>
|
|
|
|
|
|
|
|
<p className={styles.description}>
|
2021-03-31 18:07:37 -05:00
|
|
|
A playlist rotates through a pre-selected list of dashboards. A playlist can be a great way to build
|
2021-03-23 01:45:04 -05:00
|
|
|
situational awareness, or just show off your metrics to your team or visitors.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<PlaylistForm onSubmit={onSubmit} playlist={playlist} />
|
|
|
|
</Page.Contents>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps: MapStateToProps<ConnectedProps, {}, StoreState> = (state: StoreState) => ({
|
|
|
|
navModel: getNavModel(state.navIndex, 'playlists'),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(PlaylistNewPage);
|