Skip to content

Commit

Permalink
Optimiz max_active_requests check & remove the max_active_requests in…
Browse files Browse the repository at this point in the history
…put box from app edit form
  • Loading branch information
takatost committed Jul 9, 2024
1 parent 09f3801 commit 279f8d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
4 changes: 3 additions & 1 deletion api/services/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ def update_app(self, app: App, args: dict) -> App:
"""
app.name = args.get('name')
app.description = args.get('description', '')
app.max_active_requests = args.get('max_active_requests', 0)
app.max_active_requests = args.get('max_active_requests', 0) or 0
if app.max_active_requests < 0:
app.max_active_requests = 0
app.icon = args.get('icon')
app.icon_background = args.get('icon_background')
app.updated_at = datetime.now(timezone.utc).replace(tzinfo=None)
Expand Down
22 changes: 0 additions & 22 deletions web/app/components/explore/create-app-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use client'
import type { ChangeEvent } from 'react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { RiCloseLine } from '@remixicon/react'
Expand All @@ -15,15 +14,13 @@ export type CreateAppModalProps = {
show: boolean
isEditModal?: boolean
appName: string
maxActiveRequests: number
appDescription: string
appIcon: string
appIconBackground: string
onConfirm: (info: {
name: string
icon: string
icon_background: string
max_active_requests: number
description: string
}) => Promise<void>
onHide: () => void
Expand All @@ -35,20 +32,13 @@ const CreateAppModal = ({
appIcon,
appIconBackground,
appName,
maxActiveRequests,
appDescription,
onConfirm,
onHide,
}: CreateAppModalProps) => {
const { t } = useTranslation()

const [name, setName] = React.useState(appName)
const [max_active_requests, setMaxActiveRequests] = useState(maxActiveRequests)
const handleMaxActiveRequestsChange = (e: ChangeEvent<HTMLInputElement>) => {
const value = e.target.value
if (value === '' || (parseInt(value) >= 0 && !value.startsWith('-')))
setMaxActiveRequests(parseInt(value))
}
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
const [emoji, setEmoji] = useState({ icon: appIcon, icon_background: appIconBackground })
const [description, setDescription] = useState(appDescription || '')
Expand All @@ -64,7 +54,6 @@ const CreateAppModal = ({
onConfirm({
name,
...emoji,
max_active_requests,
description,
})
onHide()
Expand Down Expand Up @@ -100,17 +89,6 @@ const CreateAppModal = ({
/>
</div>
</div>
{/* max active requests */}
<div className='pt-2'>
<div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.appMaxActiveRequests')}</div>
<input
type="number"
className='w-full h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg border border-transparent outline-none appearance-none caret-primary-600 placeholder:text-gray-400 hover:bg-gray-50 hover:border hover:border-gray-300 focus:bg-gray-50 focus:border focus:border-gray-300 focus:shadow-xs'
placeholder={t('app.newApp.appMaxActiveRequestsPlaceholder') || ''}
value={max_active_requests}
onChange={handleMaxActiveRequestsChange}
/>
</div>
{/* description */}
<div className='pt-2'>
<div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.captionDescription')}</div>
Expand Down

0 comments on commit 279f8d5

Please sign in to comment.