Skip to content

Commit

Permalink
Merge branch 'develop' into topher/bump-mongoengine
Browse files Browse the repository at this point in the history
  • Loading branch information
findtopher authored Oct 29, 2024
2 parents 5ea2521 + cf5a33d commit ecb591f
Show file tree
Hide file tree
Showing 160 changed files with 5,097 additions and 1,908 deletions.
1 change: 1 addition & 0 deletions app/packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<div id="teams"></div>
<div id="modal"></div>
<div id="colorModal"></div>
<div id="queryPerformance"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
113 changes: 113 additions & 0 deletions app/packages/app/src/components/QueryPerformanceToast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { Toast } from "@fiftyone/components";
import { QP_MODE } from "@fiftyone/core";
import { getBrowserStorageEffectForKey } from "@fiftyone/state";
import { Box, Button, Typography } from "@material-ui/core";
import { Bolt } from "@mui/icons-material";
import React, { useEffect, useState } from "react";
import { createPortal } from "react-dom";
import { atom, useRecoilState } from "recoil";

const SHOWN_FOR = 10000;

const hideQueryPerformanceToast = atom({
key: "hideQueryPerformanceToast",
default: false,
effects: [
getBrowserStorageEffectForKey("hideQueryPerformanceToast", {
valueClass: "boolean",
}),
],
});

const QueryPerformanceToast = () => {
const [shown, setShown] = useState(false);
const [disabled, setDisabled] = useRecoilState(hideQueryPerformanceToast);
const element = document.getElementById("queryPerformance");

useEffect(() => {
const listen = () => {
setShown(true);
};
window.addEventListener("queryperformance", listen);
return () => window.removeEventListener("queryperformance", listen);
}, []);

if (!element) {
throw new Error("no query performance element");
}

if (!shown || disabled) {
return null;
}

return createPortal(
<Toast
duration={SHOWN_FOR}
primary={(setOpen) => {
return (
<Button
variant="contained"
size="small"
onClick={() => {
open(QP_MODE, "_blank")?.focus();
setOpen(false);
}}
style={{ marginLeft: "auto" }} // Right align the button
>
View Documentation
</Button>
);
}}
secondary={(setOpen) => {
return (
<div>
<Button
variant="text"
color="secondary"
size="small"
onClick={() => {
setDisabled(true);
setOpen(false);
}}
style={{ marginLeft: "auto" }} // Right align the button
>
Don&apos;t show me again
</Button>
</div>
);
}}
message={
<>
<Box sx={{ display: "flex", alignItems: "center" }}>
<Bolt sx={{ color: "#f5b700", marginRight: "8px" }} />
<Typography
variant="subtitle1"
sx={{ fontWeight: 500, marginRight: "8px" }}
>
Query Performance is Available!
</Typography>
<Typography
variant="caption"
sx={{
color: "#fff",
borderRadius: "2px",
padding: "2px 4px",
fontWeight: 600,
}}
>
NEW
</Typography>
</Box>
<br />
<Typography variant="body2" sx={{ color: "#757575" }}>
Index the most critical fields for faster data loading and query
performance.
</Typography>
</>
}
/>,
element
);
};

export default QueryPerformanceToast;
20 changes: 3 additions & 17 deletions app/packages/app/src/pages/__generated__/IndexPageQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/packages/app/src/pages/datasets/DatasetPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { usePreloadedQuery } from "react-relay";
import { useRecoilValue } from "recoil";
import { graphql } from "relay-runtime";
import Nav from "../../components/Nav";
import QueryPerformanceToast from "../../components/QueryPerformanceToast";
import type { Route } from "../../routing";
import style from "../index.module.css";
import type { DatasetPageQuery } from "./__generated__/DatasetPageQuery.graphql";
Expand Down Expand Up @@ -115,6 +116,7 @@ const DatasetPage: Route<DatasetPageQuery> = ({ prepared }) => {
)}
</div>
<Snackbar />
<QueryPerformanceToast />
</Nav>
);
};
Expand Down
Loading

0 comments on commit ecb591f

Please sign in to comment.