mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fixed publishing issue when site has no active newsletters (#20627)
Ref [ENG-1253](https://linear.app/tryghost/issue/ENG-1253/) Not allowing users to archive their last active newsletter
This commit is contained in:
parent
f05ba155b8
commit
7c1a732a30
1 changed files with 8 additions and 1 deletions
|
@ -106,8 +106,15 @@ const Sidebar: React.FC<{
|
||||||
const {localSettings} = useSettingGroup();
|
const {localSettings} = useSettingGroup();
|
||||||
const [siteTitle] = getSettingValues(localSettings, ['title']) as string[];
|
const [siteTitle] = getSettingValues(localSettings, ['title']) as string[];
|
||||||
const handleError = useHandleError();
|
const handleError = useHandleError();
|
||||||
|
const {data: {newsletters: apiNewsletters} = {}} = useBrowseNewsletters();
|
||||||
|
|
||||||
let newsletterAddress = renderSenderEmail(newsletter, config, defaultEmailAddress);
|
let newsletterAddress = renderSenderEmail(newsletter, config, defaultEmailAddress);
|
||||||
|
const [newsletters, setNewsletters] = useState<Newsletter[]>(apiNewsletters || []);
|
||||||
|
const activeNewsletters = newsletters.filter(n => n.status === 'active');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setNewsletters(apiNewsletters || []);
|
||||||
|
}, [apiNewsletters]);
|
||||||
|
|
||||||
const fontOptions: SelectOption[] = [
|
const fontOptions: SelectOption[] = [
|
||||||
{value: 'serif', label: 'Elegant serif', className: 'font-serif'},
|
{value: 'serif', label: 'Elegant serif', className: 'font-serif'},
|
||||||
|
@ -252,7 +259,7 @@ const Sidebar: React.FC<{
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
<div className='mb-5 mt-10'>
|
<div className='mb-5 mt-10'>
|
||||||
{newsletter.status === 'active' ? (!onlyOne && <Button color='red' label='Archive newsletter' link onClick={confirmStatusChange} />) : <Button color='green' label='Reactivate newsletter' link onClick={confirmStatusChange} />}
|
{newsletter.status === 'active' ? (!onlyOne && <Button color='red' disabled={activeNewsletters.length === 1} label='Archive newsletter' link onClick={confirmStatusChange}/>) : <Button color='green' label='Reactivate newsletter' link onClick={confirmStatusChange} />}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue