Skip to content

Commit 89df078

Browse files
authored
Merge pull request #388 from AllenInstitute/feature/356-copy-to-vast-status-indicator
356: Copy to VAST status indicator
2 parents 58d348c + a64aeb5 commit 89df078

File tree

7 files changed

+70
-7
lines changed

7 files changed

+70
-7
lines changed

packages/core/components/FileDetails/FileAnnotationList.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
/* flex child */
1313
flex: 1 1 100%;
1414
}
15+
16+
.status-indicator {
17+
font-style: italic;
18+
}

packages/core/components/FileDetails/FileAnnotationList.tsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ export default function FileAnnotationList(props: FileAnnotationListProps) {
7373
}
7474

7575
let annotationValue = annotation.extractFromFile(fileDetails);
76-
if (annotationValue === Annotation.MISSING_VALUE) {
77-
// Nothing to show for this annotation -- skip
78-
return accum;
79-
}
76+
let fmsStateIndicator = false;
8077

8178
if (annotation.name === AnnotationName.LOCAL_FILE_PATH) {
82-
if (localPath === null) {
83-
// localPath hasn't loaded yet, but it should eventually because there is an
84-
// annotation named AnnotationName.LOCAL_FILE_PATH
79+
if (fileDetails && fileDetails.downloadInProgress) {
80+
annotationValue = "Copying to VAST in progress…";
81+
fmsStateIndicator = true;
82+
} else if (localPath === null) {
83+
// localPath hasn't loaded yet or there is no local path annotation
8584
return accum;
8685
} else {
8786
// Use the user's /allen mount point, if known
@@ -94,13 +93,19 @@ export default function FileAnnotationList(props: FileAnnotationListProps) {
9493
annotationValue = fileDetails.cloudPath;
9594
}
9695

96+
if (annotationValue === Annotation.MISSING_VALUE) {
97+
// Nothing to show for this annotation -- skip
98+
return accum;
99+
}
100+
97101
return [
98102
...accum,
99103
<FileAnnotationRow
100104
key={annotation.displayName}
101105
className={styles.row}
102106
name={annotation.displayName}
103107
value={annotationValue}
108+
fmsStateIndicator={fmsStateIndicator}
104109
/>,
105110
];
106111
}, [] as JSX.Element[]);

packages/core/components/FileDetails/FileAnnotationRow.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@
5252
/* Allow whitespace to be rendered (including carriage returns & new lines) */
5353
white-space: pre-wrap;
5454
}
55+
56+
.fms-state-indicator {
57+
font-style: italic;
58+
}

packages/core/components/FileDetails/FileAnnotationRow.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface FileAnnotationRowProps {
1111
className?: string;
1212
name: string;
1313
value: string;
14+
fmsStateIndicator?: boolean;
1415
}
1516

1617
/**
@@ -66,6 +67,7 @@ export default function FileAnnotationRow(props: FileAnnotationRowProps) {
6667
<Cell
6768
className={classNames(styles.cell, styles.value, {
6869
[styles.smallFont]: shouldDisplaySmallFont,
70+
[styles.fmsStateIndicator]: props.fmsStateIndicator,
6971
})}
7072
columnKey="value"
7173
width={1}

packages/core/components/FileDetails/test/FileAnnotationList.test.tsx

+42
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,47 @@ describe("<FileAnnotationList />", () => {
123123
}
124124
);
125125
});
126+
127+
it("has loading message when file is downloading", () => {
128+
// Arrange
129+
class FakeExecutionEnvService extends ExecutionEnvServiceNoop {
130+
public formatPathForHost(posixPath: string): Promise<string> {
131+
return Promise.resolve(posixPath);
132+
}
133+
}
134+
const { store } = configureMockStore({
135+
state: mergeState(initialState, {
136+
metadata: {
137+
annotations: TOP_LEVEL_FILE_ANNOTATIONS,
138+
},
139+
interaction: {
140+
platformDependentServices: {
141+
executionEnvService: new FakeExecutionEnvService(),
142+
},
143+
},
144+
}),
145+
});
146+
147+
const fileDetails = new FileDetail({
148+
file_path: "path/to/file",
149+
file_id: "abc123",
150+
file_name: "MyFile.txt",
151+
file_size: 7,
152+
uploaded: "01/01/01",
153+
annotations: [{ name: "shouldBeInLocal", values: [true] }],
154+
});
155+
156+
// Act
157+
const { findByText } = render(
158+
<Provider store={store}>
159+
<FileAnnotationList isLoading={false} fileDetails={fileDetails} />
160+
</Provider>
161+
);
162+
163+
// Assert
164+
["File Path (Local VAST)", "Copying to VAST in progress…"].forEach(async (cellText) => {
165+
expect(await findByText(cellText)).to.not.be.undefined;
166+
});
167+
});
126168
});
127169
});

packages/core/entity/Annotation/AnnotationName.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default {
88
FILE_PATH: "file_path", // a file attribute (top-level prop on file documents in MongoDb)
99
LOCAL_FILE_PATH: "Local File Path", // (optional) annotation for FMS files on the local NAS
1010
PLATE_BARCODE: "Plate Barcode",
11+
SHOULD_BE_IN_LOCAL: "Should Be in Local Cache",
1112
THUMBNAIL_PATH: "thumbnail", // (optional) file attribute (top-level prop on the file documents in MongoDb)
1213
TYPE: "Type", // matches an annotation in filemetadata.annotation
1314
UPLOADED: "uploaded", // matches an annotation in filemetadata.annotation

packages/core/entity/FileDetail/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ export default class FileDetail {
173173
return this.path;
174174
}
175175

176+
public get downloadInProgress(): boolean {
177+
const shouldBeInLocal = this.getFirstAnnotationValue(AnnotationName.SHOULD_BE_IN_LOCAL);
178+
return Boolean(shouldBeInLocal) && !this.localPath;
179+
}
180+
176181
public get size(): number | undefined {
177182
const size = this.fileDetail.file_size || this.getFirstAnnotationValue("File Size");
178183
if (size === undefined) {

0 commit comments

Comments
 (0)