mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): disallow loading/deleting workflow if already open
This commit is contained in:
parent
6e028d691a
commit
06104f3851
@ -1651,7 +1651,8 @@
|
|||||||
"clearWorkflowSearchFilter": "Clear Workflow Search Filter",
|
"clearWorkflowSearchFilter": "Clear Workflow Search Filter",
|
||||||
"workflowName": "Workflow Name",
|
"workflowName": "Workflow Name",
|
||||||
"workflowEditorReset": "Workflow Editor Reset",
|
"workflowEditorReset": "Workflow Editor Reset",
|
||||||
"workflowEditorMenu": "Workflow Editor Menu"
|
"workflowEditorMenu": "Workflow Editor Menu",
|
||||||
|
"workflowIsOpen": "Workflow is Open"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"storeNotInitialized": "Store is not initialized"
|
"storeNotInitialized": "Store is not initialized"
|
||||||
|
@ -4,9 +4,10 @@ import dateFormat, { masks } from 'dateformat';
|
|||||||
import { useDeleteLibraryWorkflow } from 'features/workflowLibrary/hooks/useDeleteLibraryWorkflow';
|
import { useDeleteLibraryWorkflow } from 'features/workflowLibrary/hooks/useDeleteLibraryWorkflow';
|
||||||
import { useGetAndLoadLibraryWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadLibraryWorkflow';
|
import { useGetAndLoadLibraryWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadLibraryWorkflow';
|
||||||
import { useWorkflowLibraryModalContext } from 'features/workflowLibrary/context/useWorkflowLibraryModalContext';
|
import { useWorkflowLibraryModalContext } from 'features/workflowLibrary/context/useWorkflowLibraryModalContext';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback, useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { WorkflowRecordListItemDTO } from 'services/api/types';
|
import { WorkflowRecordListItemDTO } from 'services/api/types';
|
||||||
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
workflowDTO: WorkflowRecordListItemDTO;
|
workflowDTO: WorkflowRecordListItemDTO;
|
||||||
@ -14,6 +15,7 @@ type Props = {
|
|||||||
|
|
||||||
const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
|
const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const workflowId = useAppSelector((state) => state.workflow.id);
|
||||||
const { onClose } = useWorkflowLibraryModalContext();
|
const { onClose } = useWorkflowLibraryModalContext();
|
||||||
const { deleteWorkflow, deleteWorkflowResult } = useDeleteLibraryWorkflow({});
|
const { deleteWorkflow, deleteWorkflowResult } = useDeleteLibraryWorkflow({});
|
||||||
const { getAndLoadWorkflow, getAndLoadWorkflowResult } =
|
const { getAndLoadWorkflow, getAndLoadWorkflowResult } =
|
||||||
@ -27,12 +29,17 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
|
|||||||
getAndLoadWorkflow(workflowDTO.workflow_id);
|
getAndLoadWorkflow(workflowDTO.workflow_id);
|
||||||
}, [getAndLoadWorkflow, workflowDTO.workflow_id]);
|
}, [getAndLoadWorkflow, workflowDTO.workflow_id]);
|
||||||
|
|
||||||
|
const isOpen = useMemo(
|
||||||
|
() => workflowId === workflowDTO.workflow_id,
|
||||||
|
[workflowId, workflowDTO.workflow_id]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex key={workflowDTO.workflow_id} w="full">
|
<Flex key={workflowDTO.workflow_id} w="full">
|
||||||
<Flex w="full" alignItems="center" gap={2} h={12}>
|
<Flex w="full" alignItems="center" gap={2} h={12}>
|
||||||
<Flex flexDir="column" flexGrow={1} h="full">
|
<Flex flexDir="column" flexGrow={1} h="full">
|
||||||
<Flex alignItems="center" w="full" h="50%">
|
<Flex alignItems="center" w="full" h="50%">
|
||||||
<Heading size="sm">
|
<Heading size="sm" variant={isOpen ? 'accent' : undefined}>
|
||||||
{workflowDTO.name || t('workflows.unnamedWorkflow')}
|
{workflowDTO.name || t('workflows.unnamedWorkflow')}
|
||||||
</Heading>
|
</Heading>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
@ -70,6 +77,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
<IAIButton
|
<IAIButton
|
||||||
|
isDisabled={isOpen}
|
||||||
onClick={handleGetAndLoadWorkflow}
|
onClick={handleGetAndLoadWorkflow}
|
||||||
isLoading={getAndLoadWorkflowResult.isLoading}
|
isLoading={getAndLoadWorkflowResult.isLoading}
|
||||||
aria-label={t('workflows.openWorkflow')}
|
aria-label={t('workflows.openWorkflow')}
|
||||||
@ -79,6 +87,7 @@ const WorkflowLibraryListItem = ({ workflowDTO }: Props) => {
|
|||||||
{workflowDTO.category === 'user' && (
|
{workflowDTO.category === 'user' && (
|
||||||
<IAIButton
|
<IAIButton
|
||||||
colorScheme="error"
|
colorScheme="error"
|
||||||
|
isDisabled={isOpen}
|
||||||
onClick={handleDeleteWorkflow}
|
onClick={handleDeleteWorkflow}
|
||||||
isLoading={deleteWorkflowResult.isLoading}
|
isLoading={deleteWorkflowResult.isLoading}
|
||||||
aria-label={t('workflows.deleteWorkflow')}
|
aria-label={t('workflows.deleteWorkflow')}
|
||||||
|
12
invokeai/frontend/web/src/theme/components/heading.ts
Normal file
12
invokeai/frontend/web/src/theme/components/heading.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { defineStyle, defineStyleConfig } from '@chakra-ui/react';
|
||||||
|
import { mode } from '@chakra-ui/theme-tools';
|
||||||
|
|
||||||
|
const accent = defineStyle((props) => ({
|
||||||
|
color: mode('accent.500', 'accent.300')(props),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const headingTheme = defineStyleConfig({
|
||||||
|
variants: {
|
||||||
|
accent,
|
||||||
|
},
|
||||||
|
});
|
@ -21,6 +21,7 @@ import { textTheme } from './components/text';
|
|||||||
import { textareaTheme } from './components/textarea';
|
import { textareaTheme } from './components/textarea';
|
||||||
import { tooltipTheme } from './components/tooltip';
|
import { tooltipTheme } from './components/tooltip';
|
||||||
import { reactflowStyles } from './custom/reactflow';
|
import { reactflowStyles } from './custom/reactflow';
|
||||||
|
import { headingTheme } from 'theme/components/heading';
|
||||||
|
|
||||||
export const theme: ThemeOverride = {
|
export const theme: ThemeOverride = {
|
||||||
config: {
|
config: {
|
||||||
@ -146,6 +147,7 @@ export const theme: ThemeOverride = {
|
|||||||
Menu: menuTheme,
|
Menu: menuTheme,
|
||||||
Text: textTheme,
|
Text: textTheme,
|
||||||
Tooltip: tooltipTheme,
|
Tooltip: tooltipTheme,
|
||||||
|
Heading: headingTheme,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user