Skip to content

Commit c76fa2e

Browse files
committed
Add confirmation dialog for removing browser profiles
- in settings, before removing a profile tell the user it's irreversible and ask for confirmation
1 parent 8786749 commit c76fa2e

5 files changed

Lines changed: 79 additions & 9 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export const translations = {
2+
'settings.browser-profiles.confirm-delete.message': {
3+
en: 'Are you sure you want to remove browser profile "{name}"?',
4+
pl: 'Czy na pewno chcesz usunąć profil przeglądarki "{name}"?',
5+
'zh-cn': '您确定要移除浏览器配置文件 "{name}" 吗?',
6+
ja: 'ブラウザプロファイル "{name}" を削除してもよろしいですか?',
7+
'zh-tw': '您確定要移除瀏覽器設定檔 "{name}" 嗎?',
8+
de: 'Möchten Sie das Browser-Profil "{name}" wirklich entfernen?',
9+
es: '¿Estás seguro de que quieres eliminar el perfil del navegador "{name}"?',
10+
fr: 'Voulez-vous vraiment supprimer le profil du navigateur "{name}" ?',
11+
'pt-br':
12+
'Tem certeza de que deseja remover o perfil do navegador "{name}"?',
13+
ru: 'Вы уверены, что хотите удалить профиль браузера "{name}"?',
14+
ko: '브라우저 프로필 "{name}"을(를) 제거하시겠습니까?',
15+
it: 'Sei sicuro di voler rimuovere il profilo del browser "{name}"?',
16+
tr: '"{name}" tarayıcı profilini kaldırmak istediğinizden emin misiniz?',
17+
cs: 'Opravdu chcete odebrat profil prohlížeče "{name}"?',
18+
hu: 'Biztosan el szeretné távolítani a(z) "{name}" böngészőprofilt?',
19+
bg: 'Сигурни ли сте, че искате да премахнете профила на браузъра "{name}"?'
20+
},
21+
'settings.browser-profiles.confirm-delete.detail': {
22+
en: 'This action is irreversible and will permanently delete all data associated with this profile.',
23+
pl: 'Ta czynność jest nieodwracalna i trwale usunie wszystkie dane powiązane z tym profilem.',
24+
'zh-cn': '此操作不可逆,将永久删除与此配置文件关联的所有数据。',
25+
ja: 'この操作は元に戻せず、このプロファイルに関連付けられたすべてのデータが完全に削除されます。',
26+
'zh-tw': '此操作不可逆,將永久刪除此設定檔關聯的所有資料。',
27+
de: 'Diese Aktion ist unwiderruflich und löscht alle mit diesem Profil verknüpften Daten dauerhaft.',
28+
es: 'Esta acción es irreversible y eliminará permanentemente todos los datos asociados con este perfil.',
29+
fr: 'Cette action est irréversible et supprimera définitivement toutes les données associées à ce profil.',
30+
'pt-br':
31+
'Esta ação é irreversível e excluirá permanentemente todos os dados associados a este perfil.',
32+
ru: 'Это действие необратимо и безвозвратно удалит все данные, связанные с этим профилем.',
33+
ko: '이 작업은 되돌릴 수 없으며 이 프로필과 관련된 모든 데이터가 영구적으로 삭제됩니다.',
34+
it: 'Questa azione è irreversibile ed eliminerà definitivamente tutti i dati associati a questo profilo.',
35+
tr: 'Bu işlem geri alınamaz ve bu profille ilişkili tüm verileri kalıcı olarak silecektir.',
36+
cs: 'Tato akce je nevratná a trvale smaže všechna data spojená s tímto profilem.',
37+
hu: 'Ez a művelet visszafordíthatatlan, és véglegesen törli a profilhoz tartozó összes adatot.',
38+
bg: 'Това действие е необратимо и ще изтрие за постоянно всички данни, свързани с този профил.'
39+
}
40+
} as const

