Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) =>
const [outputSchema, setOutputSchema] = useState([])

const [name, setName] = useState('')
const [selectAll, setSelectAll] = useState(false)

const onRowUpdate = (newRow) => {
setTimeout(() => {
Expand Down Expand Up @@ -116,6 +117,24 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) =>
return () => dispatch({ type: HIDE_CANVAS_DIALOG })
}, [show, dispatch])

useEffect(() => {
if (outputSchema.length > 0) {
setSelectAll(outputSchema.every((row) => row.shared))
} else {
setSelectAll(false)
}
}, [outputSchema])

const handleSelectAll = () => {
setOutputSchema((prev) => prev.map((row) => ({ ...row, shared: true })))
setSelectAll(true)
}

const handleDeselectAll = () => {
setOutputSchema((prev) => prev.map((row) => ({ ...row, shared: false })))
setSelectAll(false)
}

const shareItemRequest = async () => {
try {
const obj = {
Expand Down Expand Up @@ -186,6 +205,14 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) =>
</Stack>
<OutlinedInput id='name' type='string' disabled={true} fullWidth placeholder={name} value={name} name='name' />
</Box>
<Stack direction='row' justifyContent='space-between' sx={{ p: 2, pb: 1 }}>
<Button size='small' variant={selectAll ? 'outlined' : 'contained'} onClick={handleSelectAll}>
Check All ({outputSchema.length})
</Button>
<Button size='small' variant={selectAll ? 'contained' : 'outlined'} onClick={handleDeselectAll}>
Uncheck All
</Button>
</Stack>
<Box sx={{ p: 2 }}>
<Grid columns={columns} rows={outputSchema} onRowUpdate={onRowUpdate} />
</Box>
Expand Down