mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Compare commits
2 Commits
release/ad
...
maryhipp/a
Author | SHA1 | Date | |
---|---|---|---|
c25e6777ff | |||
770cd36167 |
@ -12,12 +12,23 @@ class BoardDTO(BoardRecord):
|
||||
"""The URL of the thumbnail of the most recent image in the board."""
|
||||
image_count: int = Field(description="The number of images in the board.")
|
||||
"""The number of images in the board."""
|
||||
actions: Optional[dict[str, bool]] = Field(
|
||||
default=None,
|
||||
description="Allowed actions on board."
|
||||
)
|
||||
"""Allowed actions on board."""
|
||||
|
||||
|
||||
def board_record_to_dto(board_record: BoardRecord, cover_image_name: Optional[str], image_count: int) -> BoardDTO:
|
||||
def board_record_to_dto(
|
||||
board_record: BoardRecord,
|
||||
cover_image_name: Optional[str],
|
||||
image_count: int,
|
||||
actions: Optional[dict[str, bool]] = None
|
||||
) -> BoardDTO:
|
||||
"""Converts a board record to a board DTO."""
|
||||
return BoardDTO(
|
||||
**board_record.model_dump(exclude={"cover_image_name"}),
|
||||
cover_image_name=cover_image_name,
|
||||
image_count=image_count,
|
||||
actions=actions
|
||||
)
|
||||
|
@ -29,6 +29,11 @@ class ImageDTO(ImageRecord, ImageUrlsDTO):
|
||||
description="The workflow that generated this image.",
|
||||
)
|
||||
"""The workflow that generated this image."""
|
||||
actions: Optional[dict[str, bool]] = Field(
|
||||
default=None,
|
||||
description="Allowed actions on image."
|
||||
)
|
||||
"""Allowed actions on image."""
|
||||
|
||||
|
||||
def image_record_to_dto(
|
||||
@ -37,6 +42,7 @@ def image_record_to_dto(
|
||||
thumbnail_url: str,
|
||||
board_id: Optional[str],
|
||||
workflow_id: Optional[str],
|
||||
actions: Optional[dict[str, bool]] = None
|
||||
) -> ImageDTO:
|
||||
"""Converts an image record to an image DTO."""
|
||||
return ImageDTO(
|
||||
@ -45,4 +51,5 @@ def image_record_to_dto(
|
||||
thumbnail_url=thumbnail_url,
|
||||
board_id=board_id,
|
||||
workflow_id=workflow_id,
|
||||
actions=actions
|
||||
)
|
||||
|
@ -7,10 +7,11 @@ type Props = {
|
||||
tooltip: string;
|
||||
icon?: ReactElement;
|
||||
styleOverrides?: SystemStyleObject;
|
||||
isDisabled?: boolean;
|
||||
};
|
||||
|
||||
const IAIDndImageIcon = (props: Props) => {
|
||||
const { onClick, tooltip, icon, styleOverrides } = props;
|
||||
const { onClick, tooltip, icon, styleOverrides, isDisabled = false } = props;
|
||||
|
||||
const resetIconShadow = useColorModeValue(
|
||||
`drop-shadow(0px 0px 0.1rem var(--invokeai-colors-base-600))`,
|
||||
@ -18,6 +19,7 @@ const IAIDndImageIcon = (props: Props) => {
|
||||
);
|
||||
return (
|
||||
<IAIIconButton
|
||||
isDisabled={isDisabled}
|
||||
onClick={onClick}
|
||||
aria-label={tooltip}
|
||||
tooltip={tooltip}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { MenuItem } from '@chakra-ui/react';
|
||||
import { memo, useCallback } from 'react';
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { FaTrash } from 'react-icons/fa';
|
||||
import { BoardDTO } from 'services/api/types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -17,23 +17,21 @@ const GalleryBoardContextMenuItems = ({ board, setBoardToDelete }: Props) => {
|
||||
setBoardToDelete(board);
|
||||
}, [board, setBoardToDelete]);
|
||||
|
||||
const isDeleteDisabled = useMemo(() => {
|
||||
if (board?.actions) {
|
||||
return board.actions.delete === false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, [board]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{board.image_count > 0 && (
|
||||
<>
|
||||
{/* <MenuItem
|
||||
isDisabled={!board.image_count}
|
||||
icon={<FaImages />}
|
||||
onClickCapture={handleAddBoardToBatch}
|
||||
>
|
||||
Add Board to Batch
|
||||
</MenuItem> */}
|
||||
</>
|
||||
)}
|
||||
<MenuItem
|
||||
sx={{ color: 'error.600', _dark: { color: 'error.300' } }}
|
||||
icon={<FaTrash />}
|
||||
onClick={handleDelete}
|
||||
isDisabled={isDeleteDisabled}
|
||||
>
|
||||
{t('boards.deleteBoard')}
|
||||
</MenuItem>
|
||||
|
@ -15,7 +15,7 @@ import { initialImageSelected } from 'features/parameters/store/actions';
|
||||
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
||||
import { useCopyImageToClipboard } from 'common/hooks/useCopyImageToClipboard';
|
||||
import { setActiveTab } from 'features/ui/store/uiSlice';
|
||||
import { memo, useCallback } from 'react';
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { flushSync } from 'react-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@ -153,6 +153,22 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => {
|
||||
}
|
||||
}, [unstarImages, imageDTO]);
|
||||
|
||||
const isDeleteDisabled = useMemo(() => {
|
||||
if (imageDTO?.actions) {
|
||||
return imageDTO.actions.delete === false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, [imageDTO]);
|
||||
|
||||
const isUnstarDisabled = useMemo(() => {
|
||||
if (imageDTO?.actions) {
|
||||
return imageDTO.actions.unstar === false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, [imageDTO]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MenuItem
|
||||
@ -233,6 +249,7 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => {
|
||||
<MenuItem
|
||||
icon={customStarUi ? customStarUi.off.icon : <MdStar />}
|
||||
onClickCapture={handleUnstarImage}
|
||||
isDisabled={isUnstarDisabled}
|
||||
>
|
||||
{customStarUi ? customStarUi.off.text : t('gallery.unstarImage')}
|
||||
</MenuItem>
|
||||
@ -248,6 +265,7 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => {
|
||||
sx={{ color: 'error.600', _dark: { color: 'error.300' } }}
|
||||
icon={<FaTrash />}
|
||||
onClickCapture={handleDelete}
|
||||
isDisabled={isDeleteDisabled}
|
||||
>
|
||||
{t('gallery.deleteImage')}
|
||||
</MenuItem>
|
||||
|
@ -112,6 +112,14 @@ const GalleryImage = (props: HoverableImageProps) => {
|
||||
return '';
|
||||
}, [imageDTO?.starred, customStarUi]);
|
||||
|
||||
const isUnstarDisabled = useMemo(() => {
|
||||
if (imageDTO?.actions) {
|
||||
return imageDTO?.starred && imageDTO.actions.unstar === false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, [imageDTO]);
|
||||
|
||||
if (!imageDTO) {
|
||||
return <IAIFillSkeleton />;
|
||||
}
|
||||
@ -149,6 +157,13 @@ const GalleryImage = (props: HoverableImageProps) => {
|
||||
onClick={toggleStarredState}
|
||||
icon={starIcon}
|
||||
tooltip={starTooltip}
|
||||
isDisabled={isUnstarDisabled}
|
||||
styleOverrides={{
|
||||
_disabled: {
|
||||
cursor: 'not-allowed',
|
||||
opacity: 1,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
{isHovered && shift && (
|
||||
|
483
invokeai/frontend/web/src/services/api/schema.d.ts
vendored
483
invokeai/frontend/web/src/services/api/schema.d.ts
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user