diff --git a/frontend/src/AppBuilder/QueryPanel/QueryCard.jsx b/frontend/src/AppBuilder/QueryPanel/QueryCard.jsx index fbad517a81..088f3c7318 100644 --- a/frontend/src/AppBuilder/QueryPanel/QueryCard.jsx +++ b/frontend/src/AppBuilder/QueryPanel/QueryCard.jsx @@ -13,6 +13,11 @@ import useStore from '@/AppBuilder/_stores/store'; import { Confirm } from '@/Editor/Viewer/Confirm'; // TODO: enable delete query confirmation popup import { debounce } from 'lodash'; +import { Button as ButtonComponent } from '@/components/ui/Button/Button.jsx'; +import Edit from '@/_ui/Icon/bulkIcons/Edit'; +import Trash from '@/_ui/Icon/solidIcons/Trash'; +import { OverlayTrigger, Popover } from 'react-bootstrap'; +import classNames from 'classnames'; export const QueryCard = ({ dataQuery, darkMode = false, localDs }) => { const appId = useStore((state) => state.app.appId); @@ -27,6 +32,7 @@ export const QueryCard = ({ dataQuery, darkMode = false, localDs }) => { const duplicateQuery = useStore((state) => state.dataQuery.duplicateQuery); const setPreviewData = useStore((state) => state.queryPanel.setPreviewData); const [showDeleteConfirmation, setShowDeleteConfirmation] = useState(false); + const [showQueryMenu, setShowQueryMenu] = useState(false); const hasPermissions = selectedDataSourceScope === 'global' ? canUpdateDataSource(dataQuery?.data_source_id) || @@ -36,10 +42,40 @@ export const QueryCard = ({ dataQuery, darkMode = false, localDs }) => { const shouldFreeze = useStore((state) => state.getShouldFreeze()); + const QUERY_MENU_OPTIONS = [ + { + label: 'Rename', + value: 'rename', + icon: , + }, + { + label: 'Duplicate', + value: 'duplicate', + icon: , + }, + { + label: 'Delete', + value: 'delete', + icon: , + }, + ]; + + const handleQueryMenuActions = (value) => { + if (value === 'rename') { + setRenamingQuery(true); + } + if (value === 'duplicate') { + debouncedDuplicateQuery(dataQuery?.id, appId); + } + if (value === 'delete') { + deleteDataQuery(); + } + setShowQueryMenu(false); + }; + const [renamingQuery, setRenamingQuery] = useState(false); - const deleteDataQuery = (e) => { - e.stopPropagation(); + const deleteDataQuery = () => { setShowDeleteConfirmation(true); }; @@ -141,73 +177,60 @@ export const QueryCard = ({ dataQuery, darkMode = false, localDs }) => { )} - {!shouldFreeze && isQuerySelected && ( -
-
setRenamingQuery(true)} - > - - - - - -
-
debouncedDuplicateQuery(dataQuery?.id, appId)} - > - - - -
-
- {isDeletingQueryInProcess ? ( -
-
-
- ) : ( - - - + setShowQueryMenu(false)} + show={showQueryMenu && isQuerySelected} + popperConfig={{ + modifiers: [ + { + name: 'offset', + options: { + offset: [0, 3], + }, + }, + ], + }} + overlay={ + + + {QUERY_MENU_OPTIONS.map((option) => ( +
{ + e.stopPropagation(); + handleQueryMenuActions(option.value); + }} > - - - - - )} -
- -
- )} +
{option.icon}
+
+ {option?.label} +
+
+ ))} + + + } + > + setShowQueryMenu(!showQueryMenu)} + size="small" + variant="outline" + className="" + /> + + ( + + + +); + +export default MoreVertical01; diff --git a/frontend/src/_ui/Icon/solidIcons/index.js b/frontend/src/_ui/Icon/solidIcons/index.js index 11ab593839..6227a1f0af 100644 --- a/frontend/src/_ui/Icon/solidIcons/index.js +++ b/frontend/src/_ui/Icon/solidIcons/index.js @@ -236,6 +236,7 @@ import WorkflowV3 from './WorkflowV3.jsx'; import WorkspaceV3 from './WorkspaceV3.jsx'; import EnterpriseCrown from './EnterrpiseCrown.jsx'; import Moon from './Moon.jsx'; +import MoreVertical01 from './MoreVertical01.jsx'; const Icon = (props) => { switch (props.name) { @@ -713,6 +714,8 @@ const Icon = (props) => { return ; case 'moon': return ; + case 'morevertical01': + return ; default: return ; }