Skip to content

Commit 7070aef

Browse files
Enable Code button when viewing historical work orders (#4280)
* Enable Code button when viewing historical work orders (#4279) Fixes bug where Code button was disabled when viewing historical work orders with version != latest. Users can now open FullScreenIDE to view code and logs together for debugging failed runs. Changes: - Remove isReadOnly check from Code button disabled condition - Update tooltip to "View read-only code and logs" for clarity - Show keyboard shortcut (Cmd+E) in all states - Add test for Code button with pinned version parameter * Update CHANGELOG for #4279 * Simplify Code button tooltip text Remove conditional tooltip logic and always show 'Open full-screen code editor' with keyboard shortcut, regardless of state. * its not full screen anymore ;-) --------- Co-authored-by: Taylor Downs <taylor@openfn.org>
1 parent 3991fc4 commit 7070aef

File tree

3 files changed

+57
-14
lines changed

3 files changed

+57
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ and this project adheres to
2121

2222
### Fixed
2323

24+
- Fixed Code button being disabled when viewing historical work orders
25+
[#4279](https://github.com/OpenFn/lightning/issues/4279)
26+
2427
## [2.15.5] - 2025-12-23
2528

2629
### Fixed

assets/js/collaborative-editor/components/inspector/JobInspector.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,9 @@ export function JobInspector({
8181
<Tooltip
8282
content={
8383
<>
84-
{isIDEOpen
85-
? 'IDE is already open'
86-
: isReadOnly
87-
? 'Cannot edit in read-only mode'
88-
: 'Open full-screen code editor '}
89-
{!isIDEOpen && !isReadOnly && (
90-
<>
91-
{' '}
92-
{'( '}
93-
<ShortcutKeys keys={['mod', 'e']} />
94-
{' )'}
95-
</>
96-
)}
84+
Open code editor {'( '}
85+
<ShortcutKeys keys={['mod', 'e']} />
86+
{' )'}
9787
</>
9888
}
9989
side="top"
@@ -102,7 +92,7 @@ export function JobInspector({
10292
<Button
10393
variant="primary"
10494
onClick={() => updateSearchParams({ panel: 'editor' })}
105-
disabled={isIDEOpen || isReadOnly}
95+
disabled={isIDEOpen}
10696
>
10797
Code
10898
</Button>

assets/test/collaborative-editor/components/inspector/JobInspector.test.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,56 @@ describe('JobInspector - Footer Button States', () => {
362362
expect(codeButton).not.toBeDisabled();
363363
});
364364

365+
test('Code button is enabled when viewing pinned version', () => {
366+
// Set URL with version parameter to simulate viewing historical work order
367+
urlState.setParams({ v: '5' });
368+
369+
// Set edit permissions
370+
act(() => {
371+
(mockChannel as any)._test.emit('session_context', {
372+
user: null,
373+
project: null,
374+
config: { require_email_verification: false },
375+
permissions: {
376+
can_edit_workflow: true,
377+
can_run_workflow: true,
378+
can_write_webhook_auth_method: true,
379+
},
380+
latest_snapshot_lock_version: 6,
381+
project_repo_connection: null,
382+
webhook_auth_methods: [],
383+
workflow_template: null,
384+
has_read_ai_disclaimer: false,
385+
});
386+
});
387+
388+
const job = workflowStore.getSnapshot().jobs[0];
389+
const mockOnClose = vi.fn();
390+
const mockOnOpenRunPanel = vi.fn();
391+
392+
render(
393+
<JobInspector
394+
job={job}
395+
onClose={mockOnClose}
396+
onOpenRunPanel={mockOnOpenRunPanel}
397+
/>,
398+
{
399+
wrapper: createWrapper(
400+
workflowStore,
401+
credentialStore,
402+
sessionContextStore,
403+
adaptorStore,
404+
awarenessStore
405+
),
406+
}
407+
);
408+
409+
const codeButton = screen.getByRole('button', { name: /code/i });
410+
411+
// Code button should be enabled even when viewing pinned version
412+
expect(codeButton).not.toBeDisabled();
413+
});
414+
365415
test('Delete button is disabled when job has downstream dependencies', () => {
366416
// Create a workflow with two jobs where job-2 depends on job-1
367417
const ydocWithDeps = createWorkflowYDoc({

0 commit comments

Comments
 (0)