diff --git a/packages/grafana-ui/src/components/Collapse/CollapsableSection.tsx b/packages/grafana-ui/src/components/Collapse/CollapsableSection.tsx index e11a7f57657..07ceb023fe6 100644 --- a/packages/grafana-ui/src/components/Collapse/CollapsableSection.tsx +++ b/packages/grafana-ui/src/components/Collapse/CollapsableSection.tsx @@ -1,5 +1,5 @@ import React, { FC, ReactNode, useState } from 'react'; -import { css } from 'emotion'; +import { css, cx } from 'emotion'; import { GrafanaTheme } from '@grafana/data'; import { useStyles } from '../../themes'; import { Icon } from '..'; @@ -13,14 +13,20 @@ export interface Props { export const CollapsableSection: FC = ({ label, isOpen, children }) => { const [open, toggleOpen] = useState(isOpen); const styles = useStyles(collapsableSectionStyles); + const headerClass = cx({ + [styles.header]: true, + [styles.headerCollapsed]: !open, + }); + + const tooltip = `Click to ${open ? 'collapse' : 'expand'}`; return (
-
toggleOpen(!open)} className={styles.header}> - +
toggleOpen(!open)} className={headerClass} title={tooltip}> {label} +
-
{open && children}
+ {open &&
{children}
}
); }; @@ -28,11 +34,19 @@ export const CollapsableSection: FC = ({ label, isOpen, children }) => { const collapsableSectionStyles = (theme: GrafanaTheme) => { return { header: css` + display: flex; + justify-content: space-between; font-size: ${theme.typography.size.lg}; cursor: pointer; `, + headerCollapsed: css` + border-bottom: 1px solid ${theme.colors.border2}; + `, + icon: css` + color: ${theme.colors.textWeak}; + `, content: css` - padding: ${theme.spacing.md} 0 ${theme.spacing.md} ${theme.spacing.md}; + padding: ${theme.spacing.md} 0; `, }; }; diff --git a/public/app/features/alerting/EditNotificationChannelPage.tsx b/public/app/features/alerting/EditNotificationChannelPage.tsx index 8d1bfa15710..1f92cb44839 100644 --- a/public/app/features/alerting/EditNotificationChannelPage.tsx +++ b/public/app/features/alerting/EditNotificationChannelPage.tsx @@ -86,7 +86,7 @@ export class EditNotificationChannelPage extends PureComponent {

Edit notification channel

{notificationChannel && notificationChannel.id > 0 ? (
{

New notification channel

- + {({ register, errors, control, getValues, watch }) => { const selectedChannel = notificationChannelTypes.find(c => c.value === getValues().type.value); diff --git a/public/app/features/alerting/components/BasicSettings.tsx b/public/app/features/alerting/components/BasicSettings.tsx index 9f686f541f4..c3373e7d945 100644 --- a/public/app/features/alerting/components/BasicSettings.tsx +++ b/public/app/features/alerting/components/BasicSettings.tsx @@ -1,6 +1,6 @@ import React, { FC } from 'react'; import { SelectableValue } from '@grafana/data'; -import { CollapsableSection, Field, Input, InputControl, Select } from '@grafana/ui'; +import { Field, Input, InputControl, Select } from '@grafana/ui'; import { NotificationChannelOptions } from './NotificationChannelOptions'; import { NotificationSettingsProps } from './NotificationChannelForm'; import { NotificationChannelSecureFields, NotificationChannelType } from '../../../types'; @@ -23,7 +23,7 @@ export const BasicSettings: FC = ({ resetSecureField, }) => { return ( - + <> @@ -39,6 +39,6 @@ export const BasicSettings: FC = ({ errors={errors} control={control} /> - + ); }; diff --git a/public/app/features/alerting/components/NotificationChannelForm.tsx b/public/app/features/alerting/components/NotificationChannelForm.tsx index 29fd9afc0ac..28b23697838 100644 --- a/public/app/features/alerting/components/NotificationChannelForm.tsx +++ b/public/app/features/alerting/components/NotificationChannelForm.tsx @@ -41,9 +41,14 @@ export const NotificationChannelForm: FC = ({ }, []); const currentFormValues = getValues(); - return selectedChannel ? ( - <> -
+ + if (!selectedChannel) { + return ; + } + + return ( +
+
= ({ errors={errors} control={control} /> - {/* If there are no non-required fields, don't render this section*/} - {selectedChannel.options.filter(o => !o.required).length > 0 && ( +
+ {/* If there are no non-required fields, don't render this section*/} + {selectedChannel.options.filter(o => !o.required).length > 0 && ( +
= ({ errors={errors} control={control} /> - )} +
+ )} +
= ({ control={control} />
- - - - - + - - - - ) : ( - + + + + +
+
); }; const getStyles = stylesFactory((theme: GrafanaTheme) => { return { - basicSettings: css` - margin-bottom: ${theme.spacing.xl}; + formContainer: css``, + formItem: css` + flex-grow: 1; + padding-top: ${theme.spacing.md}; + `, + formButtons: css` + padding-top: ${theme.spacing.xl}; `, }; }); diff --git a/public/app/features/alerting/components/NotificationChannelOptions.tsx b/public/app/features/alerting/components/NotificationChannelOptions.tsx index 52fb6eaa9f9..9b3bba4618d 100644 --- a/public/app/features/alerting/components/NotificationChannelOptions.tsx +++ b/public/app/features/alerting/components/NotificationChannelOptions.tsx @@ -59,9 +59,14 @@ export const NotificationChannelOptions: FC = ({ onResetSecureField(option.propertyName)} variant="secondary" type="button"> - Reset + suffix={ + } />