mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
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:
parent
4284e4bcdc
commit
1b75747ca0
1 changed files with 23 additions and 10 deletions
|
@ -1,10 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import TopLevelGroup from '../../TopLevelGroup';
|
import TopLevelGroup from '../../TopLevelGroup';
|
||||||
import useSettingGroup from '../../../hooks/useSettingGroup';
|
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 {getSettingValues} from '@tryghost/admin-x-framework/api/settings';
|
||||||
|
import {useGlobalData} from '../../providers/GlobalDataProvider';
|
||||||
|
|
||||||
const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
|
const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
|
||||||
|
const {siteData} = useGlobalData();
|
||||||
const {
|
const {
|
||||||
localSettings,
|
localSettings,
|
||||||
isEditing,
|
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>) => {
|
const handleToggleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
updateSetting('is_private', e.target.checked);
|
updateSetting('is_private', e.target.checked);
|
||||||
|
@ -37,15 +39,30 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
|
||||||
updateSetting('password', e.target.value);
|
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 = (
|
const values = (
|
||||||
<SettingGroupContent
|
<SettingGroupContent
|
||||||
values={[
|
values={[
|
||||||
{
|
{
|
||||||
key: 'private',
|
key: 'private',
|
||||||
value: passwordEnabled ? (
|
value: passwordEnabled ? (
|
||||||
<div className='flex items-center gap-1'>
|
<div className='w-full'>
|
||||||
<Icon colorClass='text-yellow' name='lock-locked' size='sm' />
|
<div className='flex items-center gap-1'>
|
||||||
<span>Your site is password protected</span>
|
{/* <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>
|
||||||
) : (
|
) : (
|
||||||
<div className='flex items-center gap-1 text-grey-900 dark:text-grey-400'>
|
<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 = (
|
const inputs = (
|
||||||
<SettingGroupContent>
|
<SettingGroupContent>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
@ -74,7 +87,7 @@ const LockSite: React.FC<{ keywords: string[] }> = ({keywords}) => {
|
||||||
{passwordEnabled &&
|
{passwordEnabled &&
|
||||||
<TextField
|
<TextField
|
||||||
error={!!errors.password}
|
error={!!errors.password}
|
||||||
hint={errors.password || hint}
|
hint={errors.password}
|
||||||
placeholder="Enter password"
|
placeholder="Enter password"
|
||||||
title="Site password"
|
title="Site password"
|
||||||
value={password}
|
value={password}
|
||||||
|
|
Loading…
Add table
Reference in a new issue