Skip to content

Commit 823d0a7

Browse files
authored
Changed "published" button in automations header (TryGhost#27852)
towards https://linear.app/ghost/issue/NY-1267 ![When inactive](https://github.com/user-attachments/assets/5fea2938-3743-4ba0-afee-47a6107930e9) ![When active](https://github.com/user-attachments/assets/f006bdbb-00e9-47f5-87e6-2ff59b303b29) If the automation is active, there's now a little dropdown with a "Turn off" button. The "Published" button is now disabled and has different text. If the automation is inactive, the button looks the same as it did before. The buttons don't actually do anything yet -- that's coming soon!
1 parent 5df5bef commit 823d0a7

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

apps/posts/src/views/Automations/components/automation-header.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import React from 'react';
2-
import {Button, Skeleton} from '@tryghost/shade/components';
2+
import {Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Skeleton} from '@tryghost/shade/components';
33
import {Link} from '@tryghost/admin-x-framework';
44
import {LucideIcon} from '@tryghost/shade/utils';
5+
import type {AutomationDetail} from '@tryghost/admin-x-framework/api/automations';
56

67
interface AutomationHeaderProps {
7-
name?: string;
8-
isLoading?: boolean;
8+
automation: AutomationDetail | undefined;
9+
isLoading: boolean;
910
}
1011

11-
const AutomationHeader: React.FC<AutomationHeaderProps> = ({name, isLoading = false}) => {
12+
const AutomationHeader: React.FC<AutomationHeaderProps> = ({automation, isLoading}) => {
13+
const name = automation?.name;
14+
const isActive = automation?.status === 'active';
15+
1216
return (
1317
<header className='relative z-10 flex h-14 shrink-0 items-center justify-between bg-background px-4 shadow-sm'>
1418
<div className='flex min-w-0 items-center gap-3'>
@@ -24,7 +28,28 @@ const AutomationHeader: React.FC<AutomationHeaderProps> = ({name, isLoading = fa
2428
)}
2529
</div>
2630
<div className='flex shrink-0 items-center gap-3'>
27-
<Button disabled={isLoading}>Publish changes</Button>
31+
{isActive && (
32+
<DropdownMenu>
33+
<DropdownMenuTrigger asChild>
34+
<Button aria-label='Automation options' size='icon' variant='ghost'>
35+
<LucideIcon.Ellipsis />
36+
</Button>
37+
</DropdownMenuTrigger>
38+
<DropdownMenuContent align='end'>
39+
{/* TODO(NY-1267) Make this button do something */}
40+
<DropdownMenuItem>
41+
<LucideIcon.Power className='size-4' />
42+
Turn off
43+
</DropdownMenuItem>
44+
</DropdownMenuContent>
45+
</DropdownMenu>
46+
)}
47+
<Button
48+
// TODO(NY-1267) Make this button do something
49+
disabled={isLoading || isActive}
50+
>
51+
{isActive ? 'Published' : 'Publish changes'}
52+
</Button>
2853
</div>
2954
</header>
3055
);

apps/posts/src/views/Automations/editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const AutomationEditor: React.FC = () => {
1414

1515
return (
1616
<div className='flex h-full w-full flex-col' data-testid='automation-editor'>
17-
<AutomationHeader isLoading={isLoading} name={automation?.name} />
17+
<AutomationHeader automation={automation} isLoading={isLoading} />
1818
<AutomationCanvas automation={automation} isError={isError} isLoading={isLoading} />
1919
</div>
2020
);

0 commit comments

Comments
 (0)