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
This commit is contained in:
Piotr Jamróz 2023-04-05 21:08:12 +02:00 committed by GitHub
parent f27326f7d9
commit 90b15d41bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -162,7 +162,9 @@ export default function CorrelationsPage() {
</div>
)}
{showEmptyListCTA && <EmptyCorrelationsCTA onClick={() => setIsAdding(true)} />}
{showEmptyListCTA && (
<EmptyCorrelationsCTA canWriteCorrelations={canWriteCorrelations} onClick={() => setIsAdding(true)} />
)}
{
// This error is not actionable, it'd be nice to have a recovery button

View File

@ -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 ? (
<EmptyListCTA
title="You haven't defined any correlation yet."
buttonIcon="gf-glue"
@ -16,5 +18,10 @@ export const EmptyCorrelationsCTA = ({ onClick }: Props) => {
buttonTitle="Add correlation"
proTip="you can also define correlations via datasource provisioning"
/>
) : (
<Card>
<Card.Heading>There are no correlations configured yet.</Card.Heading>
<Card.Description>Please contact your administrator to create new correlations.</Card.Description>
</Card>
);
};