<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <img width="771" alt="Screenshot 2024-05-24 at 3 48 22 PM" src="https://github.com/nrwl/nx/assets/16211801/11ad5526-8449-4b9f-9e02-296903855dd5"> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { ExternalLink } from '@nx/graph/ui-tooltips';
|
|
|
|
export interface TargetExecutorProps {
|
|
command?: string;
|
|
commands?: string[];
|
|
script?: string;
|
|
executor?: string;
|
|
isCompact?: boolean;
|
|
link?: string;
|
|
}
|
|
|
|
export function TargetExecutor({
|
|
command,
|
|
commands,
|
|
script,
|
|
executor,
|
|
isCompact,
|
|
link,
|
|
}: TargetExecutorProps) {
|
|
if (script) {
|
|
return link ? <ExternalLink href={link}>{script}</ExternalLink> : script;
|
|
}
|
|
|
|
if (commands) {
|
|
if (isCompact) {
|
|
return link ? (
|
|
<ExternalLink href={link}>
|
|
{commands.length === 1 ? commands[0] : executor}
|
|
</ExternalLink>
|
|
) : commands.length === 1 ? (
|
|
commands[0]
|
|
) : (
|
|
executor
|
|
);
|
|
}
|
|
return (
|
|
<ul>
|
|
{commands?.map((c) =>
|
|
c ? (
|
|
<li>{link ? <ExternalLink href={link}>{c}</ExternalLink> : c}</li>
|
|
) : null
|
|
)}
|
|
</ul>
|
|
);
|
|
}
|
|
|
|
const displayText = command ?? executor ?? '';
|
|
return link ? (
|
|
<ExternalLink href={link}>{displayText}</ExternalLink>
|
|
) : (
|
|
displayText
|
|
);
|
|
}
|