mirror of
https://github.com/langgenius/dify.git
synced 2026-07-15 09:27:36 +08:00
fix: inputPlaceholderValue of frontend
This commit is contained in:
@ -309,7 +309,8 @@ describe('SettingsModal', () => {
|
||||
expect(screen.getByRole('textbox', { name: inputPlaceholderName })).toHaveValue('Updated prompt')
|
||||
})
|
||||
|
||||
it('should disable the input placeholder for Cloud sandbox plans', () => {
|
||||
it('should display paid webapp settings as defaults for Cloud sandbox plans', async () => {
|
||||
mockOnSave.mockResolvedValueOnce(undefined)
|
||||
mockUseProviderContext.mockReturnValue({
|
||||
...baseProviderContextValue,
|
||||
enableBilling: true,
|
||||
@ -317,14 +318,26 @@ describe('SettingsModal', () => {
|
||||
...baseProviderContextValue.plan,
|
||||
type: Plan.sandbox,
|
||||
},
|
||||
webappCopyrightEnabled: false,
|
||||
webappCopyrightEnabled: true,
|
||||
})
|
||||
|
||||
renderSettingsModal()
|
||||
|
||||
fireEvent.click(screen.getByText('appOverview.overview.appInfo.settings.more.entry'))
|
||||
|
||||
expect(screen.getByRole('textbox', { name: inputPlaceholderName })).toBeDisabled()
|
||||
const inputPlaceholder = screen.getByRole('textbox', { name: inputPlaceholderName })
|
||||
expect(inputPlaceholder).toBeDisabled()
|
||||
expect(inputPlaceholder).toHaveValue('')
|
||||
expect(screen.queryByPlaceholderText('appOverview.overview.appInfo.settings.more.copyRightPlaceholder')).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByText('common.operation.save'))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockOnSave).toHaveBeenCalledWith(expect.objectContaining({
|
||||
copyright: '',
|
||||
input_placeholder: '',
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
it('should keep the input placeholder editable when billing is disabled', async () => {
|
||||
|
||||
@ -157,7 +157,8 @@ const SettingsModal: FC<ISettingsModalProps> = ({
|
||||
const inputPlaceholderLabelId = React.useId()
|
||||
const inputPlaceholderDescriptionId = React.useId()
|
||||
|
||||
const inputPlaceholderValue = inputInfo.inputPlaceholder ?? ''
|
||||
const inputPlaceholderValue = isCloudSandboxPlan ? '' : (inputInfo.inputPlaceholder ?? '')
|
||||
const copyrightSwitchValue = isCloudSandboxPlan ? false : inputInfo.copyrightSwitchValue
|
||||
// Editable + has value + blurred -> preview as gray placeholder text (matches how it'll render in chat).
|
||||
const showInputPlaceholderPreview = !isCloudSandboxPlan && inputPlaceholderValue.trim().length > 0 && !inputPlaceholderFocused
|
||||
const inputPlaceholderField = (
|
||||
@ -263,9 +264,9 @@ const SettingsModal: FC<ISettingsModalProps> = ({
|
||||
chat_color_theme: inputInfo.chatColorTheme,
|
||||
chat_color_theme_inverted: inputInfo.chatColorThemeInverted,
|
||||
prompt_public: false,
|
||||
copyright: !webappCopyrightEnabled
|
||||
copyright: (!webappCopyrightEnabled || isCloudSandboxPlan)
|
||||
? ''
|
||||
: inputInfo.copyrightSwitchValue
|
||||
: copyrightSwitchValue
|
||||
? inputInfo.copyright
|
||||
: '',
|
||||
privacy_policy: inputInfo.privacyPolicy,
|
||||
@ -501,7 +502,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
|
||||
{webappCopyrightEnabled
|
||||
? (
|
||||
<Switch
|
||||
checked={inputInfo.copyrightSwitchValue}
|
||||
checked={copyrightSwitchValue}
|
||||
onCheckedChange={v => setInputInfo({ ...inputInfo, copyrightSwitchValue: v })}
|
||||
/>
|
||||
)
|
||||
@ -512,7 +513,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
|
||||
<div>
|
||||
<Switch
|
||||
disabled
|
||||
checked={inputInfo.copyrightSwitchValue}
|
||||
checked={copyrightSwitchValue}
|
||||
onCheckedChange={v => setInputInfo({ ...inputInfo, copyrightSwitchValue: v })}
|
||||
/>
|
||||
</div>
|
||||
@ -525,7 +526,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
|
||||
)}
|
||||
</div>
|
||||
<p className="pb-0.5 body-xs-regular text-text-tertiary">{t(`${prefixSettings}.more.copyrightTip`, { ns: 'appOverview' })}</p>
|
||||
{inputInfo.copyrightSwitchValue && (
|
||||
{copyrightSwitchValue && (
|
||||
<Input
|
||||
className="mt-2 h-10"
|
||||
value={inputInfo.copyright}
|
||||
|
||||
Reference in New Issue
Block a user