Skip to content

Commit 2c668c3

Browse files
committed
Get file details panel to show/hide with prov
1 parent 488ffd0 commit 2c668c3

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

packages/core/components/FileDetails/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ import { useDispatch } from "react-redux";
66
import FileAnnotationList from "./FileAnnotationList";
77
import Pagination from "./Pagination";
88
import useFileDetails from "./useFileDetails";
9+
import useThumbnailPath from "./useThumbnailPath";
910
import { PrimaryButton, TertiaryButton } from "../Buttons";
1011
import Tooltip from "../Tooltip";
1112
import { ROOT_ELEMENT_ID } from "../../App";
1213
import FileThumbnail from "../../components/FileThumbnail";
14+
import useDownloadFiles from "../../hooks/useDownloadFiles";
1315
import useOpenWithMenuItems from "../../hooks/useOpenWithMenuItems";
1416
import useTruncatedString from "../../hooks/useTruncatedString";
1517
import { interaction } from "../../state";
1618

1719
import styles from "./FileDetails.module.css";
18-
import useDownloadFiles from "../../hooks/useDownloadFiles";
19-
import useThumbnailPath from "./useThumbnailPath";
20+
2021

2122
interface Props {
2223
className?: string;
@@ -76,11 +77,10 @@ export default function FileDetails(props: Props) {
7677
const dispatch = useDispatch();
7778

7879
const [fileDetails, isLoading] = useFileDetails();
79-
const openWithMenuItems = useOpenWithMenuItems(fileDetails || undefined);
80+
const openWithMenuItems = useOpenWithMenuItems(fileDetails);
8081
const truncatedFileName = useTruncatedString(fileDetails?.name || "", 30);
81-
const { isThumbnailLoading, thumbnailPath } = useThumbnailPath(fileDetails || undefined);
82-
const { isDownloadDisabled, disabledDownloadReason, onDownload } = useDownloadFiles(fileDetails || undefined);
83-
82+
const { isThumbnailLoading, thumbnailPath } = useThumbnailPath(fileDetails);
83+
const { isDownloadDisabled, disabledDownloadReason, onDownload } = useDownloadFiles(fileDetails);
8484

8585
return (
8686
<div

packages/core/components/FileDetails/useFileDetails.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { isUndefined } from "lodash";
21
import * as React from "react";
32
import { useSelector } from "react-redux";
43

@@ -10,10 +9,10 @@ import { selection } from "../../state";
109
* This hook exposes loading state: if a network request is in flight for file details the second element
1110
* of the return array will be true.
1211
*/
13-
export default function useFileDetails(): [FileDetail | null, boolean] {
12+
export default function useFileDetails(): [FileDetail | undefined, boolean] {
1413
const fileSelection = useSelector(selection.selectors.getFileSelection);
1514

16-
const [fileDetails, setFileDetails] = React.useState<FileDetail | null>(null);
15+
const [fileDetails, setFileDetails] = React.useState<FileDetail | undefined>();
1716
const [isLoading, setIsLoading] = React.useState(false);
1817

1918
React.useEffect(() => {
@@ -26,13 +25,7 @@ export default function useFileDetails(): [FileDetail | null, boolean] {
2625
fileSelection
2726
.fetchFocusedItemDetails()
2827
.then((detail) => {
29-
if (ignoreResponse) {
30-
return;
31-
}
32-
33-
if (isUndefined(detail)) {
34-
setFileDetails(null);
35-
} else {
28+
if (!ignoreResponse) {
3629
setFileDetails(detail);
3730
}
3831
})

packages/core/components/RelationshipDiagram/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import classNames from "classnames";
21
import * as React from "react";
32
import { useDispatch, useSelector } from "react-redux";
43

@@ -11,14 +10,15 @@ import styles from "./RelationshipDiagram.module.css";
1110

1211

1312
interface Props {
13+
className?: string;
1414
origin?: FileDetail;
1515
}
1616

1717
/**
1818
* Overlay for displaying a relationship diagram/graph
1919
* Should use as much of the screen as possible
2020
*/
21-
export default function RelationshipDiagram({ origin }: Props) {
21+
export default function RelationshipDiagram({ className, origin }: Props) {
2222
const dispatch = useDispatch();
2323
const provenanceRefreshKey = useSelector(interaction.selectors.getProvenanceRefreshKey);
2424

@@ -29,10 +29,8 @@ export default function RelationshipDiagram({ origin }: Props) {
2929
}
3030
}, [origin, originalOriginName, setOriginalOriginName]);
3131

32-
console.log("hidden", !!origin, origin);
33-
3432
return (
35-
<div className={classNames({ [styles.hidden]: !!origin})}>
33+
<div className={className}>
3634
<div className={styles.header}>
3735
<PrimaryButton
3836
iconName="Back"

packages/core/state/interaction/reducer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ export default makeReducer<InteractionStateBranch>(
196196
}),
197197
[SET_ORIGIN_FOR_PROVENANCE]: (state, action: SetOriginForProvenance) => ({
198198
...state,
199-
originForProvenance: action.payload,
199+
fileForDetailPanel: undefined,
200200
provenanceRefreshKey: uniqueId(),
201+
originForProvenance: action.payload,
201202
}),
202203
[SET_VISIBLE_MODAL]: (state, action: SetVisibleModalAction) => ({
203204
...state,

0 commit comments

Comments
 (0)