feat(ui): make archiving and auto-add mutually exclusive

This commit is contained in:
Mary Hipp 2024-06-26 14:15:58 -04:00 committed by psychedelicious
parent 68c0aa898f
commit 071e8bcee4
3 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import type { ContextMenuProps } from '@invoke-ai/ui-library'; import type { ContextMenuProps } from '@invoke-ai/ui-library';
import { ContextMenu, MenuGroup, MenuItem, MenuList } from '@invoke-ai/ui-library'; import { ContextMenu, MenuGroup, MenuItem, MenuList, Tooltip } from '@invoke-ai/ui-library';
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { autoAddBoardIdChanged, selectGallerySlice } from 'features/gallery/store/gallerySlice'; import { autoAddBoardIdChanged, selectGallerySlice } from 'features/gallery/store/gallerySlice';
@ -88,9 +88,11 @@ const BoardContextMenu = ({ board, board_id, setBoardToDelete, children }: Props
{t('boards.unarchiveBoard')} {t('boards.unarchiveBoard')}
</MenuItem> </MenuItem>
) : ( ) : (
<MenuItem icon={<PiArchiveFill />} onClick={handleArchive}> <Tooltip label={isSelectedForAutoAdd && 'testing'}>
{t('boards.archiveBoard')} <MenuItem icon={<PiArchiveFill />} onClick={handleArchive} isDisabled={isSelectedForAutoAdd}>
</MenuItem> {t('boards.archiveBoard')}
</MenuItem>
</Tooltip>
))} ))}
{board && <GalleryBoardContextMenuItems board={board} setBoardToDelete={setBoardToDelete} />} {board && <GalleryBoardContextMenuItems board={board} setBoardToDelete={setBoardToDelete} />}

View File

@ -56,10 +56,10 @@ const GalleryBoard = ({ board, isSelected, setBoardToDelete }: GalleryBoardProps
const handleSelectBoard = useCallback(() => { const handleSelectBoard = useCallback(() => {
dispatch(boardIdSelected({ boardId: board_id })); dispatch(boardIdSelected({ boardId: board_id }));
if (autoAssignBoardOnClick) { if (autoAssignBoardOnClick && !board.archived) {
dispatch(autoAddBoardIdChanged(board_id)); dispatch(autoAddBoardIdChanged(board_id));
} }
}, [board_id, autoAssignBoardOnClick, dispatch]); }, [board_id, autoAssignBoardOnClick, dispatch, board.archived]);
const [updateBoard, { isLoading: isUpdateBoardLoading }] = useUpdateBoardMutation(); const [updateBoard, { isLoading: isUpdateBoardLoading }] = useUpdateBoardMutation();

View File

@ -2,9 +2,11 @@ import type { BoardId } from 'features/gallery/store/types';
import { t } from 'i18next'; import { t } from 'i18next';
import { useListAllBoardsQuery } from 'services/api/endpoints/boards'; import { useListAllBoardsQuery } from 'services/api/endpoints/boards';
import { selectListBoardsQueryArgs } from '../../../features/gallery/store/gallerySelectors'; import { selectListBoardsQueryArgs } from '../../../features/gallery/store/gallerySelectors';
import { useAppSelector } from '../../../app/store/storeHooks';
export const useBoardName = (board_id: BoardId) => { export const useBoardName = (board_id: BoardId) => {
const { boardName } = useListAllBoardsQuery({}, { const queryArgs = useAppSelector(selectListBoardsQueryArgs);
const { boardName } = useListAllBoardsQuery(queryArgs, {
selectFromResult: ({ data }) => { selectFromResult: ({ data }) => {
const selectedBoard = data?.find((b) => b.board_id === board_id); const selectedBoard = data?.find((b) => b.board_id === board_id);
const boardName = selectedBoard?.board_name || t('boards.uncategorized'); const boardName = selectedBoard?.board_name || t('boards.uncategorized');