-
Notifications
You must be signed in to change notification settings - Fork 0
feat(editor): expression node visual distinction #24
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
Open
albertgwo
wants to merge
2
commits into
feat/engine-pr0c-schema-additions
Choose a base branch
from
feat/engine-pr12-editor-visuals
base: feat/engine-pr0c-schema-additions
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import type { ComponentType } from 'react' | ||
| import { ShieldBadgeIcon, LandmarkBadgeIcon, KeyBadgeIcon, EyeBadgeIcon } from './icons' | ||
|
|
||
| export type DataClass = 'pii' | 'financial' | 'credentials' | 'internal' | ||
|
|
||
| interface BadgeDef { | ||
| icon: ComponentType<{ size?: number; className?: string }> | ||
| colorVar: string | ||
| label: string | ||
| } | ||
|
|
||
| const BADGE_MAP: Record<DataClass, BadgeDef> = { | ||
| pii: { icon: ShieldBadgeIcon, colorVar: 'var(--fp-badge-pii)', label: 'PII' }, | ||
| financial: { icon: LandmarkBadgeIcon, colorVar: 'var(--fp-badge-financial)', label: 'Financial' }, | ||
| credentials: { | ||
| icon: KeyBadgeIcon, | ||
| colorVar: 'var(--fp-badge-credentials)', | ||
| label: 'Credentials', | ||
| }, | ||
| internal: { icon: EyeBadgeIcon, colorVar: 'var(--fp-badge-internal)', label: 'Internal' }, | ||
| } | ||
|
|
||
| export interface DataClassBadgesProps { | ||
| /** Classifications explicitly set on this element */ | ||
| explicit?: DataClass[] | ||
| /** Classifications inherited from the lane (shown at 50% opacity) */ | ||
| inherited?: DataClass[] | ||
| /** Icon size in pixels (default 12) */ | ||
| size?: number | ||
| } | ||
|
|
||
| export function DataClassBadges({ | ||
| explicit = [], | ||
| inherited = [], | ||
| size = 12, | ||
| }: DataClassBadgesProps) { | ||
| const allClasses = [...new Set([...explicit, ...inherited])] | ||
| if (allClasses.length === 0) return null | ||
|
|
||
| return ( | ||
| <div className="fp-data-badges" data-testid="data-class-badges"> | ||
| {allClasses.map((dc) => { | ||
| const badge = BADGE_MAP[dc] | ||
| const Icon = badge.icon | ||
| const isExplicit = explicit.includes(dc) | ||
|
|
||
| return ( | ||
| <span | ||
| key={dc} | ||
| className="fp-data-badge" | ||
| data-testid={`data-badge-${dc}`} | ||
| data-inherited={!isExplicit ? 'true' : undefined} | ||
| title={`${badge.label}${isExplicit ? '' : ' (inherited from lane)'}`} | ||
| style={{ | ||
| color: badge.colorVar, | ||
| opacity: isExplicit ? 1 : 0.5, | ||
| }} | ||
| > | ||
| <Icon size={size} /> | ||
| </span> | ||
| ) | ||
| })} | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/editor/src/components/__tests__/LaneHeaderBadges.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { describe, it, expect, vi, afterEach } from 'vitest' | ||
| import { render, screen, cleanup } from '@testing-library/react' | ||
| import { LaneHeader } from '../LaneHeader' | ||
|
|
||
| function renderLaneHeader(overrides?: Partial<React.ComponentProps<typeof LaneHeader>>) { | ||
| const defaults = { | ||
| laneId: 'lane-1', | ||
| name: 'Customer Actions', | ||
| color: '#3b82f6', | ||
| collapsed: false, | ||
| onToggleCollapse: vi.fn(), | ||
| onRename: vi.fn(), | ||
| } | ||
| const props = { ...defaults, ...overrides } | ||
| return { ...render(<LaneHeader {...props} />), props } | ||
| } | ||
|
|
||
| describe('LaneHeader – data classification badges', () => { | ||
| afterEach(() => { | ||
| cleanup() | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| it('shows data classification badges when dataClass is provided', () => { | ||
| const { container } = renderLaneHeader({ dataClass: ['pii', 'financial'] }) | ||
|
|
||
| const badges = container.querySelector('[data-testid="data-class-badges"]') | ||
| expect(badges).toBeTruthy() | ||
| expect(container.querySelector('[data-testid="data-badge-pii"]')).toBeTruthy() | ||
| expect(container.querySelector('[data-testid="data-badge-financial"]')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('shows badges at 100% opacity (lane-level is always explicit)', () => { | ||
| const { container } = renderLaneHeader({ dataClass: ['credentials'] }) | ||
|
|
||
| const badge = container.querySelector('[data-testid="data-badge-credentials"]') | ||
| expect(badge).toBeTruthy() | ||
| expect((badge as HTMLElement).style.opacity).toBe('1') | ||
| expect(badge?.getAttribute('data-inherited')).toBeNull() | ||
| }) | ||
|
|
||
| it('does not show badges when dataClass is not provided', () => { | ||
| const { container } = renderLaneHeader() | ||
|
|
||
| expect(container.querySelector('[data-testid="data-class-badges"]')).toBeNull() | ||
| }) | ||
|
|
||
| it('does not show badges when dataClass is empty array', () => { | ||
| const { container } = renderLaneHeader({ dataClass: [] }) | ||
|
|
||
| expect(container.querySelector('[data-testid="data-class-badges"]')).toBeNull() | ||
| }) | ||
|
|
||
| it('still renders lane name alongside badges', () => { | ||
| renderLaneHeader({ dataClass: ['internal'] }) | ||
|
|
||
| expect(screen.getByText('Customer Actions')).toBeTruthy() | ||
| expect(screen.getByLabelText('Collapse lane')).toBeTruthy() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| /** | ||
| * Inline SVG icon components for action modes and data classification badges. | ||
| * Uses the same props signature as lucide-react icons for compatibility with NodeShell. | ||
| */ | ||
|
|
||
| interface IconProps { | ||
| size?: number | ||
| className?: string | ||
| } | ||
|
|
||
| /* ── Action Mode Icons ──────────────────────── */ | ||
|
|
||
| export function CalculatorIcon({ size = 16, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <rect width="16" height="20" x="4" y="2" rx="2" /> | ||
| <line x1="8" x2="16" y1="6" y2="6" /> | ||
| <line x1="16" x2="16" y1="14" y2="18" /> | ||
| <path d="M16 10h.01" /> | ||
| <path d="M12 10h.01" /> | ||
| <path d="M8 10h.01" /> | ||
| <path d="M12 14h.01" /> | ||
| <path d="M8 14h.01" /> | ||
| <path d="M12 18h.01" /> | ||
| <path d="M8 18h.01" /> | ||
| </svg> | ||
| ) | ||
| } | ||
|
|
||
| export function TableIcon({ size = 16, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <path d="M12 3v18" /> | ||
| <rect width="18" height="18" x="3" y="3" rx="2" /> | ||
| <path d="M3 9h18" /> | ||
| <path d="M3 15h18" /> | ||
| </svg> | ||
| ) | ||
| } | ||
|
|
||
| /* ── Data Classification Badge Icons ────────── */ | ||
|
|
||
| export function ShieldBadgeIcon({ size = 12, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" /> | ||
| </svg> | ||
| ) | ||
| } | ||
|
|
||
| export function LandmarkBadgeIcon({ size = 12, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <line x1="3" x2="21" y1="22" y2="22" /> | ||
| <line x1="6" x2="6" y1="18" y2="11" /> | ||
| <line x1="10" x2="10" y1="18" y2="11" /> | ||
| <line x1="14" x2="14" y1="18" y2="11" /> | ||
| <line x1="18" x2="18" y1="18" y2="11" /> | ||
| <polygon points="12 2 20 7 4 7" /> | ||
| </svg> | ||
| ) | ||
| } | ||
|
|
||
| export function KeyBadgeIcon({ size = 12, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <path d="m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4" /> | ||
| <path d="m21 2-9.6 9.6" /> | ||
| <circle cx="7.5" cy="15.5" r="5.5" /> | ||
| </svg> | ||
| ) | ||
| } | ||
|
|
||
| export function EyeBadgeIcon({ size = 12, className }: IconProps) { | ||
| return ( | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width={size} | ||
| height={size} | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth={2} | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| className={className} | ||
| aria-hidden="true" | ||
| > | ||
| <path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /> | ||
| <circle cx="12" cy="12" r="3" /> | ||
| </svg> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/editor was modified but no .changeset/*.md was added — should we add a .changeset file documenting the @ruminaider/flowprint-editor change?
Finding type:
AI Coding Guidelines| Severity: 🟠 MediumWant Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents:
Heads up!
Your free trial ends tomorrow.
To keep getting your PRs reviewed by Baz, update your team's subscription