Skip to content

Commit 0ab144f

Browse files
committed
feat(settings): support multi workspace for SettingsForm
1 parent 18cc16f commit 0ab144f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

packages/react-settings-form/src/SettingsForm.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@ import { NodePath } from './components/NodePath'
1818
import { Empty } from 'antd'
1919
import cls from 'classnames'
2020
import './styles.less'
21+
import { useWorkbench } from 'packages/react/lib'
2122

2223
const GlobalState = {
2324
idleRequest: null,
2425
}
2526

2627
export const SettingsForm: React.FC<ISettingFormProps> = observer(
2728
(props) => {
28-
const operation = useOperation()
29-
const node = useCurrentNode()
30-
const selected = useSelected()
29+
const workbench = useWorkbench()
30+
const currentWorkspace =
31+
workbench?.activeWorkspace || workbench?.currentWorkspace
32+
const currentWorkspaceId = currentWorkspace?.id
33+
const operation = useOperation(currentWorkspaceId)
34+
const node = useCurrentNode(currentWorkspaceId)
35+
const selected = useSelected(currentWorkspaceId)
3136
const prefix = usePrefix('settings-form')
3237
const schema = node?.designerProps?.propsSchema
3338
const form = useMemo(() => {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useSelected } from './useSelected'
22
import { useTree } from './useTree'
33

4-
export const useCurrentNode = () => {
5-
const selected = useSelected()
6-
const tree = useTree()
4+
export const useCurrentNode = (workspaceId?: string) => {
5+
const selected = useSelected(workspaceId)
6+
const tree = useTree(workspaceId)
77
return tree?.findById?.(selected[0])
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSelection } from './useSelection'
22

3-
export const useSelected = () => {
4-
const selection = useSelection()
3+
export const useSelected = (workspaceId?: string) => {
4+
const selection = useSelection(workspaceId)
55
return selection?.selected || []
66
}

0 commit comments

Comments
 (0)