mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add toggle for isNodesEnabled in settings (#3839)
Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
This commit is contained in:
parent
0724eb9e0a
commit
0073fc8619
@ -11,7 +11,7 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector, current } from '@reduxjs/toolkit';
|
||||||
import { VALID_LOG_LEVELS } from 'app/logging/useLogger';
|
import { VALID_LOG_LEVELS } from 'app/logging/useLogger';
|
||||||
import { LOCALSTORAGE_KEYS, LOCALSTORAGE_PREFIX } from 'app/store/constants';
|
import { LOCALSTORAGE_KEYS, LOCALSTORAGE_PREFIX } from 'app/store/constants';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
@ -23,6 +23,7 @@ import {
|
|||||||
SystemState,
|
SystemState,
|
||||||
consoleLogLevelChanged,
|
consoleLogLevelChanged,
|
||||||
setEnableImageDebugging,
|
setEnableImageDebugging,
|
||||||
|
setIsNodesEnabled,
|
||||||
setShouldConfirmOnDelete,
|
setShouldConfirmOnDelete,
|
||||||
setShouldDisplayGuides,
|
setShouldDisplayGuides,
|
||||||
shouldAntialiasProgressImageChanged,
|
shouldAntialiasProgressImageChanged,
|
||||||
@ -60,6 +61,7 @@ const selector = createSelector(
|
|||||||
consoleLogLevel,
|
consoleLogLevel,
|
||||||
shouldLogToConsole,
|
shouldLogToConsole,
|
||||||
shouldAntialiasProgressImage,
|
shouldAntialiasProgressImage,
|
||||||
|
isNodesEnabled,
|
||||||
} = system;
|
} = system;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -80,6 +82,7 @@ const selector = createSelector(
|
|||||||
shouldLogToConsole,
|
shouldLogToConsole,
|
||||||
shouldAntialiasProgressImage,
|
shouldAntialiasProgressImage,
|
||||||
shouldShowAdvancedOptions,
|
shouldShowAdvancedOptions,
|
||||||
|
isNodesEnabled,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -93,6 +96,7 @@ type ConfigOptions = {
|
|||||||
shouldShowBetaLayout: boolean;
|
shouldShowBetaLayout: boolean;
|
||||||
shouldShowAdvancedOptionsSettings: boolean;
|
shouldShowAdvancedOptionsSettings: boolean;
|
||||||
shouldShowClearIntermediates: boolean;
|
shouldShowClearIntermediates: boolean;
|
||||||
|
shouldShowNodesToggle: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SettingsModalProps = {
|
type SettingsModalProps = {
|
||||||
@ -113,6 +117,7 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
config?.shouldShowAdvancedOptionsSettings ?? true;
|
config?.shouldShowAdvancedOptionsSettings ?? true;
|
||||||
const shouldShowClearIntermediates =
|
const shouldShowClearIntermediates =
|
||||||
config?.shouldShowClearIntermediates ?? true;
|
config?.shouldShowClearIntermediates ?? true;
|
||||||
|
const shouldShowNodesToggle = config?.shouldShowNodesToggle ?? true;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shouldShowDeveloperSettings) {
|
if (!shouldShowDeveloperSettings) {
|
||||||
@ -143,6 +148,7 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
shouldLogToConsole,
|
shouldLogToConsole,
|
||||||
shouldAntialiasProgressImage,
|
shouldAntialiasProgressImage,
|
||||||
shouldShowAdvancedOptions,
|
shouldShowAdvancedOptions,
|
||||||
|
isNodesEnabled,
|
||||||
} = useAppSelector(selector);
|
} = useAppSelector(selector);
|
||||||
|
|
||||||
const handleClickResetWebUI = useCallback(() => {
|
const handleClickResetWebUI = useCallback(() => {
|
||||||
@ -173,6 +179,13 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
[dispatch]
|
[dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleToggleNodes = useCallback(
|
||||||
|
(e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
dispatch(setIsNodesEnabled(e.target.checked));
|
||||||
|
},
|
||||||
|
[dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{cloneElement(children, {
|
{cloneElement(children, {
|
||||||
@ -257,6 +270,13 @@ const SettingsModal = ({ children, config }: SettingsModalProps) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{shouldShowNodesToggle && (
|
||||||
|
<IAISwitch
|
||||||
|
label="Enable Nodes Editor (Experimental)"
|
||||||
|
isChecked={isNodesEnabled}
|
||||||
|
onChange={handleToggleNodes}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</StyledFlex>
|
</StyledFlex>
|
||||||
|
|
||||||
{shouldShowDeveloperSettings && (
|
{shouldShowDeveloperSettings && (
|
||||||
|
@ -85,6 +85,7 @@ export interface SystemState {
|
|||||||
language: keyof typeof LANGUAGES;
|
language: keyof typeof LANGUAGES;
|
||||||
isUploading: boolean;
|
isUploading: boolean;
|
||||||
boardIdToAddTo?: string;
|
boardIdToAddTo?: string;
|
||||||
|
isNodesEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialSystemState: SystemState = {
|
export const initialSystemState: SystemState = {
|
||||||
@ -117,6 +118,7 @@ export const initialSystemState: SystemState = {
|
|||||||
isPersisted: false,
|
isPersisted: false,
|
||||||
language: 'en',
|
language: 'en',
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
|
isNodesEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const systemSlice = createSlice({
|
export const systemSlice = createSlice({
|
||||||
@ -192,6 +194,9 @@ export const systemSlice = createSlice({
|
|||||||
progressImageSet(state, action: PayloadAction<ProgressImage | null>) {
|
progressImageSet(state, action: PayloadAction<ProgressImage | null>) {
|
||||||
state.progressImage = action.payload;
|
state.progressImage = action.payload;
|
||||||
},
|
},
|
||||||
|
setIsNodesEnabled(state, action: PayloadAction<boolean>) {
|
||||||
|
state.isNodesEnabled = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers(builder) {
|
extraReducers(builder) {
|
||||||
/**
|
/**
|
||||||
@ -400,6 +405,7 @@ export const {
|
|||||||
shouldAntialiasProgressImageChanged,
|
shouldAntialiasProgressImageChanged,
|
||||||
languageChanged,
|
languageChanged,
|
||||||
progressImageSet,
|
progressImageSet,
|
||||||
|
setIsNodesEnabled,
|
||||||
} = systemSlice.actions;
|
} = systemSlice.actions;
|
||||||
|
|
||||||
export default systemSlice.reducer;
|
export default systemSlice.reducer;
|
||||||
|
@ -37,6 +37,7 @@ import NodesTab from './tabs/Nodes/NodesTab';
|
|||||||
import ResizeHandle from './tabs/ResizeHandle';
|
import ResizeHandle from './tabs/ResizeHandle';
|
||||||
import TextToImageTab from './tabs/TextToImage/TextToImageTab';
|
import TextToImageTab from './tabs/TextToImage/TextToImageTab';
|
||||||
import UnifiedCanvasTab from './tabs/UnifiedCanvas/UnifiedCanvasTab';
|
import UnifiedCanvasTab from './tabs/UnifiedCanvas/UnifiedCanvasTab';
|
||||||
|
import { systemSelector } from '../../system/store/systemSelectors';
|
||||||
|
|
||||||
export interface InvokeTabInfo {
|
export interface InvokeTabInfo {
|
||||||
id: InvokeTabName;
|
id: InvokeTabName;
|
||||||
@ -84,11 +85,20 @@ const tabs: InvokeTabInfo[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const enabledTabsSelector = createSelector(
|
const enabledTabsSelector = createSelector(
|
||||||
configSelector,
|
[configSelector, systemSelector],
|
||||||
(config) => {
|
(config, system) => {
|
||||||
const { disabledTabs } = config;
|
const { disabledTabs } = config;
|
||||||
|
const { isNodesEnabled } = system;
|
||||||
|
|
||||||
return tabs.filter((tab) => !disabledTabs.includes(tab.id));
|
const enabledTabs = tabs.filter((tab) => {
|
||||||
|
if (tab.id === 'nodes') {
|
||||||
|
return isNodesEnabled && !disabledTabs.includes(tab.id);
|
||||||
|
} else {
|
||||||
|
return !disabledTabs.includes(tab.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return enabledTabs;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
memoizeOptions: { resultEqualityCheck: isEqual },
|
memoizeOptions: { resultEqualityCheck: isEqual },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user