From 90b15d41bff7385941807dd709d8fddc56df07f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jamr=C3=B3z?= Date: Wed, 5 Apr 2023 21:08:12 +0200 Subject: [PATCH] Correlations: Don't show Add button in empty call-to-action page when user has no sufficient permissions (#66006) Do not show add correlation button if user has no permissions to add new correlations --- public/app/features/correlations/CorrelationsPage.tsx | 4 +++- .../correlations/components/EmptyCorrelationsCTA.tsx | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/public/app/features/correlations/CorrelationsPage.tsx b/public/app/features/correlations/CorrelationsPage.tsx index 9f1904f07ae..57f2d08924e 100644 --- a/public/app/features/correlations/CorrelationsPage.tsx +++ b/public/app/features/correlations/CorrelationsPage.tsx @@ -162,7 +162,9 @@ export default function CorrelationsPage() { )} - {showEmptyListCTA && setIsAdding(true)} />} + {showEmptyListCTA && ( + setIsAdding(true)} /> + )} { // This error is not actionable, it'd be nice to have a recovery button diff --git a/public/app/features/correlations/components/EmptyCorrelationsCTA.tsx b/public/app/features/correlations/components/EmptyCorrelationsCTA.tsx index 56546672601..1228224ffc2 100644 --- a/public/app/features/correlations/components/EmptyCorrelationsCTA.tsx +++ b/public/app/features/correlations/components/EmptyCorrelationsCTA.tsx @@ -1,14 +1,16 @@ import React from 'react'; +import { Card } from '@grafana/ui'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; interface Props { onClick?: () => void; + canWriteCorrelations: boolean; } -export const EmptyCorrelationsCTA = ({ onClick }: Props) => { +export const EmptyCorrelationsCTA = ({ onClick, canWriteCorrelations }: Props) => { // TODO: if there are no datasources show a different message - return ( + return canWriteCorrelations ? ( { buttonTitle="Add correlation" proTip="you can also define correlations via datasource provisioning" /> + ) : ( + + There are no correlations configured yet. + Please contact your administrator to create new correlations. + ); };