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
4 changes: 2 additions & 2 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labkey/components",
"version": "7.1.0",
"version": "7.1.1",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"sideEffects": false,
"files": [
Expand Down
8 changes: 8 additions & 0 deletions packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# @labkey/components
Components, models, actions, and utility functions for LabKey applications and pages

### version 7.1.1
*Released*: 8 December 2025
- Sample Amount/Units polish: part 2
- Introduced a two-tier unit selection system (Amount Type, Display Units) in sample designer
- Added new measurement units (ug, ng) with updated display precision for existing units
- Added a new formsy rule `sampleAmount` for validating sample amount/units input on forms
- Disallow large amount (>1.79769E308) for amounts input on form, editable grid, and sample storage editor

### version 7.1.0
*Released*: 3 December 2025
- ChartBuilderModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ export class SampleTypeDesignerImpl extends React.PureComponent<InjectedBaseDoma
return;
}

const metricUnitRequired = metricUnitProps?.metricUnitRequired;
const isValid = model.isValid(defaultSampleFieldConfig, metricUnitRequired);
const isValid = model.isValid(defaultSampleFieldConfig);

this.props.onFinish(isValid, () => this.saveDomain(false, comment ?? auditUserComment));

Expand All @@ -386,7 +385,7 @@ export class SampleTypeDesignerImpl extends React.PureComponent<InjectedBaseDoma
} else if (getDuplicateAlias(model.parentAliases, true).size > 0) {
exception =
'Duplicate parent alias header found: ' + getDuplicateAlias(model.parentAliases, true).join(', ');
} else if (!model.isMetricUnitValid(metricUnitRequired)) {
} else if (!model.isMetricUnitValid()) {
exception = metricUnitProps?.metricUnitLabel + ' field is required.';
} else {
exception = model.domain.getFirstFieldError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { DomainDetails, DomainPanelStatus } from '../models';

import { getTestAPIWrapper } from '../../../APIWrapper';

import { SampleTypePropertiesPanel } from './SampleTypePropertiesPanel';
import { getValidUnitKinds, SampleTypePropertiesPanel, UnitKinds } from './SampleTypePropertiesPanel';
import { SampleTypeModel } from './models';
import { UNITS_KIND } from '../../../util/measurement';

describe('SampleTypePropertiesPanel', () => {
const BASE_PROPS = {
Expand Down Expand Up @@ -114,15 +115,15 @@ describe('SampleTypePropertiesPanel', () => {
container = renderWithAppContext(
<SampleTypePropertiesPanel
{...BASE_PROPS}
dataClassAliasCaption="Source"
dataClassParentageLabel="source"
dataClassTypeCaption="source type"
includeDataClasses
model={sampleTypeModel}
parentOptions={[{ schema: 'exp.data' }]}
includeDataClasses
useSeparateDataClassesAliasMenu
sampleAliasCaption="Parent"
sampleTypeCaption="sample type"
dataClassAliasCaption="Source"
dataClassTypeCaption="source type"
dataClassParentageLabel="source"
useSeparateDataClassesAliasMenu
/>
);
});
Expand Down Expand Up @@ -154,7 +155,6 @@ describe('SampleTypePropertiesPanel', () => {
metricUnitProps={{
includeMetricUnitProperty: true,
metricUnitLabel: 'Display Units',
metricUnitRequired: true,
metricUnitHelpMsg: 'Sample storage volume will be displayed using the selected metric unit.',
metricUnitOptions: [
{ id: 'mL', label: 'ml' },
Expand All @@ -180,9 +180,9 @@ describe('SampleTypePropertiesPanel', () => {
renderWithAppContext(
<SampleTypePropertiesPanel
{...BASE_PROPS}
showLinkToStudy
appPropertiesOnly={false}
model={sampleTypeModelWithTimepoint}
showLinkToStudy
/>
);
});
Expand All @@ -201,9 +201,9 @@ describe('SampleTypePropertiesPanel', () => {
renderWithAppContext(
<SampleTypePropertiesPanel
{...BASE_PROPS}
showLinkToStudy={false}
appPropertiesOnly={false}
model={sampleTypeModelWithTimepoint}
showLinkToStudy={false}
/>
);
});
Expand Down Expand Up @@ -255,11 +255,11 @@ describe('SampleTypePropertiesPanel', () => {
renderWithAppContext(
<SampleTypePropertiesPanel
{...BASE_PROPS}
model={SampleTypeModel.create(data)}
appPropertiesOnly={false}
aliquotNamePatternProps={{
showAliquotNameExpression: true,
}}
appPropertiesOnly={false}
model={SampleTypeModel.create(data)}
namePreviews={[null, 'S-parentSample-1']}
/>
);
Expand All @@ -271,3 +271,30 @@ describe('SampleTypePropertiesPanel', () => {
expect(aliquotField.textContent).toEqual('Aliquot Naming Pattern');
});
});

describe('getValidUnitKinds', () => {
test('returns all unit kinds when lockUnitKind and metricUnit are undefined', () => {
const result = getValidUnitKinds();
expect(result).toEqual(Object.values(UnitKinds));
});

test('returns all unit kinds when lockUnitKind is false', () => {
const result = getValidUnitKinds(false, 'mL');
expect(result).toEqual(Object.values(UnitKinds));
});

test('returns NONE and the unit kind matching the metricUnit when lockUnitKind is true', () => {
const result = getValidUnitKinds(true, 'mL');
expect(result).toEqual([UnitKinds[UNITS_KIND.NONE], UnitKinds[UNITS_KIND.VOLUME]]);
});

test('returns only NONE when lockUnitKind is true and metricUnit is invalid', () => {
const result = getValidUnitKinds(true, 'invalidUnit');
expect(result).toEqual([UnitKinds[UNITS_KIND.NONE]]);
});

test('returns only all when lockUnitKind is true and metricUnit is undefined', () => {
const result = getValidUnitKinds(true);
expect(result).toEqual(Object.values(UnitKinds));
});
});
Loading