Skip to content

Commit 04751b9

Browse files
Mary Hipppsychedelicious
Mary Hipp
authored andcommitted
add mutation for unpublishing
1 parent 1d78b29 commit 04751b9

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,10 @@
13061306
"unableToCopy": "Unable to Copy",
13071307
"unableToCopyDesc": "Your browser does not support clipboard access. Firefox users may be able to fix this by following ",
13081308
"unableToCopyDesc_theseSteps": "these steps",
1309-
"fluxFillIncompatibleWithT2IAndI2I": "FLUX Fill is not compatible with Text to Image or Image to Image. Use other FLUX models for these tasks."
1309+
"fluxFillIncompatibleWithT2IAndI2I": "FLUX Fill is not compatible with Text to Image or Image to Image. Use other FLUX models for these tasks.",
1310+
"problemUnpublishingWorkflow": "Problem Unpublishing Workflow",
1311+
"problemUnpublishingWorkflowDescription": "There was a problem unpublishing the workflow. Please try again.",
1312+
"workflowUnpublished": "Workflow Unpublished"
13101313
},
13111314
"popovers": {
13121315
"clipSkip": {
@@ -1786,8 +1789,8 @@
17861789
"minimum": "Minimum",
17871790
"maximum": "Maximum",
17881791
"publish": "Publish",
1789-
"published": "Published",
17901792
"unpublish": "Unpublish",
1793+
"published": "Published",
17911794
"workflowLocked": "Workflow Locked",
17921795
"workflowLockedPublished": "Published workflows are locked for editing.\nYou can unpublish the workflow to edit it, or make a copy of it.",
17931796
"workflowLockedDuringPublishing": "Workflow is locked while configuring for publishing.",

invokeai/frontend/web/src/features/nodes/components/sidePanel/PublishedWorkflowPanelContent.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
11
import { Button, Flex, Heading, Text } from '@invoke-ai/ui-library';
2+
import { useAppSelector } from 'app/store/storeHooks';
3+
import { selectWorkflowId } from 'features/nodes/store/workflowSlice';
4+
import { toast } from 'features/toast/toast';
25
import { useSaveOrSaveAsWorkflow } from 'features/workflowLibrary/hooks/useSaveOrSaveAsWorkflow';
3-
import { memo } from 'react';
6+
import { memo, useCallback } from 'react';
47
import { useTranslation } from 'react-i18next';
58
import { PiCopyBold, PiLockOpenBold } from 'react-icons/pi';
9+
import { useUnpublishWorkflowMutation } from 'services/api/endpoints/workflows';
610

711
export const PublishedWorkflowPanelContent = memo(() => {
812
const { t } = useTranslation();
913
const saveAs = useSaveOrSaveAsWorkflow();
14+
const [unpublishWorkflow] = useUnpublishWorkflowMutation();
15+
const workflowId = useAppSelector(selectWorkflowId);
16+
17+
const handleUnpublish = useCallback(async () => {
18+
if (workflowId) {
19+
try {
20+
await unpublishWorkflow(workflowId).unwrap();
21+
toast({
22+
title: t('toast.workflowUnpublished'),
23+
status: 'success',
24+
});
25+
} catch (error) {
26+
toast({
27+
title: t('toast.problemUnpublishingWorkflow'),
28+
description: t('toast.problemUnpublishingWorkflowDescription'),
29+
status: 'error',
30+
});
31+
}
32+
}
33+
}, [unpublishWorkflow, workflowId, t]);
34+
1035
return (
1136
<Flex flexDir="column" w="full" h="full" gap={2} alignItems="center">
1237
<Heading size="md" pt={32}>
@@ -16,7 +41,7 @@ export const PublishedWorkflowPanelContent = memo(() => {
1641
<Button size="md" onClick={saveAs} variant="ghost" leftIcon={<PiCopyBold />}>
1742
{t('common.saveAs')}
1843
</Button>
19-
<Button size="md" onClick={undefined} variant="ghost" leftIcon={<PiLockOpenBold />}>
44+
<Button size="md" onClick={handleUnpublish} variant="ghost" leftIcon={<PiLockOpenBold />}>
2045
{t('workflows.builder.unpublish')}
2146
</Button>
2247
</Flex>

invokeai/frontend/web/src/services/api/endpoints/workflows.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ export const workflowsApi = api.injectEndpoints({
148148
}),
149149
invalidatesTags: (result, error, workflow_id) => [{ type: 'Workflow', id: workflow_id }],
150150
}),
151+
unpublishWorkflow: build.mutation<void, string>({
152+
query: (workflow_id) => ({
153+
url: buildWorkflowsUrl(`i/${workflow_id}/unpublish`),
154+
method: 'POST',
155+
}),
156+
invalidatesTags: (result, error, workflow_id) => [{ type: 'Workflow', id: workflow_id }],
157+
}),
151158
}),
152159
});
153160

@@ -163,4 +170,5 @@ export const {
163170
useListWorkflowsInfiniteInfiniteQuery,
164171
useSetWorkflowThumbnailMutation,
165172
useDeleteWorkflowThumbnailMutation,
173+
useUnpublishWorkflowMutation,
166174
} = workflowsApi;

0 commit comments

Comments
 (0)