diff --git a/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx b/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx index f9ba47e73fd..67fa1e57920 100644 --- a/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx +++ b/packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx @@ -6,7 +6,7 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba import { cloneDeep } from 'lodash' // Material -import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Box, Stack, OutlinedInput, Typography } from '@mui/material' +import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Box, Stack, OutlinedInput, Typography, Checkbox, FormControlLabel } from '@mui/material' // Project imports import { StyledButton } from '@/ui-component/button/StyledButton' @@ -47,6 +47,28 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) => const [outputSchema, setOutputSchema] = useState([]) const [name, setName] = useState('') + const [selectAll, setSelectAll] = useState(false) + + // Handle select all / deselect all + const handleSelectAllChange = (event) => { + const checked = event.target.checked + setSelectAll(checked) + setOutputSchema((prevRows) => { + return prevRows.map((row) => ({ + ...row, + shared: checked + })) + }) + } + + // Update selectAll state when individual rows change + useEffect(() => { + if (outputSchema.length > 0) { + const allSelected = outputSchema.every((row) => row.shared) + const noneSelected = outputSchema.every((row) => !row.shared) + setSelectAll(allSelected ? true : noneSelected ? false : false) + } + }, [outputSchema]) const onRowUpdate = (newRow) => { setTimeout(() => { @@ -187,6 +209,13 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) => + + Workspaces + } + label={Select All} + /> +