fix(graph): add better pdv empty states when no targets exist (#28797)

This commit is contained in:
MaxKless 2024-11-07 17:02:16 +01:00 committed by GitHub
parent a1fe42b158
commit 0d746ef587
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 58 additions and 1 deletions

View File

@ -94,3 +94,25 @@ export const TwoTargets: Story = {
collapseAllTargets: () => {}, collapseAllTargets: () => {},
} as TargetConfigurationGroupListProps, } as TargetConfigurationGroupListProps,
}; };
export const NoTargets: Story = {
args: {
project: {
name: 'react',
type: 'lib',
data: {
root: 'libs/react',
targets: {},
},
},
sourceMap: {
react: ['react'],
},
variant: 'default',
onRunTarget: () => {},
onViewInTaskGraph: () => {},
selectedTargetGroup: 'build',
setExpandTargets: () => {},
collapseAllTargets: () => {},
} as TargetConfigurationGroupListProps,
};

View File

@ -100,7 +100,7 @@ export function TargetConfigurationGroupList({
</TargetConfigurationGroupContainer> </TargetConfigurationGroupContainer>
</> </>
); );
} else { } else if (targetsGroup.targets.length > 0) {
return ( return (
<ul className={className}> <ul className={className}>
{targetsGroup.targets.map((targetName) => { {targetsGroup.targets.map((targetName) => {
@ -122,5 +122,40 @@ export function TargetConfigurationGroupList({
})} })}
</ul> </ul>
); );
} else {
return (
<div className="pt-4">
<p className="mb-2">No targets configured.</p>
<p>
There are two ways to create targets:
<ul className="ml-6 mt-2 list-disc space-y-2">
<li>
<a
href="https://nx.dev/plugin-registry"
className="text-slate-500 hover:underline dark:text-slate-400"
>
Add an Nx plugin
</a>{' '}
that{' '}
<a
href="https://nx.dev/concepts/inferred-tasks"
className="text-slate-500 hover:underline dark:text-slate-400"
>
infers targets for you
</a>
</li>
<li>
Manually define targets in the{' '}
<a
href="https://nx.dev/reference/project-configuration#task-definitions-targets"
className="text-slate-500 hover:underline dark:text-slate-400"
>
project configuration targets property
</a>
</li>
</ul>
</p>
</div>
);
} }
} }