mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add translation strings for clear intermediates
This commit is contained in:
@ -1106,7 +1106,17 @@
|
|||||||
"showAdvancedOptions": "Show Advanced Options",
|
"showAdvancedOptions": "Show Advanced Options",
|
||||||
"showProgressInViewer": "Show Progress Images in Viewer",
|
"showProgressInViewer": "Show Progress Images in Viewer",
|
||||||
"ui": "User Interface",
|
"ui": "User Interface",
|
||||||
"useSlidersForAll": "Use Sliders For All Options"
|
"useSlidersForAll": "Use Sliders For All Options",
|
||||||
|
"clearIntermediatesDesc1": "Clearing intermediates will reset your Canvas and ControlNet state.",
|
||||||
|
"clearIntermediatesDesc2": "Intermediate images are byproducts of generation, different from the result images in the gallery. Clearing intermediates will free disk space.",
|
||||||
|
"clearIntermediatesDesc3": "Your gallery images will not be deleted.",
|
||||||
|
"clearIntermediates": "Clear Intermediates",
|
||||||
|
"clearIntermediates_one": "Clear 1 Intermediate",
|
||||||
|
"clearIntermediates_other": "Clear {{number}} Intermediates",
|
||||||
|
"noIntermediates": "No Intermediates to Clear",
|
||||||
|
"intermediatesCleared_one": "Cleared 1 Intermediate",
|
||||||
|
"intermediatesCleared_other": "Cleared {{number}} Intermediates",
|
||||||
|
"intermediatesClearedFailed": "Problem Clearing Intermediates"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"addedToBoard": "Added to board",
|
"addedToBoard": "Added to board",
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Heading, Text } from '@chakra-ui/react';
|
import { Heading, Text } from '@chakra-ui/react';
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
import { controlAdaptersReset } from 'features/controlAdapters/store/controlAdaptersSlice';
|
import { controlAdaptersReset } from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import IAIButton from '../../../../common/components/IAIButton';
|
import IAIButton from '../../../../common/components/IAIButton';
|
||||||
import {
|
import {
|
||||||
useClearIntermediatesMutation,
|
useClearIntermediatesMutation,
|
||||||
@ -12,6 +13,7 @@ import { addToast } from '../../store/systemSlice';
|
|||||||
import StyledFlex from './StyledFlex';
|
import StyledFlex from './StyledFlex';
|
||||||
|
|
||||||
export default function SettingsClearIntermediates() {
|
export default function SettingsClearIntermediates() {
|
||||||
|
const { t } = useTranslation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const { data: intermediatesCount, refetch: updateIntermediatesCount } =
|
const { data: intermediatesCount, refetch: updateIntermediatesCount } =
|
||||||
@ -23,32 +25,49 @@ export default function SettingsClearIntermediates() {
|
|||||||
const handleClickClearIntermediates = useCallback(() => {
|
const handleClickClearIntermediates = useCallback(() => {
|
||||||
clearIntermediates()
|
clearIntermediates()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.then((response) => {
|
.then((number) => {
|
||||||
dispatch(controlAdaptersReset());
|
dispatch(controlAdaptersReset());
|
||||||
dispatch(resetCanvas());
|
dispatch(resetCanvas());
|
||||||
dispatch(
|
dispatch(
|
||||||
addToast({
|
addToast({
|
||||||
title: `Cleared ${response} intermediates`,
|
title:
|
||||||
|
number === 1
|
||||||
|
? t('settings.intermediatesCleared_one')
|
||||||
|
: t('settings.intermediatesCleared_other', { number }),
|
||||||
status: 'info',
|
status: 'info',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
dispatch(
|
||||||
|
addToast({
|
||||||
|
title: t('settings.intermediatesClearedFailed'),
|
||||||
|
status: 'error',
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}, [clearIntermediates, dispatch]);
|
}, [t, clearIntermediates, dispatch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// update the count on mount
|
// update the count on mount
|
||||||
updateIntermediatesCount();
|
updateIntermediatesCount();
|
||||||
}, [updateIntermediatesCount]);
|
}, [updateIntermediatesCount]);
|
||||||
|
|
||||||
const buttonText = intermediatesCount
|
const buttonText = useMemo(() => {
|
||||||
? `Clear ${intermediatesCount} Intermediate${
|
if (!intermediatesCount) {
|
||||||
intermediatesCount > 1 ? 's' : ''
|
return t('settings.noIntermediates');
|
||||||
}`
|
}
|
||||||
: 'No Intermediates to Clear';
|
if (intermediatesCount === 1) {
|
||||||
|
return t('settings.clearIntermediates_one');
|
||||||
|
}
|
||||||
|
return t('settings.clearIntermediates_other', {
|
||||||
|
number: intermediatesCount,
|
||||||
|
});
|
||||||
|
}, [intermediatesCount, t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledFlex>
|
<StyledFlex>
|
||||||
<Heading size="sm">Clear Intermediates</Heading>
|
<Heading size="sm">{t('settings.clearIntermediates')}</Heading>
|
||||||
<IAIButton
|
<IAIButton
|
||||||
colorScheme="warning"
|
colorScheme="warning"
|
||||||
onClick={handleClickClearIntermediates}
|
onClick={handleClickClearIntermediates}
|
||||||
@ -57,15 +76,9 @@ export default function SettingsClearIntermediates() {
|
|||||||
>
|
>
|
||||||
{buttonText}
|
{buttonText}
|
||||||
</IAIButton>
|
</IAIButton>
|
||||||
<Text fontWeight="bold">
|
<Text fontWeight="bold">{t('settings.clearIntermediatesDesc1')}</Text>
|
||||||
Clearing intermediates will reset your Canvas and ControlNet state.
|
<Text variant="subtext">{t('settings.clearIntermediatesDesc2')}</Text>
|
||||||
</Text>
|
<Text variant="subtext">{t('settings.clearIntermediatesDesc3')}</Text>
|
||||||
<Text variant="subtext">
|
|
||||||
Intermediate images are byproducts of generation, different from the
|
|
||||||
result images in the gallery. Clearing intermediates will free disk
|
|
||||||
space.
|
|
||||||
</Text>
|
|
||||||
<Text variant="subtext">Your gallery images will not be deleted.</Text>
|
|
||||||
</StyledFlex>
|
</StyledFlex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user