From 6c3d4a11cc703a6f3c50b74ccfaaa7f4ce76cd97 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Thu, 29 Jun 2023 01:09:51 +0800 Subject: [PATCH] feat: close #2141 danger zone --- app/components/button.module.scss | 20 ++++++++- app/components/button.tsx | 4 +- app/components/error.tsx | 4 +- app/components/settings.tsx | 72 ++++++++++++++++++------------- app/locales/ar.ts | 8 +--- app/locales/cn.ts | 22 +++++++--- app/locales/cs.ts | 8 +--- app/locales/de.ts | 9 +--- app/locales/en.ts | 19 +++++--- app/locales/es.ts | 8 +--- app/locales/fr.ts | 9 +--- app/locales/it.ts | 8 +--- app/locales/jp.ts | 8 +--- app/locales/ko.ts | 8 +--- app/locales/no.ts | 6 +-- app/locales/ru.ts | 8 +--- app/locales/tr.ts | 8 +--- app/locales/tw.ts | 8 +--- app/locales/vi.ts | 8 +--- 19 files changed, 106 insertions(+), 139 deletions(-) diff --git a/app/components/button.module.scss b/app/components/button.module.scss index 27e4278b..e332df2d 100644 --- a/app/components/button.module.scss +++ b/app/components/button.module.scss @@ -28,6 +28,21 @@ } } + &.danger { + color: rgba($color: red, $alpha: 0.8); + border-color: rgba($color: red, $alpha: 0.5); + background-color: rgba($color: red, $alpha: 0.05); + + &:hover { + border-color: red; + background-color: rgba($color: red, $alpha: 0.1); + } + + path { + fill: red !important; + } + } + &:hover, &:focus { border-color: var(--primary); @@ -57,9 +72,12 @@ } .icon-button-text { - margin-left: 5px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + + &:not(:first-child) { + margin-left: 5px; + } } diff --git a/app/components/button.tsx b/app/components/button.tsx index 51698d07..7a563392 100644 --- a/app/components/button.tsx +++ b/app/components/button.tsx @@ -2,10 +2,12 @@ import * as React from "react"; import styles from "./button.module.scss"; +export type ButtonType = "primary" | "danger" | null; + export function IconButton(props: { onClick?: () => void; icon?: JSX.Element; - type?: "primary" | "danger"; + type?: ButtonType; text?: string; bordered?: boolean; shadow?: boolean; diff --git a/app/components/error.tsx b/app/components/error.tsx index 33abe931..b38341e2 100644 --- a/app/components/error.tsx +++ b/app/components/error.tsx @@ -59,9 +59,7 @@ export class ErrorBoundary extends React.Component { icon={} text="Clear All Data" onClick={async () => { - if ( - await showConfirm(Locale.Settings.Actions.ConfirmClearAll) - ) { + if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) { this.clearAndSaveData(); } }} diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 54389c9b..47d76496 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -200,6 +200,44 @@ function UserPromptModal(props: { onClose?: () => void }) { ); } +function DangerItems() { + const chatStore = useChatStore(); + const appConfig = useAppConfig(); + + return ( + + + { + if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) { + appConfig.reset(); + } + }} + type="danger" + /> + + + { + if (await showConfirm(Locale.Settings.Danger.Clear.Confirm)) { + chatStore.clearAllData(); + } + }} + type="danger" + /> + + + ); +} + function SyncItems() { const syncStore = useSyncStore(); const webdav = syncStore.webDavConfig; @@ -290,7 +328,6 @@ export function Settings() { const [showEmojiPicker, setShowEmojiPicker] = useState(false); const config = useAppConfig(); const updateConfig = config.update; - const resetConfig = config.reset; const chatStore = useChatStore(); const updateStore = useUpdateStore(); @@ -375,40 +412,13 @@ export function Settings() {
-
- } - onClick={async () => { - if ( - await showConfirm(Locale.Settings.Actions.ConfirmClearAll) - ) { - chatStore.clearAllData(); - } - }} - bordered - title={Locale.Settings.Actions.ClearAll} - /> -
-
- } - onClick={async () => { - if ( - await showConfirm(Locale.Settings.Actions.ConfirmResetAll) - ) { - resetConfig(); - } - }} - bordered - title={Locale.Settings.Actions.ResetAll} - /> -
+
+
} onClick={() => navigate(Path.Home)} bordered - title={Locale.Settings.Actions.Close} />
@@ -691,6 +701,8 @@ export function Settings() { {shouldShowPromptModal && ( setShowPromptModal(false)} /> )} + + ); diff --git a/app/locales/ar.ts b/app/locales/ar.ts index 7a3eaa2b..6ece142b 100644 --- a/app/locales/ar.ts +++ b/app/locales/ar.ts @@ -100,13 +100,7 @@ const ar: PartialLocaleType = { Settings: { Title: "الإعدادات", SubTitle: "جميع الإعدادات", - Actions: { - ClearAll: "مسح جميع البيانات", - ResetAll: "إعادة تعيين جميع الإعدادات", - Close: "إغلاق", - ConfirmResetAll: "هل أنت متأكد من رغبتك في إعادة تعيين جميع الإعدادات؟", - ConfirmClearAll: "هل أنت متأكد من رغبتك في مسح جميع البيانات؟", - }, + Lang: { Name: "Language", // تنبيه: إذا كنت ترغب في إضافة ترجمة جديدة، يرجى عدم ترجمة هذه القيمة وتركها "Language" All: "كل اللغات", diff --git a/app/locales/cn.ts b/app/locales/cn.ts index ae22efa9..d8b4bd0f 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -108,13 +108,21 @@ const cn = { }, Settings: { Title: "设置", - SubTitle: "设置选项", - Actions: { - ClearAll: "清除所有数据", - ResetAll: "重置所有选项", - Close: "关闭", - ConfirmResetAll: "确认重置所有配置?", - ConfirmClearAll: "确认清除所有数据?", + SubTitle: "所有设置选项", + + Danger: { + Reset: { + Title: "重置所有设置", + SubTitle: "重置所有设置项回默认值", + Action: "立即重置", + Confirm: "确认重置所有设置?", + }, + Clear: { + Title: "清除所有数据", + SubTitle: "清除所有聊天、设置数据", + Action: "立即清除", + Confirm: "确认清除所有聊天、设置数据?", + }, }, Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` diff --git a/app/locales/cs.ts b/app/locales/cs.ts index e1706b72..9f9afab0 100644 --- a/app/locales/cs.ts +++ b/app/locales/cs.ts @@ -61,13 +61,7 @@ const cs: PartialLocaleType = { Settings: { Title: "Nastavení", SubTitle: "Všechna nastavení", - Actions: { - ClearAll: "Vymazat všechna data", - ResetAll: "Obnovit veškeré nastavení", - Close: "Zavřít", - ConfirmResetAll: "Jste si jisti, že chcete obnovit všechna nastavení?", - ConfirmClearAll: "Jste si jisti, že chcete smazat všechna data?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Všechny jazyky", diff --git a/app/locales/de.ts b/app/locales/de.ts index 30eb2b0d..b8158c12 100644 --- a/app/locales/de.ts +++ b/app/locales/de.ts @@ -61,14 +61,7 @@ const de: PartialLocaleType = { Settings: { Title: "Einstellungen", SubTitle: "Alle Einstellungen", - Actions: { - ClearAll: "Alle Daten löschen", - ResetAll: "Alle Einstellungen zurücksetzen", - Close: "Schließen", - ConfirmResetAll: - "Möchten Sie wirklich alle Konfigurationen zurücksetzen?", - ConfirmClearAll: "Möchten Sie wirklich alle Chats zurücksetzen?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Alle Sprachen", diff --git a/app/locales/en.ts b/app/locales/en.ts index 5261e7ed..3b6b7ff6 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -111,12 +111,19 @@ const en: LocaleType = { Settings: { Title: "Settings", SubTitle: "All Settings", - Actions: { - ClearAll: "Clear All Data", - ResetAll: "Reset All Settings", - Close: "Close", - ConfirmResetAll: "Are you sure you want to reset all configurations?", - ConfirmClearAll: "Are you sure you want to reset all data?", + Danger: { + Reset: { + Title: "Reset All Settings", + SubTitle: "Reset all setting items to default", + Action: "Reset", + Confirm: "Confirm to reset all settings to default?", + }, + Clear: { + Title: "Clear All Data", + SubTitle: "Clear all messages and settings", + Action: "Clear", + Confirm: "Confirm to clear all messages and settings?", + }, }, Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` diff --git a/app/locales/es.ts b/app/locales/es.ts index 4f89208b..e7f8cca4 100644 --- a/app/locales/es.ts +++ b/app/locales/es.ts @@ -61,13 +61,7 @@ const es: PartialLocaleType = { Settings: { Title: "Configuración", SubTitle: "Todas las configuraciones", - Actions: { - ClearAll: "Borrar todos los datos", - ResetAll: "Restablecer todas las configuraciones", - Close: "Cerrar", - ConfirmResetAll: "Are you sure you want to reset all configurations?", - ConfirmClearAll: "Are you sure you want to reset all chat?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Todos los idiomas", diff --git a/app/locales/fr.ts b/app/locales/fr.ts index db5e3544..b6b8c032 100644 --- a/app/locales/fr.ts +++ b/app/locales/fr.ts @@ -61,14 +61,7 @@ const fr: PartialLocaleType = { Settings: { Title: "Paramètres", SubTitle: "Toutes les configurations", - Actions: { - ClearAll: "Effacer toutes les données", - ResetAll: "Réinitialiser les configurations", - Close: "Fermer", - ConfirmResetAll: - "Êtes-vous sûr de vouloir réinitialiser toutes les configurations?", - ConfirmClearAll: "Êtes-vous sûr de vouloir supprimer toutes les données?", - }, + Lang: { Name: "Language", // ATTENTION : si vous souhaitez ajouter une nouvelle traduction, ne traduisez pas cette valeur, laissez-la sous forme de `Language` All: "Toutes les langues", diff --git a/app/locales/it.ts b/app/locales/it.ts index 72206754..8962968a 100644 --- a/app/locales/it.ts +++ b/app/locales/it.ts @@ -61,13 +61,7 @@ const it: PartialLocaleType = { Settings: { Title: "Impostazioni", SubTitle: "Tutte le impostazioni", - Actions: { - ClearAll: "Cancella tutti i dati", - ResetAll: "Resetta tutte le impostazioni", - Close: "Chiudi", - ConfirmResetAll: "Sei sicuro vuoi cancellare tutte le impostazioni?", - ConfirmClearAll: "Sei sicuro vuoi cancellare tutte le chat?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Tutte le lingue", diff --git a/app/locales/jp.ts b/app/locales/jp.ts index 02a0bf86..cf0f1d7a 100644 --- a/app/locales/jp.ts +++ b/app/locales/jp.ts @@ -61,13 +61,7 @@ const jp: PartialLocaleType = { Settings: { Title: "設定", SubTitle: "設定オプション", - Actions: { - ClearAll: "すべてのデータをクリア", - ResetAll: "すべてのオプションをリセット", - Close: "閉じる", - ConfirmResetAll: "すべての設定をリセットしてもよろしいですか?", - ConfirmClearAll: "すべてのチャットをリセットしてもよろしいですか?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "全ての言語", diff --git a/app/locales/ko.ts b/app/locales/ko.ts index 8985fcfb..a3a5f73d 100644 --- a/app/locales/ko.ts +++ b/app/locales/ko.ts @@ -61,13 +61,7 @@ const ko: PartialLocaleType = { Settings: { Title: "설정", SubTitle: "모든 설정", - Actions: { - ClearAll: "모든 데이터 지우기", - ResetAll: "모든 설정 초기화", - Close: "닫기", - ConfirmResetAll: "모든 설정을 초기화하시겠습니까?", - ConfirmClearAll: "모든 데이터를 지우시겠습니까?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "All Languages", diff --git a/app/locales/no.ts b/app/locales/no.ts index f46a454f..b296bd5c 100644 --- a/app/locales/no.ts +++ b/app/locales/no.ts @@ -56,11 +56,7 @@ const no: PartialLocaleType = { Settings: { Title: "Innstillinger", SubTitle: "Alle innstillinger", - Actions: { - ClearAll: "Fjern alle data", - ResetAll: "Nullstill innstillinger", - Close: "Lukk", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` }, diff --git a/app/locales/ru.ts b/app/locales/ru.ts index fcc494c0..9121e278 100644 --- a/app/locales/ru.ts +++ b/app/locales/ru.ts @@ -61,13 +61,7 @@ const ru: PartialLocaleType = { Settings: { Title: "Настройки", SubTitle: "Все настройки", - Actions: { - ClearAll: "Очистить все данные", - ResetAll: "Сбросить все настройки", - Close: "Закрыть", - ConfirmResetAll: "Вы уверены, что хотите сбросить все настройки?", - ConfirmClearAll: "Вы уверены, что хотите очистить все данные?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Все языки", diff --git a/app/locales/tr.ts b/app/locales/tr.ts index fb49b64c..e199f115 100644 --- a/app/locales/tr.ts +++ b/app/locales/tr.ts @@ -61,13 +61,7 @@ const tr: PartialLocaleType = { Settings: { Title: "Ayarlar", SubTitle: "Tüm Ayarlar", - Actions: { - ClearAll: "Tüm Verileri Temizle", - ResetAll: "Tüm Ayarları Sıfırla", - Close: "Kapat", - ConfirmResetAll: "Tüm ayarları sıfırlamak istediğinizden emin misiniz?", - ConfirmClearAll: "Tüm sohbeti sıfırlamak istediğinizden emin misiniz?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Tüm Diller", diff --git a/app/locales/tw.ts b/app/locales/tw.ts index adc2767e..cb92a81d 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -59,13 +59,7 @@ const tw: PartialLocaleType = { Settings: { Title: "設定", SubTitle: "設定選項", - Actions: { - ClearAll: "清除所有資料", - ResetAll: "重設所有設定", - Close: "關閉", - ConfirmResetAll: "您確定要重設所有設定嗎?", - ConfirmClearAll: "您確定要清除所有数据嗎?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "所有语言", diff --git a/app/locales/vi.ts b/app/locales/vi.ts index fea4545d..cc0178b1 100644 --- a/app/locales/vi.ts +++ b/app/locales/vi.ts @@ -61,13 +61,7 @@ const vi: PartialLocaleType = { Settings: { Title: "Cài đặt", SubTitle: "Tất cả cài đặt", - Actions: { - ClearAll: "Xóa toàn bộ dữ liệu", - ResetAll: "Khôi phục cài đặt gốc", - Close: "Đóng", - ConfirmResetAll: "Bạn chắc chắn muốn thiết lập lại tất cả cài đặt?", - ConfirmClearAll: "Bạn chắc chắn muốn thiết lập lại tất cả dữ liệu?", - }, + Lang: { Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language` All: "Tất cả ngôn ngữ",