Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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.13.1",
"version": "7.13.1-fb-crossSampleTypeWarnings.0",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"sideEffects": false,
"files": [
Expand Down
6 changes: 6 additions & 0 deletions packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# @labkey/components
Components, models, actions, and utility functions for LabKey applications and pages

### version TBD
*Released*: TBD
- File import warnings for cross type sample import case
- InferDomain API call and response to include distinctValues for specified column keys
- EntityIdCreationModel.getSchemaQuery to include optional targetQueryName param

### version 7.13.1
*Released*: 26 January 2026
- Merge from release26.1-SNAPSHOT to develop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ export class EntityIdCreationModel extends Record({
};
}

getSchemaQuery(): SchemaQuery {
const entityTypeName = this.getTargetEntityTypeValue();
getSchemaQuery(targetQueryName?: string): SchemaQuery {
const entityTypeName = targetQueryName ?? this.getTargetEntityTypeValue();
return entityTypeName ? new SchemaQuery(this.entityDataType.instanceSchemaName, entityTypeName) : undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class FilePreviewGrid extends React.Component<Props, any> {
<>
<strong>{header}</strong>
{(warningMsg || previewData?.warningMsg) && (
<Alert bsStyle="warning" className="margin-top">
<Alert bsStyle="warning" className="margin-top file-preview-grid__warning">
{warningMsg}
{previewData?.warningMsg}
</Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ exports[`<FilePreviewGrid/> previewData.warningMsg 1`] = `
File preview:
</strong>
<div
class="margin-top alert alert-warning"
class="margin-top file-preview-grid__warning alert alert-warning"
role="alert"
>
Duplicate fields
Expand Down Expand Up @@ -799,7 +799,7 @@ exports[`<FilePreviewGrid/> warning message 1`] = `
File preview:
</strong>
<div
class="margin-top alert alert-warning"
class="margin-top file-preview-grid__warning alert alert-warning"
role="alert"
>
Testing warning message
Expand Down Expand Up @@ -969,7 +969,7 @@ exports[`<FilePreviewGrid/> warning message and previewData.warningMsg 1`] = `
File preview:
</strong>
<div
class="margin-top alert alert-warning"
class="margin-top file-preview-grid__warning alert alert-warning"
role="alert"
>
Testing warning message
Expand Down
27 changes: 25 additions & 2 deletions packages/components/src/public/InferDomainResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fromJS, List, Record } from 'immutable';
import { fromJS, List, Map, Record } from 'immutable';

import { ActionURL, Ajax, Utils } from '@labkey/api';

Expand All @@ -9,16 +9,19 @@ export class InferDomainResponse extends Record({
fields: List<QueryColumn>(),
reservedFields: List<QueryColumn>(),
commentLineCount: undefined,
distinctValues: Map<string, List<string>>(),
}) {
declare data: List<any>;
declare fields: List<QueryColumn>;
declare reservedFields: List<QueryColumn>;
declare commentLineCount?: number;
declare distinctValues: Map<string, List<string>>;

static create(rawModel): InferDomainResponse {
let data = List<any>();
let fields = List<QueryColumn>();
let reservedFields = List<QueryColumn>();
let distinctValues = Map<string, List<string>>();

if (rawModel) {
if (rawModel.data) {
Expand All @@ -32,21 +35,37 @@ export class InferDomainResponse extends Record({
if (rawModel.reservedFields) {
reservedFields = List(rawModel.reservedFields.map(field => new QueryColumn(field)));
}

if (rawModel.distinctValues) {
distinctValues = Map<string, List<string>>(
Object.entries(rawModel.distinctValues).map(([key, value]) => [
key,
List<string>(value),
])
);
}
}

return new InferDomainResponse({
data,
fields,
reservedFields,
commentLineCount: rawModel.commentLineCount,
distinctValues,
});
}

// get the distinct values for a specific column, return empty list if the column doesn't exist
getDistinctValuesForColumn(columnName: string): List<string> {
return this.distinctValues.get(columnName, List<string>());
}
}

export function inferDomainFromFile(
file: File | string, // file or webdav url path
numLinesToInclude: number,
domainKindName?: string
domainKindName?: string,
distinctValueColumns?: string[]
): Promise<InferDomainResponse> {
return new Promise((resolve, reject) => {
const form = new FormData();
Expand All @@ -56,6 +75,10 @@ export function inferDomainFromFile(
if (domainKindName) {
form.append('domainKindName', domainKindName);
}
if (distinctValueColumns && distinctValueColumns.length > 0) {
// append each value separately so they are received as an array on the server
distinctValueColumns.forEach(col => form.append('distinctValueColumns', col));
}

Ajax.request({
url: ActionURL.buildURL('property', 'inferDomain.api'),
Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/public/files/FileAttachmentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,13 @@ export class FileAttachmentForm extends PureComponent<FileAttachmentFormProps, S
}
}

this.updatePreviewStatus('Uploading file...');

inferDomainFromFile(file, previewGridProps.previewCount, previewGridProps.domainKindName)
this.updatePreviewStatus('Loading file preview...');
inferDomainFromFile(
file,
previewGridProps.previewCount,
previewGridProps.domainKindName,
previewGridProps.distinctValueColumns
)
.then(response => {
this.updatePreviewStatus(null);

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/public/files/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface FileSizeLimitProps {

export interface FileGridPreviewProps {
acceptedFormats?: string; // comma-separated list of allowed extensions i.e. '.png, .jpg, .jpeg'
distinctValueColumns?: string[];
domainKindName?: string;
errorStyle?: string;
header?: string;
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/theme/fileupload.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@
.file-upload__file-entry-listing.well {
background-color: #f5f5f5;
}

.file-preview-grid__warning {
// since <p> tags have default margin, override it here for the warning "row"s
.row :last-child {
margin-bottom: 0;
}
.row:not(:last-child) {
margin-bottom: 10px;
}
}