feat(ui): progress alert config setting

- Add `invocationProgressAlert` as a disable-able feature. Hide the alert and the setting in system settings when disabled.
- Fix merge conflict
This commit is contained in:
psychedelicious
2024-11-14 10:38:52 -08:00
parent 17c7b57145
commit 829bc1bc7d
6 changed files with 31 additions and 13 deletions

View File

@@ -1,17 +1,17 @@
import { Alert, AlertDescription, AlertIcon, AlertTitle } from '@invoke-ai/ui-library';
import { useStore } from '@nanostores/react';
import { useAppSelector } from 'app/store/storeHooks';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
import { selectSystemShouldShowInvocationProgressDetail } from 'features/system/store/systemSlice';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { $canvasProgressMessage } from 'services/events/stores';
import { $invocationProgressMessage } from 'services/events/stores';
export const CanvasAlertsInvocationProgress = memo(() => {
const CanvasAlertsInvocationProgressContent = memo(() => {
const { t } = useTranslation();
const progressEventMessage = useStore($canvasProgressMessage);
const shouldShowInvocationProgressDetail = useAppSelector(selectSystemShouldShowInvocationProgressDetail);
const invocationProgressMessage = useStore($invocationProgressMessage);
if (!shouldShowInvocationProgressDetail || !progressEventMessage) {
if (!invocationProgressMessage) {
return null;
}
@@ -19,9 +19,27 @@ export const CanvasAlertsInvocationProgress = memo(() => {
<Alert status="loading" borderRadius="base" fontSize="sm" shadow="md" w="fit-content">
<AlertIcon />
<AlertTitle>{t('common.generating')}</AlertTitle>
<AlertDescription>{progressEventMessage}</AlertDescription>
<AlertDescription>{invocationProgressMessage}</AlertDescription>
</Alert>
);
});
CanvasAlertsInvocationProgressContent.displayName = 'CanvasAlertsInvocationProgressContent';
export const CanvasAlertsInvocationProgress = memo(() => {
const isProgressMessageAlertEnabled = useFeatureStatus('invocationProgressAlert');
const shouldShowInvocationProgressDetail = useAppSelector(selectSystemShouldShowInvocationProgressDetail);
// The alert is disabled at the system level
if (!isProgressMessageAlertEnabled) {
return null;
}
// The alert is disabled at the user level
if (!shouldShowInvocationProgressDetail) {
return null;
}
return <CanvasAlertsInvocationProgressContent />;
});
CanvasAlertsInvocationProgress.displayName = 'CanvasAlertsInvocationProgress';