Skip to content

Commit c1f2a9d

Browse files
Node Editor: QoL Fixes (#3734)
- Make the viewport fit to view on Init - Update Reload Schema to an icon.
2 parents c3adb30 + 222d8b0 commit c1f2a9d

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,5 +674,8 @@
674674
"showProgressImages": "Show Progress Images",
675675
"hideProgressImages": "Hide Progress Images",
676676
"swapSizes": "Swap Sizes"
677+
},
678+
"nodes": {
679+
"reloadSchema": "Reload Schema"
677680
}
678681
}

invokeai/frontend/web/src/features/nodes/components/Flow.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import {
77
OnConnectEnd,
88
OnConnectStart,
99
OnEdgesChange,
10+
OnInit,
1011
OnNodesChange,
1112
ReactFlow,
13+
ReactFlowInstance,
1214
} from 'reactflow';
1315
import {
1416
connectionEnded,
@@ -67,6 +69,12 @@ export const Flow = () => {
6769
dispatch(connectionEnded());
6870
}, [dispatch]);
6971

72+
const onInit: OnInit = useCallback((v: ReactFlowInstance) => {
73+
if (v) {
74+
v.fitView();
75+
}
76+
}, []);
77+
7078
return (
7179
<ReactFlow
7280
nodeTypes={nodeTypes}
@@ -77,6 +85,7 @@ export const Flow = () => {
7785
onConnectStart={onConnectStart}
7886
onConnect={onConnect}
7987
onConnectEnd={onConnectEnd}
88+
onInit={onInit}
8089
defaultEdgeOptions={{
8190
style: { strokeWidth: 2 },
8291
}}

invokeai/frontend/web/src/features/nodes/components/panels/TopCenterPanel.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
import { HStack } from '@chakra-ui/react';
2-
import { useAppDispatch } from 'app/store/storeHooks';
3-
import IAIButton from 'common/components/IAIButton';
4-
import { memo, useCallback } from 'react';
2+
import { memo } from 'react';
53
import { Panel } from 'reactflow';
6-
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
7-
import NodeInvokeButton from '../ui/NodeInvokeButton';
4+
85
import CancelButton from 'features/parameters/components/ProcessButtons/CancelButton';
6+
import NodeInvokeButton from '../ui/NodeInvokeButton';
7+
import ReloadSchemaButton from '../ui/ReloadSchemaButton';
98

109
const TopCenterPanel = () => {
11-
const dispatch = useAppDispatch();
12-
13-
const handleReloadSchema = useCallback(() => {
14-
dispatch(receivedOpenAPISchema());
15-
}, [dispatch]);
16-
1710
return (
1811
<Panel position="top-center">
1912
<HStack>
2013
<NodeInvokeButton />
2114
<CancelButton />
22-
<IAIButton onClick={handleReloadSchema}>Reload Schema</IAIButton>
15+
<ReloadSchemaButton />
2316
</HStack>
2417
</Panel>
2518
);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useAppDispatch } from 'app/store/storeHooks';
2+
import IAIIconButton from 'common/components/IAIIconButton';
3+
import { useCallback } from 'react';
4+
import { useTranslation } from 'react-i18next';
5+
import { FaSyncAlt } from 'react-icons/fa';
6+
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
7+
8+
export default function ReloadSchemaButton() {
9+
const { t } = useTranslation();
10+
const dispatch = useAppDispatch();
11+
12+
const handleReloadSchema = useCallback(() => {
13+
dispatch(receivedOpenAPISchema());
14+
}, [dispatch]);
15+
16+
return (
17+
<IAIIconButton
18+
icon={<FaSyncAlt />}
19+
tooltip={t('nodes.reloadSchema')}
20+
aria-label={t('nodes.reloadSchema')}
21+
onClick={handleReloadSchema}
22+
/>
23+
);
24+
}

0 commit comments

Comments
 (0)