feat: close #2141 danger zone
This commit is contained in:
parent
98afd5516b
commit
6c3d4a11cc
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -59,9 +59,7 @@ export class ErrorBoundary extends React.Component<any, IErrorBoundaryState> {
|
||||
icon={<ResetIcon />}
|
||||
text="Clear All Data"
|
||||
onClick={async () => {
|
||||
if (
|
||||
await showConfirm(Locale.Settings.Actions.ConfirmClearAll)
|
||||
) {
|
||||
if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) {
|
||||
this.clearAndSaveData();
|
||||
}
|
||||
}}
|
||||
|
@ -200,6 +200,44 @@ function UserPromptModal(props: { onClose?: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
function DangerItems() {
|
||||
const chatStore = useChatStore();
|
||||
const appConfig = useAppConfig();
|
||||
|
||||
return (
|
||||
<List>
|
||||
<ListItem
|
||||
title={Locale.Settings.Danger.Reset.Title}
|
||||
subTitle={Locale.Settings.Danger.Reset.SubTitle}
|
||||
>
|
||||
<IconButton
|
||||
text={Locale.Settings.Danger.Reset.Action}
|
||||
onClick={async () => {
|
||||
if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) {
|
||||
appConfig.reset();
|
||||
}
|
||||
}}
|
||||
type="danger"
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem
|
||||
title={Locale.Settings.Danger.Clear.Title}
|
||||
subTitle={Locale.Settings.Danger.Clear.SubTitle}
|
||||
>
|
||||
<IconButton
|
||||
text={Locale.Settings.Danger.Clear.Action}
|
||||
onClick={async () => {
|
||||
if (await showConfirm(Locale.Settings.Danger.Clear.Confirm)) {
|
||||
chatStore.clearAllData();
|
||||
}
|
||||
}}
|
||||
type="danger"
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
||||
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() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="window-actions">
|
||||
<div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<ClearIcon />}
|
||||
onClick={async () => {
|
||||
if (
|
||||
await showConfirm(Locale.Settings.Actions.ConfirmClearAll)
|
||||
) {
|
||||
chatStore.clearAllData();
|
||||
}
|
||||
}}
|
||||
bordered
|
||||
title={Locale.Settings.Actions.ClearAll}
|
||||
/>
|
||||
</div>
|
||||
<div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<ResetIcon />}
|
||||
onClick={async () => {
|
||||
if (
|
||||
await showConfirm(Locale.Settings.Actions.ConfirmResetAll)
|
||||
) {
|
||||
resetConfig();
|
||||
}
|
||||
}}
|
||||
bordered
|
||||
title={Locale.Settings.Actions.ResetAll}
|
||||
/>
|
||||
</div>
|
||||
<div className="window-action-button"></div>
|
||||
<div className="window-action-button"></div>
|
||||
<div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<CloseIcon />}
|
||||
onClick={() => navigate(Path.Home)}
|
||||
bordered
|
||||
title={Locale.Settings.Actions.Close}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -691,6 +701,8 @@ export function Settings() {
|
||||
{shouldShowPromptModal && (
|
||||
<UserPromptModal onClose={() => setShowPromptModal(false)} />
|
||||
)}
|
||||
|
||||
<DangerItems />
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
@ -100,13 +100,7 @@ const ar: PartialLocaleType = {
|
||||
Settings: {
|
||||
Title: "الإعدادات",
|
||||
SubTitle: "جميع الإعدادات",
|
||||
Actions: {
|
||||
ClearAll: "مسح جميع البيانات",
|
||||
ResetAll: "إعادة تعيين جميع الإعدادات",
|
||||
Close: "إغلاق",
|
||||
ConfirmResetAll: "هل أنت متأكد من رغبتك في إعادة تعيين جميع الإعدادات؟",
|
||||
ConfirmClearAll: "هل أنت متأكد من رغبتك في مسح جميع البيانات؟",
|
||||
},
|
||||
|
||||
Lang: {
|
||||
Name: "Language", // تنبيه: إذا كنت ترغب في إضافة ترجمة جديدة، يرجى عدم ترجمة هذه القيمة وتركها "Language"
|
||||
All: "كل اللغات",
|
||||
|
@ -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`
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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`
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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: "全ての言語",
|
||||
|
@ -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",
|
||||
|
@ -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`
|
||||
},
|
||||
|
@ -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: "Все языки",
|
||||
|
@ -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",
|
||||
|
@ -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: "所有语言",
|
||||
|
@ -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ữ",
|
||||
|
Loading…
x
Reference in New Issue
Block a user