Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graph): update atomizer metadata & pdv hint #26733

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions graph/project-details/src/lib/project-details-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ export function ProjectDetailsWrapper({
environment === 'nx-console' ? 'bottom' : 'top'
}
connectedToCloud={connectedToCloud}
nxConnectCallback={
environment === 'nx-console' ? handleNxConnect : undefined
}
onNxConnect={environment === 'nx-console' ? handleNxConnect : undefined}
/>
<ErrorToast errors={errors} />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ProjectDetailsProps {
targetName: string;
}) => void;
onRunTarget?: (data: { projectName: string; targetName: string }) => void;
nxConnectCallback?: () => void;
onNxConnect?: () => void;
viewInProjectGraphPosition?: 'top' | 'bottom';
}

Expand All @@ -43,7 +43,7 @@ export const ProjectDetails = ({
onViewInProjectGraph,
onViewInTaskGraph,
onRunTarget,
nxConnectCallback,
onNxConnect,
viewInProjectGraphPosition = 'top',
connectedToCloud,
}: ProjectDetailsProps) => {
Expand Down Expand Up @@ -166,7 +166,7 @@ export const ProjectDetails = ({
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
connectedToCloud={connectedToCloud}
nxConnectCallback={nxConnectCallback}
onNxConnect={onNxConnect}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ import { TargetConfigurationGroupHeader } from '../target-configuration-details-
export interface TargetConfigurationGroupContainerProps {
targetGroupName: string;
targetsNumber: number;
nonAtomizedTarget?: string;
connectedToCloud?: boolean;
nxConnectCallback?: () => void;
children: React.ReactNode;
}

export function TargetConfigurationGroupContainer({
targetGroupName,
targetsNumber,
nonAtomizedTarget,
connectedToCloud,
nxConnectCallback,
children,
}: TargetConfigurationGroupContainerProps) {
if (targetsNumber === 0) {
Expand All @@ -25,9 +19,6 @@ export function TargetConfigurationGroupContainer({
<TargetConfigurationGroupHeader
targetGroupName={targetGroupName}
targetsNumber={targetsNumber}
nonAtomizedTarget={nonAtomizedTarget}
connectedToCloud={connectedToCloud}
nxConnectCallback={nxConnectCallback}
className="sticky top-0 z-10 bg-white dark:bg-slate-900"
/>
<div className="rounded-md border border-slate-200 p-2 dark:border-slate-700">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,33 @@
import { AtomizerTooltip, Tooltip } from '@nx/graph/ui-tooltips';
import { Pill } from '../pill';
import { Square3Stack3DIcon } from '@heroicons/react/24/outline';

export interface TargetConfigurationGroupHeaderProps {
targetGroupName: string;
targetsNumber: number;
className?: string;
nonAtomizedTarget?: string;
connectedToCloud?: boolean;
nxConnectCallback?: () => void;
showIcon?: boolean;
}

export const TargetConfigurationGroupHeader = ({
targetGroupName,
targetsNumber,
nonAtomizedTarget,
connectedToCloud = true,
nxConnectCallback,

className = '',
}: TargetConfigurationGroupHeaderProps) => {
return (
<header
className={`flex items-center gap-2 px-4 py-2 text-lg capitalize ${className}`}
>
{targetGroupName}{' '}
{nonAtomizedTarget && <Square3Stack3DIcon className="h-5 w-5" />}
{targetGroupName !== 'Others' && (
xiongemi marked this conversation as resolved.
Show resolved Hide resolved
<Square3Stack3DIcon className="h-5 w-5" />
)}
<Pill
text={
targetsNumber.toString() +
(targetsNumber === 1 ? ' target' : ' targets')
}
/>
{nonAtomizedTarget && (
<Tooltip
openAction="hover"
strategy="fixed"
usePortal={true}
content={
(
<AtomizerTooltip
connectedToCloud={connectedToCloud}
nonAtomizedTarget={nonAtomizedTarget}
nxConnectCallback={nxConnectCallback}
/>
) as any
}
>
<span className="inline-flex">
<Pill
color={connectedToCloud ? 'grey' : 'yellow'}
text={'Atomizer'}
/>
</span>
</Tooltip>
)}
</header>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import type { ProjectGraphProjectNode } from '@nx/devkit';

import { TargetConfigurationDetailsListItem } from '../target-configuration-details-list-item/target-configuration-details-list-item';
import { TargetConfigurationGroupContainer } from '../target-configuration-details-group-container/target-configuration-details-group-container';
import {
getNonAtomizedTargetForGroup,
groupTargets,
} from '../utils/group-targets';
import { groupTargets } from '../utils/group-targets';
import { useMemo } from 'react';

export interface TargetConfigurationGroupListProps {
Expand All @@ -19,7 +16,7 @@ export interface TargetConfigurationGroupListProps {
projectName: string;
targetName: string;
}) => void;
nxConnectCallback?: () => void;
onNxConnect?: () => void;
connectedToCloud?: boolean;
className?: string;
}
Expand All @@ -30,7 +27,7 @@ export function TargetConfigurationGroupList({
sourceMap,
onRunTarget,
onViewInTaskGraph,
nxConnectCallback,
onNxConnect,
className = '',
connectedToCloud,
}: TargetConfigurationGroupListProps) {
Expand All @@ -51,22 +48,18 @@ export function TargetConfigurationGroupList({
<TargetConfigurationGroupContainer
targetGroupName={targetGroupName}
targetsNumber={targets.length}
nonAtomizedTarget={getNonAtomizedTargetForGroup(
project,
targetGroupName
)}
connectedToCloud={connectedToCloud}
nxConnectCallback={nxConnectCallback}
key={targetGroupName}
>
<ul className={className}>
{targets.map((targetName) => (
<TargetConfigurationDetailsListItem
project={project}
sourceMap={sourceMap}
connectedToCloud={connectedToCloud}
variant={variant}
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
onNxConnect={onNxConnect}
targetName={targetName}
collapsable={true}
key={targetName}
Expand All @@ -88,9 +81,11 @@ export function TargetConfigurationGroupList({
<TargetConfigurationDetailsListItem
project={project}
sourceMap={sourceMap}
connectedToCloud={connectedToCloud}
variant={variant}
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
onNxConnect={onNxConnect}
targetName={targetName}
collapsable={true}
key={targetName}
Expand All @@ -109,9 +104,11 @@ export function TargetConfigurationGroupList({
<TargetConfigurationDetailsListItem
project={project}
sourceMap={sourceMap}
connectedToCloud={connectedToCloud}
variant={variant}
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
onNxConnect={onNxConnect}
targetName={targetName}
collapsable={true}
key={targetName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
PlayIcon,
} from '@heroicons/react/24/outline';

import { PropertyInfoTooltip, Tooltip } from '@nx/graph/ui-tooltips';
import {
AtomizerTooltip,
PropertyInfoTooltip,
Tooltip,
} from '@nx/graph/ui-tooltips';
import { twMerge } from 'tailwind-merge';
import { Pill } from '../pill';
import { TargetTechnologies } from '../target-technologies/target-technologies';
Expand All @@ -26,11 +30,13 @@ export interface TargetConfigurationDetailsHeaderProps {
projectName: string;
targetName: string;
sourceMap: Record<string, string[]>;
connectedToCloud?: boolean;
onRunTarget?: (data: { projectName: string; targetName: string }) => void;
onViewInTaskGraph?: (data: {
projectName: string;
targetName: string;
}) => void;
onNxConnect?: () => void;
}

export const TargetConfigurationDetailsHeader = ({
Expand All @@ -41,9 +47,11 @@ export const TargetConfigurationDetailsHeader = ({
targetConfiguration,
projectName,
targetName,
connectedToCloud = true,
sourceMap,
onRunTarget,
onViewInTaskGraph,
onNxConnect,
}: TargetConfigurationDetailsHeaderProps) => {
const handleCopyClick = async (copyText: string) => {
await window.navigator.clipboard.writeText(copyText);
Expand Down Expand Up @@ -97,7 +105,7 @@ export const TargetConfigurationDetailsHeader = ({
</p>
)}
</div>
<div>
<div className="flex items-center gap-2">
{targetName === 'nx-release-publish' && (
<Tooltip
openAction="hover"
Expand All @@ -109,6 +117,31 @@ export const TargetConfigurationDetailsHeader = ({
</span>
</Tooltip>
)}
{targetConfiguration.metadata?.nonAtomizedTarget && (
<Tooltip
openAction="hover"
strategy="fixed"
usePortal={true}
content={
(
<AtomizerTooltip
connectedToCloud={connectedToCloud}
nonAtomizedTarget={
targetConfiguration.metadata.nonAtomizedTarget
}
onNxConnect={onNxConnect}
/>
) as any
}
>
<span className="inline-flex">
<Pill
color={connectedToCloud ? 'grey' : 'yellow'}
text={'Atomizer'}
/>
</span>
</Tooltip>
)}
{targetConfiguration.cache && (
<Tooltip
openAction="hover"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import TargetConfigurationDetails from '../target-configuration-details/target-c
export interface TargetConfigurationDetailsListItemProps {
project: ProjectGraphProjectNode;
sourceMap: Record<string, string[]>;
connectedToCloud?: boolean;
variant?: 'default' | 'compact';
onRunTarget?: (data: { projectName: string; targetName: string }) => void;
onViewInTaskGraph?: (data: {
projectName: string;
targetName: string;
}) => void;
onNxConnect?: () => void;
targetName: string;
collapsable: boolean;
}
Expand All @@ -20,8 +22,10 @@ export function TargetConfigurationDetailsListItem({
project,
variant,
sourceMap,
connectedToCloud,
onRunTarget,
onViewInTaskGraph,
onNxConnect,
targetName,
collapsable,
}: TargetConfigurationDetailsListItemProps) {
Expand All @@ -37,8 +41,10 @@ export function TargetConfigurationDetailsListItem({
targetName={targetName}
targetConfiguration={target}
sourceMap={sourceMap}
connectedToCloud={connectedToCloud}
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
onNxConnect={onNxConnect}
collapsable={collapsable}
/>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface TargetConfigurationDetailsProps {
targetName: string;
targetConfiguration: TargetConfiguration;
sourceMap: Record<string, string[]>;
connectedToCloud?: boolean;
variant?: 'default' | 'compact';
onCollapse?: (targetName: string) => void;
onExpand?: (targetName: string) => void;
Expand All @@ -32,6 +33,7 @@ interface TargetConfigurationDetailsProps {
projectName: string;
targetName: string;
}) => void;
onNxConnect?: () => void;
collapsable: boolean;
}

Expand All @@ -41,8 +43,10 @@ export default function TargetConfigurationDetails({
targetName,
targetConfiguration,
sourceMap,
connectedToCloud,
onViewInTaskGraph,
onRunTarget,
onNxConnect,
collapsable,
}: TargetConfigurationDetailsProps) {
const isCompact = variant === 'compact';
Expand Down Expand Up @@ -95,9 +99,11 @@ export default function TargetConfigurationDetails({
targetConfiguration={targetConfiguration}
projectName={projectName}
targetName={targetName}
connectedToCloud={connectedToCloud}
sourceMap={sourceMap}
onRunTarget={onRunTarget}
onViewInTaskGraph={onViewInTaskGraph}
onNxConnect={onNxConnect}
/>
{/* body */}
{!collapsed && (
Expand Down
15 changes: 0 additions & 15 deletions graph/ui-project-details/src/lib/utils/group-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,3 @@ function sortNxReleasePublishLast(a: string, b: string) {
if (b === 'nx-release-publish') return -1;
return a.localeCompare(b);
}

export function getNonAtomizedTargetForGroup(
project: ProjectGraphProjectNode,
targetGroupName: string
): string | undefined {
const targetWithNonAtomizedEquivalent = project.data.metadata?.targetGroups?.[
targetGroupName
]?.find(
(target) => project.data.targets?.[target]?.metadata?.nonAtomizedTarget
);
return targetWithNonAtomizedEquivalent
? project.data.targets?.[targetWithNonAtomizedEquivalent]?.metadata
?.nonAtomizedTarget
: undefined;
}
Loading