From bd19a06fa951e140e939e0a92bb49b70f4b952f1 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 13 Sep 2022 16:18:50 +0100 Subject: [PATCH] Update create/edit playlist pages to work with topnav (#55104) --- .../features/playlist/PlaylistEditPage.tsx | 27 +++++++------------ .../app/features/playlist/PlaylistNewPage.tsx | 19 ++++++------- public/app/features/playlist/styles.ts | 17 ------------ 3 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 public/app/features/playlist/styles.ts diff --git a/public/app/features/playlist/PlaylistEditPage.tsx b/public/app/features/playlist/PlaylistEditPage.tsx index d72018ec05f..87081223d53 100644 --- a/public/app/features/playlist/PlaylistEditPage.tsx +++ b/public/app/features/playlist/PlaylistEditPage.tsx @@ -1,14 +1,13 @@ import React from 'react'; import { useAsync } from 'react-use'; +import { NavModelItem } from '@grafana/data'; import { locationService } from '@grafana/runtime'; -import { useStyles2 } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; import { PlaylistForm } from './PlaylistForm'; import { getPlaylist, updatePlaylist } from './api'; -import { getPlaylistStyles } from './styles'; import { Playlist } from './types'; export interface RouteParams { @@ -18,7 +17,6 @@ export interface RouteParams { interface Props extends GrafanaRouteComponentProps {} export const PlaylistEditPage = ({ match }: Props) => { - const styles = useStyles2(getPlaylistStyles); const playlist = useAsync(() => getPlaylist(match.params.uid), [match.params]); const onSubmit = async (playlist: Playlist) => { @@ -26,23 +24,18 @@ export const PlaylistEditPage = ({ match }: Props) => { locationService.push('/playlists'); }; - return ( - - -

Edit playlist

+ const pageNav: NavModelItem = { + text: 'Edit 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.', + }; + return ( + + {playlist.error &&
Error loading playlist: {JSON.stringify(playlist.error)}
} - {playlist.value && ( - <> -

- 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. -

- - - - )} + {playlist.value && }
); diff --git a/public/app/features/playlist/PlaylistNewPage.tsx b/public/app/features/playlist/PlaylistNewPage.tsx index 5437fdbba7c..2c6a8eb5ef1 100644 --- a/public/app/features/playlist/PlaylistNewPage.tsx +++ b/public/app/features/playlist/PlaylistNewPage.tsx @@ -1,16 +1,14 @@ import React, { useState } from 'react'; +import { NavModelItem } from '@grafana/data'; import { locationService } from '@grafana/runtime'; -import { useStyles2 } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import { PlaylistForm } from './PlaylistForm'; import { createPlaylist, getDefaultPlaylist } from './api'; -import { getPlaylistStyles } from './styles'; import { Playlist } from './types'; export const PlaylistNewPage = () => { - const styles = useStyles2(getPlaylistStyles); const [playlist] = useState(getDefaultPlaylist()); const onSubmit = async (playlist: Playlist) => { @@ -18,16 +16,15 @@ export const PlaylistNewPage = () => { locationService.push('/playlists'); }; + 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.', + }; + return ( - + -

New Playlist

- -

- 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. -

-
diff --git a/public/app/features/playlist/styles.ts b/public/app/features/playlist/styles.ts deleted file mode 100644 index 0d04725bae5..00000000000 --- a/public/app/features/playlist/styles.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { css } from '@emotion/css'; - -import { GrafanaTheme2 } from '@grafana/data'; - -export function getPlaylistStyles(theme: GrafanaTheme2) { - return { - description: css` - label: description; - width: 555px; - margin-bottom: 20px; - `, - subHeading: css` - label: sub-heading; - margin-bottom: ${theme.spacing(2)}; - `, - }; -}