Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): accept gallery drops on the Uncategorized board
Josh Corbett2058366a940e
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsxindex 8e3a87434d..f342f7b8a3 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx@@ -14,7 +14,12 @@ import { useTranslation } from 'react-i18next';import { BoardCover } from './GalleryBoardCover';import { GalleryBoardRowShell } from './GalleryBoardRowShell';-import { getGalleryBoardDropData, getGalleryBoardDropId, isGalleryItemDragData } from './galleryDnd';+import {+ acceptsGalleryItemMoves,+ getGalleryBoardDropData,+ getGalleryBoardDropId,+ isGalleryItemDragData,+} from './galleryDnd';import { getBoardCounts } from './galleryStateView';export const GalleryBoardRow = ({@@ -40,7 +45,7 @@ export const GalleryBoardRow = ({const boardLabel = getGalleryBoardLabel(board, t);const canDropItems =- board.kind === 'board' &&+ acceptsGalleryItemMoves(board.kind) &&isGalleryItemDragData(dragData) &&dragData.items.some((ref) => loadedItemBoardIds.get(toGalleryItemKey(ref)) !== board.id);diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.test.tsindex 2c3cbc2d78..1182c2dfcb 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.test.ts@@ -130,6 +130,19 @@ describe('galleryDnd', () => {});});+ it('moves items out of their board when dropped on Uncategorized', () => {+ const boarded = createItem('image', 'boarded.png', 'board-a');+ const loose = createItem('image', 'loose.png', 'none');+ const dragData = getGalleryItemDragData([+ { kind: 'image', name: boarded.name },+ { kind: 'image', name: loose.name },+ ]);++ expect(+ resolveGalleryBoardDrop(dragData, getGalleryBoardDropData('none', 'uncategorized'), [boarded, loose])+ ).toEqual({ boardId: 'none', items: [{ kind: 'image', name: boarded.name }] });+ });+it('rejects non-item drags, virtual-board drops, and drops with no item left to move', () => {const image = createItem('image', 'image.png', 'board-a');const dragData = getGalleryItemDragData([{ kind: 'image', name: image.name }]);diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.tsindex 2a5e71ba88..ad602d6b6c 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDnd.ts@@ -43,6 +43,10 @@ export const getGalleryItemDragId = (export const getGalleryBoardDropId = (boardId: string): string => `gallery-board:${boardId}`;+/** Real boards and Uncategorized hold items; date boards are views and accept no moves. */+export const acceptsGalleryItemMoves = (boardKind: GalleryBoardKind): boolean =>+ boardKind === 'board' || boardKind === 'uncategorized';+/** Droppable id for the search field: dropping a gallery image there searches by similarity. */export const GALLERY_SEMANTIC_SEARCH_DROP_ID = 'gallery-semantic-search-drop';@@ -131,7 +135,11 @@ export const resolveGalleryBoardDrop = (overData: unknown,loadedItems: readonly GalleryItem[]): GalleryBoardDropResolution | null => {- if (!isGalleryItemDragData(activeData) || !isGalleryBoardDropData(overData) || overData.boardKind !== 'board') {+ if (+ !isGalleryItemDragData(activeData) ||+ !isGalleryBoardDropData(overData) ||+ !acceptsGalleryItemMoves(overData.boardKind)+ ) {return null;}