Skip to content

Commit 476ebd1

Browse files
feat(ui): add board button tooltip when private boards enabled
1 parent 2460689 commit 476ebd1

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
},
1818
"boards": {
1919
"addBoard": "Add Board",
20+
"addPrivateBoard": "Add Private Board",
21+
"addSharedBoard": "Add Shared Board",
2022
"archiveBoard": "Archive Board",
2123
"archived": "Archived",
2224
"autoAddBoard": "Auto-Add Board",

invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/AddBoardButton.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IconButton } from '@invoke-ai/ui-library';
2-
import { useAppDispatch } from 'app/store/storeHooks';
2+
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
33
import { boardIdSelected } from 'features/gallery/store/gallerySlice';
4-
import { memo, useCallback } from 'react';
4+
import { memo, useCallback, useMemo } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { PiPlusBold } from 'react-icons/pi';
77
import { useCreateBoardMutation } from 'services/api/endpoints/boards';
@@ -13,23 +13,32 @@ type Props = {
1313
const AddBoardButton = ({ isPrivateBoard }: Props) => {
1414
const { t } = useTranslation();
1515
const dispatch = useAppDispatch();
16+
const allowPrivateBoards = useAppSelector((s) => s.config.allowPrivateBoards);
1617
const [createBoard, { isLoading }] = useCreateBoardMutation();
17-
const DEFAULT_BOARD_NAME = t('boards.myBoard');
18+
const label = useMemo(() => {
19+
if (!allowPrivateBoards) {
20+
return t('boards.addBoard');
21+
}
22+
if (isPrivateBoard) {
23+
return t('boards.addPrivateBoard');
24+
}
25+
return t('boards.addSharedBoard');
26+
}, [allowPrivateBoards, isPrivateBoard, t]);
1827
const handleCreateBoard = useCallback(async () => {
1928
try {
20-
const board = await createBoard({ board_name: DEFAULT_BOARD_NAME, is_private: isPrivateBoard }).unwrap();
29+
const board = await createBoard({ board_name: t('boards.myBoard'), is_private: isPrivateBoard }).unwrap();
2130
dispatch(boardIdSelected({ boardId: board.board_id }));
2231
} catch {
2332
//no-op
2433
}
25-
}, [createBoard, DEFAULT_BOARD_NAME, isPrivateBoard, dispatch]);
34+
}, [t, createBoard, isPrivateBoard, dispatch]);
2635

2736
return (
2837
<IconButton
2938
icon={<PiPlusBold />}
3039
isLoading={isLoading}
31-
tooltip={t('boards.addBoard')}
32-
aria-label={t('boards.addBoard')}
40+
tooltip={label}
41+
aria-label={label}
3342
onClick={handleCreateBoard}
3443
size="md"
3544
data-testid="add-board-button"

0 commit comments

Comments
 (0)