| 1 |
import { UpdateSiteVisibilityConfirm } from '@agent/workflows/settings/components/UpdateSiteVisibilityConfirm'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
const { abilities, agentContext } = window.extAgentData; |
| 5 |
|
| 6 |
// A clicked suggestion skips the backend, so its reply must be written here. |
| 7 |
const unpublishExample = { |
| 8 |
text: __('Unpublish my site', 'extendify-local'), |
| 9 |
agentResponse: { |
| 10 |
// translators: Shown when the user clicks the "Unpublish my site" suggestion, above a confirm card. |
| 11 |
reply: __('Ready to take your site back offline?', 'extendify-local'), |
| 12 |
whenFinishedTool: { |
| 13 |
id: 'update-site-visibility', |
| 14 |
labels: { |
| 15 |
// translators: Success notice — the site is now hidden. Not "publishing was canceled". |
| 16 |
confirm: __('Unpublished the site', 'extendify-local'), |
| 17 |
cancel: __('Canceled unpublishing the site', 'extendify-local'), |
| 18 |
}, |
| 19 |
}, |
| 20 |
}, |
| 21 |
}; |
| 22 |
|
| 23 |
const publishExample = { |
| 24 |
text: __('Publish my site', 'extendify-local'), |
| 25 |
agentResponse: { |
| 26 |
// translators: Shown when the user clicks the "Publish my site" suggestion, above a confirm card. |
| 27 |
reply: __('Ready to make your site live?', 'extendify-local'), |
| 28 |
whenFinishedTool: { |
| 29 |
id: 'update-site-visibility', |
| 30 |
labels: { |
| 31 |
confirm: __('Published the site', 'extendify-local'), |
| 32 |
// translators: Neutral notice — the user backed out, so the site is still hidden. |
| 33 |
cancel: __('Canceled publishing the site', 'extendify-local'), |
| 34 |
}, |
| 35 |
}, |
| 36 |
}, |
| 37 |
}; |
| 38 |
|
| 39 |
// A hidden site stays eligible with the flag off, or it can never go live. |
| 40 |
const inScope = () => |
| 41 |
Boolean(agentContext?.comingSoonEnabled) || !agentContext?.sitePublished; |
| 42 |
|
| 43 |
export default { |
| 44 |
available: () => Boolean(abilities?.canEditSettings) && inScope(), |
| 45 |
id: 'update-site-visibility', |
| 46 |
whenFinished: { component: UpdateSiteVisibilityConfirm }, |
| 47 |
example: agentContext?.sitePublished ? unpublishExample : publishExample, |
| 48 |
}; |
| 49 |
|