Skip to content

Commit 0073fc8

Browse files
maryhippMary Hipp
andauthored
add toggle for isNodesEnabled in settings (#3839)
Co-authored-by: Mary Hipp <[email protected]>
1 parent 0724eb9 commit 0073fc8

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

invokeai/frontend/web/src/features/system/components/SettingsModal/SettingsModal.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Text,
1212
useDisclosure,
1313
} from '@chakra-ui/react';
14-
import { createSelector } from '@reduxjs/toolkit';
14+
import { createSelector, current } from '@reduxjs/toolkit';
1515
import { VALID_LOG_LEVELS } from 'app/logging/useLogger';
1616
import { LOCALSTORAGE_KEYS, LOCALSTORAGE_PREFIX } from 'app/store/constants';
1717
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
@@ -23,6 +23,7 @@ import {
2323
SystemState,
2424
consoleLogLevelChanged,
2525
setEnableImageDebugging,
26+
setIsNodesEnabled,
2627
setShouldConfirmOnDelete,
2728
setShouldDisplayGuides,
2829
shouldAntialiasProgressImageChanged,
@@ -60,6 +61,7 @@ const selector = createSelector(
6061
consoleLogLevel,
6162
shouldLogToConsole,
6263
shouldAntialiasProgressImage,
64+
isNodesEnabled,
6365
} = system;
6466

6567
const {
@@ -80,6 +82,7 @@ const selector = createSelector(
8082
shouldLogToConsole,
8183
shouldAntialiasProgressImage,
8284
shouldShowAdvancedOptions,
85+
isNodesEnabled,
8386
};
8487
},
8588
{
@@ -93,6 +96,7 @@ type ConfigOptions = {
9396
shouldShowBetaLayout: boolean;
9497
shouldShowAdvancedOptionsSettings: boolean;
9598
shouldShowClearIntermediates: boolean;
99+
shouldShowNodesToggle: boolean;
96100
};
97101

98102
type SettingsModalProps = {
@@ -113,6 +117,7 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
113117
config?.shouldShowAdvancedOptionsSettings ?? true;
114118
const shouldShowClearIntermediates =
115119
config?.shouldShowClearIntermediates ?? true;
120+
const shouldShowNodesToggle = config?.shouldShowNodesToggle ?? true;
116121

117122
useEffect(() => {
118123
if (!shouldShowDeveloperSettings) {
@@ -143,6 +148,7 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
143148
shouldLogToConsole,
144149
shouldAntialiasProgressImage,
145150
shouldShowAdvancedOptions,
151+
isNodesEnabled,
146152
} = useAppSelector(selector);
147153

148154
const handleClickResetWebUI = useCallback(() => {
@@ -173,6 +179,13 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
173179
[dispatch]
174180
);
175181

182+
const handleToggleNodes = useCallback(
183+
(e: ChangeEvent<HTMLInputElement>) => {
184+
dispatch(setIsNodesEnabled(e.target.checked));
185+
},
186+
[dispatch]
187+
);
188+
176189
return (
177190
<>
178191
{cloneElement(children, {
@@ -257,6 +270,13 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
257270
)
258271
}
259272
/>
273+
{shouldShowNodesToggle && (
274+
<IAISwitch
275+
label="Enable Nodes Editor (Experimental)"
276+
isChecked={isNodesEnabled}
277+
onChange={handleToggleNodes}
278+
/>
279+
)}
260280
</StyledFlex>
261281

262282
{shouldShowDeveloperSettings && (

invokeai/frontend/web/src/features/system/store/systemSlice.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface SystemState {
8585
language: keyof typeof LANGUAGES;
8686
isUploading: boolean;
8787
boardIdToAddTo?: string;
88+
isNodesEnabled: boolean;
8889
}
8990

9091
export const initialSystemState: SystemState = {
@@ -117,6 +118,7 @@ export const initialSystemState: SystemState = {
117118
isPersisted: false,
118119
language: 'en',
119120
isUploading: false,
121+
isNodesEnabled: false,
120122
};
121123

122124
export const systemSlice = createSlice({
@@ -192,6 +194,9 @@ export const systemSlice = createSlice({
192194
progressImageSet(state, action: PayloadAction<ProgressImage | null>) {
193195
state.progressImage = action.payload;
194196
},
197+
setIsNodesEnabled(state, action: PayloadAction<boolean>) {
198+
state.isNodesEnabled = action.payload;
199+
},
195200
},
196201
extraReducers(builder) {
197202
/**
@@ -400,6 +405,7 @@ export const {
400405
shouldAntialiasProgressImageChanged,
401406
languageChanged,
402407
progressImageSet,
408+
setIsNodesEnabled,
403409
} = systemSlice.actions;
404410

405411
export default systemSlice.reducer;

invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import NodesTab from './tabs/Nodes/NodesTab';
3737
import ResizeHandle from './tabs/ResizeHandle';
3838
import TextToImageTab from './tabs/TextToImage/TextToImageTab';
3939
import UnifiedCanvasTab from './tabs/UnifiedCanvas/UnifiedCanvasTab';
40+
import { systemSelector } from '../../system/store/systemSelectors';
4041

4142
export interface InvokeTabInfo {
4243
id: InvokeTabName;
@@ -84,11 +85,20 @@ const tabs: InvokeTabInfo[] = [
8485
];
8586

8687
const enabledTabsSelector = createSelector(
87-
configSelector,
88-
(config) => {
88+
[configSelector, systemSelector],
89+
(config, system) => {
8990
const { disabledTabs } = config;
91+
const { isNodesEnabled } = system;
9092

91-
return tabs.filter((tab) => !disabledTabs.includes(tab.id));
93+
const enabledTabs = tabs.filter((tab) => {
94+
if (tab.id === 'nodes') {
95+
return isNodesEnabled && !disabledTabs.includes(tab.id);
96+
} else {
97+
return !disabledTabs.includes(tab.id);
98+
}
99+
});
100+
101+
return enabledTabs;
92102
},
93103
{
94104
memoizeOptions: { resultEqualityCheck: isEqual },

0 commit comments

Comments
 (0)