Skip to content

Commit 66d325a

Browse files
committed
Fixed wrong version count update
1 parent 6eec648 commit 66d325a

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

__tests__/v2/VersionUpdate.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function createFetchResponse(data) {
2424

2525
// The component to be tested must be imported after the mock setup
2626
import VersionUpdate from '../../src/lib/components/v2/workflow/VersionUpdate.svelte';
27+
import { writable } from 'svelte/store';
2728

2829
const newArgsSchema = {
2930
title: 'MyTask',
@@ -700,7 +701,7 @@ function renderVersionUpdate(task, workflowTask, updateCandidates) {
700701
workflowTask,
701702
updateCandidates,
702703
updateWorkflowCallback: nop,
703-
updateNewVersionsCount: nop
704+
newVersionsCount: writable(0)
704705
}
705706
});
706707
}

playwright.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default defineConfig({
8080

8181
webServer: [
8282
{
83-
command: './tests/start-test-server.sh --branch 2453-partly-move-task-version-update-from-fractal-web-to-fractal-server',
83+
command: './tests/start-test-server.sh --branch main',
8484
port: 8000,
8585
waitForPort: true,
8686
stdout: 'pipe',

src/lib/components/v2/workflow/VersionUpdate.svelte

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* @property {import('fractal-components/types/api').WorkflowTaskV2} workflowTask
1515
* @property {Array<{ task_id: number, version: string }>} updateCandidates
1616
* @property {(workflowTask: import('fractal-components/types/api').WorkflowTaskV2) => void} updateWorkflowCallback
17-
* @property {(count: number) => Promise<void>} updateNewVersionsCount
17+
* @property {import('svelte/store').Writable<number>} newVersionsCount
1818
*/
1919
2020
/** @type {Props} */
21-
let { workflowTask, updateCandidates, updateWorkflowCallback, updateNewVersionsCount } = $props();
21+
let { workflowTask, updateCandidates, updateWorkflowCallback, newVersionsCount } = $props();
2222
2323
/** @type {VersionUpdateFixArgs|undefined} */
2424
let fixArgsComponentNonParallel = $state();
@@ -40,20 +40,13 @@
4040
/** @type {import('$lib/components/common/StandardErrorAlert.svelte').default|undefined} */
4141
let errorAlert = undefined;
4242
43-
async function setup() {
43+
function setup() {
4444
if (errorAlert) {
4545
errorAlert.hide();
4646
}
4747
selectedUpdateVersion = '';
4848
fixArgsComponentNonParallel?.reset();
4949
fixArgsComponentParallel?.reset();
50-
51-
await tick(); // wait taskHasArgsSchema is set
52-
if (!taskHasArgsSchema) {
53-
return;
54-
}
55-
56-
await updateNewVersionsCount(updateCandidates.length);
5750
}
5851
5952
/**
@@ -196,6 +189,10 @@
196189
$effect(() => {
197190
loadSelectedTask(selectedUpdateVersion);
198191
});
192+
193+
$effect(() => {
194+
newVersionsCount.set(updateCandidates.length);
195+
});
199196
</script>
200197
201198
<div>

src/routes/v2/projects/[projectId]/workflows/[workflowId]/+page.svelte

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import RunStatus from '$lib/components/jobs/RunStatus.svelte';
2727
import RunStatusModal from '$lib/components/jobs/RunStatusModal.svelte';
2828
import { navigating, navigationCancelled } from '$lib/stores';
29+
import { writable } from 'svelte/store';
2930
3031
/** @type {number|undefined} */
3132
const defaultDatasetId = $derived(page.data.defaultDatasetId);
@@ -486,14 +487,7 @@
486487
return updateCandidates;
487488
}
488489
489-
let newVersionsCount = $state(0);
490-
/**
491-
* Used to receive new version count from VersionUpdate component.
492-
* @param count {number}
493-
*/
494-
async function updateNewVersionsCount(count) {
495-
newVersionsCount = count;
496-
}
490+
const newVersionsCount = writable(0);
497491
498492
/** @type {{[key: number]: import('fractal-components/types/api').ImagesStatus}} */
499493
let statuses = $state({});
@@ -1013,8 +1007,8 @@
10131007
aria-current={workflowTabContextId === 4}
10141008
>
10151009
Version
1016-
{#if newVersionsCount}
1017-
<span class="badge bg-primary rounded-pill">{newVersionsCount}</span>
1010+
{#if $newVersionsCount}
1011+
<span class="badge bg-primary rounded-pill">{$newVersionsCount}</span>
10181012
{/if}
10191013
</button>
10201014
</li>
@@ -1103,7 +1097,7 @@
11031097
workflowTask={selectedWorkflowTask}
11041098
updateWorkflowCallback={taskUpdated}
11051099
updateCandidates={newVersionsMap[selectedWorkflowTask.task_id] || []}
1106-
{updateNewVersionsCount}
1100+
{newVersionsCount}
11071101
/>
11081102
{/if}
11091103
</div>

0 commit comments

Comments
 (0)