‎apps/editor/src/i18n/translations/views/settings/handlers/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { translations as handle_delete_provider } from './handle-delete-provider
77
import { translations as handle_select_default_web_configuration } from './handle-select-default-web-configuration'
88
import { translations as handle_select_default_cli_configuration } from './handle-select-default-cli-configuration'
99
import { translations as handle_test_provider_connection } from './handle-test-provider-connection'
10+
import { translations as handle_update_browser_profiles } from './handle-update-browser-profiles'
1011

1112
export const translations = {
1213
...handle_open_allow_patterns_settings,
@@ -17,5 +18,6 @@ export const translations = {
1718
...handle_delete_provider,
1819
...handle_select_default_web_configuration,
1920
...handle_select_default_cli_configuration,
20-
...handle_test_provider_connection
21+
...handle_test_provider_connection,
22+
...handle_update_browser_profiles
2123
}

‎apps/editor/src/views/settings/backend/message-handlers/handle-update-browser-profiles.ts‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ import * as os from 'os'
33
import * as path from 'path'
44
import * as vscode from 'vscode'
55
import { UpdateBrowserProfilesMessage } from '@/views/settings/types/messages'
6+
import { SettingsViewProvider } from '@/views/settings/backend/settings-view-provider'
67
import { Logger } from '@shared/utils/logger'
8+
import { t } from '@/i18n'
9+
import { handle_get_browser_profiles } from './handle-get-browser-profiles'
710

811
export const handle_update_browser_profiles = async (
12+
settings_provider: SettingsViewProvider,
913
message: UpdateBrowserProfilesMessage
1014
): Promise<void> => {
1115
const config = vscode.workspace.getConfiguration('codeWebChat')
1216
const existing_profiles = config.get<string[]>('browserProfiles', []) || []
1317

14-
await config.update(
15-
'browserProfiles',
16-
message.browser_profiles,
17-
vscode.ConfigurationTarget.Global
18-
)
19-
2018
const updated_profiles_set = new Set(
2119
message.browser_profiles.map((p) => p.trim())
2220
)
@@ -33,6 +31,31 @@ export const handle_update_browser_profiles = async (
3331
)
3432
)
3533

34+
if (removed_profiles.length > 0) {
35+
const delete_button = t('common.delete')
36+
const result = await vscode.window.showWarningMessage(
37+
t('settings.browser-profiles.confirm-delete.message', {
38+
name: removed_profiles.join(', ')
39+
}),
40+
{
41+
modal: true,
42+
detail: t('settings.browser-profiles.confirm-delete.detail')
43+
},
44+
delete_button
45+
)
46+
47+
if (result !== delete_button) {
48+
await handle_get_browser_profiles(settings_provider)
49+
return
50+
}
51+
}
52+
53+
await config.update(
54+
'browserProfiles',
55+
message.browser_profiles,
56+
vscode.ConfigurationTarget.Global
57+
)
58+
3659
if (removed_profiles.length === 0) {
3760
return
3861
}

‎apps/editor/src/views/settings/backend/settings-view-provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class SettingsViewProvider {
204204
} else if (message.command === 'GET_BROWSER_PROFILES') {
205205
await handlers.handle_get_browser_profiles(this)
206206
} else if (message.command === 'UPDATE_BROWSER_PROFILES') {
207-
await handlers.handle_update_browser_profiles(message)
207+
await handlers.handle_update_browser_profiles(this, message)
208208
} else if (message.command === 'GET_FORWARDED_PORTS') {
209209
await handlers.handle_get_forwarded_ports(this)
210210
} else if (message.command === 'UPDATE_FORWARDED_PORTS') {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,12 @@ export const use_settings = (vscode: any) => {
317317
}
318318

319319
const handle_update_browser_profiles = (profiles: string[]) => {
320-
set_browser_profiles(profiles)
320+
const is_removal =
321+
browser_profiles !== undefined &&
322+
profiles.length < browser_profiles.length
323+
if (!is_removal) {
324+
set_browser_profiles(profiles)
325+
}
321326
post_message(vscode, {
322327
command: 'UPDATE_BROWSER_PROFILES',
323328
browser_profiles: profiles

0 commit comments

Comments
 (0)