diff --git a/public/app/features/alerting/unified/rule-list/components/DataSourceSection.tsx b/public/app/features/alerting/unified/rule-list/components/DataSourceSection.tsx index 9df0aa641b3..11f4f5cbf01 100644 --- a/public/app/features/alerting/unified/rule-list/components/DataSourceSection.tsx +++ b/public/app/features/alerting/unified/rule-list/components/DataSourceSection.tsx @@ -1,14 +1,16 @@ import { css } from '@emotion/css'; import { PropsWithChildren, ReactNode } from 'react'; +import { useToggle } from 'react-use'; import { GrafanaTheme2 } from '@grafana/data'; -import { LinkButton, Stack, Text, useStyles2 } from '@grafana/ui'; +import { IconButton, LinkButton, Stack, Text, useStyles2 } from '@grafana/ui'; import { Trans, t } from 'app/core/internationalization'; -import { RulesSourceIdentifier } from 'app/types/unified-alerting'; +import { GrafanaRulesSourceSymbol, RulesSourceIdentifier } from 'app/types/unified-alerting'; import { RulesSourceApplication } from 'app/types/unified-alerting-dto'; import { Spacer } from '../../components/Spacer'; import { WithReturnButton } from '../../components/WithReturnButton'; +import { isAdmin } from '../../utils/misc'; import { DataSourceIcon } from './Namespace'; import { LoadingIndicator } from './RuleGroup'; @@ -32,7 +34,17 @@ export const DataSourceSection = ({ description = null, }: DataSourceSectionProps) => { const styles = useStyles2(getStyles); - + const [isCollapsed, toggleCollapsed] = useToggle(false); + const configureLink = (() => { + if (uid === GrafanaRulesSourceSymbol) { + const userIsAdmin = isAdmin(); + if (!userIsAdmin) { + return; + } + return '/alerting/admin'; + } + return `/connections/datasources/edit/${String(uid)}`; + })(); return (
@@ -41,7 +53,13 @@ export const DataSourceSection = ({
{loader ?? ( + {application && } + {name} @@ -52,19 +70,21 @@ export const DataSourceSection = ({ )} - - Configure - - } - /> + {configureLink && ( + + Configure + + } + /> + )} )}
-
{children}
+ {!isCollapsed &&
{children}
}
);