Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/free-spies-open.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@platforma-open/milaboratories.samples-and-data.workflow': minor
'@platforma-open/milaboratories.samples-and-data.model': minor
'@platforma-open/milaboratories.samples-and-data.ui': minor
'@platforma-open/milaboratories.samples-and-data': minor
---

Added subtitle, removed editable title
1 change: 0 additions & 1 deletion model/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export function isGroupedDataset(ds: DSAny): ds is DSGrouped {
}

export interface BlockArgs {
blockTitle?: string;
sampleIds: PlId[];
sampleLabelColumnLabel: string;
sampleLabels: Record<PlId, string>;
Expand Down
12 changes: 9 additions & 3 deletions model/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type {
ImportFileHandle,
InferHrefType,
InferOutputsType,
PlId,
TreeNodeAccessor,
} from '@platforma-sdk/model';
import {
BlockModel,
type InferOutputsType,
} from '@platforma-sdk/model';
import { isGroupedDataset, type BlockArgs } from './args';

Expand All @@ -15,7 +15,6 @@ export type BlockUiState = { suggestedImport: boolean };
export const platforma = BlockModel.create()

.withArgs<BlockArgs>({
blockTitle: 'Samples & Data',
sampleIds: [],
metadata: [],
sampleLabelColumnLabel: 'Sample',
Expand Down Expand Up @@ -92,7 +91,14 @@ export const platforma = BlockModel.create()
},
)

.title((ctx) => ctx.args.blockTitle ?? 'Samples & Data')
.title(() => 'Samples & Data')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The title 'Samples & Data' is hardcoded. This string is also used in other places, such as ui/src/pages/MetadataPage.vue and workflow/src/main.tpl.tengo. To follow the DRY (Don't Repeat Yourself) principle and improve maintainability, consider defining this as a constant in a shared location (e.g., in the model package) and importing it where needed. This makes future changes to the title easier to manage across the application.


.subtitle((ctx) => {
const datasetsNum = ctx.args.datasets.length;
if (datasetsNum === 0) return 'No datasets';
if (datasetsNum === 1) return '1 dataset';
return `${datasetsNum} datasets`;
})

.sections((ctx) => {
return [
Expand Down
412 changes: 165 additions & 247 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ packages:
- test

catalog:
'@platforma-sdk/block-tools': 2.6.28
'@platforma-sdk/model': 1.49.0
'@platforma-sdk/ui-vue': 1.49.0
'@platforma-sdk/tengo-builder': 2.4.7
'@platforma-sdk/workflow-tengo': 5.7.3
'@platforma-sdk/block-tools': 2.6.29
'@platforma-sdk/model': 1.51.2
'@platforma-sdk/ui-vue': 1.51.4
'@platforma-sdk/tengo-builder': 2.4.8
'@platforma-sdk/workflow-tengo': 5.8.0
"@platforma-sdk/blocks-deps-updater": 2.0.0
"@platforma-sdk/eslint-config": ^1.2.0
'@platforma-sdk/package-builder': 3.10.7

'@platforma-open/milaboratories.runenv-python-3': ^1.7.5
'@platforma-open/milaboratories.runenv-r-samples-and-data': ^1.0.1

'@platforma-sdk/test': 1.49.1
'@milaboratories/helpers': 1.12.1
'@platforma-sdk/test': 1.51.3
'@milaboratories/helpers': 1.13.0

'vue': ^3.5.24
'vue-tsc': ^2.2.8
Expand Down
6 changes: 5 additions & 1 deletion test/src/wf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ blockTest('empty inputs', { timeout: 7000 }, async ({ rawPrj: project, ml, helpe
const blockState = project.getBlockState(blockId);
console.dir(await blockState.getValue(), { depth: 5 });
const stableState = await blockState.awaitStableValue();
expect(stableState.outputs).toStrictEqual({ fileImports: { ok: true, value: {} }, sampleGroups: { ok: true, value: { } }, availableColumns: { ok: true, value: {} } });
expect(stableState.outputs).toStrictEqual({
fileImports: { ok: true, stable: true, value: {} },
sampleGroups: { ok: true, stable: true, value: { } },
availableColumns: { ok: true, stable: true, value: {} },
});
});

blockTest('simple input', async ({ rawPrj: project, ml, helpers, expect }) => {
Expand Down
11 changes: 1 addition & 10 deletions ui/src/pages/MetadataPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
PlBtnGhost,
PlBtnPrimary,
PlDialogModal,
PlEditableTitle,
PlTextField,
} from '@platforma-sdk/ui-vue';
import { computed, reactive, shallowRef, useCssModule } from 'vue';
Expand Down Expand Up @@ -374,15 +373,7 @@ const gridOptions = computed<GridOptions<MetadataRow>>(() => ({
</script>

<template>
<PlBlockPage>
<template #title>
<PlEditableTitle
v-model="app.model.args.blockTitle"
:max-length="40"
max-width="600px"
placeholder="Samples & Data"
/>
</template>
<PlBlockPage title="Samples & Data">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The title 'Samples & Data' is hardcoded here. This string is also used in model/src/index.ts. To adhere to the DRY principle, this should be a shared constant imported from the model package.

<template #append>
<PlBtnGhost icon="dna-import" @click.stop="() => (app.showImportDataset = true)">
Import Dataset
Expand Down
7 changes: 1 addition & 6 deletions workflow/src/main.tpl.tengo
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,14 @@ wf.body(func(args) {
}
}

blockTitle := args.blockTitle
if is_undefined(blockTitle) {
blockTitle = "Samples & Data"
}

for _, dataset in args.datasets {
proc := dsProcessors[dataset.content.type]
if is_undefined(proc) {
ll.panic("Unknown dataset type %v", dataset.content.type)
}

trace := pSpec.makeTrace(undefined,
{type: "milaboratories.samples-and-data", id: blockId, importance: 10, label: blockTitle},
{type: "milaboratories.samples-and-data", id: blockId, importance: 10, label: "Samples & Data"},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The label 'Samples & Data' is hardcoded. This string is also used in the frontend (model and ui packages). For consistency, it would be ideal to use a shared constant. If sharing a constant between TypeScript and Tengo is not straightforward, at least consider defining it as a local constant at the top of this file to avoid magic strings.

{type: "milaboratories.samples-and-data/dataset", id: dataset.id, importance: 100, label: dataset.label}
)

Expand Down