Skip to content

Commit

Permalink
Merge pull request #5163 from voxel51/merge/release/v1.1.0
Browse files Browse the repository at this point in the history
Merge `release/v1.1.0` to `develop`
  • Loading branch information
benjaminpkane authored Nov 22, 2024
2 parents f3604d5 + d4b81bb commit 6a5b17f
Show file tree
Hide file tree
Showing 63 changed files with 1,548 additions and 9,149 deletions.
2 changes: 1 addition & 1 deletion app/packages/app/src/routing/RouterContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const makeGetEntryResource = <T extends OperationType>() => {
hard: boolean;
handleError?: (error: unknown) => void;
}): Resource<Entry<T>> => {
if (isReusable(location)) {
if (!hard && isReusable(location)) {
// throw the current resource (page) if it can be reused
throw currentResource;
}
Expand Down
2 changes: 1 addition & 1 deletion app/packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@fiftyone/state": "*",
"@mui/icons-material": "^5.10.2",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.9.0",
"@react-spring/web": "^9.7.3",
"@textea/json-viewer": "^3.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ const PillBadge = ({
success: "#8BC18D",
};

const getColor = (colorValue: string): string => {
return COLORS[colorValue] || colorValue;
};

const chipStyle: { [key: string]: string | number } = {
color: COLORS[chipColor || "default"] || COLORS.default,
color: getColor(chipColor || color || "default"),
fontSize: 14,
fontWeight: 500,
paddingLeft: 1,
Expand Down
2 changes: 1 addition & 1 deletion app/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fiftyone/state": "*",
"@fiftyone/utilities": "*",
"@monaco-editor/react": "^4.5.0",
"@mui/icons-material": "^5.10.2",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.9.0",
"@react-spring/web": "^9.4.3",
"@use-gesture/react": "^10.3.0",
Expand Down
36 changes: 0 additions & 36 deletions app/packages/core/src/components/FieldLabelAndInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { InfoIcon, useTheme } from "@fiftyone/components";
import * as fos from "@fiftyone/state";
import { coloring } from "@fiftyone/state";
import { Field, formatDate, formatDateTime } from "@fiftyone/utilities";
import Bolt from "@mui/icons-material/Bolt";
import PaletteIcon from "@mui/icons-material/Palette";
import React, {
MutableRefObject,
Expand All @@ -20,7 +19,6 @@ import {
} from "recoil";
import styled from "styled-components";
import { ExternalLink } from "../../utils/generic";
import { QP_MODE } from "../../utils/links";
import { activeColorEntry } from "../ColorModal/state";

const selectedFieldInfo = atom<string | null>({
Expand Down Expand Up @@ -321,40 +319,6 @@ function FieldInfoExpanded({
);
}

const QueryPerformance: React.FunctionComponent<{
color: string;
path: string;
}> = ({ color, path }) => {
const queryPerformance = useRecoilValue(fos.queryPerformance);
const indexed = useRecoilValue(fos.pathHasIndexes(path));
const theme = useTheme();
if (!queryPerformance || !indexed) {
return null;
}

return (
<FieldInfoTableContainer color={color}>
<tbody>
<tr>
<td>
<Bolt sx={{ color }} fontSize={"small"} />
</td>
<td>
<ContentValue>
<ExternalLink
style={{ color: theme.text.primary }}
href={QP_MODE}
>
Lightning indexed
</ExternalLink>
</ContentValue>
</td>
</tr>
</tbody>
</FieldInfoTableContainer>
);
};

type CustomizeColorProp = {
color: string;
onClick: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const NumericFieldFilter = ({ color, modal, named = true, path }: Props) => {
};

return (
<Container onClick={(e) => e.stopPropagation()}>
<Container
data-cy={`numeric-filter-${path}`}
onClick={(e) => e.stopPropagation()}
>
{named && name && (
<FieldLabelAndInfo
nested
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selector, useTheme } from "@fiftyone/components";
import * as fos from "@fiftyone/state";
import Bolt from "@mui/icons-material/Bolt";
import React from "react";
import type { RecoilState } from "recoil";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import FieldLabelAndInfo from "../../FieldLabelAndInfo";
import { LightningBolt } from "../../Sidebar/Entries/FilterablePathEntry/Icon";
import { isInKeypointsField } from "../state";
import useQueryPerformanceTimeout from "../use-query-performance-timeout";
import Checkboxes from "./Checkboxes";
Expand Down Expand Up @@ -103,9 +103,7 @@ const StringFilter = ({
template={({ label, hoverTarget }) => (
<NamedStringFilterHeader>
<span ref={hoverTarget}>{label}</span>
{showQueryPerformanceIcon && (
<Bolt fontSize={"small"} sx={{ color: theme.action.active }} />
)}
{showQueryPerformanceIcon && <LightningBolt />}
</NamedStringFilterHeader>
)}
/>
Expand Down
4 changes: 4 additions & 0 deletions app/packages/core/src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function Grid() {
looker?.destroy();
lookerStore.delete(id.description);
},
detach: (id) => {
const looker = lookerStore.get(id.description);
looker?.detach();
},
onItemClick: setSample,
retainItems: true,
rowAspectRatioThreshold: threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { useRecoilValue } from "recoil";
import styled from "styled-components";
import Arrow from "./Arrow";

export const LightningIcon = styled(Bolt)`
const LightningIcon = styled(Bolt)`
color: ${({ theme }) => theme.text.secondary};
`;

export const LightningBolt: React.FC = (_) => {
return (
<Tooltip placement="top-center" text={"Indexed"}>
<LightningIcon style={{ height: 16, marginRight: 2, width: 16 }} />
<LightningIcon
data-cy={"query-performance"}
style={{ height: 16, marginRight: 2, width: 16 }}
/>
</Tooltip>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const QueryPerformanceIcon = () => {
<Box sx={{ padding: "8px 8px 8px 8px" }}>
<SectionTitle>Query Performance is Enabled</SectionTitle>
<Text>
Some fields are indexed for better query performance. You can
create or manage indexes from here.
Fields that are indexed will have better query performance.
</Text>
<Box
display="flex"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ export default function Evaluation(props: EvaluationProps) {
variant="outlined"
color="secondary"
sx={{ width: "100%" }}
onClick={closeConfusionMatrixConfigDialog}
onClick={closeClassPerformanceConfigDialog}
>
Cancel
</Button>
Expand Down
49 changes: 28 additions & 21 deletions app/packages/core/src/plugins/SchemaIO/components/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function TableView(props: ViewPropsType) {
size = "small",
variant = "filled",
max_inline_actions = 1,
tooltips = []
tooltips = [],
} = view;
const { rows, selectedCells, selectedRows, selectedColumns } =
getTableData(props);
Expand All @@ -47,23 +47,26 @@ export default function TableView(props: ViewPropsType) {
const selectedCellColor =
selected_color || theme.palette.background.activeCell;

const getRowActions = useCallback((row) => {
const computedRowActions = [] as any;
for (const action of row_actions) {
if (action.rows?.[row] !== false) {
computedRowActions.push({
...action,
onClick: (action, e) => {
handleClick(panelId, {
operator: action.on_click,
params: { path, event: action.name, row },
});
},
});
const getRowActions = useCallback(
(row) => {
const computedRowActions = [] as any;
for (const action of row_actions) {
if (action.rows?.[row] !== false) {
computedRowActions.push({
...action,
onClick: (action, e) => {
handleClick(panelId, {
operator: action.on_click,
params: { path, event: action.name, row },
});
},
});
}
}
}
return computedRowActions;
}, []);
return computedRowActions;
},
[row_actions, handleClick, panelId, path]
);

const getTooltips = useCallback((tooltipList) => {
const tooltipDict = {};
Expand Down Expand Up @@ -181,14 +184,16 @@ export default function TableView(props: ViewPropsType) {
selectedCells.has(coordinate) ||
isRowSelected ||
selectedColumns.has(columnIndex);

const tooltip = tooltipMap[coordinate]; // Check if there's a tooltip for the cell
const content = formatCellValue(item[key], props);
const cell = (
<TableCell
key={key}
sx={{
background: isSelected ? selectedCellColor : "unset",
background: isSelected
? selectedCellColor
: "unset",
}}
onClick={() => {
handleCellClick(rowIndex, columnIndex);
Expand All @@ -199,10 +204,12 @@ export default function TableView(props: ViewPropsType) {
<Tooltip title={tooltip} arrow>
<span> {content} </span>
</Tooltip>
) : (content)}
) : (
content
)}
</TableCell>
);

return cell;
})}

Expand Down
117 changes: 117 additions & 0 deletions app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { useEffect, useRef } from "react";
import { usePanelEvent } from "@fiftyone/operators";
import { usePanelId } from "@fiftyone/spaces";
import { ViewPropsType } from "../utils/types";

export type TimerViewParams = {
on_interval?: string;
on_timeout?: string;
interval?: number;
timeout?: number;
params?: object;
};

class Timer {
protected _ref: NodeJS.Timeout | null = null;

start() {}
stop() {}
}

class IntervalTimer extends Timer {
constructor(private interval: number, private onInterval: () => void) {
super();
}

start() {
this.stop();
this._ref = setInterval(() => this.onInterval(), this.interval);
}
stop() {
if (this._ref) {
clearInterval(this._ref);
this._ref = null;
}
}
}

class TimeoutTimer extends Timer {
constructor(private timeout: number, private onTimeout: () => void) {
super();
}

start() {
this.stop();
this._ref = setTimeout(() => this.onTimeout(), this.timeout);
}
stop(): void {
if (this._ref) {
clearTimeout(this._ref);
this._ref = null;
}
}
}

function useTimer(params: TimerViewParams) {
const panelId = usePanelId();
const triggerEvent = usePanelEvent();
const {
on_interval,
interval,
timeout,
on_timeout,
params: operator_params,
} = params;
const ref = useRef<Timer | null>(null);

useEffect(() => {
if (!interval && !timeout) {
console.warn(
"useTimer requires either `interval` or `timeout` to be defined."
);
return;
}

const TimerType = interval ? IntervalTimer : TimeoutTimer;
const handleTimerEvent = interval
? () => {
if (on_interval) {
triggerEvent(panelId, {
operator: on_interval,
params: operator_params || {},
prompt: null,
});
}
}
: () => {
if (on_timeout) {
triggerEvent(panelId, {
operator: on_timeout,
params: operator_params || {},
prompt: null,
});
}
};

// Clean up existing timer
if (ref.current) {
ref.current.stop();
}

// Initialize and start the timer
ref.current = new TimerType(interval || timeout!, handleTimerEvent);
ref.current.start();

return () => {
ref.current?.stop();
};
}, [on_interval, interval, on_timeout, timeout, triggerEvent, panelId]);
}

export default function TimerView(props: ViewPropsType) {
const { schema } = props;
const { view = {} } = schema;

useTimer(view as TimerViewParams);
return null;
}
1 change: 1 addition & 0 deletions app/packages/core/src/plugins/SchemaIO/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export { default as TagsView } from "./TagsView";
export { default as TextFieldView } from "./TextFieldView";
export { default as TextView } from "./TextView";
export { default as TimelineView } from "./TimelineView";
export { default as TimerView } from "./TimerView";
export { default as ToastView } from "./ToastView";
export { default as TreeSelectionView } from "./TreeSelectionView";
export { default as TupleView } from "./TupleView";
Expand Down
Loading

0 comments on commit 6a5b17f

Please sign in to comment.