Skip to content

Commit 2a994a1

Browse files
committed
Add support for pinning and unpinning API and web configurations in settings
- action.pin and action.unpin - in settings, show pinned and allow pinning configurations - move 'insert new configuration' to 'actions' ├── apps │ └── editor │ └── src │ └── views │ ├── prompt │ │ ├── backend │ │ │ └── message-handlers │ │ │ ├── handle-toggle-pinned-api-configuration.ts │ │ │ ├── handle-toggle-pinned-web-configuration.ts │ │ │ └── index.ts │ │ └── frontend │ │ └── Main │ │ └── MainView │ │ └── MainView.tsx │ └── settings │ ├── backend │ │ ├── message-handlers │ │ │ └── index.ts │ │ └── settings-view-provider.ts │ ├── frontend │ │ ├── Home │ │ │ ├── Home.tsx │ │ │ └── sections │ │ │ ├── ApiConfigurationsSection.tsx │ │ │ └── WebConfigurationsSection.tsx │ │ ├── Settings.tsx │ │ ├── hooks │ │ │ └── use-settings.ts │ │ └── i18n │ │ └── translations │ │ ├── actions.ts │ │ ├── api-calls.ts │ │ └── chatbots.ts │ └── types │ └── messages.ts └── packages └── ui └── src └── components └── editor ├── prompt │ └── Configurations │ └── Configurations.tsx └── settings └── SortableList └── SortableList.tsx
1 parent 8117398 commit 2a994a1

8 files changed

