-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Keep workflow preview values readable #8256
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
Merged
BillLeoutsakosvl346
merged 2 commits into
codex/control-fix-workflow-preview-actions
from
codex/emcn-next-preview-readonly
Sep 24, 2026
Merged
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
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
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
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
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
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
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
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
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
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
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
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
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
90 changes: 90 additions & 0 deletions
90
...kspaceId]/w/components/preview/components/preview-editor/preview-readonly-styles.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,90 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| import { act } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('next/navigation', () => ({ useParams: () => ({ workspaceId: 'workspace-1' }) })) | ||
| vi.mock('@/hooks/use-webhook-management', () => ({ | ||
| useWebhookManagement: () => ({ webhookUrl: null }), | ||
| })) | ||
| vi.mock( | ||
| '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value', | ||
| () => ({ useSubBlockValue: () => [undefined, vi.fn()] }) | ||
| ) | ||
|
|
||
| import { SubBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block' | ||
| import { READONLY_PREVIEW_STYLES } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-editor/preview-readonly-styles' | ||
| import type { SubBlockConfig } from '@/blocks/types' | ||
|
|
||
| const config: SubBlockConfig = { id: 'enabled', type: 'switch', title: 'Enabled' } | ||
|
|
||
| let container: HTMLDivElement | ||
| let root: Root | ||
|
|
||
| beforeEach(() => { | ||
| ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true | ||
| container = document.createElement('div') | ||
| document.body.appendChild(container) | ||
| root = createRoot(container) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => root.unmount()) | ||
| container.remove() | ||
| }) | ||
|
|
||
| describe('workflow preview read-only appearance', () => { | ||
| it('shows a preview value at full opacity while retaining the disabled interaction state', () => { | ||
| act(() => | ||
| root.render( | ||
| <> | ||
| <style>{`button[disabled] { opacity: 0.5; } ${READONLY_PREVIEW_STYLES}`}</style> | ||
| <div className='readonly-preview'> | ||
| <div data-testid='preview'> | ||
| <SubBlock | ||
| blockId='block-1' | ||
| config={config} | ||
| isPreview | ||
| subBlockValues={{ enabled: { value: true } }} | ||
| /> | ||
| <div data-preview-readonly> | ||
| <button type='button' disabled> | ||
| Remove file | ||
| </button> | ||
| </div> | ||
| </div> | ||
| <div data-testid='disabled'> | ||
| <SubBlock blockId='block-1' config={config} disabled /> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ) | ||
| ) | ||
|
|
||
| const preview = container.querySelector('[data-testid="preview"]')! | ||
| const previewSwitch = preview.querySelector('[role="switch"]') as HTMLButtonElement | ||
| const disabled = container.querySelector('[data-testid="disabled"]')! | ||
| const disabledSwitch = disabled.querySelector('[role="switch"]') as HTMLButtonElement | ||
|
|
||
| expect(preview.querySelector('[data-preview-readonly]')).not.toBeNull() | ||
| expect(previewSwitch.hasAttribute('disabled')).toBe(true) | ||
| expect(previewSwitch.getAttribute('aria-checked')).toBe('true') | ||
| expect(getComputedStyle(previewSwitch).opacity).toBe('1') | ||
| expect(getComputedStyle(previewSwitch).pointerEvents).toBe('none') | ||
| const removeButton = preview.querySelector('button:not([role="switch"])') as HTMLButtonElement | ||
| expect(getComputedStyle(removeButton).pointerEvents).toBe('none') | ||
| expect(getComputedStyle(removeButton).opacity).toBe('0.5') | ||
|
|
||
| act(() => { | ||
| previewSwitch.click() | ||
| previewSwitch.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true })) | ||
| }) | ||
| expect(previewSwitch.getAttribute('aria-checked')).toBe('true') | ||
|
|
||
| expect(disabled.querySelector('[data-preview-readonly]')).toBeNull() | ||
| expect(disabledSwitch.hasAttribute('disabled')).toBe(true) | ||
| expect(getComputedStyle(disabledSwitch).opacity).toBe('0.5') | ||
| }) | ||
| }) |
27 changes: 27 additions & 0 deletions
27
...e/[workspaceId]/w/components/preview/components/preview-editor/preview-readonly-styles.ts
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,27 @@ | ||
| /** | ||
| * Keep preview fields noninteractive while showing intentionally read-only controls | ||
| * and their marked value overlays at full opacity in both preview sections. | ||
| */ | ||
| export const READONLY_PREVIEW_STYLES = ` | ||
| .readonly-preview, | ||
| .readonly-preview * { | ||
| cursor: default !important; | ||
| } | ||
| .readonly-preview [data-preview-readonly] :is( | ||
| input, | ||
|
BillLeoutsakosvl346 marked this conversation as resolved.
|
||
| textarea, | ||
| [role="combobox"], | ||
| [role="slider"], | ||
| [role="switch"], | ||
| [role="checkbox"] | ||
| ) { | ||
| opacity: 1 !important; | ||
| pointer-events: none; | ||
| } | ||
| .readonly-preview [data-preview-readonly] :is(button, [role="button"]) { | ||
| pointer-events: none; | ||
| } | ||
| .readonly-preview [data-preview-readonly] [data-preview-full-opacity] { | ||
| opacity: 1 !important; | ||
| } | ||
| ` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.