Skip to content

Commit

Permalink
fix: TKC-779 (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
haneabogdan authored Oct 30, 2023
1 parent e0e29e4 commit 8233b07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {ConfigContext} from '@contexts';

import {Button, Text, Title} from '@custom-antd';

import {SystemAccess, useSystemAccess} from '@hooks/useSystemAccess';

import {HelpCard} from '@molecules';
import {StyledHelpCardsContainer, StyledLastHelpCardContainer} from '@molecules/HelpCard/HelpCard.styled';

Expand All @@ -27,6 +25,7 @@ type EmptyListContentProps = {
emptyListReadonlyTitle?: string;
emptyListReadonlyDescription?: string;
actionType: 'create' | 'run';
isReadOnly?: boolean;
};

const actionTypeToPermission: Record<EmptyListContentProps['actionType'], Permissions> = {
Expand All @@ -44,10 +43,10 @@ const EmptyListContent: React.FC<PropsWithChildren<EmptyListContentProps>> = pro
emptyListReadonlyTitle,
emptyListReadonlyDescription,
actionType,
isReadOnly,
} = props;

const {discordUrl} = useContext(ConfigContext);
const isClusterAvailable = useSystemAccess(SystemAccess.agent);
const isActionAvailable = usePermission(actionTypeToPermission[actionType]);

return (
Expand All @@ -59,7 +58,7 @@ const EmptyListContent: React.FC<PropsWithChildren<EmptyListContentProps>> = pro
<Text className="regular middle text-center" color={Colors.slate400}>
{description}
</Text>
{isClusterAvailable ? (
{!isReadOnly ? (
<Button $customType="primary" onClick={onButtonClick}>
{buttonText}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const EmptyExecutionsListContent: React.FC<EmptyExecutionsListContentProps> = pr
const {id, entity, details} = useEntityDetailsPick('id', 'entity', 'details');
const onAddSteps = useDashboardNavigate(`/${entity}/${id}/settings/tests`);
const mayRun = usePermission(Permissions.runEntity);
const isReadOnly = details?.readOnly;

if (!details) {
return null;
Expand All @@ -45,11 +46,16 @@ const EmptyExecutionsListContent: React.FC<EmptyExecutionsListContentProps> = pr
if (entity === 'tests') {
return (
<EmptyListContent
title="Trigger your first run"
description="Your test has no past executions. Trigger the first run!"
title={isReadOnly ? 'No past executions' : 'Trigger your first run'}
description={
isReadOnly
? 'Adjust the timeframe to view older executions.'
: 'Your test has no past executions. Trigger the first run!'
}
buttonText="Run this test now"
onButtonClick={onRun}
actionType="run"
isReadOnly={isReadOnly}
/>
);
}
Expand All @@ -62,6 +68,7 @@ const EmptyExecutionsListContent: React.FC<EmptyExecutionsListContentProps> = pr
buttonText="Add your tests to this suite"
onButtonClick={onAddSteps}
actionType="create"
isReadOnly={isReadOnly}
>
<HelpCard isLink link={externalLinks.createTestSuite}>
Learn how to add test suites
Expand All @@ -72,11 +79,16 @@ const EmptyExecutionsListContent: React.FC<EmptyExecutionsListContentProps> = pr

return (
<EmptyListContent
title="Trigger your first run"
description="Your test suite has no past executions. Trigger the first run!"
title={isReadOnly ? 'No past executions' : 'Trigger your first run'}
description={
isReadOnly
? 'Adjust the timeframe to view older executions.'
: 'Your test suite has no past executions. Trigger the first run!'
}
buttonText="Run this test suite"
onButtonClick={onRun}
actionType="run"
isReadOnly={isReadOnly}
/>
);
};
Expand Down

0 comments on commit 8233b07

Please sign in to comment.