Lines changed: 105 additions & 57 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,15 @@ type Props = {
181181
}) => void
182182
on_edit_api_configuration: (id: string) => void
183183
on_delete_api_configuration: (id: string) => void
184+
on_toggle_pinned_api_configuration: (config: ApiConfiguration) => void
184185
on_reorder_web_configurations: (reordered: WebConfiguration[]) => void
185186
on_add_web_configuration: (params?: {
186187
insertion_index?: number
187188
exact_insertion?: boolean
188189
}) => void
189190
on_edit_web_configuration: (id: string) => void
190191
on_delete_web_configuration: (name: string) => void
192+
on_toggle_pinned_web_configuration: (config: WebConfiguration) => void
191193
on_open_external_url: (url: string) => void
192194
scroll_to_section_on_load?: NavItem
193195
}
@@ -680,6 +682,7 @@ export const Home: React.FC<Props> = (props) => {
680682
on_add_web_configuration={props.on_add_web_configuration}
681683
on_edit_web_configuration={props.on_edit_web_configuration}
682684
on_delete_web_configuration={props.on_delete_web_configuration}
685+
on_toggle_pinned_web_configuration={props.on_toggle_pinned_web_configuration}
683686
reuse_last_tab={props.reuse_last_tab}
684687
on_reuse_last_tab_change={props.on_reuse_last_tab_change}
685688
gemini_user_id={props.gemini_user_id}
@@ -715,6 +718,7 @@ export const Home: React.FC<Props> = (props) => {
715718
on_add_api_configuration={props.on_add_api_configuration}
716719
on_edit_api_configuration={props.on_edit_api_configuration}
717720
on_delete_api_configuration={props.on_delete_api_configuration}
721+
on_toggle_pinned_api_configuration={props.on_toggle_pinned_api_configuration}
718722
edit_files_instructions={edit_files_instructions}
719723
set_edit_files_instructions={set_edit_files_instructions}
720724
on_edit_files_instructions_blur={() => {

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type Props = {
3434
}) => void
3535
on_delete_api_configuration: (id: string) => void
3636
on_edit_api_configuration: (id: string) => void
37+
on_toggle_pinned_api_configuration: (config: ApiConfiguration) => void
3738
on_set_default_api_configuration: (
3839
api_feature: ApiFeature,
3940
api_configuration_id: string | null
@@ -162,7 +163,7 @@ export const ApiConfigurationsSection = forwardRef<HTMLDivElement, Props>(
162163
<>
163164
<IconButton
164165
codicon_icon="insert"
165-
title={t('api-calls.model-providers.action.insert')}
166+
title={t('action.insert')}
166167
on_click={() =>
167168
props.on_add_provider({ insertion_index: index })
168169
}
@@ -253,9 +254,17 @@ export const ApiConfigurationsSection = forwardRef<HTMLDivElement, Props>(
253254
}}
254255
render_actions={(config, index) => (
255256
<>
257+
<IconButton
258+
codicon_icon={config.is_pinned ? 'pinned' : 'pin'}
259+
title={config.is_pinned ? t('action.unpin') : t('action.pin')}
260+
on_click={(e) => {
261+
e.stopPropagation()
262+
props.on_toggle_pinned_api_configuration(config)
263+
}}
264+
/>
256265
<IconButton
257266
codicon_icon="insert"
258-
title={t('api-calls.configurations.action.insert')}
267+
title={t('action.insert')}
259268
on_click={() =>
260269
props.on_add_api_configuration({
261270
insertion_index: index

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Props = {
2424
}) => void
2525
on_edit_web_configuration: (id: string) => void
2626
on_delete_web_configuration: (name: string) => void
27+
on_toggle_pinned_web_configuration: (config: WebConfiguration) => void
2728
set_section_ref: (id: NavItem, el: HTMLDivElement | null) => void
2829
reuse_last_tab: boolean
2930
on_reuse_last_tab_change: (enabled: boolean) => void
@@ -233,9 +234,17 @@ export const WebConfigurationsSection = forwardRef<HTMLDivElement, Props>(
233234
}}
234235
render_actions={(config, index) => (
235236
<>
237+
<IconButton
238+
codicon_icon={config.is_pinned ? 'pinned' : 'pin'}
239+
title={config.is_pinned ? t('action.unpin') : t('action.pin')}
240+
on_click={(e) => {
241+
e.stopPropagation()
242+
props.on_toggle_pinned_web_configuration(config)
243+
}}
244+
/>
236245
<IconButton
237246
codicon_icon="insert"
238-
title={t('chatbots.configurations.action.insert')}
247+
title={t('action.insert')}
239248
on_click={() =>
240249
props.on_add_web_configuration({
241250
insertion_index: index

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ export const Settings = () => {
268268
on_delete_api_configuration={
269269
settings_hook.handle_delete_api_configuration
270270
}
271+
on_toggle_pinned_api_configuration={
272+
settings_hook.handle_toggle_pinned_api_configuration
273+
}
271274
web_configurations={settings_hook.web_configurations!}
272275
set_web_configurations={settings_hook.set_web_configurations}
273276
on_reorder_web_configurations={
@@ -287,6 +290,9 @@ export const Settings = () => {
287290
on_delete_web_configuration={
288291
settings_hook.handle_delete_web_configuration
289292
}
293+
on_toggle_pinned_web_configuration={
294+
settings_hook.handle_toggle_pinned_web_configuration
295+
}
290296
on_open_external_url={settings_hook.handle_open_external_url}
291297
scroll_to_section_on_load={scroll_to_section_on_load}
292298
/>

‎apps/editor/src/views/settings/frontend/hooks/use-settings.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,24 @@ export const use_settings = (vscode: any) => {
464464
})
465465
}
466466

467+
const handle_toggle_pinned_api_configuration = (config: ApiConfiguration) => {
468+
post_message(vscode, {
469+
command: 'UPDATE_API_CONFIGURATION',
470+
updating_api_configuration: config,
471+
updated_api_configuration: { ...config, is_pinned: !config.is_pinned },
472+
origin: 'save'
473+
})
474+
}
475+
476+
const handle_toggle_pinned_web_configuration = (config: WebConfiguration) => {
477+
post_message(vscode, {
478+
command: 'UPDATE_WEB_CONFIGURATION',
479+
updating_web_configuration: config,
480+
updated_web_configuration: { ...config, is_pinned: !config.is_pinned },
481+
origin: 'save'
482+
})
483+
}
484+
467485
return {
468486
providers,
469487
set_providers,
@@ -500,6 +518,8 @@ export const use_settings = (vscode: any) => {
500518
handle_reorder_web_configurations,
501519
handle_add_web_configuration,
502520
handle_delete_web_configuration,
521+
handle_toggle_pinned_api_configuration,
522+
handle_toggle_pinned_web_configuration,
503523
handle_synchronize_edit_format_between_targets_change,
504524
handle_commit_instructions_change,
505525
handle_attach_ascii_tree_of_context_change,

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,59 @@ export const translations = {
1616
cs: 'Přidat nový',
1717
hu: 'Új Hozzáadása',
1818
bg: 'Добавяне на нов'
19+
},
20+
'action.insert': {
21+
en: 'Insert configuration',
22+
pl: 'Wstaw konfigurację',
23+
'zh-cn': '插入配置',
24+
ja: '設定を挿入',
25+
'zh-tw': '插入設定',
26+
de: 'Konfiguration einfügen',
27+
es: 'Insertar configuración',
28+
fr: 'Insérer une configuration',
29+
'pt-br': 'Inserir configuração',
30+
ru: 'Вставить конфигурацию',
31+
ko: '구성 삽입',
32+
it: 'Inserisci configurazione',
33+
tr: 'Yapılandırma ekle',
34+
cs: 'Vložit konfiguraci',
35+
hu: 'Konfiguráció beszúrása',
36+
bg: 'Вмъкване на конфигурация'
37+
},
38+
'action.pin': {
39+
en: 'Pin',
40+
pl: 'Przypnij',
41+
'zh-cn': '固定',
42+
ja: 'ピン留め',
43+
'zh-tw': '固定',
44+
de: 'Anheften',
45+
es: 'Fijar',
46+
fr: 'Épingler',
47+
'pt-br': 'Fixar',
48+
ru: 'Закрепить',
49+
ko: '고정',
50+
it: 'Fissa',
51+
tr: 'Sabitle',
52+
cs: 'Připnout',
53+
hu: 'Rögzítés',
54+
bg: 'Закрепване'
55+
},
56+
'action.unpin': {
57+
en: 'Unpin',
58+
pl: 'Odepnij',
59+
'zh-cn': '取消固定',
60+
ja: 'ピン留め解除',
61+
'zh-tw': '取消固定',
62+
de: 'Loslösen',
63+
es: 'Desfijar',
64+
fr: 'Détacher',
65+
'pt-br': 'Desafixar',
66+
ru: 'Открепить',
67+
ko: '고정 해제',
68+
it: 'Rimuovi fissaggio',
69+
tr: 'Sabitlemeyi Kaldır',
70+
cs: 'Odepnout',
71+
hu: 'Rögzítés törlése',
72+
bg: 'Откачане'
1973
}
2074
} as const

‎apps/editor/src/views/settings/frontend/i18n/translations/api-calls.ts‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,6 @@ export const translations = {
7373
hu: 'A hitelesítő adatok biztonságosan vannak tárolva a {link} a gépén.',
7474
bg: 'Идентификационните данни се съхраняват сигурно в {link} на вашата машина.'
7575
},
76-
'api-calls.model-providers.action.insert': {
77-
en: 'Insert a new provider below/above',
78-
pl: 'Wstaw nowego dostawcę poniżej/powyżej',
79-
'zh-cn': '在下方/上方插入新提供商',
80-
ja: '下/上に新しいプロバイダーを挿入',
81-
'zh-tw': '在下方/上方插入新供應商',
82-
de: 'Neuen Anbieter darunter/darüber einfügen',
83-
es: 'Insertar un nuevo proveedor debajo/arriba',
84-
fr: 'Insérer un nouveau fournisseur en dessous/au-dessus',
85-
'pt-br': 'Inserir um novo provedor abaixo/acima',
86-
ru: 'Вставить нового провайдера ниже/выше',
87-
ko: '아래/위에 새 제공자 삽입',
88-
it: 'Inserisci un nuovo fornitore sotto/sopra',
89-
tr: 'Aşağıya/yukarıya yeni bir sağlayıcı ekle',
90-
cs: 'Vložit nového poskytovatele pod/nad',
91-
hu: 'Új szolgáltató beszúrása alá/fölé',
92-
bg: 'Вмъкване на нов доставчик отдолу/отгоре'
93-
},
9476
'api-calls.model-providers.action.edit': {
9577
en: 'Edit provider',
9678
pl: 'Edytuj dostawcę',
@@ -199,24 +181,6 @@ export const translations = {
199181
hu: 'Küldjön promptokat a szerkesztőből.',
200182
bg: 'Изпращайте промптове от самия редактор.'
201183
},
202-
'api-calls.configurations.action.insert': {
203-
en: 'Insert a new configuration below/above',
204-
pl: 'Wstaw nową konfigurację poniżej/powyżej',
205-
'zh-cn': '在下方/上方插入新配置',
206-
ja: '下/上に新しい設定を挿入',
207-
'zh-tw': '在下方/上方插入新設定',
208-
de: 'Neue Konfiguration darunter/darüber einfügen',
209-
es: 'Insertar una nueva configuración debajo/arriba',
210-
fr: 'Insérer une nouvelle configuration en dessous/au-dessus',
211-
'pt-br': 'Inserir uma nova configuração abaixo/acima',
212-
ru: 'Вставить новую конфигурацию ниже/выше',
213-
ko: '아래/위에 새 구성 삽입',
214-
it: 'Inserisci una nuova configurazione sotto/sopra',
215-
tr: 'Aşağıya/yukarıya yeni bir yapılandırma ekle',
216-
cs: 'Vložit novou konfiguraci pod/nad',
217-
hu: 'Új konfiguráció beszúrása alá/fölé',
218-
bg: 'Вмъкване на нова конфигурация отдолу/отгоре'
219-
},
220184
'api-calls.configurations.action.edit': {
221185
en: 'Edit configuration',
222186
pl: 'Edytuj konfigurację',

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,6 @@ export const translations = {
7272
hu: 'A böngészővel való kommunikáció helyi WebSocketeket használ.',
7373
bg: 'Комуникацията с браузъра използва локални WebSocket.'
7474
},
75-
'chatbots.configurations.action.insert': {
76-
en: 'Insert a new configuration below/above',
77-
pl: 'Wstaw nową konfigurację poniżej/powyżej',
78-
'zh-cn': '在下方/上方插入新配置',
79-
ja: '下/上に新しい設定を挿入',
80-
'zh-tw': '在下方/上方插入新設定',
81-
de: 'Neue Konfiguration darunter/darüber einfügen',
82-
es: 'Insertar una nueva configuración debajo/arriba',
83-
fr: 'Insérer une nouvelle configuration en dessous/au-dessus',
84-
'pt-br': 'Inserir uma nova configuração abaixo/acima',
85-
ru: 'Вставить новую конфигурацию ниже/выше',
86-
ko: '아래/위에 새 구성 삽입',
87-
it: 'Inserisci una nuova configurazione sotto/sopra',
88-
tr: 'Aşağıya/yukarıya yeni bir yapılandırma ekle',
89-
cs: 'Vložit novou konfiguraci pod/nad',
90-
hu: 'Új konfiguráció beszúrása alá/fölé',
91-
bg: 'Вмъкване на нова конфигурация отдолу/отгоре'
92-
},
9375
'chatbots.configurations.action.edit': {
9476
en: 'Edit configuration',
9577
pl: 'Edytuj konfigurację',

0 commit comments

Comments
 (0)