Skip to content

Commit a6cbfd8

Browse files
committed
Remove warning for missing web configurations
- in settings, when there is no chatbots - should not warn about it, simply show empty list ├── apps │ └── editor │ └── src │ └── views │ └── settings │ └── frontend │ ├── Home │ │ ├── Home.tsx │ │ └── sections │ │ └── WebSection.tsx │ └── i18n │ └── translations │ └── common.ts └── packages └── ui └── src └── components └── editor └── settings ├── NavigationItemGroup │ └── NavigationItemGroup.tsx ├── NavigationItemSection │ └── NavigationItemSection.tsx └── SortableList └── SortableList.tsx
1 parent 3fc9cb2 commit a6cbfd8

3 files changed

Lines changed: 116 additions & 157 deletions

File tree

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ export const Home: React.FC<Props> = (props) => {
175175
return props.providers.length == 0
176176
} else if (id == 'section:api:group:models') {
177177
return props.api_configurations.length == 0
178-
} else if (id == 'section:web:group:chatbots') {
179-
return props.web_configurations.length == 0
180178
} else {
181179
return false
182180
}

‎apps/editor/src/views/settings/frontend/Home/sections/WebSection.tsx‎

Lines changed: 116 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Group as UiGroup } from '@ui/components/editor/settings/Group/Group'
44
import { Notice as UiNotice } from '@ui/components/editor/settings/Notice'
55
import { Input as UiInput } from '@ui/components/editor/common/Input'
66
import { Item as UiItem } from '@ui/components/editor/settings/Item'
7-
import { Button } from '@ui/components/editor/common/Button'
87
import { SortableList } from '@ui/components/editor/settings/SortableList'
98
import { IconButton } from '@ui/components/editor/common/IconButton'
109
import { WebConfiguration } from '@shared/types/web-configuration'
@@ -107,155 +106,135 @@ export const WebSection = forwardRef<HTMLDivElement, Props>((props, ref) => {
107106
<div
108107
ref={(el) => props.set_section_ref('section:web:group:chatbots', el)}
109108
>
110-
<UiGroup
111-
title={t('chatbots.configurations.title')}
112-
notice_slot={
113-
!props.web_configurations.length ? (
114-
<UiNotice
115-
type="warning"
116-
slot_right={
117-
<Button on_click={() => props.on_add_web_configuration()}>
118-
{t('action.add-new')}
119-
</Button>
120-
}
121-
>
122-
{t('common.missing-chatbot')}
123-
</UiNotice>
124-
) : null
125-
}
126-
>
127-
{props.web_configurations.length > 0 && (
128-
<SortableList
129-
items={props.web_configurations.map((c, index) => ({
130-
...c,
131-
id: c.name ?? `unnamed-${index}`
132-
}))}
133-
on_reorder={(reordered) => {
134-
const restored = reordered.map(
135-
({ id: _id, ...rest }) => rest as WebConfiguration
136-
)
137-
props.set_web_configurations(restored)
138-
props.on_reorder_web_configurations(restored)
139-
}}
140-
on_add={props.on_add_web_configuration}
141-
translations={{
142-
add_title: t('action.add-new'),
143-
item_text: t('chatbots.configurations.item'),
144-
items_text: t('chatbots.configurations.items'),
145-
items_text_many: t('chatbots.configurations.items-many')
146-
}}
147-
render_content={(config) => {
148-
const is_unnamed =
149-
!config.name ||
150-
config.name.startsWith('unnamed-') ||
151-
/^\(\d+\)$/.test(config.name.trim())
152-
const display_name = is_unnamed
153-
? config.chatbot!
154-
: config.name!.replace(/ \(\d+\)$/, '')
155-
156-
const get_details = (): string[] => {
157-
const { chatbot, model, reasoning_effort } = config
158-
const model_display_name =
159-
model && chatbot && CHATBOTS[chatbot]
160-
? CHATBOTS[chatbot].models?.[model]?.label || model
161-
: null
109+
<UiGroup title={t('chatbots.configurations.title')}>
110+
<SortableList
111+
items={props.web_configurations.map((c, index) => ({
112+
...c,
113+
id: c.name ?? `unnamed-${index}`
114+
}))}
115+
on_reorder={(reordered) => {
116+
const restored = reordered.map(
117+
({ id: _id, ...rest }) => rest as WebConfiguration
118+
)
119+
props.set_web_configurations(restored)
120+
props.on_reorder_web_configurations(restored)
121+
}}
122+
on_add={props.on_add_web_configuration}
123+
translations={{
124+
add_title: t('action.add-new'),
125+
item_text: t('chatbots.configurations.item'),
126+
items_text: t('chatbots.configurations.items'),
127+
items_text_many: t('chatbots.configurations.items-many')
128+
}}
129+
render_content={(config) => {
130+
const is_unnamed =
131+
!config.name ||
132+
config.name.startsWith('unnamed-') ||
133+
/^\(\d+\)$/.test(config.name.trim())
134+
const display_name = is_unnamed
135+
? config.chatbot!
136+
: config.name!.replace(/ \(\d+\)$/, '')
162137

163-
const details: string[] = []
164-
if (is_unnamed) {
165-
if (model_display_name) details.push(model_display_name)
166-
} else if (model_display_name) {
167-
details.push(chatbot!, model_display_name)
168-
} else if (chatbot) {
169-
details.push(chatbot)
170-
}
138+
const get_details = (): string[] => {
139+
const { chatbot, model, reasoning_effort } = config
140+
const model_display_name =
141+
model && chatbot && CHATBOTS[chatbot]
142+
? CHATBOTS[chatbot].models?.[model]?.label || model
143+
: null
171144

172-
if (reasoning_effort) {
173-
details.push(reasoning_effort)
174-
}
145+
const details: string[] = []
146+
if (is_unnamed) {
147+
if (model_display_name) details.push(model_display_name)
148+
} else if (model_display_name) {
149+
details.push(chatbot!, model_display_name)
150+
} else if (chatbot) {
151+
details.push(chatbot)
152+
}
175153

176-
return details
154+
if (reasoning_effort) {
155+
details.push(reasoning_effort)
177156
}
178157

179-
const details = get_details()
158+
return details
159+
}
180160

181-
return (
182-
<>
183-
{config.chatbot && chatbot_to_icon[config.chatbot] && (
184-
<div
185-
style={{
186-
width: 16,
187-
height: 16,
188-
display: 'flex',
189-
alignItems: 'center',
190-
justifyContent: 'center',
191-
fill: 'var(--vscode-foreground)'
192-
}}
193-
>
194-
<Icon variant={chatbot_to_icon[config.chatbot]} />
195-
</div>
196-
)}
161+
const details = get_details()
162+
163+
return (
164+
<>
165+
{config.chatbot && chatbot_to_icon[config.chatbot] && (
197166
<div
198167
style={{
199-
flex: 1,
200-
overflow: 'hidden',
201-
whiteSpace: 'nowrap',
202-
textOverflow: 'ellipsis'
168+
width: 16,
169+
height: 16,
170+
display: 'flex',
171+
alignItems: 'center',
172+
justifyContent: 'center',
173+
fill: 'var(--vscode-foreground)'
203174
}}
204175
>
205-
<span>{display_name}</span>
206-
{details.length > 0 && (
207-
<span
208-
style={{
209-
marginLeft: '0.5em',
210-
opacity: 0.7,
211-
fontSize: '0.9em'
212-
}}
213-
>
214-
{details.join(' · ')}
215-
</span>
216-
)}
176+
<Icon variant={chatbot_to_icon[config.chatbot]} />
217177
</div>
218-
</>
219-
)
220-
}}
221-
render_actions={(config, index) => (
222-
<>
223-
<IconButton
224-
codicon_icon={config.is_pinned ? 'pinned' : 'pin'}
225-
title={
226-
config.is_pinned ? t('action.unpin') : t('action.pin')
227-
}
228-
on_click={(e) => {
229-
e.stopPropagation()
230-
props.on_toggle_pinned_web_configuration(config)
178+
)}
179+
<div
180+
style={{
181+
flex: 1,
182+
overflow: 'hidden',
183+
whiteSpace: 'nowrap',
184+
textOverflow: 'ellipsis'
231185
}}
232-
/>
233-
<IconButton
234-
codicon_icon="insert"
235-
title={t('action.insert')}
236-
on_click={() =>
237-
props.on_add_web_configuration({
238-
insertion_index: index
239-
})
240-
}
241-
/>
242-
<IconButton
243-
codicon_icon="edit"
244-
title={t('chatbots.configurations.action.edit')}
245-
on_click={() => props.on_edit_web_configuration(config.id)}
246-
/>
247-
<IconButton
248-
codicon_icon="trash"
249-
title={t('chatbots.configurations.action.delete')}
250-
on_click={(e) => {
251-
e.stopPropagation()
252-
props.on_delete_web_configuration(config.id)
253-
}}
254-
/>
186+
>
187+
<span>{display_name}</span>
188+
{details.length > 0 && (
189+
<span
190+
style={{
191+
marginLeft: '0.5em',
192+
opacity: 0.7,
193+
fontSize: '0.9em'
194+
}}
195+
>
196+
{details.join(' · ')}
197+
</span>
198+
)}
199+
</div>
255200
</>
256-
)}
257-
/>
258-
)}
201+
)
202+
}}
203+
render_actions={(config, index) => (
204+
<>
205+
<IconButton
206+
codicon_icon={config.is_pinned ? 'pinned' : 'pin'}
207+
title={config.is_pinned ? t('action.unpin') : t('action.pin')}
208+
on_click={(e) => {
209+
e.stopPropagation()
210+
props.on_toggle_pinned_web_configuration(config)
211+
}}
212+
/>
213+
<IconButton
214+
codicon_icon="insert"
215+
title={t('action.insert')}
216+
on_click={() =>
217+
props.on_add_web_configuration({
218+
insertion_index: index
219+
})
220+
}
221+
/>
222+
<IconButton
223+
codicon_icon="edit"
224+
title={t('chatbots.configurations.action.edit')}
225+
on_click={() => props.on_edit_web_configuration(config.id)}
226+
/>
227+
<IconButton
228+
codicon_icon="trash"
229+
title={t('chatbots.configurations.action.delete')}
230+
on_click={(e) => {
231+
e.stopPropagation()
232+
props.on_delete_web_configuration(config.id)
233+
}}
234+
/>
235+
</>
236+
)}
237+
/>
259238
{has_gemini && (
260239
<UiItem
261240
title={t('chatbots.configurations.gemini-user-id.title')}

‎apps/editor/src/views/settings/frontend/i18n/translations/common.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,5 @@ export const translations = {
3434
cs: 'Sbalit',
3535
hu: 'Összecsukás',
3636
bg: 'Свиване'
37-
},
38-
'common.missing-chatbot': {
39-
en: 'Missing chatbot',
40-
pl: 'Brak chatbota',
41-
'zh-cn': '缺少聊天机器人',
42-
ja: 'チャットボットが不足しています',
43-
'zh-tw': '缺少聊天機器人',
44-
de: 'Fehlender Chatbot',
45-
es: 'Falta chatbot',
46-
fr: 'Chatbot manquant',
47-
'pt-br': 'Chatbot ausente',
48-
ru: 'Отсутствует чат-бот',
49-
ko: '챗봇이 누락되었습니다',
50-
it: 'Chatbot mancante',
51-
tr: 'Eksik chatbot',
52-
cs: 'Chybějící chatbot',
53-
hu: 'Hiányzó chatbot',
54-
bg: 'Липсващ чатбот'
5537
}
5638
} as const

0 commit comments

Comments
 (0)