From 5e98ba54fa1e57bcd2fa8c3b8ffdd3757ece6fa4 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Fri, 2 Aug 2024 08:05:43 -0700 Subject: [PATCH 1/2] dashboard edit support --- .../SchemaIO/components/DashboardView.tsx | 26 +++++++++++++++++++ fiftyone/operators/types.py | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx b/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx index 8d9e729268..4558de6512 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx @@ -19,6 +19,7 @@ import { Button } from "."; import { getPath, getProps } from "../utils"; import { ObjectSchemaType, ViewPropsType } from "../utils/types"; import DynamicIO from "./DynamicIO"; +import { Edit } from "@mui/icons-material"; const AddItemCTA = ({ onAdd }) => { return ( @@ -69,6 +70,7 @@ export default function DashboardView(props: ViewPropsType) { const propertiesAsArray = []; const allow_addition = schema.view.allow_addition; const allow_deletion = schema.view.allow_deletion; + const allow_edit = schema.view.allow_edit; for (const property in properties) { propertiesAsArray.push({ id: property, ...properties[property] }); @@ -76,6 +78,17 @@ export default function DashboardView(props: ViewPropsType) { const panelId = usePanelId(); const triggerPanelEvent = usePanelEvent(); + const onEditItem = useCallback( + ({ id, path }) => { + if (schema.view.on_edit_item) { + triggerPanelEvent(panelId, { + operator: schema.view.on_edit_item, + params: { id, path }, + }); + } + }, + [panelId, props, schema.view.on_edit_item, triggerPanelEvent] + ); const onCloseItem = useCallback( ({ id, path }) => { if (schema.view.on_remove_item) { @@ -185,6 +198,19 @@ export default function DashboardView(props: ViewPropsType) { > {property.title || id} + {allow_edit && ( + e.stopPropagation()} + onClick={(e) => { + e.stopPropagation(); + onEditItem({ id, path: getPath(path, id) }); + }} + sx={{ color: theme.text.secondary }} + > + + + )} {allow_deletion && ( Date: Fri, 2 Aug 2024 08:15:53 -0700 Subject: [PATCH 2/2] dashboard edit fixes --- .../SchemaIO/components/DashboardView.tsx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx b/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx index 4558de6512..50bd7b8e13 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/DashboardView.tsx @@ -198,32 +198,34 @@ export default function DashboardView(props: ViewPropsType) { > {property.title || id} - {allow_edit && ( - e.stopPropagation()} - onClick={(e) => { - e.stopPropagation(); - onEditItem({ id, path: getPath(path, id) }); - }} - sx={{ color: theme.text.secondary }} - > - - - )} - {allow_deletion && ( - e.stopPropagation()} - onClick={(e) => { - e.stopPropagation(); - onCloseItem({ id, path: getPath(path, id) }); - }} - sx={{ color: theme.text.secondary }} - > - - - )} + + {allow_edit && ( + e.stopPropagation()} + onClick={(e) => { + e.stopPropagation(); + onEditItem({ id, path: getPath(path, id) }); + }} + sx={{ color: theme.text.secondary }} + > + + + )} + {allow_deletion && ( + e.stopPropagation()} + onClick={(e) => { + e.stopPropagation(); + onCloseItem({ id, path: getPath(path, id) }); + }} + sx={{ color: theme.text.secondary }} + > + + + )} +