Skip to content

Commit 523d891

Browse files
authored
Fix issues discovered by ermrestjs vite branch (#2628)
1 parent e206b36 commit 523d891

File tree

11 files changed

+156
-60
lines changed

11 files changed

+156
-60
lines changed

.github/workflows/e2e.yml

+18-18
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,6 @@ jobs:
138138
- name: Restart apache
139139
run: |
140140
sudo service apache2 restart
141-
- name: Run all features test spec
142-
id: test-all-features
143-
continue-on-error: true
144-
run: |
145-
cd chaise
146-
make testallfeatures
147-
- name: Run all features confirmation test spec
148-
id: test-all-features-confirmation
149-
continue-on-error: true
150-
run: |
151-
cd chaise
152-
make testallfeaturesconfirmation
153141
- name: Run default config test spec
154142
id: test-default-config
155143
continue-on-error: true
@@ -162,18 +150,30 @@ jobs:
162150
run: |
163151
cd chaise
164152
make testdeleteprohibited
165-
- name: Check on all features test spec
166-
if: always() && steps.test-all-features.outcome != 'success'
167-
run: exit 1
168-
- name: Check on all features confirmation test spec
169-
if: always() && steps.test-all-features-confirmation.outcome != 'success'
170-
run: exit 1
153+
- name: Run all features confirmation test spec
154+
id: test-all-features-confirmation
155+
continue-on-error: true
156+
run: |
157+
cd chaise
158+
make testallfeaturesconfirmation
159+
- name: Run all features test spec
160+
id: test-all-features
161+
continue-on-error: true
162+
run: |
163+
cd chaise
164+
make testallfeatures
171165
- name: Check on default config test spec
172166
if: always() && steps.test-default-config.outcome != 'success'
173167
run: exit 1
174168
- name: Check on delete prohibited test spec
175169
if: always() && steps.test-delete-prohibited.outcome != 'success'
176170
run: exit 1
171+
- name: Check on all features confirmation test spec
172+
if: always() && steps.test-all-features-confirmation.outcome != 'success'
173+
run: exit 1
174+
- name: Check on all features test spec
175+
if: always() && steps.test-all-features.outcome != 'success'
176+
run: exit 1
177177
- uses: actions/upload-artifact@v4
178178
if: always()
179179
with:

Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ CHAISE_BASE_PATH:=$(WEB_URL_ROOT)$(CHAISE_REL_PATH)
2727
ERMRESTJS_BASE_PATH:=$(WEB_URL_ROOT)$(ERMRESTJS_REL_PATH)
2828
OSD_VIEWER_BASE_PATH:=$(WEB_URL_ROOT)$(OSD_VIEWER_REL_PATH)
2929

30-
# ERMrestjs dependencies
31-
ERMRESTJS_DEPS=ermrest.vendor.min.js \
32-
ermrest.min.js
33-
3430
# Project name
3531
PROJ=chaise
3632

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@isrd-isi-edu/chaise",
33
"description": "An adaptive User Interface for ERMrest data sources",
4-
"version": "0.0.25",
4+
"version": "0.0.26",
55
"license": "Apache-2.0",
66
"engines": {
77
"node": ">= 20.0.0",

src/components/modals/upload-progress-modal.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ const UploadProgressModal = ({ rows, linkedData, show, onSuccess, onCancel }: Up
199199
setIsUpload(false);
200200
uploadRowsRef.current.forEach((row: UploadFileObject[]) => {
201201
row.forEach((item: UploadFileObject) => {
202-
item.hatracObj.calculateChecksum(item.row, item.linkedData).then(
203-
(url: string) => onChecksumCompleted(item, url),
204-
onError,
205-
(uploaded: number) => onChecksumProgressChanged(item, uploaded));
202+
item.hatracObj.calculateChecksum(
203+
item.row,
204+
item.linkedData,
205+
(uploaded: number) => onChecksumProgressChanged(item, uploaded)
206+
).then((url: string) => onChecksumCompleted(item, url)).catch(onError);
206207
});
207208
});
208209
};
@@ -286,10 +287,10 @@ const UploadProgressModal = ({ rows, linkedData, show, onSuccess, onCancel }: Up
286287
let startChunkIdx = 0;
287288
if (item.partialUpload) startChunkIdx = lastContiguousChunkRef.current?.[item.uploadKey].lastChunkIdx + 1;
288289

289-
item.hatracObj.start(startChunkIdx).then(
290-
() => onUploadCompleted(item),
291-
onError,
292-
(size: number) => onProgressChanged(item, size));
290+
item.hatracObj.start(
291+
startChunkIdx,
292+
(size: number) => onProgressChanged(item, size)
293+
).then(() => onUploadCompleted(item)).catch(onError)
293294
};
294295

295296
// Complete upload jobs one by one

src/models/record.ts

+29-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import {
66
RecordsetProviderUpdateMainEntity
77
} from '@isrd-isi-edu/chaise/src/models/recordset'
88

9-
// utils
10-
import { isObjectAndNotNull } from '@isrd-isi-edu/chaise/src/utils/type-utils';
11-
129
export interface RecordRelatedModelRecordsetProps {
1310
page: any,
1411
isLoading: boolean,
@@ -21,12 +18,27 @@ export interface RecordRelatedModel {
2118
isInline: boolean,
2219
isPureBinary: boolean,
2320
initialReference: any,
21+
/**
22+
* whether we're showing the tabular view or custom view
23+
*/
2424
isTableDisplay: boolean,
25-
// this indicates that the tableMarkdownContent has been initialized:
26-
// we should not show the related table before initialzing the tableMarkdownContent
25+
/**
26+
* this indicates that the tableMarkdownContent has been initialized:
27+
* we should not show the related table before initialzing the tableMarkdownContent
28+
*/
2729
tableMarkdownContentInitialized: boolean,
28-
tableMarkdownContent: string|null, // TODO
30+
/**
31+
* the "custom display" content.
32+
*/
33+
tableMarkdownContent: string|null,
34+
/**
35+
* information that the recordset provider shares with record page
36+
* (has page, isLoading, etc)
37+
*/
2938
recordsetState: RecordRelatedModelRecordsetProps,
39+
/**
40+
* The props that will be passed to the recordset provider for the related model
41+
*/
3042
recordsetProps: {
3143
initialPageLimit: number,
3244
config: RecordsetConfig,
@@ -54,11 +66,19 @@ export interface RecordColumnModel {
5466

5567
export interface RecordRelatedRequestModel {
5668
index: number,
57-
// whether we should do the waitfor logic:
69+
/**
70+
* whether we should do the waitfor logic:
71+
*/
5872
hasWaitFor: boolean,
59-
// this indicates that we got the waitfor data:
60-
// only if w got the waitfor data, and the main data we can popuplate the tableMarkdownContent value
73+
/**
74+
* this indicates that we got the waitfor data:
75+
* only if w got the waitfor data, and the main data we can popuplate the tableMarkdownContent value
76+
*/
6177
waitForDataLoaded: boolean,
78+
/**
79+
* to avoid computing this multiple times.
80+
*/
81+
tableMarkdownContentProcessed: boolean,
6282
registered: boolean,
6383
updateMainEntity: RecordsetProviderUpdateMainEntity,
6484
fetchSecondaryRequests: RecordsetProviderFetchSecondaryRequests,

src/providers/record.tsx

+73-5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export default function RecordProvider({
290290
if (m.hasWaitFor) {
291291
m.waitForDataLoaded = false;
292292
}
293+
m.tableMarkdownContentProcessed = false;
293294
});
294295

295296
// related table
@@ -300,6 +301,7 @@ export default function RecordProvider({
300301
if (m.hasWaitFor) {
301302
m.waitForDataLoaded = false;
302303
}
304+
m.tableMarkdownContentProcessed = false;
303305
});
304306

305307
// update the cause list
@@ -369,9 +371,14 @@ export default function RecordProvider({
369371
}
370372

371373
// -------------------------- flow control function ---------------------- //
372-
const printDebugMessage = (message: string, counter?: number): void => {
374+
const printDebugMessage = (message: string, relatedModel?: RecordRelatedModel, counter?: number): void => {
373375
counter = typeof counter !== 'number' ? flowControl.current.queue.counter : counter;
374-
$log.debug(`${Date.now()}, ${counter}: ${message}`);
376+
let dm = `${Date.now()}, ${counter}: `;
377+
if (relatedModel) {
378+
dm += `${relatedModel.isInline ? 'inline' : 'related'}(index=${relatedModel.index}), `;
379+
}
380+
dm += `${message}`;
381+
$log.debug(dm);
375382
};
376383

377384
/**
@@ -652,6 +659,7 @@ export default function RecordProvider({
652659
// this indicates that we got the waitfor data:
653660
// only if w got the waitfor data, and the main data we can popuplate the tableMarkdownContent value
654661
waitForDataLoaded: !col.hasWaitFor,
662+
tableMarkdownContentProcessed: false,
655663
updateMainEntity: () => { throw new Error('function not registered') },
656664
fetchSecondaryRequests: () => { throw new Error('function not registered') },
657665
addUpdateCauses: () => { throw new Error('function not registered') },
@@ -679,6 +687,7 @@ export default function RecordProvider({
679687
index,
680688
hasWaitFor: ref.display.sourceHasWaitFor,
681689
waitForDataLoaded: false,
690+
tableMarkdownContentProcessed: false,
682691
updateMainEntity: () => { throw new Error('function not registered') },
683692
fetchSecondaryRequests: () => { throw new Error('function not registered') },
684693
addUpdateCauses: () => { throw new Error('function not registered') },
@@ -708,10 +717,30 @@ export default function RecordProvider({
708717
* @param values the updated values
709718
*/
710719
const updateRelatedRecordsetState = (index: number, isInline: boolean, values: RecordRelatedModelRecordsetProps) => {
720+
printDebugMessage(`${isInline ? 'inline' : 'related'}(index=${index}), updating recordset state isLoading: ${values.isLoading}`);
721+
const updatedValues: { [key: string]: any } = { recordsetState: values };
722+
723+
/**
724+
* There might be a delay between recieving the data and updating the state. If the delay is long enough that the
725+
* waitForDataLoaded is set to true but the recordsetState still is not updated, the attachPseudoColumnValue might not
726+
* be able to process the markdown content. So the following checks if that the case and if so, it would compute the
727+
* markdown content.
728+
*/
729+
const rm = isInline ? flowControl.current.inlineRelatedRequestModels[index] : flowControl.current.relatedRequestModels[index];
730+
const m = isInline ? columnModels[index].relatedModel : relatedModels[index];
731+
const hasMainData = values.page && !values.isLoading;
732+
const hasWaitForData = !rm.hasWaitFor || rm.waitForDataLoaded;
733+
if (!rm.tableMarkdownContentProcessed && hasMainData && hasWaitForData) {
734+
printDebugMessage('updating markdown content in updateRelatedRecordsetState', m);
735+
rm.tableMarkdownContentProcessed = true;
736+
updatedValues.tableMarkdownContentInitialized = true;
737+
updatedValues.tableMarkdownContent = values.page.getContent(flowControl.current.templateVariables);
738+
}
739+
711740
if (isInline) {
712-
setColumnModelsRelatedModelByIndex(index, { recordsetState: values });
741+
setColumnModelsRelatedModelByIndex(index, updatedValues);
713742
} else {
714-
setRelatedModelsByIndex(index, { recordsetState: values });
743+
setRelatedModelsByIndex(index, updatedValues);
715744
}
716745
};
717746

@@ -754,13 +783,19 @@ export default function RecordProvider({
754783
reqModel.processed = !res.success;
755784

756785
const rm = isInline ? flowControl.current.inlineRelatedRequestModels[index] : flowControl.current.relatedRequestModels[index];
786+
const m = isInline ? columnModels[index].relatedModel : relatedModels[index];
757787

758788
/*
759789
* the returned `res` boolean indicates whether we should consider this response final or not.
760790
* it doesn't necessarily mean that the response was successful, so we should not use the page blindly.
761791
* If the request errored out (timeout or other types of error) page will be undefined.
762792
*/
763-
if (res.success && res.page && (!rm.hasWaitFor || rm.waitForDataLoaded)) {
793+
const hasMainData = res.success && res.page;
794+
const hasWaitForData = !rm.hasWaitFor || rm.waitForDataLoaded;
795+
if (hasMainData && hasWaitForData) {
796+
printDebugMessage('updating markdown content in afterUpdateRelatedEntity', m);
797+
798+
rm.tableMarkdownContentProcessed = true;
764799
const updatedValues = {
765800
tableMarkdownContentInitialized: true,
766801
tableMarkdownContent: res.page.getContent(flowControl.current.templateVariables)
@@ -770,6 +805,8 @@ export default function RecordProvider({
770805
} else {
771806
setRelatedModelsByIndex(index, updatedValues);
772807
}
808+
} else {;
809+
printDebugMessage(`unable to update markdown content, main:${hasMainData}, waitFor: ${hasWaitForData}`, m);
773810
}
774811
};
775812
};
@@ -810,12 +847,28 @@ export default function RecordProvider({
810847
cb = activeListModel.column.getAggregatedValue(pageRef.current, logObj);
811848
}
812849

850+
const dependentSummary = activeListModel.objects.map((obj: any) => {
851+
let objType;
852+
if (obj.column) {
853+
objType = 'column';
854+
} else if (obj.inline) {
855+
objType = 'inline';
856+
} else {
857+
objType = 'related';
858+
}
859+
return `${objType}(index=${obj.index})`;
860+
});
861+
862+
const description = `(${activeListModel.entityset ? 'entityset' : 'aggregate'}) for: ${dependentSummary.join(', ')}`;
863+
printDebugMessage(`fetching 2nd req ${description}`);
813864
cb.then(function (values: any) {
814865
if (flowControl.current.queue.counter !== current) {
815866
resolve(false);
816867
return;
817868
}
818869

870+
printDebugMessage(`successful 2nd req fetch ${description}`);
871+
819872
// remove the column error (they might retry)
820873
const errroIndexes: any = {};
821874
activeListModel.objects.forEach(function (obj: any) {
@@ -876,6 +929,8 @@ export default function RecordProvider({
876929
return;
877930
}
878931

932+
printDebugMessage(`failed 2nd req ${description}`);
933+
879934
const errorIndexes: any = {};
880935
activeListModel.objects.forEach(function (obj: any) {
881936
if (obj.column || obj.inline) {
@@ -959,6 +1014,7 @@ export default function RecordProvider({
9591014
reqModel = flowControl.current.inlineRelatedRequestModels[obj.index];
9601015
}
9611016
const hasAll = ref.display.sourceWaitFor.every(hasColumnData);
1017+
printDebugMessage(`hasAll: ${hasAll}`, obj.related ? relatedModelsRef.current[obj.index] : columnModelsRef.current[obj.index].relatedModel);
9621018
if (!hasAll) return;
9631019

9641020
// in case the main request was slower, this will just signal so the other
@@ -974,6 +1030,8 @@ export default function RecordProvider({
9741030
}
9751031
});
9761032

1033+
printDebugMessage(`attachPseudoColumnValue, doneInlines: ${Object.keys(doneInlines)}, doneRelated: ${Object.keys(doneRelated)}`);
1034+
9771035
// set the values
9781036
setRecordValues((prevValues: any) => (
9791037
prevValues.map((val: any, index: number) => {
@@ -995,10 +1053,15 @@ export default function RecordProvider({
9951053
// otherwise we should just wait for the related/inline table data to get back to popuplate the tableMarkdownContent
9961054
let mdProps: { tableMarkdownContentInitialized: boolean, tableMarkdownContent: string | null } | object = {};
9971055
if (val.relatedModel.recordsetState.page && !val.relatedModel.recordsetState.isLoading) {
1056+
printDebugMessage('updating markdown content in attachPseudoColumnValue', val.relatedModel);
1057+
const rm = flowControl.current.inlineRelatedRequestModels[index];
1058+
rm.tableMarkdownContentProcessed = true;
9981059
mdProps = {
9991060
tableMarkdownContentInitialized: true,
10001061
tableMarkdownContent: val.relatedModel.recordsetState.page.getContent(flowControl.current.templateVariables),
10011062
}
1063+
} else {
1064+
printDebugMessage('unable to update markdown content since main page is still not loaded', val.relatedModel);
10021065
}
10031066
return { ...val, isLoading: false, relatedModel: { ...val.relatedModel, ...mdProps } };
10041067
}
@@ -1013,11 +1076,16 @@ export default function RecordProvider({
10131076
// if the page data is already fetched, we can just popuplate the tableMarkdownContent value.
10141077
// otherwise we should just wait for the related/inline table data to get back to popuplate the tableMarkdownContent
10151078
if (val.recordsetState.page && !val.recordsetState.isLoading) {
1079+
printDebugMessage('updating markdown content in attachPseudoColumnValue', val);
1080+
const rm = flowControl.current.relatedRequestModels[index];
1081+
rm.tableMarkdownContentProcessed = true;
10161082
return {
10171083
...val,
10181084
tableMarkdownContentInitialized: true,
10191085
tableMarkdownContent: val.recordsetState.page.getContent(flowControl.current.templateVariables),
10201086
}
1087+
} else {
1088+
printDebugMessage('unable to update markdown content since main page is still not loaded', val);
10211089
}
10221090
}
10231091
return val;

0 commit comments

Comments
 (0)