Skip to content

Commit 11b2352

Browse files
committed
Improved arguments form titles
1 parent a6d9c56 commit 11b2352

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

src/lib/components/common/jschema/schema_management.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ export function stripSchemaProperties(schema, legacy = true) {
541541
if (schema.required) {
542542
schema.required = schema.required.filter((k) => !ignoreProperties.includes(k));
543543
}
544+
return schema;
544545
}
545546

546547
/**

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import { displayStandardErrorAlert } from '$lib/common/errors';
55
import FormBuilder from './FormBuilder.svelte';
66
import ImportExportArgs from './ImportExportArgs.svelte';
7-
import { stripNullAndEmptyObjectsAndArrays } from '$lib/components/common/jschema/schema_management';
7+
import {
8+
stripNullAndEmptyObjectsAndArrays,
9+
stripSchemaProperties
10+
} from '$lib/components/common/jschema/schema_management';
811
912
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1'];
1013
@@ -127,12 +130,27 @@
127130
function argsSchemaVersionValid(argsSchemaVersion) {
128131
return argsSchemaVersion && SUPPORTED_SCHEMA_VERSIONS.includes(argsSchemaVersion);
129132
}
133+
134+
$: showNonParallelTitle =
135+
!workflowTask.is_legacy_task &&
136+
workflowTask.task.args_schema_non_parallel &&
137+
Object.keys(
138+
stripSchemaProperties(workflowTask.task.args_schema_non_parallel, workflowTask.is_legacy_task)
139+
.properties
140+
).length;
141+
142+
$: showParallelTitle =
143+
argsSchemaParallel &&
144+
Object.keys(stripSchemaProperties(argsSchemaParallel, workflowTask.is_legacy_task).properties)
145+
.length;
130146
</script>
131147
132148
<div id="workflow-arguments-schema-panel">
133149
<div id="json-schema-validation-errors" />
134150
{#if workflowTask.task_type === 'non_parallel' || workflowTask.task_type === 'compound'}
135-
<h5 class="ps-2 mt-3">Args non parallel</h5>
151+
{#if showNonParallelTitle}
152+
<h5 class="ps-2 mt-3">Initialisation Parameters</h5>
153+
{/if}
136154
{#if !workflowTask.is_legacy_task && workflowTask.task.args_schema_non_parallel && isSchemaValid}
137155
<div class="args-list">
138156
<JSchema
@@ -153,17 +171,13 @@
153171
</div>
154172
{/if}
155173
{/if}
156-
{#if workflowTask.task_type === 'compound'}
174+
{#if workflowTask.task_type === 'compound' && showParallelTitle}
157175
<hr />
158176
{/if}
159177
{#if workflowTask.task_type === 'parallel' || workflowTask.task_type === 'compound'}
160-
<h5 class="ps-2 mt-3">
161-
{#if workflowTask.is_legacy_task}
162-
Args (legacy task)
163-
{:else}
164-
Args parallel
165-
{/if}
166-
</h5>
178+
{#if showParallelTitle}
179+
<h5 class="ps-2 mt-3">Compute Parameters</h5>
180+
{/if}
167181
{#if argsSchemaParallel && isSchemaValid}
168182
<div class="args-list">
169183
<JSchema
@@ -184,6 +198,9 @@
184198
</div>
185199
{/if}
186200
{/if}
201+
{#if !showNonParallelTitle && !showParallelTitle}
202+
<p class="mt-3 ps-3">No arguments</p>
203+
{/if}
187204
<div class="d-flex jschema-controls-bar p-3">
188205
<ImportExportArgs
189206
{workflowTask}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@
150150
<div id="json-schema">
151151
{#key schemaManager}
152152
<PropertiesBlock properties={parsedSchema.properties} required={parsedSchema.required} />
153-
{#if Object.entries(parsedSchema.properties).length === 0}
154-
<span class="ps-2">-</span>
155-
{/if}
156153
{/key}
157154
</div>
158155
{:else if parsedSchema === undefined}

tests/v2/run_mock_tasks.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ test('Collect and run mock tasks [v2]', async ({ page, workflow, request }) => {
126126
).toHaveText(datasetName2);
127127
});
128128

129-
await test.step('Select the first dataset', async () => {
130-
await page
131-
.getByRole('combobox', { name: 'Dataset', exact: true })
132-
.first()
133-
.selectOption(datasetName1);
134-
});
135-
136129
await test.step('Add and select create_ome_zarr_compound', async () => {
137130
await workflow.addCollectedTask('create_ome_zarr_compound');
138131
await workflow.selectTask('create_ome_zarr_compound');
@@ -144,6 +137,13 @@ test('Collect and run mock tasks [v2]', async ({ page, workflow, request }) => {
144137
await page.getByText('Arguments changes saved successfully').waitFor();
145138
});
146139

140+
await test.step('Select the first dataset', async () => {
141+
await page
142+
.getByRole('combobox', { name: 'Dataset', exact: true })
143+
.first()
144+
.selectOption(datasetName1);
145+
});
146+
147147
await test.step('Start the job', async () => {
148148
await page.getByRole('button', { name: 'Run workflow' }).click();
149149
const modal = page.locator('.modal.show');

0 commit comments

Comments
 (0)