Fixed hardcoded private RSS URL in settings (#19199)

refs ADM-16

---------

Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
This commit is contained in:
Jono M 2023-11-30 14:45:37 +00:00 committed by GitHub
parent 4284e4bcdc
commit 1b75747ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,12 @@
import React from 'react';
import TopLevelGroup from '../../TopLevelGroup';
import useSettingGroup from '../../../hooks/useSettingGroup';
import {Icon, Link, SettingGroupContent, TextField, Toggle, withErrorBoundary} from '@tryghost/admin-x-design-system';
import {Hint, Icon, Separator, SettingGroupContent, TextField, Toggle, withErrorBoundary} from '@tryghost/admin-x-design-system';
import {getSettingValues} from '@tryghost/admin-x-framework/api/settings';
import {useGlobalData} from '../../providers/GlobalDataProvider';
const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
const {siteData} = useGlobalData();
const {
localSettings,
isEditing,
@ -27,7 +29,7 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
}
});
const [passwordEnabled, password] = getSettingValues(localSettings, ['is_private', 'password']) as [boolean, string];
const [passwordEnabled, password, publicHash] = getSettingValues(localSettings, ['is_private', 'password', 'public_hash']) as [boolean, string, string];
const handleToggleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
updateSetting('is_private', e.target.checked);
@ -37,15 +39,30 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
updateSetting('password', e.target.value);
};
const privateRssUrl = `${siteData.url.replace(/\/$/, '')}/${publicHash}/rss`;
const hint = (
<>A private RSS feed is available at <a className='break-all text-green' href={privateRssUrl} rel="noopener noreferrer" target='_blank'>{privateRssUrl}</a></>
);
const values = (
<SettingGroupContent
values={[
{
key: 'private',
value: passwordEnabled ? (
<div className='flex items-center gap-1'>
<Icon colorClass='text-yellow' name='lock-locked' size='sm' />
<span>Your site is password protected</span>
<div className='w-full'>
<div className='flex items-center gap-1'>
{/* <div className='rounded-full border border-yellow p-2'> */}
<Icon colorClass='text-yellow' name='lock-locked' size='sm' />
{/* </div> */}
<div className='leading-supertight'>
Your site is password protected
</div>
</div>
{hint && <div className='mt-7 w-full'>
<Separator />
<Hint>{hint}</Hint>
</div>}
</div>
) : (
<div className='flex items-center gap-1 text-grey-900 dark:text-grey-400'>
@ -58,10 +75,6 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
/>
);
const hint = (
<>A private RSS feed is available at <Link className='break-all' href="http://localhost:2368/51aa059ba6eb50c24c14047d4255ac/rss">http://localhost:2368/51aa059ba6eb50c24c14047d4255ac/rss</Link></>
);
const inputs = (
<SettingGroupContent>
<Toggle
@ -74,7 +87,7 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
{passwordEnabled &&
<TextField
error={!!errors.password}
hint={errors.password || hint}
hint={errors.password}
placeholder="Enter password"
title="Site password"
value={password}