use icons for running unit tests, w/ lantz

This commit is contained in:
burnettk 2023-06-01 10:43:27 -04:00
parent 619f7e41bd
commit b02c28697d
2 changed files with 22 additions and 42 deletions

View File

@ -1,4 +1,4 @@
import { PlayOutline, Checkmark, Close } from '@carbon/icons-react'; import { Rule, Checkmark, Close } from '@carbon/icons-react';
import { Button, Modal } from '@carbon/react'; import { Button, Modal } from '@carbon/react';
import { useState } from 'react'; import { useState } from 'react';
import { useUriListForPermissions } from '../hooks/UriListForPermissions'; import { useUriListForPermissions } from '../hooks/UriListForPermissions';
@ -11,12 +11,12 @@ import {
type OwnProps = { type OwnProps = {
processModelFile?: ProcessFile; processModelFile?: ProcessFile;
buttonType?: string; titleText: string;
}; };
export default function ProcessModelTestRun({ export default function ProcessModelTestRun({
processModelFile, processModelFile,
buttonType = 'icon', titleText,
}: OwnProps) { }: OwnProps) {
const [testCaseResults, setTestCaseResults] = const [testCaseResults, setTestCaseResults] =
useState<TestCaseResults | null>(null); useState<TestCaseResults | null>(null);
@ -153,29 +153,16 @@ export default function ProcessModelTestRun({
}; };
const buttonElement = () => { const buttonElement = () => {
if (buttonType === 'icon') { return (
return ( <Button
<Button kind="ghost"
kind="ghost" renderIcon={Rule}
renderIcon={PlayOutline} iconDescription={titleText}
iconDescription="Run BPMN unit tests defined in this file" hasIconOnly
hasIconOnly size="lg"
size="lg" onClick={() => onProcessModelTestRun()}
onClick={() => onProcessModelTestRun()} />
/> );
);
}
if (buttonType === 'text') {
return (
<Button
onClick={() => onProcessModelTestRun()}
title="Run all BPMN unit tests for this process model"
>
Run Unit Tests
</Button>
);
}
return null;
}; };
return ( return (

View File

@ -324,7 +324,10 @@ export default function ProcessModelShow() {
if (isTestCaseFile(processModelFile)) { if (isTestCaseFile(processModelFile)) {
elements.push( elements.push(
<Can I="POST" a={targetUris.processModelTestsPath} ability={ability}> <Can I="POST" a={targetUris.processModelTestsPath} ability={ability}>
<ProcessModelTestRun processModelFile={processModelFile} /> <ProcessModelTestRun
processModelFile={processModelFile}
titleText="Run BPMN unit tests defined in this file"
/>
</Can> </Can>
); );
} }
@ -664,6 +667,11 @@ export default function ProcessModelShow() {
disabled={publishDisabled} disabled={publishDisabled}
/> />
</Can> </Can>
<Can I="POST" a={targetUris.processModelTestsPath} ability={ability}>
{hasTestCaseFiles ? (
<ProcessModelTestRun titleText="Run all BPMN unit tests for this process model" />
) : null}
</Can>
</Stack> </Stack>
<p className="process-description">{processModel.description}</p> <p className="process-description">{processModel.description}</p>
<Stack orientation="horizontal" gap={3}> <Stack orientation="horizontal" gap={3}>
@ -681,21 +689,6 @@ export default function ProcessModelShow() {
<br /> <br />
</> </>
</Can> </Can>
<Can
I="POST"
a={targetUris.processModelPublishPath}
ability={ability}
>
<Can
I="POST"
a={targetUris.processModelTestsPath}
ability={ability}
>
{hasTestCaseFiles ? (
<ProcessModelTestRun buttonType="text" />
) : null}
</Can>
</Can>
</Stack> </Stack>
{processModelFilesSection()} {processModelFilesSection()}
<Can I="GET" a={targetUris.processInstanceListPath} ability={ability}> <Can I="GET" a={targetUris.processInstanceListPath} ability={ability}>