Skip to content

Commit ba74737

Browse files
psychedeliciousmaryhipp
authored andcommitted
feat(ui): add button to disable info popovers from info popover
1 parent 95661c8 commit ba74737

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"negativePrompt": "Negative Prompt",
106106
"discordLabel": "Discord",
107107
"dontAskMeAgain": "Don't ask me again",
108+
"dontShowMeThese": "Don't show me these",
108109
"editor": "Editor",
109110
"error": "Error",
110111
"file": "File",
@@ -1099,6 +1100,8 @@
10991100
"displayInProgress": "Display Progress Images",
11001101
"enableImageDebugging": "Enable Image Debugging",
11011102
"enableInformationalPopovers": "Enable Informational Popovers",
1103+
"informationalPopoversDisabled": "Informational Popovers Disabled",
1104+
"informationalPopoversDisabledDesc": "Informational popovers have been disabled. Enable them in Settings.",
11021105
"enableInvisibleWatermark": "Enable Invisible Watermark",
11031106
"enableNSFWChecker": "Enable NSFW Checker",
11041107
"general": "General",

invokeai/frontend/web/src/common/components/InformationalPopover/InformationalPopover.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import {
1010
PopoverContent,
1111
PopoverTrigger,
1212
Portal,
13+
Spacer,
1314
Text,
1415
} from '@invoke-ai/ui-library';
15-
import { useAppSelector } from 'app/store/storeHooks';
16+
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
17+
import { setShouldEnableInformationalPopovers } from 'features/system/store/systemSlice';
18+
import { toast } from 'features/toast/toast';
1619
import { merge, omit } from 'lodash-es';
1720
import type { ReactElement } from 'react';
1821
import { memo, useCallback, useMemo } from 'react';
@@ -71,7 +74,7 @@ type ContentProps = {
7174

7275
const Content = ({ data, feature }: ContentProps) => {
7376
const { t } = useTranslation();
74-
77+
const dispatch = useAppDispatch();
7578
const heading = useMemo<string | undefined>(() => t(`popovers.${feature}.heading`), [feature, t]);
7679

7780
const paragraphs = useMemo<string[]>(
@@ -82,16 +85,25 @@ const Content = ({ data, feature }: ContentProps) => {
8285
[feature, t]
8386
);
8487

85-
const handleClick = useCallback(() => {
88+
const onClickLearnMore = useCallback(() => {
8689
if (!data?.href) {
8790
return;
8891
}
8992
window.open(data.href);
9093
}, [data?.href]);
9194

95+
const onClickDontShowMeThese = useCallback(() => {
96+
dispatch(setShouldEnableInformationalPopovers(false));
97+
toast({
98+
title: t('settings.informationalPopoversDisabled'),
99+
description: t('settings.informationalPopoversDisabledDesc'),
100+
status: 'info',
101+
});
102+
}, [dispatch, t]);
103+
92104
return (
93-
<PopoverContent w={96}>
94-
<PopoverCloseButton />
105+
<PopoverContent maxW={300}>
106+
<PopoverCloseButton top={2} />
95107
<PopoverBody>
96108
<Flex gap={2} flexDirection="column" alignItems="flex-start">
97109
{heading && (
@@ -116,20 +128,19 @@ const Content = ({ data, feature }: ContentProps) => {
116128
{paragraphs.map((p) => (
117129
<Text key={p}>{p}</Text>
118130
))}
119-
{data?.href && (
120-
<>
121-
<Divider />
122-
<Button
123-
pt={1}
124-
onClick={handleClick}
125-
leftIcon={<PiArrowSquareOutBold />}
126-
alignSelf="flex-end"
127-
variant="link"
128-
>
131+
132+
<Divider />
133+
<Flex alignItems="center" justifyContent="space-between" w="full">
134+
<Button onClick={onClickDontShowMeThese} variant="link" size="sm">
135+
{t('common.dontShowMeThese')}
136+
</Button>
137+
<Spacer />
138+
{data?.href && (
139+
<Button onClick={onClickLearnMore} leftIcon={<PiArrowSquareOutBold />} variant="link" size="sm">
129140
{t('common.learnMore') ?? heading}
130141
</Button>
131-
</>
132-
)}
142+
)}
143+
</Flex>
133144
</Flex>
134145
</PopoverBody>
135146
</PopoverContent>

0 commit comments

Comments
 (0)