mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into model-manager-ui-30
This commit is contained in:
@ -1,47 +1,44 @@
|
||||
import {
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuItemOption,
|
||||
MenuList,
|
||||
MenuOptionGroup,
|
||||
} from '@chakra-ui/react';
|
||||
import { SCHEDULERS } from 'app/constants';
|
||||
|
||||
import { SCHEDULER_LABEL_MAP, SCHEDULER_NAMES } from 'app/constants';
|
||||
import { RootState } from 'app/store/store';
|
||||
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import IAIButton from 'common/components/IAIButton';
|
||||
import { setSchedulers } from 'features/ui/store/uiSlice';
|
||||
import { isArray } from 'lodash-es';
|
||||
import IAIMantineMultiSelect from 'common/components/IAIMantineMultiSelect';
|
||||
import { SchedulerParam } from 'features/parameters/store/parameterZodSchemas';
|
||||
import { favoriteSchedulersChanged } from 'features/ui/store/uiSlice';
|
||||
import { map } from 'lodash-es';
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export default function SettingsSchedulers() {
|
||||
const schedulers = useAppSelector((state: RootState) => state.ui.schedulers);
|
||||
const data = map(SCHEDULER_NAMES, (s) => ({
|
||||
value: s,
|
||||
label: SCHEDULER_LABEL_MAP[s],
|
||||
})).sort((a, b) => a.label.localeCompare(b.label));
|
||||
|
||||
export default function SettingsSchedulers() {
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const schedulerSettingsHandler = (v: string | string[]) => {
|
||||
if (isArray(v)) dispatch(setSchedulers(v.sort()));
|
||||
};
|
||||
const enabledSchedulers = useAppSelector(
|
||||
(state: RootState) => state.ui.favoriteSchedulers
|
||||
);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(v: string[]) => {
|
||||
dispatch(favoriteSchedulersChanged(v as SchedulerParam[]));
|
||||
},
|
||||
[dispatch]
|
||||
);
|
||||
|
||||
return (
|
||||
<Menu closeOnSelect={false}>
|
||||
<MenuButton as={IAIButton}>
|
||||
{t('settings.availableSchedulers')}
|
||||
</MenuButton>
|
||||
<MenuList maxHeight={64} overflowY="scroll">
|
||||
<MenuOptionGroup
|
||||
value={schedulers}
|
||||
type="checkbox"
|
||||
onChange={schedulerSettingsHandler}
|
||||
>
|
||||
{SCHEDULERS.map((scheduler) => (
|
||||
<MenuItemOption key={scheduler} value={scheduler}>
|
||||
{scheduler}
|
||||
</MenuItemOption>
|
||||
))}
|
||||
</MenuOptionGroup>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
<IAIMantineMultiSelect
|
||||
label={t('settings.favoriteSchedulers')}
|
||||
value={enabledSchedulers}
|
||||
data={data}
|
||||
onChange={handleChange}
|
||||
clearable
|
||||
searchable
|
||||
maxSelectedValues={99}
|
||||
placeholder={t('settings.favoriteSchedulersPlaceholder')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user