Skip to content

Commit 3c7c5dc

Browse files
authored
Issue 754: Display and log errors (#1913)
1 parent 1e3d315 commit 3c7c5dc

File tree

6 files changed

+28
-48
lines changed

6 files changed

+28
-48
lines changed

packages/components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/components",
3-
"version": "7.7.1",
3+
"version": "7.7.2",
44
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
55
"sideEffects": false,
66
"files": [

packages/components/releaseNotes/components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# @labkey/components
22
Components, models, actions, and utility functions for LabKey applications and pages
33

4+
### version 7.7.2
5+
*Released*: 30 December 2025
6+
- Remove unused `getVolumeMinStep` method
7+
- Improve typings, test checks
8+
49
### version 7.7.1
510
*Released*: 29 December 2025
611
- [GitHub Issue 734](https://github.com/LabKey/internal-issues/issues/734) Update sizing of comment input box for better display in narrow screens

packages/components/src/internal/components/samples/actions.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,8 @@ describe('getGroupedSampleDomainFields', () => {
8484

8585
test('field split by derivationDataScope', () => {
8686
const result = _getGroupedSampleDomainFields(sampleTypeDomain, queryInfo);
87-
expect(result.aliquotFields.length).toBe(1);
88-
expect(result.aliquotFields[0]).toBe('aliq$c$d$s');
89-
expect(result.independentFields.length).toBe(1);
90-
expect(result.independentFields[0]).toBe('all$c$d$s');
91-
expect(result.metaFields.length).toBe(3);
92-
expect(result.metaFields[0]).toBe('name');
93-
expect(result.metaFields[1]).toBe('spec char$c$d$s');
94-
expect(result.metaFields[2]).toBe('parent$c$d$s');
87+
expect(result.aliquotFields).toEqual(['aliq$c$d$s']);
88+
expect(result.independentFields).toEqual(['all$c$d$s']);
89+
expect(result.metaFields).toEqual(['name', 'spec char$c$d$s', 'parent$c$d$s']);
9590
});
9691
});

packages/components/src/internal/components/samples/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ export function _getGroupedSampleDomainFields(
153153
sampleTypeDomain: DomainDetails,
154154
queryInfo: QueryInfo
155155
): GroupedSampleFields {
156-
const metaFields = [];
157-
const independentFields = [];
158-
const aliquotFields = [];
156+
const aliquotFields: string[] = [];
157+
const independentFields: string[] = [];
158+
const metaFields: string[] = [];
159159

160160
sampleTypeDomain.domainDesign.fields.forEach(field => {
161161
const col = queryInfo.getColumnFromName(field.name);

packages/components/src/internal/util/measurement.ts

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ export const MEASUREMENT_UNITS: Record<string, MeasurementUnit> = {
185185
},
186186
};
187187

188-
export function getMeasurementUnit(unitStr: string): MeasurementUnit {
188+
export function getMeasurementUnit(unitStr: string): MeasurementUnit | null {
189189
if (!unitStr) return null;
190+
const unitStrLc = unitStr.toLowerCase();
190191

191-
const unit = MEASUREMENT_UNITS[unitStr?.toLowerCase()];
192+
const unit = MEASUREMENT_UNITS[unitStrLc];
192193
if (unit) return unit;
193194

194-
const unitStrLc = unitStr.toLowerCase();
195-
if (MEASUREMENT_UNITS.unit.altLabels.indexOf(unitStrLc) > -1) {
195+
if (MEASUREMENT_UNITS.unit.altLabels?.indexOf(unitStrLc) > -1) {
196196
return {
197197
...MEASUREMENT_UNITS.unit,
198198
label: unitStrLc,
@@ -204,11 +204,7 @@ export function getMeasurementUnit(unitStr: string): MeasurementUnit {
204204
return null;
205205
}
206206

207-
/**
208-
* @param unitAStr
209-
* @param unitBStr
210-
*/
211-
export function areUnitsCompatible(unitAStr: string, unitBStr: string) {
207+
export function areUnitsCompatible(unitAStr: string, unitBStr: string): boolean {
212208
if (unitAStr == unitBStr) {
213209
return true;
214210
}
@@ -221,19 +217,19 @@ export function areUnitsCompatible(unitAStr: string, unitBStr: string) {
221217
if (!unitAStr && unitBStr) {
222218
return false;
223219
}
224-
const unitA: MeasurementUnit = getMeasurementUnit(unitAStr);
225-
const unitB: MeasurementUnit = getMeasurementUnit(unitBStr);
220+
const unitA = getMeasurementUnit(unitAStr);
221+
const unitB = getMeasurementUnit(unitBStr);
226222
if (!unitA || !unitB) {
227223
return false;
228224
}
229225
return unitA.kind === unitB.kind;
230226
}
231227

232228
export function getMetricUnitOptions(metricUnit?: string, showLongLabel?: boolean): { label: string; value: string }[] {
233-
const unit: MeasurementUnit = getMeasurementUnit(metricUnit);
229+
const unit = getMeasurementUnit(metricUnit);
234230

235231
const options = [];
236-
for (const [key, value] of Object.entries(MEASUREMENT_UNITS)) {
232+
for (const value of Object.values(MEASUREMENT_UNITS)) {
237233
if (!unit || value.kind === unit.kind) {
238234
if (value.kind === UNITS_KIND.COUNT) {
239235
if (showLongLabel)
@@ -274,36 +270,20 @@ export function getMetricUnitOptionsFromKind(
274270
return getMetricUnitOptions(metricUnit, showLongLabel);
275271
}
276272

277-
export function getAltUnitKeys(unitTypeStr): string[] {
278-
const unit: MeasurementUnit = getMeasurementUnit(unitTypeStr);
273+
export function getAltUnitKeys(unitTypeStr: string): string[] {
274+
const unit = getMeasurementUnit(unitTypeStr);
279275
const options = [];
280-
Object.values(MEASUREMENT_UNITS).forEach(value => {
276+
for (const value of Object.values(MEASUREMENT_UNITS)) {
281277
if (!unit || value.kind === unit.kind) {
282278
if (value.altLabels) {
283279
options.push(...value.altLabels);
284280
} else options.push(value.label);
285281
}
286-
});
287-
288-
return options;
289-
}
290-
291-
export function getVolumeMinStep(sampleTypeUnit?: MeasurementUnit | string) {
292-
const step = 0.01;
293-
if (!sampleTypeUnit) {
294-
return step;
295282
}
296283

297-
const unit = typeof sampleTypeUnit === 'string' ? getMeasurementUnit(sampleTypeUnit) : sampleTypeUnit;
298-
299-
// If we don't know the units, or it is 'unit' then use the default
300-
if (!unit || unit.baseUnit === MEASUREMENT_UNITS.unit.baseUnit) {
301-
return step;
302-
}
303-
304-
return Math.pow(10, -unit.displayPrecision); // Track uL and mg to a single unit
284+
return options;
305285
}
306286

307-
export function isMeasurementUnitIgnoreCase(expected: MeasurementUnit, val: string) {
287+
export function isMeasurementUnitIgnoreCase(expected: MeasurementUnit, val: string): boolean {
308288
return expected.label.localeCompare(val, 'en-US', { sensitivity: 'base' }) === 0;
309289
}

0 commit comments

Comments
 (0)