Skip to content

Commit

Permalink
Merge pull request #388 from AllenInstitute/feature/356-copy-to-vast-…
Browse files Browse the repository at this point in the history
…status-indicator

356: Copy to VAST status indicator
  • Loading branch information
pgarrison authored Jan 9, 2025
2 parents 58d348c + a64aeb5 commit 89df078
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
/* flex child */
flex: 1 1 100%;
}

.status-indicator {
font-style: italic;
}
19 changes: 12 additions & 7 deletions packages/core/components/FileDetails/FileAnnotationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ export default function FileAnnotationList(props: FileAnnotationListProps) {
}

let annotationValue = annotation.extractFromFile(fileDetails);
if (annotationValue === Annotation.MISSING_VALUE) {
// Nothing to show for this annotation -- skip
return accum;
}
let fmsStateIndicator = false;

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

if (annotationValue === Annotation.MISSING_VALUE) {
// Nothing to show for this annotation -- skip
return accum;
}

return [
...accum,
<FileAnnotationRow
key={annotation.displayName}
className={styles.row}
name={annotation.displayName}
value={annotationValue}
fmsStateIndicator={fmsStateIndicator}
/>,
];
}, [] as JSX.Element[]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
/* Allow whitespace to be rendered (including carriage returns & new lines) */
white-space: pre-wrap;
}

.fms-state-indicator {
font-style: italic;
}
2 changes: 2 additions & 0 deletions packages/core/components/FileDetails/FileAnnotationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface FileAnnotationRowProps {
className?: string;
name: string;
value: string;
fmsStateIndicator?: boolean;
}

/**
Expand Down Expand Up @@ -66,6 +67,7 @@ export default function FileAnnotationRow(props: FileAnnotationRowProps) {
<Cell
className={classNames(styles.cell, styles.value, {
[styles.smallFont]: shouldDisplaySmallFont,
[styles.fmsStateIndicator]: props.fmsStateIndicator,
})}
columnKey="value"
width={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,47 @@ describe("<FileAnnotationList />", () => {
}
);
});

it("has loading message when file is downloading", () => {
// Arrange
class FakeExecutionEnvService extends ExecutionEnvServiceNoop {
public formatPathForHost(posixPath: string): Promise<string> {
return Promise.resolve(posixPath);
}
}
const { store } = configureMockStore({
state: mergeState(initialState, {
metadata: {
annotations: TOP_LEVEL_FILE_ANNOTATIONS,
},
interaction: {
platformDependentServices: {
executionEnvService: new FakeExecutionEnvService(),
},
},
}),
});

const fileDetails = new FileDetail({
file_path: "path/to/file",
file_id: "abc123",
file_name: "MyFile.txt",
file_size: 7,
uploaded: "01/01/01",
annotations: [{ name: "shouldBeInLocal", values: [true] }],
});

// Act
const { findByText } = render(
<Provider store={store}>
<FileAnnotationList isLoading={false} fileDetails={fileDetails} />
</Provider>
);

// Assert
["File Path (Local VAST)", "Copying to VAST in progress…"].forEach(async (cellText) => {
expect(await findByText(cellText)).to.not.be.undefined;
});
});
});
});
1 change: 1 addition & 0 deletions packages/core/entity/Annotation/AnnotationName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
FILE_PATH: "file_path", // a file attribute (top-level prop on file documents in MongoDb)
LOCAL_FILE_PATH: "Local File Path", // (optional) annotation for FMS files on the local NAS
PLATE_BARCODE: "Plate Barcode",
SHOULD_BE_IN_LOCAL: "Should Be in Local Cache",
THUMBNAIL_PATH: "thumbnail", // (optional) file attribute (top-level prop on the file documents in MongoDb)
TYPE: "Type", // matches an annotation in filemetadata.annotation
UPLOADED: "uploaded", // matches an annotation in filemetadata.annotation
Expand Down
5 changes: 5 additions & 0 deletions packages/core/entity/FileDetail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ export default class FileDetail {
return this.path;
}

public get downloadInProgress(): boolean {
const shouldBeInLocal = this.getFirstAnnotationValue(AnnotationName.SHOULD_BE_IN_LOCAL);
return Boolean(shouldBeInLocal) && !this.localPath;
}

public get size(): number | undefined {
const size = this.fileDetail.file_size || this.getFirstAnnotationValue("File Size");
if (size === undefined) {
Expand Down

0 comments on commit 89df078

Please sign in to comment.